/*
  Kelspi shared styles.

  Every colour, font and corner radius here comes from a token defined in
  static/themes/<theme>.css. Do not put raw colours or fonts in this file.
  If a design needs a new value, add a token to every theme instead.
*/

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.4;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.05; margin: 0; }
p { margin: 0; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 1em; height: 1em; flex: none; }

/* Shared pieces */
.eyebrow {
  font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.chip {
  display: inline-block; padding: 6px 12px; border-radius: var(--radius-pill);
  background: var(--surface); color: var(--muted); font-size: 14px;
}
.panel { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; }
.status { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 18px; }
.status-ok { background: var(--ok-bg); color: var(--ok-ink); }
.status-warn { background: var(--warn-bg); color: var(--warn-ink); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 56px; padding: 0 24px;
  border: 2px solid transparent; border-radius: var(--radius-md);
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-display); font-size: 20px; font-weight: 800;
  text-decoration: none; cursor: pointer;
}
.button-secondary { background: transparent; border-color: var(--line); color: var(--ink); font-weight: 600; }
.button-big { min-height: 104px; font-size: 32px; }
.button-tall { min-height: 80px; font-size: 26px; }
.button-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 600; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.text-input {
  flex: 1 1 220px; min-height: 56px; padding: 0 16px;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink); font-size: 22px;
}

/* Stand scanner (kiosk)
   Every size follows the screen's height as well as its width, so each panel fits the
   screen without scrolling, on an iPad either way round and on a phone (Ben, 13 Oct).
   The largest sizes are the ones a big iPad always had. --vh is 1% of the height
   left with Safari's bars showing (svh), or of the whole screen on an older Safari. */
.kiosk {
  --vh: 1vh;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  gap: clamp(10px, calc(3 * var(--vh)), 24px);
  padding: clamp(10px, calc(3.5 * var(--vh)), 28px) clamp(16px, 4vw, 40px);
}
@supports (height: 1svh) { .kiosk { --vh: 1svh; } }
.kiosk-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.stand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.stand-badge {
  flex: none; width: clamp(40px, calc(7 * var(--vh)), 56px); height: clamp(40px, calc(7 * var(--vh)), 56px);
  border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: clamp(18px, calc(3 * var(--vh)), 24px); font-weight: 800;
}
.stand-name { font-family: var(--font-display); font-size: clamp(18px, calc(3.4 * var(--vh)), 26px); font-weight: 600; line-height: 1.2; }
.kiosk-main { flex: 1; display: flex; flex-direction: column; }
.state {
  flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, calc(5 * var(--vh)), 48px); align-items: center;
}

.camera {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  border: 3px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.camera video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: var(--camera-bg);
}
.camera.is-front video { transform: scaleX(-1); }
.camera-off { color: var(--muted); font-size: 18px; }
.camera-status { margin-top: 12px; color: var(--muted); font-size: 18px; }
.camera-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.camera-controls .button { flex: 1 1 auto; }
/* On the stand the camera is never taller than --camera-h, so the words under or beside
   it still fit. With no picture yet (camera off, refused or starting) it is a short box,
   so the message and the Start button fit too. It grows once the camera shows. */
.kiosk .camera {
  --camera-h: calc(60 * var(--vh));
  width: min(100%, calc(var(--camera-h) * 4 / 3)); margin-inline: auto;
}
.kiosk .camera:has(> video[hidden]) { aspect-ratio: auto; width: 100%; min-height: clamp(56px, calc(14 * var(--vh)), 160px); }
.kiosk .camera-status { margin-top: clamp(6px, calc(1.5 * var(--vh)), 12px); font-size: clamp(15px, calc(2.4 * var(--vh)), 18px); }
.kiosk .camera-controls { margin-top: 0; }
.kiosk .camera-controls .button { margin-top: 16px; }
.ready-copy { display: flex; flex-direction: column; gap: clamp(10px, calc(2.6 * var(--vh)), 20px); }
.ready-copy h1 { font-size: clamp(24px, min(calc(7.5 * var(--vh)), 5vw), 60px); font-weight: 800; letter-spacing: -0.02em; }
.ready-copy .hint { font-size: clamp(16px, calc(2.9 * var(--vh)), 22px); color: var(--muted); }
.kiosk .status { font-size: clamp(15px, calc(2.4 * var(--vh)), 18px); }
.kiosk .text-input { flex-basis: 140px; min-width: 0; min-height: clamp(48px, calc(7 * var(--vh)), 56px); }
.kiosk .field-row .button { min-height: clamp(48px, calc(7 * var(--vh)), 56px); }

/* The tick and its dots are drawn in proportion to --tick. */
.tick {
  --tick: clamp(80px, calc(24 * var(--vh)), 220px);
  position: relative; flex: none; width: var(--tick); height: var(--tick);
  margin: calc(var(--tick) * 0.155) 0 0 calc(var(--tick) * 0.21);
}
.tick-ring { position: absolute; inset: calc(var(--tick) * -0.082); border-radius: 50%; border: 6px solid var(--second); }
.tick-dot-a {
  position: absolute; top: calc(var(--tick) * -0.155); right: calc(var(--tick) * -0.18);
  width: calc(var(--tick) * 0.155); height: calc(var(--tick) * 0.155);
  border-radius: 50%; background: var(--second);
}
.tick-dot-b {
  position: absolute; bottom: calc(var(--tick) * -0.09); left: calc(var(--tick) * -0.21);
  width: calc(var(--tick) * 0.09); height: calc(var(--tick) * 0.09);
  border-radius: 50%; background: var(--accent);
}
.tick-core {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-size: calc(var(--tick) * 0.545);
}
.tick-warn .tick-core { background: var(--warn-bg); color: var(--warn-ink); border: 6px solid var(--warn-ink); }
.hero { display: flex; flex-direction: column; gap: clamp(10px, calc(3 * var(--vh)), 24px); }
.hero-title-warn { font-size: clamp(30px, min(calc(8.5 * var(--vh)), 6.5vw), 76px); line-height: 1; }
.hero-title {
  margin-top: clamp(4px, calc(2 * var(--vh)), 16px);
  font-size: clamp(36px, min(calc(12 * var(--vh)), 14vw), 104px);
  font-weight: 800; line-height: 0.95; letter-spacing: -0.02em;
}
.hero-text { font-size: clamp(17px, calc(3.6 * var(--vh)), 28px); color: var(--muted); }
.question {
  background: var(--surface); border-radius: var(--radius-lg); padding: clamp(16px, calc(5 * var(--vh)), 44px);
  display: flex; flex-direction: column; gap: clamp(10px, calc(2.8 * var(--vh)), 22px);
}
.question h2 { font-size: clamp(22px, calc(5.4 * var(--vh)), 42px); font-weight: 800; line-height: 1.1; }
.question p { font-size: clamp(18px, calc(3.4 * var(--vh)), 26px); font-weight: 600; }
.question-actions { display: flex; flex-direction: column; gap: clamp(10px, calc(2.8 * var(--vh)), 22px); }
.kiosk .button-big { min-height: clamp(56px, calc(13 * var(--vh)), 104px); font-size: clamp(20px, calc(4 * var(--vh)), 32px); }
.kiosk .button-tall { min-height: clamp(48px, calc(10 * var(--vh)), 80px); font-size: clamp(18px, calc(3.4 * var(--vh)), 26px); }
.state-single { grid-template-columns: minmax(0, 1fr); }
.hero-title, .hero-title-warn, .hero-text, .question h2, .ready-copy h1 { overflow-wrap: anywhere; }

.countdown { display: flex; align-items: center; gap: 20px; }
.countdown-label { font-size: clamp(15px, calc(2.4 * var(--vh)), 18px); color: var(--muted); white-space: nowrap; }
.countdown-track {
  flex: 1; height: 10px; overflow: hidden;
  border-radius: var(--radius-pill); background: var(--track);
}
.countdown-fill {
  display: block; width: 100%; height: 100%; border-radius: inherit;
  background: var(--second); transition: width 1s linear;
}

/* One column: the camera sits above the words, so it gets less of the height. */
@media (max-width: 899px) {
  .state { grid-template-columns: minmax(0, 1fr); align-content: center; }
  .kiosk .camera { --camera-h: calc(40 * var(--vh)); }
  .tick { --tick: clamp(80px, calc(16 * var(--vh)), 220px); }
  .ready-copy h1 { font-size: clamp(24px, min(calc(5.5 * var(--vh)), 7vw), 48px); }
}
/* Phones: the tick sits beside "You're in!" instead of above it. */
@media (max-width: 599px) {
  .state { align-content: start; gap: clamp(12px, calc(3.5 * var(--vh)), 28px); }
  .kiosk .camera { --camera-h: calc(28 * var(--vh)); }
  .ready-copy h1 { font-size: clamp(22px, calc(5 * var(--vh)), 36px); }
  .hero { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 24px; }
  .hero .tick { --tick: clamp(64px, calc(14 * var(--vh)), 120px); grid-row: span 2; margin: calc(var(--tick) * 0.1) calc(var(--tick) * 0.1) calc(var(--tick) * 0.1) calc(var(--tick) * 0.2); }
  .hero-title { margin-top: 0; font-size: clamp(32px, min(calc(8 * var(--vh)), 11vw), 64px); }
  .hero-title-warn { font-size: clamp(24px, min(calc(5.5 * var(--vh)), 8vw), 44px); }
  .hero-text { grid-column: 1 / -1; font-size: clamp(17px, calc(3.2 * var(--vh)), 22px); }
  .kiosk .connection { padding: 6px 10px; font-size: 14px; }
  .question { padding: clamp(14px, calc(3.5 * var(--vh)), 28px); }
  .question h2 { font-size: clamp(22px, calc(4.4 * var(--vh)), 32px); }
  .kiosk .button-big { min-height: clamp(52px, calc(11 * var(--vh)), 88px); font-size: clamp(20px, calc(3.6 * var(--vh)), 26px); }
}
/* A phone on its side: two columns again, everything small. */
@media (max-height: 500px) and (orientation: landscape) {
  .state { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: center; }
  .state-single { grid-template-columns: minmax(0, 1fr); }
  .kiosk .camera { --camera-h: calc(50 * var(--vh)); }
  .ready-copy h1 { font-size: clamp(20px, min(calc(7 * var(--vh)), 4vw), 36px); }
  .hero { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 20px; }
  .hero .tick { --tick: clamp(56px, calc(22 * var(--vh)), 120px); grid-row: span 2; margin: calc(var(--tick) * 0.1) calc(var(--tick) * 0.1) calc(var(--tick) * 0.1) calc(var(--tick) * 0.2); }
  .hero-title { margin-top: 0; font-size: clamp(28px, calc(11 * var(--vh)), 64px); }
  .hero-title-warn { font-size: clamp(22px, calc(8 * var(--vh)), 44px); }
  .hero-text { grid-column: 1 / -1; }
  .eyebrow { display: none; }
  .kiosk .start-card { width: min(720px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kiosk .start-card :is(h1, h2, p) { grid-column: 1 / -1; }
}

/* Journey pages */
.journey {
  max-width: 560px; margin: 0 auto; padding: 28px 20px 48px;
  display: flex; flex-direction: column; gap: 22px;
}
.journey-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.journey-head h1 { font-size: 42px; font-weight: 800; }
.journey h2 { font-size: 24px; font-weight: 800; }
.section { display: flex; flex-direction: column; gap: 12px; }

.progress { display: flex; align-items: center; gap: 20px; }
.ring { width: 120px; height: 120px; flex: none; }
.ring-track { stroke: var(--track); }
.ring-fill { stroke: var(--accent); }
.ring-text { fill: var(--ink); font-family: var(--font-display); font-size: 40px; font-weight: 800; }
.progress-copy { display: flex; flex-direction: column; gap: 4px; }
.stat-big { font-family: var(--font-display); font-size: 30px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 17px; color: var(--muted); }
.stat-note { margin-top: 6px; font-size: 15px; font-weight: 600; }

.badges {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
}
.badge-card {
  border-radius: var(--radius-sm); padding: 14px;
  display: flex; flex-direction: column; gap: 6px; font-size: 24px;
}
.badge-earned { background: var(--second); color: var(--on-second); }
.badge-locked { border: 2px dashed var(--line); color: var(--muted); padding: 12px; }
.badge-name { font-size: 16px; font-weight: 800; line-height: 1.15; }
.badge-locked .badge-name { font-weight: 600; }
.badge-hint { font-size: 13px; }

.stands { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.stand-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px;
  border-radius: var(--radius-sm); background: var(--surface);
}
.stand-row.is-todo { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.stand-row-check { color: var(--accent); font-size: 22px; margin-top: 1px; }
.todo-dot {
  width: 18px; height: 18px; flex: none; margin-top: 3px;
  border-radius: 50%; border: 2px solid var(--line);
}
.stand-row-main { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stand-row-name { font-size: 17px; font-weight: 600; }
.stand-row.is-todo .stand-row-name { font-weight: 400; }
.stand-row-meta { font-size: 14px; color: var(--muted); }
.stand-row-tags { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.like-icon { color: var(--like); font-size: 20px; }
/* Learn more: a full-size touch target under the stand's details. The address shows instead when printed. */
.stand-row-link { align-self: flex-start; margin-top: 8px; min-height: 44px; padding: 0 16px; font-size: 16px; }
.stand-row-link-print { display: none; }

.journey-actions { display: flex; flex-wrap: wrap; gap: 12px; }

@media print {
  .journey-actions { display: none; }
  .journey { max-width: none; }
  .stand-row-link { display: none; }
  .stand-row-link-print { display: inline; word-break: break-all; }
}

/* Admin area */
body.admin-body { background: var(--surface); }
.admin-top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 32px;
  padding: 14px 32px; background: var(--bg); border-bottom: 1px solid var(--track);
}
.admin-brand { display: flex; flex-direction: column; color: var(--ink); text-decoration: none; }
.admin-brand .eyebrow { font-size: 12px; }
.admin-brand-name { font-family: var(--font-display); font-size: 22px; font-weight: 800; line-height: 1.1; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.admin-nav a {
  padding: 8px 14px; border-radius: var(--radius-pill);
  color: var(--ink); font-size: 16px; font-weight: 600; text-decoration: none;
}
.admin-nav a:hover { background: var(--surface); }
.admin-nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }

.admin { max-width: 1240px; margin: 0 auto; padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 24px; }
.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.admin-head h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.01em; }
.report-event { margin-top: 6px; font-size: 18px; font-weight: 600; }
.share-card { margin-bottom: 24px; }
.share-url { font-size: 20px; font-weight: 700; word-break: break-all; }
.journey-event { color: var(--muted); font-weight: 600; }
.admin-intro { margin-top: 6px; color: var(--muted); font-size: 16px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.admin-actions .button { min-height: 48px; font-size: 17px; border-radius: var(--radius-sm); }

.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(0, auto);
  gap: 16px;
}
.kpi {
  display: flex; flex-direction: column; gap: 6px; padding: 20px 22px;
  border-radius: var(--radius-sm); background: var(--bg);
}
.kpi-hero { grid-column: span 2; grid-row: span 2; justify-content: center; gap: 10px; padding: 28px; }
.kpi-label { color: var(--muted); font-size: 15px; font-weight: 600; }
.kpi-value { font-family: var(--font-body); font-size: 40px; font-weight: 700; line-height: 1; }
.kpi-hero .kpi-value { font-size: 72px; }
.kpi-note { color: var(--muted); font-size: 14px; }
.kpi-strong { color: var(--ink); font-weight: 700; font-size: 16px; }
.meter { height: 12px; overflow: hidden; border-radius: var(--radius-pill); background: var(--track); }
.meter-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.report {
  display: flex; flex-direction: column; gap: 4px; padding: 24px;
  border-radius: var(--radius-sm); background: var(--bg);
}
.report h2 { font-size: 24px; font-weight: 800; }
.table-wrap { margin-top: 12px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.data-table th, .data-table td { padding: 12px; border-bottom: 1px solid var(--track); text-align: left; }
.data-table thead th {
  border-bottom: 2px solid var(--track); color: var(--muted);
  font-size: 13px; font-weight: 700; vertical-align: bottom;
}
.data-table tbody th { font-weight: 600; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tbody tr:hover { background: var(--surface); }
.data-table .empty { color: var(--muted); text-align: left; }
/* Headings may wrap, so a wide table never pushes its last column out of view (UX pass). */
.data-table thead th.num { white-space: normal; }
/* Report tables on a phone (UX pass): each row becomes a small card, a name then one
   labelled number per line, instead of numbers hidden off to the right. */
@media (max-width: 599px) {
  .stack-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table th, .stack-table td { display: block; width: auto; }
  .stack-table tbody tr { padding: 12px 0; border-bottom: 1px solid var(--track); }
  .stack-table tbody th, .stack-table td { border-bottom: 0; padding: 3px 0; }
  .stack-table tbody th { font-size: 18px; padding-bottom: 6px; }
  .stack-table td { display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: right; }
  .stack-table td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .stack-table td.empty { display: block; text-align: left; }
  .stack-table td.empty::before { content: none; }
  .stack-table .bar { display: none; }            /* the number matters more on a phone */
  .admin-head h1 { font-size: 30px; }
}
.data-table td a { white-space: nowrap; }
.bar-cell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 10px; }
.bar { width: 96px; height: 8px; overflow: hidden; border-radius: var(--radius-xs); background: var(--track); }
.bar span { display: block; height: 100%; border-radius: var(--radius-xs); background: var(--accent); }


@media (max-width: 899px) {
  .admin-top, .admin { padding-left: 20px; padding-right: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-hero { grid-row: auto; }
  .kpi-hero .kpi-value { font-size: 56px; }
}

/* Admin building blocks: cards, forms, tags and messages */
.admin-card {
  display: flex; flex-direction: column; gap: 14px; padding: 24px;
  border-radius: var(--radius-sm); background: var(--bg);
}
.admin-card h2, .report h2 { font-size: 24px; font-weight: 800; }
.admin-card > .table-wrap { margin-top: 0; }
.admin-card .kpi { background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label, .form-field .form-label { font-size: 15px; font-weight: 600; }
.form-help { color: var(--muted); font-size: 13px; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 2px solid var(--line); border-radius: var(--radius-field);
  background: var(--bg); color: var(--ink); font-size: 17px;
}
.input[type="file"] { padding: 10px 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.admin .button { min-height: 48px; font-size: 17px; border-radius: var(--radius-sm); }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .form-field { flex: 1 1 260px; }
.kpis-plain { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--surface); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tag-ok { background: var(--ok-bg); color: var(--ok-ink); }
.tag-warn { background: var(--warn-bg); color: var(--warn-ink); }
.code { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; white-space: nowrap; }
/* A form wrapping several admin cards keeps the page's spacing between them. */
.admin-stack { display: flex; flex-direction: column; gap: 24px; }
/* Wristbands just allocated, listed under the success message. */
.given-bands { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface); }
.code-list { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; line-height: 1.6; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }

/* Home page */
.home { max-width: 900px; margin: 0 auto; padding: 48px 24px; display: flex; flex-direction: column; gap: 28px; }
.home h1 { font-size: 52px; font-weight: 800; letter-spacing: -0.02em; }
.home-intro { color: var(--muted); font-size: 20px; }
.home-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.home-choice {
  display: flex; flex-direction: column; gap: 12px; padding: 28px;
  border-radius: var(--radius-lg); background: var(--surface);
}
.home-choice h2 { font-size: 28px; font-weight: 800; }
.home-choice p { color: var(--muted); font-size: 17px; flex: 1; }
.home-choice .button { align-self: flex-start; }

@media (max-width: 699px) {
  .form-grid, .home-choices { grid-template-columns: minmax(0, 1fr); }
  .home h1 { font-size: 40px; }
}

@media print {
  .admin-top, .admin-actions, .no-print { display: none !important; }
  body.admin-body { background: var(--bg); }
  .report, .kpi, .admin-card { border: 1px solid var(--track); break-inside: avoid; }
  /* Wide tables print in full instead of being cut off at the right. */
  .table-wrap { overflow: visible; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 6px 8px; }
  .data-table thead th, .data-table thead th.num { white-space: normal; }
  .bar { width: 48px; }
}

/* Organiser login and the signed-in user in the admin header */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(440px, 100%); gap: 20px; padding: 32px; }
.login-card h1 { font-size: 34px; font-weight: 800; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
/* Account menu: initial and name, opening to password, organisers and log out. */
.account-menu { position: relative; margin-left: auto; order: 2; }
/* Brand and account share the top row. The page menu gets its own row below. */
.admin-top:has(.account-menu) .admin-nav { order: 3; flex-basis: 100%; }
.account-menu summary {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill); color: var(--ink); font-size: 15px; font-weight: 600;
  cursor: pointer; list-style: none;
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { background: var(--surface); }
.account-menu summary .icon { width: 16px; height: 16px; transition: transform 0.15s; }
.account-menu[open] summary .icon { transform: rotate(180deg); }
.account-initial {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-weight: 800;
}
.account-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; min-width: 240px;
  display: flex; flex-direction: column; padding: 8px; border: 1px solid var(--track);
  border-radius: var(--radius-sm); background: var(--bg);
}
.account-who {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 12px 12px; margin-bottom: 4px;
  border-bottom: 1px solid var(--track); color: var(--muted); font-size: 14px;
}
.account-who span { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.account-panel a, .account-panel button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  text-align: left; text-decoration: none; cursor: pointer;
}
.account-panel a:hover, .account-panel button:hover, .account-panel a[aria-current="page"] { background: var(--surface); }
.account-panel form { margin: 0; }
@media (max-width: 599px) {
  .account-name { display: none; }    /* just the initial on a phone */
}
.link-button {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: transparent; color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer;
}
a.link-button { text-decoration: none; }
.link-button:hover { background: var(--surface); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions form { margin: 0; }
.temp-password { border: 2px solid var(--accent); }
.temp-password-value { font-size: 22px; font-weight: 700; user-select: all; }
.password-card { max-width: 560px; }
.device-link { font-size: 14px; word-break: break-all; white-space: normal; }
.admin-actions form { margin: 0; }

/* Scanner setup sheet: cards to print and cut out, one per stand */
.setup-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; }
.setup-card {
  display: flex; flex-direction: column; gap: 14px; padding: 22px;
  border: 2px dashed var(--line); border-radius: var(--radius-sm); background: var(--bg);
  break-inside: avoid;
}
.setup-card h2 { font-size: 26px; font-weight: 800; }
.setup-codes { display: flex; flex-wrap: wrap; gap: 18px; }
.setup-code { margin: 0; flex: 1 1 170px; display: flex; flex-direction: column; gap: 6px; }
.qr { width: 170px; height: 170px; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr path { fill: var(--ink); }
.setup-code figcaption { display: flex; flex-direction: column; font-size: 15px; }
.setup-url { font-size: 12px; color: var(--muted); word-break: break-all; }
.setup-url .code { display: block; white-space: normal; font-family: var(--font-mono); font-size: 14px; color: var(--ink); }
.setup-placement { font-size: 15px; color: var(--muted); }
.setup-steps { margin: 0; padding-left: 20px; font-size: 14px; color: var(--ink); }
.setup-help { font-size: 14px; }
@media print {
  .setup-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  /* Only the setup sheet prints without its heading: reports and packing lists keep theirs. */
  .setup-sheet-page .admin-head, .setup-sheet-page .admin-intro { display: none; }
}
.data-table tr.row-alert { background: var(--warn-bg); }

/* Stand iPad connection pill (offline queue) */
.connection {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: var(--radius-pill); background: var(--surface); font-size: 16px; font-weight: 600;
}
.connection::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ok-ink); }
.connection.is-offline { background: var(--warn-bg); color: var(--warn-ink); }
.connection.is-offline::before { background: var(--warn-ink); }
.connection.is-sending::before { background: var(--accent); }

/* Stand iPad kiosk: start screen, staff menu, scan flash */
.stand { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
/* The card is centred with auto margins, not align-items: a card taller than a phone
   screen then scrolls inside the overlay instead of losing its top off the screen. */
.start-screen, .staff-menu {
  position: fixed; inset: 0; z-index: 20; display: flex; overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(12px, 3vh, 24px); background: var(--bg);
}
.staff-menu { background: var(--surface); }
.start-screen[hidden], .staff-menu[hidden] { display: none; }
.start-card {
  width: min(560px, 100%); margin: auto; display: flex; flex-direction: column;
  gap: clamp(10px, 2.2vh, 18px); text-align: center;
  padding: clamp(18px, 4.5vh, 36px); border-radius: var(--radius-lg); background: var(--surface);
}
.staff-menu .start-card { background: var(--bg); }
.start-card h1 { font-size: clamp(32px, 7vh, 56px); font-weight: 800; }
.start-card h2 { font-size: clamp(24px, 4.5vh, 32px); font-weight: 800; }
.start-card p { font-size: clamp(16px, 2.6vh, 20px); color: var(--muted); }
.start-card .button-big { min-height: clamp(56px, 12vh, 104px); font-size: clamp(20px, 4vh, 32px); }
.staff-menu .button { min-height: clamp(44px, 7vh, 56px); }
.start-card p.status-warn { color: var(--warn-ink); }
.start-card p.start-tip { font-size: clamp(13px, 2vh, 16px); }
.flash { position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: 0; }
.flash.flash-ok { background: var(--accent); animation: flash 0.7s ease-out; }
.flash.flash-warn { background: var(--warn-ink); animation: flash 0.7s ease-out; }
@keyframes flash { from { opacity: 0.55; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flash.flash-ok, .flash.flash-warn { animation-duration: 0.2s; } }
.passcode { font-size: 18px; font-weight: 700; letter-spacing: 0.08em; }
.passcode-input { font-size: 28px; letter-spacing: 0.3em; max-width: 220px; }

/* Device links page */
.notice-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.notice-row form { margin: 0; }
.stand-filter { max-width: 420px; }
.stand-block { gap: 12px; }
.stand-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.device-row {
  display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) auto; align-items: start; gap: 8px 16px;
  padding: 12px 0; border-top: 1px solid var(--track);
}
.device-row:has(.link-panel:not([hidden])) { background: var(--surface); margin: 0 -12px; padding: 12px; border-radius: var(--radius-sm); }
.device-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.device-label { font-weight: 700; }
.device-state { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; padding-top: 4px; }
.state-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.state-ok .state-dot { background: var(--ok-ink); }
.state-ok { color: var(--ok-ink); }
.state-silent .state-dot { background: var(--warn-ink); }
.state-silent { color: var(--warn-ink); font-weight: 700; }
.device-row > .row-actions { justify-content: flex-end; }
.add-device > summary { list-style: none; display: inline-block; }
.add-device > summary::-webkit-details-marker { display: none; }
.link-panel { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 20px; margin-top: 4px; }
.link-panel[hidden] { display: none; }
.device-row:has(.link-panel:not([hidden])) .chip { background: var(--bg); }
.link-panel > .status { flex-basis: 100%; }
.link-side { display: flex; flex-direction: column; gap: 10px; flex: 1 1 240px; }
.link-qr { padding: 10px; border-radius: var(--radius-sm); background: var(--bg); }
.link-qr svg { display: block; width: 220px; height: 220px; }
.link-url { white-space: normal; overflow-wrap: anywhere; font-size: 14px; color: var(--muted); }
.add-device[open] > summary { margin-bottom: 12px; }
.folded > summary { cursor: pointer; }
.folded > summary h2 { display: inline; }
.folded[open] { gap: 16px; }
.danger-zone { border: 1px solid var(--track); }
@media (max-width: 699px) {
  .device-row { grid-template-columns: minmax(0, 1fr); }
  .device-row > .row-actions { justify-content: flex-start; }
}

/* Device status page */
.kpi-alert { background: var(--warn-bg); color: var(--warn-ink); }
.setup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.setup-list li { display: flex; gap: 14px; align-items: flex-start; }
.setup-mark {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--surface); color: var(--ink);
}
.setup-done .setup-mark { background: var(--accent); color: var(--on-accent); }
.setup-text { display: flex; flex-direction: column; }
.setup-text a { font-weight: 700; }
.kpi-link { display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.kpi-link:hover .kpi-label { text-decoration: underline; }
/* A warning tag inside a row already highlighted as a warning keeps standing out. */
.row-alert .tag-warn { background: var(--bg); box-shadow: inset 0 0 0 1px var(--warn-ink); }
.kpi-alert .kpi-label, .kpi-alert .kpi-note { color: var(--warn-ink); }
.attention { border: 2px solid var(--warn-ink); }
.attention-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.attention-list li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px 0; border-top: 1px solid var(--track);
}
.live-note { margin-top: -12px; }
#status-live > .form-help { margin-top: -12px; }
