/* PitStop station UI. Loaded after styles.css (which holds the sign-in screens and brand tokens).
   Status tones: every tone pairs a background with a text colour that passes WCAG AA (4.5:1) at body
   size; measured ratios are in docs/DESIGN.md. */
:root {
  --t-green: #22d36b;  --t-green-ink: #04210f;
  --t-amber: #ffb020;  --t-amber-ink: #2a1700;
  --t-red: #d7263d;    --t-red-ink: #ffffff;
  --t-purple: #7a45f0; --t-purple-ink: #ffffff;
  --t-blue: #2a5ff0;   --t-blue-ink: #ffffff;
  --t-cyan: #22d3ee;   --t-cyan-ink: #032a33;
  --t-grey: #55536e;   --t-grey-ink: #ffffff;
  --t-white: #f1edff;  --t-white-ink: #0c0330;
  --focus: #ffe14d;
}
.tone-green  { --bg: var(--t-green);  --ink: var(--t-green-ink); }
.tone-amber  { --bg: var(--t-amber);  --ink: var(--t-amber-ink); }
.tone-red    { --bg: var(--t-red);    --ink: var(--t-red-ink); }
.tone-purple { --bg: var(--t-purple); --ink: var(--t-purple-ink); }
.tone-blue   { --bg: var(--t-blue);   --ink: var(--t-blue-ink); }
.tone-cyan   { --bg: var(--t-cyan);   --ink: var(--t-cyan-ink); }
.tone-grey   { --bg: var(--t-grey);   --ink: var(--t-grey-ink); }
.tone-white  { --bg: var(--t-white);  --ink: var(--t-white-ink); }

[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--focus); color: #000; padding: 12px 16px; border-radius: 10px; font-weight: 700; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
.ico { display: inline-grid; place-items: center; }

.demo-banner { background: var(--t-amber); color: var(--t-amber-ink); font-weight: 800; text-align: center; padding: 6px 12px; font-size: 14px; }

/* ---------- top bar */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: rgba(12, 3, 48, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.bar-left, .bar-right { display: flex; align-items: center; gap: 10px; }
.mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: #05010f; border: 1px solid #2a1d52; font-weight: 900; font-style: italic; font-size: 17px; }
.mark span { color: var(--green); }
.bar-title { font-weight: 800; font-size: 18px; line-height: 1.1; }
.site { background: none; border: 0; color: var(--muted); padding: 2px 0; min-height: 28px; font-size: 14px; text-align: left; }
.site b { color: var(--text); }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.net .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--t-green); }
.net.off .dot { background: var(--t-red); border-radius: 2px; }
.net.wait .dot { background: var(--t-amber); border-radius: 2px; transform: rotate(45deg); }
.iconbtn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); color: var(--text); }
.menu { position: absolute; right: 12px; top: 64px; display: grid; min-width: 210px; padding: 6px; border-radius: 14px; background: #160a40; border: 1px solid var(--line); box-shadow: 0 24px 48px rgba(0,0,0,.6); }
.menu button { min-height: 52px; text-align: left; padding: 0 16px; background: none; border: 0; border-radius: 10px; color: var(--text); font-size: 17px; font-weight: 600; }
.menu button:hover, .menu button:focus-visible { background: rgba(255,255,255,.08); }

.page { width: min(100%, 720px); margin: 0 auto; padding: 14px 16px calc(120px + env(safe-area-inset-bottom)); outline: none; }
.h2 { font-size: 26px; margin: 6px 0 12px; }
.h3 { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 24px 0 10px; }
.note { color: var(--muted); font-size: 15px; line-height: 1.45; }
.note.big { font-size: 18px; color: var(--text); }
.empty { color: var(--muted); text-align: center; padding: 36px 12px; font-size: 17px; line-height: 1.5; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 8px; line-height: 1.4; }

/* ---------- summary chips, tabs, search */
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
/* Unselected filters are quiet (dark, coloured edge and icon); the selected one is solid. */
.chip { display: grid; justify-items: center; gap: 2px; min-height: 80px; padding: 8px 4px; border-radius: 14px; border: 2px solid var(--bg);
  background: rgba(23,10,60,.85); color: var(--text); font-size: 14px; font-weight: 700; }
.chip .ico { color: var(--bg); }
.chip b { font-size: 24px; line-height: 1; }
.chip .ico svg { width: 22px; height: 22px; }
.chip[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 3px var(--focus); }
.chip[aria-pressed="true"] .ico { color: var(--ink); }
.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,.06); margin-bottom: 12px; }
.tabs button { flex: 1; min-height: 48px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 700; font-size: 16px; }
.tabs [aria-pressed="true"] { background: var(--text); color: var(--ink); }
.count { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 999px; background: rgba(127,118,166,.35); font-size: 13px; }
.tabs [aria-pressed="true"] .count { background: rgba(12,3,48,.15); }
.search { position: relative; display: block; margin: 0 0 10px; }
.search svg { position: absolute; left: 14px; top: 14px; color: var(--muted); }
.search input { padding-left: 46px; text-transform: uppercase; }
.search input::placeholder { text-transform: none; color: #8f86b8; }

/* ---------- rows */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { width: 100%; display: grid; grid-template-columns: 112px 1fr auto; align-items: stretch; padding: 0; overflow: hidden;
  border-radius: 16px; border: 1px solid rgba(255,255,255,.14); background: rgba(23,10,60,.85); color: var(--text); text-align: left; min-height: 76px; }
.row .tile { display: grid; place-items: center; align-content: center; gap: 4px; padding: 8px 6px; background: var(--bg); color: var(--ink); text-align: center; }
.row .tile svg { width: 28px; height: 28px; }
.row .word { font-size: 15px; font-weight: 800; line-height: 1.15; }
.row .mid { display: grid; align-content: center; padding: 8px 12px; min-width: 0; }
.row .id b { font-size: 26px; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.row .id small { display: block; color: #a39bc9; font-size: 14px; letter-spacing: .02em; }
.row .sub { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sw { display: flex; align-items: center; gap: 4px; color: var(--t-green); font-size: 14px; font-weight: 700; }
.row .sw svg { width: 16px; height: 16px; }
.dots { display: grid; grid-template-columns: repeat(3, 14px); gap: 5px; align-content: center; padding: 0 14px 0 4px; }
.d { width: 14px; height: 14px; border: 2px solid var(--text); }
.d.motion { border-radius: 50%; }
.d.door { border-radius: 3px; }
.d.on { background: var(--t-green); border-color: var(--t-green); }
.d.quiet { background: transparent; border-color: var(--t-amber); }
.d.off { border-style: dashed; border-color: #8a82b3; }
.row.live .tile .ico, .banner.live .banner-icon { animation: pulse 1.6s ease-in-out infinite; }
.spinner { animation: spin 1.1s linear infinite; transform-origin: 12px 12px; }
@keyframes pulse { 50% { transform: scale(.86); opacity: .7; } }
@keyframes spin { to { transform: rotate(360deg); } }
.more { text-align: center; margin-top: 10px; }

/* ---------- detail */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 12px 0 4px; margin-bottom: 8px; background: none; border: 0; color: var(--text); font-size: 16px; font-weight: 700; }
.banner { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 22px; background: var(--bg); color: var(--ink); }
.banner-icon svg { width: 64px; height: 64px; stroke-width: 2.2; }
.banner-word { font-size: 30px; font-weight: 900; line-height: 1.05; }
.banner-id { margin: 4px 0 0; font-size: 18px; font-weight: 700; }
.detail { font-size: 18px; line-height: 1.45; margin: 14px 2px; }
.progress { height: 14px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; margin: 0 0 14px; }
.bar-fill { height: 100%; width: 0; background: var(--t-cyan); transition: width .6s; }
.go.big { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 64px; font-size: 20px; margin-top: 6px; }
.go.small { width: auto; min-width: 120px; margin: 0; padding: 0 24px; min-height: 52px; }
.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slot { display: grid; grid-template-columns: 44px 1fr 32px; align-items: center; gap: 10px; min-height: 64px; padding: 8px 14px; border-radius: 14px; border: 2px solid rgba(255,255,255,.14); background: rgba(23,10,60,.85); }
.slot b { font-size: 17px; }
.slot small { display: block; color: var(--muted); font-size: 14px; }
.slot .ico svg { width: 30px; height: 30px; }
.slot.on { border-color: var(--t-green); }
.slot.on .slot-state { color: var(--t-green); }
.slot.quiet, .slot.wait { border-color: var(--t-amber); }
.slot.off { border-style: dashed; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.actions .ghost { padding: 0 18px; color: var(--text); }

.tech { margin-top: 22px; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--line); }
.tech summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--muted); }
.tech .facts { font-size: 13px; font-family: ui-monospace, Consolas, monospace; }

/* ---------- scan button */
.fab { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 0 34px; border-radius: 999px; border: 3px solid #04210f;
  background: var(--green); color: #04210f; font-size: 22px; font-weight: 900; box-shadow: 0 18px 40px rgba(0,0,0,.55); }
.fab svg { width: 30px; height: 30px; stroke-width: 2.4; }
body.scanning .fab { display: none; }
body.scanning { overflow: hidden; }

/* ---------- scanner */
.scanner { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: grid; grid-template-rows: auto 1fr auto; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sc-top, .sc-bottom { position: relative; z-index: 2; padding: 14px 16px; background: rgba(0,0,0,.78); }
.sc-top { padding-top: calc(14px + env(safe-area-inset-top)); }
.sc-title { margin: 0; font-size: 20px; }
.sc-target { margin: 4px 0 0; font-size: 16px; color: #e6e1ff; }
.frame { position: relative; z-index: 1; align-self: center; justify-self: center; width: min(70vw, 300px); aspect-ratio: 1; }
.frame i { position: absolute; width: 44px; height: 44px; border: 5px solid #fff; }
.frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.sc-bottom { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sc-count { margin: 6px 0 10px; color: #e6e1ff; font-size: 15px; }
.sc-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.sc-buttons .ghost { padding: 0 18px; color: #fff; border-color: rgba(255,255,255,.6); min-height: 56px; font-size: 17px; }
.sc-buttons .ghost.absent { visibility: hidden; }
#sc-close { width: 100%; margin: 0; min-height: 60px; }
.sc-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sc-history li:not(:first-child) { font-size: 15px; padding: 8px 12px; }
.sc-last { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--bg); color: var(--ink); font-size: 17px; font-weight: 700; line-height: 1.3; }
.sc-last svg { width: 28px; height: 28px; flex: none; }
.sc-last b { font-size: 22px; }
.manual { margin-top: 12px; }
.manual label { color: #fff; }
.flash { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; text-align: center; background: var(--bg); color: var(--ink); animation: flashin .14s ease-out; }
.flash-icon svg { width: 120px; height: 120px; stroke-width: 2.2; }
.flash-word { font-size: 40px; font-weight: 900; line-height: 1.05; }
.flash-id { font-size: 64px; font-weight: 900; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.flash-sub { font-size: 20px; font-weight: 600; max-width: 22ch; line-height: 1.35; }
.flash-ok { margin-top: 18px; min-width: 200px; min-height: 64px; padding: 0 28px; border-radius: 999px; border: 3px solid var(--ink); background: var(--ink); color: var(--bg); font-size: 22px; font-weight: 900; }
@keyframes flashin { from { opacity: .3; transform: scale(1.04); } }

/* ---------- toast: top, under the bar, away from the Scan button; tap to close */
.toast { position: fixed; z-index: 40; left: 16px; right: 16px; top: 74px; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 56px; padding: 12px 16px; border: 0; border-radius: 14px; background: var(--bg); color: var(--ink); font-weight: 700; font-size: 17px; line-height: 1.3; box-shadow: 0 18px 40px rgba(0,0,0,.5); }
.toast svg { flex: none; }
.legend { margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.legend summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text); font-weight: 600; }
.legend p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.legend .d { display: inline-block; }

/* ---------- timed manual steps */
.steps-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.step-btn { display: grid; justify-items: center; gap: 6px; min-height: 96px; padding: 12px 8px; border-radius: 16px; border: 2px solid rgba(255,255,255,.2);
  background: rgba(23,10,60,.85); color: var(--text); font-size: 17px; font-weight: 700; text-align: center; }
.step-btn svg { width: 30px; height: 30px; }
.t-step { font-size: 20px; font-weight: 800; margin: 0; }
.t-clock { font-size: 72px; font-weight: 900; font-variant-numeric: tabular-nums; text-align: center; margin: 6px 0 4px; }
#t-run .sc-buttons { margin-top: 14px; }
#t-run .sc-buttons .ghost { color: var(--text); }

/* ---------- problems, report sheet, settings, metrics */
.prob { padding: 14px; border-radius: 14px; background: rgba(23,10,60,.85); border: 1px solid rgba(255,255,255,.14); border-left: 8px solid var(--t-red); }
.prob.resolved { border-left-color: var(--t-green); }
.prob-head { display: flex; gap: 8px; align-items: center; font-size: 16px; }
.prob p { margin: 8px 0; font-size: 16px; line-height: 1.45; }
.prob small { color: var(--muted); }
.media-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.media-row .ghost { padding: 0 16px; color: var(--text); }
.preview { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; margin-top: 10px; }
.sheet { width: min(100% - 24px, 520px); max-height: 92vh; padding: 22px 18px; border-radius: 20px; border: 1px solid var(--line); background: #140838; color: var(--text); }
.sheet::backdrop { background: rgba(0,0,0,.6); }
.sheet h2 { margin: 0 0 4px; }
select, textarea { width: 100%; min-height: 52px; padding: 12px 14px; font: inherit; font-size: 17px; color: #fff; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.22); border-radius: 12px; }
select option { color: #000; }
.filebtn { position: relative; display: inline-grid; place-items: center; padding: 0 16px; margin: 0; font-weight: 400; color: var(--text); }
.filebtn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.filebtn:focus-within { outline: 3px solid var(--focus); }
.sheet .sc-buttons { margin-top: 18px; }
.sheet .sc-buttons .ghost { color: var(--text); }
.card.flat { backdrop-filter: none; }
.choice { border: 0; padding: 0; margin: 18px 0 8px; }
.choice legend { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.radio { display: flex; gap: 12px; align-items: flex-start; min-height: 48px; padding: 10px 0; font-weight: 400; font-size: 16px; line-height: 1.4; margin: 0; }
.radio input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; accent-color: var(--green); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile-stat { display: grid; gap: 2px; padding: 14px; border-radius: 14px; background: rgba(23,10,60,.85); border: 1px solid rgba(255,255,255,.14); }
.tile-stat b { font-size: 30px; }
.tile-stat span { color: var(--muted); font-size: 14px; }
.tile-stat.g b { color: var(--t-green); } .tile-stat.r b { color: #ff8f9c; } .tile-stat.p b { color: #c3a6ff; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 8px 0 0; }
.barcol { flex: 1; display: grid; grid-template-rows: 1fr auto auto; height: 100%; text-align: center; font-size: 13px; color: var(--muted); }
.barcol i { align-self: end; background: var(--t-green); border-radius: 4px 4px 0 0; min-height: 2px; }
.barcol b { color: var(--text); font-size: 14px; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 15px; }
.tbl caption { text-align: left; font-weight: 800; font-size: 16px; padding-bottom: 6px; }
.tbl th, .tbl td { text-align: left; padding: 10px 6px; border-bottom: 1px solid rgba(255,255,255,.1); }
.tbl td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl thead th { color: var(--muted); font-weight: 600; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  .row.live .tile .ico, .banner.live .banner-icon, .spinner, .flash, .bar-fill { animation: none !important; transition: none !important; }
}
@media (prefers-contrast: more) {
  :root { --muted: #e4dfff; --line: #fff; }
  .row, .slot, .prob, .tile-stat { border-color: #fff; }
}
@media (min-width: 720px) {
  .summary { gap: 12px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
