/* ==========================================================================
   Value Scanner - design system
   Calm surfaces, one accent, semantic colour reserved for value/risk only.
   ========================================================================== */

:root {
  --bg:            #fafafb;
  --surface:       #ffffff;
  --surface-2:     #f5f6f8;
  --surface-3:     #eef0f4;
  --border:        #e6e8ed;
  --border-strong: #d4d7e0;

  --text:   #16181d;
  --text-2: #5b6170;
  --text-3: #8d93a3;

  --accent:      #4f46e5;
  --accent-hover:#4338ca;
  --accent-soft: #eef2ff;
  --accent-line: #c7d0fb;

  --pos:      #0d8f5b;
  --pos-soft: #e7f6ee;
  --neg:      #cf4436;
  --neg-soft: #fdeeec;
  --warn:     #a8710e;
  --warn-soft:#fdf4e3;
  --info-soft:#eaf2fd;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 20, 34, .05);
  --shadow:    0 4px 14px rgba(16, 20, 34, .08);
  --shadow-lg: 0 18px 48px rgba(16, 20, 34, .16);

  --sidebar-w: 232px;
  --topbar-h:  57px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg:            #0c0d11;
  --surface:       #13151b;
  --surface-2:     #191c23;
  --surface-3:     #21242d;
  --border:        #23262f;
  --border-strong: #333743;

  --text:   #e9ebf1;
  --text-2: #98a0b0;
  --text-3: #6b7284;

  --accent:      #7b78f5;
  --accent-hover:#8f8cf8;
  --accent-soft: #1c1d33;
  --accent-line: #3a3866;

  --pos:      #35c48a;
  --pos-soft: #0f2a20;
  --neg:      #f0665a;
  --neg-soft: #2e1715;
  --warn:     #e0a63f;
  --warn-soft:#2b2110;
  --info-soft:#141f2e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: var(--accent-soft); color: var(--text); }

/* scrollbars ------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ==========================================================================
   layout
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.brand-name { font-weight: 620; letter-spacing: -.01em; font-size: 14.5px; }
.brand-sub  { font-size: 11px; color: var(--text-3); margin-top: -2px; }

.nav { padding: 12px 10px; overflow-y: auto; flex: 1; min-height: 0; }
.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  padding: 0 10px 7px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  user-select: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 560; }
.nav-item .ico { width: 16px; display: grid; place-items: center; opacity: .85; }
.nav-item .badge {
  margin-left: auto;
  font-family: var(--mono); font-size: 10.5px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 20px;
}
.nav-item.active .badge { background: #fff2; color: inherit; }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
  flex-shrink: 0;
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  flex-shrink: 0;
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.topbar .sub { font-size: 12px; color: var(--text-3); }
.topbar .spacer { flex: 1; }

.content { flex: 1; overflow: auto; min-height: 0; }
.view { padding: 22px 24px 60px; max-width: 1560px; }
.view.wide { max-width: none; }

/* ==========================================================================
   primitives
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h2 { margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: -.005em; }
.card-head .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
/* The gap already separates grid cells; the stacked-card margin would
   lift the first card of a row 16 px above its neighbours. */
.grid > .card + .card { margin-top: 0; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 372px; align-items: start; }
@media (max-width: 1180px) {
  .grid.c3, .grid.c4, .grid.side { grid-template-columns: minmax(0, 1fr); }
}

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.tight { gap: 7px; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* buttons ---------------------------------------------------------------- */
.btn {
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 520;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--neg); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--neg-soft); }
/* A ticket that already has its slip photo: green so it stands apart at a
   glance from one still waiting for a photo. Theme-aware via --pos. */
.btn.ok { color: var(--pos); border-color: var(--pos); background: var(--pos-soft); }
.btn.ok:hover { background: var(--pos); color: #fff; border-color: var(--pos); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.icon { padding: 6px; width: 30px; justify-content: center; }

/* inputs ----------------------------------------------------------------- */
label.field { display: block; }
.field-label {
  display: block;
  font-size: 11.5px; font-weight: 560; color: var(--text-2);
  margin-bottom: 5px;
  letter-spacing: .005em;
}
input[type="text"], input[type="number"], input[type="password"],
input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%238d93a3' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; user-select: none; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; }

/* chips ------------------------------------------------------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip .n { font-family: var(--mono); font-size: 10.5px; opacity: .7; }
.chip.static { cursor: default; }

.tag {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 620; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 5px;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag.strong { background: var(--pos-soft); color: var(--pos); }
.tag.value  { background: var(--info-soft); color: var(--accent); }
.tag.thin   { background: var(--surface-3); color: var(--text-2); }
.tag.unver  { background: var(--warn-soft); color: var(--warn); }
.tag.neutral{ background: var(--surface-3); color: var(--text-3); }
.tag.neg    { background: var(--neg-soft); color: var(--neg); }

/* The result box of a ticket leg, coloured by what it says so a slip of
   many legs reads at a glance: green won, red lost, blue voided (odds
   1.00), plain while still open. */
select.res-won  { background-color: var(--pos-soft); color: var(--pos); border-color: var(--pos); font-weight: 600; }
select.res-lost { background-color: var(--neg-soft); color: var(--neg); border-color: var(--neg); font-weight: 600; }
select.res-void { background-color: var(--info-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
select.res-won option, select.res-lost option, select.res-void option {
  background: var(--surface-2); color: var(--text); font-weight: 400;
}

.grade {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 5px;
  font-size: 11px; font-weight: 700;
  font-family: var(--mono);
}
.grade.A { background: var(--pos-soft); color: var(--pos); }
.grade.B { background: var(--info-soft); color: var(--accent); }
.grade.C { background: var(--surface-3); color: var(--text-2); }
.grade.D { background: var(--warn-soft); color: var(--warn); }
.grade.E { background: var(--neg-soft); color: var(--neg); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }

/* stats ------------------------------------------------------------------ */
.stat { padding: 14px 16px; }
.stat-label {
  font-size: 11px; font-weight: 560; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
}
.stat-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 23px; font-weight: 600; letter-spacing: -.02em;
  margin-top: 4px; line-height: 1.15;
}
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* Statistik: rows with a handful of picks are shown, but quietly. */
.stats-note { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
table.data.stats tbody tr { cursor: default; }
table.data.stats tbody tr.thin td { color: var(--text-3); }

/* meter ------------------------------------------------------------------ */
.meter { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .25s; }
.meter.pos > i { background: var(--pos); }
.meter.warn > i { background: var(--warn); }
.meter.neg > i { background: var(--neg); }

/* ==========================================================================
   table
   ========================================================================== */

.table-wrap { overflow: auto; max-height: calc(100vh - var(--topbar-h) - 210px); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px; font-weight: 620; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.data thead th:hover { color: var(--text); }
table.data thead th.sorted { color: var(--accent); }
table.data thead th.r, table.data td.r { text-align: right; }
table.data thead th.c, table.data td.c { text-align: center; }
table.data tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr.sel td { background: var(--accent-soft); }
/* The saved ticket whose detail is open below the list. The soft tint
   alone vanished among twenty rows in the dark theme, so the row also
   carries a bar and its name in the accent colour -- one glance says
   which ticket the panel belongs to. */
table.data tbody tr.sel-open td { background: var(--accent-soft); }
table.data tbody tr.sel-open td:first-child {
  box-shadow: inset 4px 0 0 var(--accent); color: var(--accent); font-weight: 700;
}
table.data tbody tr.sel-open:hover td { background: var(--accent-soft); }
/* A tag with display set would otherwise ignore the hidden attribute. */
.tag[hidden] { display: none !important; }
table.data tbody tr.picked td { box-shadow: inset 2px 0 0 var(--accent); }
table.data td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ev-name { font-weight: 520; }
.ev-meta { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* The shop's own fixture number, linked to the shop's own page. It sits
   inside .ev-meta at 11.5px, so it has to read as clickable without
   shouting: the browser's default blue is both louder than anything else
   on the row and nearly unreadable on the dark surface. Accent colour and
   a dotted rule do the same job inside the design system. */
.book-nr {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-line);
}
.book-nr:hover { color: var(--accent-hover); border-bottom-style: solid; }
.cell-tight { line-height: 1.35; }

.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty .big { font-size: 15px; color: var(--text-2); margin-bottom: 5px; font-weight: 520; }

/* ==========================================================================
   filter bar
   ========================================================================== */

.filters { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filter-row .field { width: 108px; flex-shrink: 0; }
.filter-row .field.grow { flex: 1; min-width: 190px; width: auto; }
.facets { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.facet-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .05em;
  width: 62px; flex-shrink: 0;
}

/* Player-chosen ordering of the value list. */
.sortby { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.sort-sel {
  font-size: 12px; padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); cursor: pointer;
}

/* The BOOK facet: one row per country, led by a small flag and the name.
   The flags are drawn in CSS -- Windows shows no emoji flags and the CSP
   allows no outside images -- so they are the stripes only, no arms. */
.facets .country {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  width: 112px; flex-shrink: 0;
}
.flag {
  display: inline-block; width: 18px; height: 12px; border-radius: 2px; position: relative;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .28); flex-shrink: 0;
  background: var(--border-strong);
}
.flag-de { background: linear-gradient(#000 0 33.4%, #dd0000 33.4% 66.7%, #ffce00 66.7%); }
.flag-ba { background: linear-gradient(to bottom left, #fecb00 0 50%, transparent 50%) 5px 0 / 10px 12px no-repeat, #002395; }
.flag-hr { background: linear-gradient(#ff0000 0 33.4%, #fff 33.4% 66.7%, #171796 66.7%); }
/* Without the chequerboard the stripes are the Dutch flag. */
.flag-hr::after {
  content: ""; position: absolute; left: 6px; top: 3px; width: 6px; height: 6px;
  background: repeating-conic-gradient(#e0001b 0 25%, #fff 0 50%) 0 0 / 2px 2px;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .35);
}
.flag-rs { background: linear-gradient(#c6363c 0 33.4%, #0c4076 33.4% 66.7%, #fff 66.7%); }
.flag-me { background: #c40308; box-shadow: inset 0 0 0 2px #d3ae3b, 0 0 0 1px rgba(0, 0, 0, .28); }

/* Real SVG flags + one clean block per country (replaces the old inline row).
   Authentic colours, crisp on mobile. */
.book-head { margin-top: 4px; }
.book-country { width: 100%; margin: 2px 0 10px; }
.country-head {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 6px;
  font-size: 12px; font-weight: 700; color: var(--text-2); letter-spacing: .2px;
}
.country-n { font-family: var(--mono); font-size: 10px; color: var(--text-3); opacity: .7; }
.flag2 {
  width: 24px; height: 16px; border-radius: 3px; display: inline-block;
  object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .30); flex-shrink: 0;
}
.flag2-none {
  width: 24px; height: 16px; border-radius: 3px; display: inline-block;
  background: var(--border-strong); box-shadow: 0 0 0 1px rgba(0, 0, 0, .30); flex-shrink: 0;
}
.book-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 2px; }

/* ==========================================================================
   drawer
   ========================================================================== */

.drawer-back {
  position: fixed; inset: 0;
  background: rgba(12, 14, 20, .34);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
}
.drawer-back.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 470px; max-width: 94vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 41;
  transform: translateX(102%);
  transition: transform .22s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px; flex-shrink: 0;
}
.drawer-body { overflow-y: auto; padding: 18px; flex: 1; }
.drawer-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}

.kv { display: grid; grid-template-columns: 1fr auto; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.section-title {
  font-size: 11px; font-weight: 620; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); margin: 22px 0 9px;
}
.section-title:first-child { margin-top: 0; }

/* ==========================================================================
   slip
   ========================================================================== */

.slip-leg {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex; gap: 10px; align-items: flex-start;
}
.slip-leg + .slip-leg { margin-top: 8px; }
.slip-leg .x { margin-left: auto; }
.slip-leg.carrier { border-left: 2px solid var(--accent); }
.slip-leg.support { border-left: 2px solid var(--text-3); }

.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-item {
  display: flex; align-items: center; gap: 9px;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.check-item .dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: var(--pos);
}
.check-item.bad { background: var(--neg-soft); }
.check-item.bad .dot { background: var(--neg); }
.check-item .detail { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

/* ==========================================================================
   misc
   ========================================================================== */

.spark { display: block; width: 100%; height: 42px; }

.toast-host {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow);
  animation: rise .22s ease-out;
}
.toast.err { background: var(--neg); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dot-live {
  width: 7px; height: 7px; border-radius: 50%; background: var(--pos);
  box-shadow: 0 0 0 3px var(--pos-soft);
  flex-shrink: 0;
}
.dot-live.off { background: var(--text-3); box-shadow: 0 0 0 3px var(--surface-3); }

code.inline {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px;
}

.formula {
  font-family: var(--mono); font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
}

.note {
  font-size: 12.5px; color: var(--text-2); line-height: 1.6;
}
.note strong { color: var(--text); font-weight: 560; }

.callout {
  border-left: 2px solid var(--accent-line);
  background: var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }


/* ==========================================================================
   ticket capture
   ========================================================================== */

video { display: block; }

.shot-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* On a phone the sidebar would eat the screen, so it collapses to a strip
   of icons and the content takes over. */
/* Value-scanner cards -- the phone view of the selections table. Hidden on
   wide screens; the media block below swaps the table for these. */
.vcards { display: none; flex-direction: column; gap: 10px; }
.vcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 13px;
  display: flex; flex-direction: column; gap: 9px;
}
.vc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vc-ev { font-weight: 600; font-size: 14px; line-height: 1.3; }
.vc-sel { font-size: 13px; color: var(--text-2); }
.vc-sel strong { color: var(--text); }
.vc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px 10px; }
.vc-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.vc-k { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.vc-v { font-size: 14px; font-weight: 560; font-variant-numeric: tabular-nums; }
.vc-v.pos { color: var(--pos); }
.vc-v.neg { color: var(--neg); }
.vc-foot { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.vc-link { font-size: 12px; color: var(--text-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.vc-foot .btn.sm { padding: 8px 15px; }

@media (max-width: 720px) {
  /* Phone: the whole PAGE scrolls, not a nest of little boxes. The desktop
     app locks to 100vh and scrolls inside .content and each .table-wrap,
     which on a phone traps you scrolling one cramped box at a time. Here the
     body grows and scrolls naturally; only wide tables scroll sideways. */
  html, body { height: auto; overflow: visible; }
  body { overflow-y: auto; overflow-x: hidden; }   /* lift the desktop overflow:hidden so the page can scroll */
  .app { height: auto; min-height: 100vh; grid-template-columns: 1fr; }
  .content { overflow: visible; }
  .main { min-height: 0; }
  .table-wrap { max-height: none; overflow-y: visible; overflow-x: auto;
                -webkit-overflow-scrolling: touch; }

  /* Nav becomes a slim sticky icon strip across the top. */
  /* A distinct, tinted top bar so the buttons stand out from the page. */
  .sidebar {
    position: sticky; top: 0; z-index: 40;
    flex-direction: row; align-items: center;
    width: auto; height: auto;
    border-right: none; border-bottom: 2px solid var(--accent);
    background: var(--accent-soft);
  }
  .brand, .sidebar-foot,
  .brand-name, .brand-sub, .nav-label { display: none; }
  /* All items WRAP into as many rows as needed (two, typically) so everything
     fits the screen width with no sideways scrolling. */
  .nav { display: flex; flex-direction: row; flex-wrap: wrap;
         justify-content: center; align-content: flex-start;
         padding: 8px 6px; gap: 6px; overflow: visible; flex: 1; min-width: 0; }
  .nav-group { display: contents; }
  /* Icon over a tiny label, uniform chips. */
  .nav-item {
    flex: 0 0 auto; width: 74px; min-height: 54px;
    flex-direction: column; align-items: center; gap: 3px;
    justify-content: center; padding: 6px 4px; white-space: normal;
    font-size: 21px;
    background: var(--surface); color: var(--text-2);
    border: 1px solid var(--border-strong); border-radius: 11px;
  }
  .nav-item .ico { width: auto; opacity: 1; line-height: 1; }
  .nav-item span:not(.ico):not(.badge) {
    display: block; font-size: 9px; line-height: 1.1; font-weight: 500;
    letter-spacing: -.1px; text-align: center; white-space: normal;
  }
  .nav-item .badge { display: none; }
  .nav-item.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .30);
  }

  /* Full, FIXED screen: nothing may scroll the page sideways. `clip` stops the
     drift without breaking the sticky top bar or vertical scroll; the pieces
     that legitimately overflow (wide tables) keep their own inner scroll. */
  html { overflow-x: clip; }
  .app, .main, .content, .sidebar, .view, .card, .topbar { max-width: 100%; min-width: 0; }
  .filter-row { width: 100%; }
  .filter-row .field.grow { min-width: 0; flex-basis: 100%; }
  input, select, textarea, .btn { max-width: 100%; box-sizing: border-box; }

  .topbar { padding: 0 12px; gap: 8px; flex-wrap: wrap; height: auto; min-height: var(--topbar-h); }
  .topbar h1 { font-size: 14px; }
  .topbar .sub, .topbar .spacer { display: none; }
  .view { padding: 14px 12px 72px; }
  /* Let the results header wrap so the sort control always fits. */
  .card-head { flex-wrap: wrap; row-gap: 6px; }
  .sortby { margin-left: 0; }
  .grid.side, .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .filter-row .field { width: calc(50% - 5px); }
  /* Swap the wide selections table for the stacked cards. */
  .only-wide { display: none !important; }
  .vcards.only-narrow { display: flex; }
  /* Roomier tap targets on touch screens. */
  .btn.sm { padding: 8px 13px; }
  .chip { padding: 7px 12px; }
  table.data tbody td, table.data thead th { padding: 11px 10px; }
}


/* ==========================================================================
   login gate
   Signed out there is no application to show, so the shell collapses to a
   single centred column and the sidebar is not rendered at all.
   ========================================================================== */

body[data-gate="on"] .app { grid-template-columns: 1fr; }
body[data-gate="on"] .sidebar { display: none; }
body[data-gate="on"] .topbar { justify-content: center; }
body[data-gate="on"] .topbar h1 { font-size: 14px; }
body[data-gate="on"] .content { display: grid; place-items: start center; }
body[data-gate="on"] .view { width: 100%; max-width: 470px; padding-top: 6vh; }

/* Ticket photo viewer: the image is fetched with the session header and
   shown as a blob, so the token never appears in a URL. */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(12, 14, 20, .82);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 96vw; max-height: 96vh;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
