:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --wash: rgba(11, 11, 11, 0.035);
  --focus: #2a78d6;
  /* categorical, fixed order */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --zone-1: #1baf7a;
  --zone-2: #4a3aa7;
  --zone-1-ink: #0b0b0b;
  --zone-2-ink: #ffffff;
  /* status (severity) — always paired with an icon and a label */
  --sev-0: #0ca30c;
  --sev-1: #fab219;
  --sev-2: #ec835a;
  --sev-3: #d03b3b;
  --sev-0-wash: rgba(12, 163, 12, 0.1);
  --sev-1-wash: rgba(250, 178, 25, 0.16);
  --sev-2-wash: rgba(236, 131, 90, 0.16);
  --sev-3-wash: rgba(208, 59, 59, 0.12);
  --critical: #d03b3b;
  --critical-text: #b42f2f;
  --good-text: #006300;
  /* capacity reference line: neutral, lighter than weekend/critical so it reads as a boundary, not a series */
  --capacity: #8a8f98;
  /* sequential blue */
  --seq-0: #f0efec;
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #184f95;
  --seq-7: #0d366b;
  --seq-ink-lo: #0b0b0b;
  --seq-ink-hi: #ffffff;
  /* header band and the Ask call to action */
  --header-bg: #0d366b;
  --header-text: #ffffff;
  --header-sub: #cde2fb;
  --header-line: rgba(255, 255, 255, 0.22);
  --header-wash: rgba(255, 255, 255, 0.12);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --wash: rgba(255, 255, 255, 0.04);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --zone-1: #199e70;
    --zone-2: #9085e9;
    --zone-2-ink: #0b0b0b;
    --critical: #e66767;
    --critical-text: #f08a8a;
    --capacity: #9aa0aa;
    --good-text: #0ca30c;
    --sev-0-wash: rgba(12, 163, 12, 0.16);
    --sev-1-wash: rgba(250, 178, 25, 0.16);
    --sev-2-wash: rgba(236, 131, 90, 0.18);
    --sev-3-wash: rgba(208, 59, 59, 0.22);
    --seq-0: #2a2a28;
    --seq-1: #1e3a5c;
    --seq-2: #1d4a7e;
    --seq-3: #1d5ca0;
    --seq-4: #1f6ec6;
    --seq-5: #2a82e0;
    --seq-6: #3a93f0;
    --seq-7: #4aa3ff;
    --seq-ink-lo: #ffffff;
    --seq-ink-hi: #0b0b0b;
    --header-bg: #10243f;
    --header-sub: #9ec5f4;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --wash: rgba(255, 255, 255, 0.04);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --zone-1: #199e70;
  --zone-2: #9085e9;
  --zone-2-ink: #0b0b0b;
  --critical: #e66767;
  --critical-text: #f08a8a;
  --capacity: #9aa0aa;
  --good-text: #0ca30c;
  --sev-0-wash: rgba(12, 163, 12, 0.16);
  --sev-1-wash: rgba(250, 178, 25, 0.16);
  --sev-2-wash: rgba(236, 131, 90, 0.18);
  --sev-3-wash: rgba(208, 59, 59, 0.22);
  --seq-0: #2a2a28;
  --seq-1: #1e3a5c;
  --seq-2: #1d4a7e;
  --seq-3: #1d5ca0;
  --seq-4: #1f6ec6;
  --seq-5: #2a82e0;
  --seq-6: #3a93f0;
  --seq-7: #4aa3ff;
  --seq-ink-lo: #ffffff;
  --seq-ink-hi: #0b0b0b;
  --header-bg: #10243f;
  --header-sub: #9ec5f4;
  --accent: #3987e5;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- chrome ---------- */
.topbar { background: var(--header-bg); color: var(--header-text); border-bottom: 1px solid var(--header-line); }
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; flex-direction: column; text-decoration: none; }
.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { color: var(--text-secondary); font-size: 13px; }
.topbar .brand-sub, .topbar .week-picker, .topbar .live { color: var(--header-sub); }
.topbar select { background: var(--header-wash); border-color: var(--header-line); color: var(--header-text); }
.topbar select option { color: #0b0b0b; background: #ffffff; }
.topbar .ghost { color: var(--header-text); border-color: var(--header-line); }
.topbar .ghost:hover { background: var(--header-wash); }
/* Compact icon buttons for the account cluster (theme / settings / sign out), right-aligned. */
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  padding: 0; border: 1px solid var(--header-line); border-radius: 8px; background: transparent;
  color: var(--header-text); cursor: pointer; text-decoration: none; flex: none;
}
.iconbtn:hover { background: var(--header-wash); }
.iconbtn svg { display: block; }
.account-sep { width: 1px; align-self: stretch; min-height: 22px; background: var(--header-line); margin: 0 2px; }
.ask-cta {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 16px; cursor: pointer;
  border: 0; border-radius: 999px; background: #ffffff; color: #0d366b; font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.ask-cta:hover, .ask-cta[aria-expanded="true"] { background: #cde2fb; }
.ask-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 25; display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; padding: 10px 20px 10px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.ask-fab:hover { filter: brightness(1.08); }
.topbar-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* Segmented Week / Last 7 days toggle. Uses the header palette so it reads on the dark topbar. */
.range-toggle { display: inline-flex; border: 1px solid var(--header-line); border-radius: 8px; overflow: hidden; }
.range-toggle button {
  background: transparent; border: 0; padding: 6px 12px; min-height: 34px; cursor: pointer;
  color: var(--header-sub); font: inherit; font-size: 13px; white-space: nowrap;
}
.range-toggle button + button { border-left: 1px solid var(--header-line); }
.range-toggle button:hover { background: var(--header-wash); color: var(--header-text); }
.range-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.week-picker { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; }
.week-picker select:disabled { opacity: 0.5; cursor: not-allowed; }
select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; min-height: 34px; color: var(--text-primary);
}
.ghost, .btn {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; min-height: 34px; cursor: pointer; color: var(--text-primary); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.ghost:hover, .btn:hover { background: var(--wash); }
.btn.primary { background: var(--text-primary); color: var(--page); border-color: transparent; font-weight: 600; }
.btn.primary:hover { opacity: 0.88; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.live { color: var(--text-secondary); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sev-0); flex: none; }
.live .dot.stale { background: var(--text-muted); }

/* Sticky, prominent breadcrumb bar: stays visible as you scroll so you always know where you are
   (Overview › Station › Day) and can step back in one click. */
.crumbs { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.crumbs-inner { max-width: 1280px; margin: 0 auto; padding: 10px 24px; min-height: 44px; font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.crumb-back { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px 5px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-primary); text-decoration: none; font-weight: 600; font-size: 13px; }
.crumb-back:hover { background: var(--wash); }
.crumb-back .arrow { font-size: 17px; line-height: 1; margin-top: -1px; }
.crumb-trail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.crumb-trail .crumb-link { text-decoration: none; color: var(--text-secondary); padding: 3px 6px; border-radius: 6px; }
.crumb-trail .crumb-link:hover { color: var(--text-primary); background: var(--wash); }
.crumb-trail .sep { color: var(--text-muted); }
.crumb-trail .crumb-current { color: var(--text-primary); font-weight: 700; }

main { max-width: 1280px; margin: 0 auto; padding: 8px 24px 64px; display: flex; flex-direction: column; gap: 20px; outline: none; }
main.loading { opacity: 0.55; transition: opacity 0.2s; }

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
/* The title block takes the free space and wraps its own text, so the controls on the right stay put
   whatever the hint says (they move below only when the card itself is narrow). */
.card-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.card-head > :not(:first-child) { flex: 0 0 auto; }
.hint { color: var(--text-secondary); font-size: 13px; margin-top: 4px; max-width: 80ch; }
.muted { color: var(--text-muted); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 20px; }
.scroll-x { overflow-x: auto; }
.empty { color: var(--text-secondary); padding: 24px 0; }
.error { color: var(--critical-text); padding: 24px 0; }

.hero { display: flex; flex-direction: column; gap: 10px; padding: 8px 0 4px; }
.hero .eyebrow { color: var(--text-secondary); font-size: 13px; }
.hero .lede { font-size: 16px; color: var(--text-secondary); max-width: 90ch; }
.hero .lede strong { color: var(--text-primary); font-weight: 600; }
/* A hero that summarises the data reads as a component, not as page instructions. */
.hero.summary { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 18px 20px; }
.summary-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* severity badge: icon + label, tinted background */
.sev { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text-primary); }
.sev svg { flex: none; }
.sev-0 { background: var(--sev-0-wash); }
.sev-1 { background: var(--sev-1-wash); }
.sev-2 { background: var(--sev-2-wash); }
.sev-3 { background: var(--sev-3-wash); }
.sev.lg { font-size: 15px; padding: 5px 14px 5px 10px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); vertical-align: middle; }

/* severity distribution strip */
.sev-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .sev-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sev-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; border-top-width: 4px; }
.sev-tile .count { font-size: 32px; font-weight: 600; line-height: 1.1; }
.sev-tile .what { color: var(--text-secondary); font-size: 13px; }
.sev-tile.is-zero .count { color: var(--text-muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 18px 16px; min-width: 0; }
.kpi .label { color: var(--text-secondary); font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.kpi .value { font-size: 44px; font-weight: 700; margin-top: 2px; line-height: 1.05; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi .detail { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }
.delta { font-size: 13px; font-weight: 600; margin-left: 6px; }
.delta.up { color: var(--critical-text); }
.delta.down { color: var(--good-text); }

/* ranking table */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-weight: 600; color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.rank tbody tr { cursor: pointer; }
.rank tbody tr:hover td { background: var(--wash); }
.rank .rank-n { color: var(--text-muted); width: 28px; }
.rank .st-name { font-weight: 600; white-space: nowrap; }
.rank .st-sub { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.rank .big { font-size: 18px; font-weight: 600; white-space: nowrap; }
.rank .bar-cell { min-width: 150px; }
.meter { height: 6px; border-radius: 3px; background: var(--seq-1); margin-top: 6px; position: relative; overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 3px; }
.small { font-size: 12px; color: var(--text-secondary); }
.nowrap { white-space: nowrap; }
.check-cell { width: 36px; }
.check-cell input { width: 16px; height: 16px; cursor: pointer; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- fleet overview (exec landing) ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--text-secondary); }
.tile .k.sub { margin-top: 2px; color: var(--text-muted); }
.tile .v { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin-top: 3px; line-height: 1.1; }
.tile .stripe { height: 3px; border-radius: 3px; margin-top: 10px; }

.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sec-head h2 { font-size: 15px; font-weight: 600; margin: 0; }

.attn-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.attn-card { text-align: left; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 7px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--sev-3); border-radius: 12px; padding: 13px 15px; }
.attn-card:hover { background: var(--wash); }
.attn-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.attn-name { font-weight: 600; font-size: 15px; }
.attn-loc { font-size: 12px; color: var(--text-muted); }
.attn-big { font-size: 13px; color: var(--text-secondary); }
.attn-big strong { color: var(--text-primary); }

.fleet-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.fleet-search { flex: 1; min-width: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 11px; color: var(--text-primary); font: inherit; font-size: 13px; }
.segs { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segs button { border: 0; border-left: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); font: inherit; font-size: 12.5px; padding: 8px 12px; cursor: pointer; }
.segs button:first-child { border-left: 0; }
.segs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.fleet-table tbody tr { cursor: pointer; }
.fleet-table tbody tr:hover td { background: var(--wash); }
.fleet-table .st-name { font-weight: 600; }
.fleet-table .st-sub { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.fleet-table .big { font-size: 16px; font-weight: 600; white-space: nowrap; }

@media (max-width: 680px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

/* "Open a day" quick nav + clickable day affordances */
.day-jump { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.day-jump-label { color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.day-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.day-chip { display: inline-flex; flex-direction: column; align-items: center; min-width: 58px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); text-decoration: none; line-height: 1.2; transition: border-color .12s, background .12s, transform .06s; }
.day-chip:hover { border-color: var(--accent); background: var(--wash); }
.day-chip:active { transform: translateY(1px); }
.day-chip .dc-day { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.day-chip .dc-date { font-size: 12px; color: var(--text-secondary); }
.fleet-table th.pick, .fleet-table td.pick { width: 34px; text-align: center; padding-left: 6px; padding-right: 4px; }
.fleet-table td.pick input { cursor: pointer; width: 16px; height: 16px; }
.daylink { color: var(--accent); }
svg text.daylink { fill: var(--accent); text-decoration: underline; }
.click-rows tbody tr { cursor: pointer; }
.click-rows tbody tr:hover td { background: var(--wash); }
.click-rows tbody tr:hover .daylink { text-decoration: underline; }

/* day matrix: text color per sequential step so labels clear contrast on every fill */
.matrix a.s0, .matrix a.s1, .matrix a.s2, .matrix a.s3 { color: var(--seq-ink-lo); }
.matrix a.s4, .matrix a.s5, .matrix a.s6, .matrix a.s7 { color: var(--seq-ink-hi); }
.matrix a.s0 { color: var(--text-muted); font-weight: 400; }
.matrix a.s4 { color: #ffffff; } /* mid step: white clears contrast in both themes */
.matrix td.cell { text-align: center; padding: 0; border-bottom: 2px solid var(--surface); border-left: 2px solid var(--surface); }
.matrix td.cell a { display: block; padding: 12px 6px; text-decoration: none; font-weight: 600; font-size: 13px; }
.matrix td.cell a:hover { outline: 2px solid var(--text-primary); outline-offset: -2px; border-radius: 4px; }
.matrix th { text-align: center; }
.matrix th:first-child { text-align: left; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-secondary); align-items: center; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .line { width: 16px; height: 0; border-top: 2px solid; display: inline-block; }
.legend .ring { width: 12px; height: 12px; border-radius: 3px; border: 2px solid var(--critical); display: inline-block; }
.legend .ramp { display: inline-flex; border-radius: 3px; overflow: hidden; }
.legend .ramp span { width: 18px; height: 10px; }

/* drivers ("why this rating") */
.drivers { display: grid; }
.driver { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.driver:last-child { border-bottom: 0; }
.driver .v { font-weight: 600; font-variant-numeric: tabular-nums; }

details.footnote { color: var(--text-secondary); font-size: 13px; }
details.footnote summary { cursor: pointer; }
details.footnote ul { margin: 8px 0 0; padding-left: 18px; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button, .seg a { background: transparent; border: 0; padding: 6px 12px; cursor: pointer; min-height: 32px; color: var(--text-secondary); text-decoration: none; display: inline-flex; align-items: center; }
.seg > * + * { border-left: 1px solid var(--border) !important; }
.seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.seg button:hover, .seg a:hover { background: var(--wash); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 8px; cursor: pointer; background: var(--surface); }
.chip input { margin: 0; }
.chip i { width: 14px; border-top: 2px solid; display: inline-block; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart text.ink { fill: var(--text-secondary); }
.chart text.strong { fill: var(--text-primary); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline, .spark .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .threshold { stroke: var(--critical); stroke-width: 1.5; }
.chart .threshold-label { fill: var(--critical-text); font-weight: 600; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; }
.chart .band { fill: var(--wash); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .cell:hover, .chart .bar:hover { opacity: 0.8; }
.spark { display: block; }
.key-line { width: 14px; border-top: 2px solid; display: inline-block; vertical-align: middle; margin-right: 6px; }
.inline-bar { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--series-1); vertical-align: middle; margin-right: 8px; }
.notes { margin-top: 12px; color: var(--text-secondary); font-size: 13px; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 12px; min-width: 140px;
}
.tooltip .t-title { color: var(--text-secondary); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .t-row .k { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tooltip .t-row .k i { width: 12px; border-top: 2px solid; display: inline-block; }
.tooltip .t-row b { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tooltip .t-flag { margin-top: 4px; color: var(--critical-text); font-weight: 600; }

/* camera frames */
.frame-viewer { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .frame-viewer { grid-template-columns: 1fr; } }
.frame-main { position: relative; background: var(--surface-2); border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; }
.frame-img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* detection boxes, drawn over the letterboxed image (svg uses the same contain geometry) */
.frame-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.frame-overlay .det { fill: none; stroke-width: 2px; vector-effect: non-scaling-stroke; }
.frame-overlay .det.counted { stroke: var(--sev-0); }                       /* counted in a lane */
.frame-overlay .det.missed { stroke: var(--text-muted); stroke-dasharray: 6 4; }  /* detected, not counted */
.det-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.det-toggle input { width: 15px; height: 15px; }
.frame-meta { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.frame-meta .drivers { width: 100%; }
.frame-time { font-size: 28px; font-weight: 600; line-height: 1.1; }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 6px; margin-top: 8px; scroll-snap-type: x proximity; }
.thumb { flex: none; width: 116px; padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; scroll-snap-align: center; color: var(--text-secondary); font-size: 11px; text-align: left; }
.thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.thumb span { display: block; padding: 3px 2px 0; font-variant-numeric: tabular-nums; }
.thumb b { color: var(--critical-text); }
.thumb.over { border-color: var(--critical); }
.thumb[aria-selected="true"] { outline: 2px solid var(--text-primary); outline-offset: 2px; color: var(--text-primary); font-weight: 600; }

@media (max-width: 640px) {
  .topbar-inner { padding: 12px 16px; }
  .crumbs-inner { padding: 10px 16px; }
  .ask-fab { right: 16px; bottom: 16px; }
  main { padding: 8px 16px 40px; }
  .card { padding: 16px; }
  h1 { font-size: 20px; }
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.login-card input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; min-height: 38px; color: var(--text-primary); font: inherit;
}
.login-card input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.login-card .btn { justify-content: center; min-height: 40px; }
.login-error { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--sev-3-wash); color: var(--critical-text); font-size: 13px; }

/* ask panel */
.ask { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 30; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12); }
.ask[hidden] { display: none; }
.ask-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.ask-head h2 { font-size: 17px; }
.ask-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ask-msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.ask-msg.user { align-self: flex-end; background: var(--text-primary); color: var(--page); border-bottom-right-radius: 4px; }
.ask-msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.ask-msg.pending { color: var(--text-muted); font-style: italic; }
.ask-msg.error { align-self: flex-start; color: var(--critical-text); background: var(--sev-3-wash); }
.ask-msg.note { color: var(--text-secondary); font-size: 13px; padding: 0; max-width: none; }
.ask-meta { font-size: 11px; color: var(--text-muted); margin-top: -6px; }
.ask-suggest .chip { padding: 6px 12px; font: inherit; font-size: 13px; color: var(--text-primary); text-align: left; }
.ask-suggest .chip:hover { background: var(--wash); }
.ask-form { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.ask-form textarea { flex: 1; resize: none; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--page); color: var(--text-primary); }
.ask-form textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; }

/* ---------- fleet page (preview of the SI design) ---------- */
.preview-link { margin: 0; }
.fleet-toolbar { gap: 10px 14px; }
.period-nav { display: inline-flex; align-items: center; gap: 8px; }
.period-nav .btn { padding: 4px 10px; min-height: 32px; }
.period-label { font-weight: 600; min-width: 13ch; text-align: center; }
.export-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.export-panel > .hint { flex-basis: 100%; }
.tiles.tiles-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles-5 .tile .v { font-size: 22px; overflow-wrap: anywhere; }
@media (max-width: 1100px) { .tiles.tiles-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .tiles.tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fleet-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.fleet-main, .fleet-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 1000px) { .fleet-grid { grid-template-columns: minmax(0, 1fr); } }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
.th-sort:hover { color: var(--text-primary); }
th.sortable[aria-sort="descending"] .th-sort, th.sortable[aria-sort="ascending"] .th-sort { color: var(--text-primary); }
.fleet-table.rank .big { font-size: 15px; }
.fleet-table.rank .meter { min-width: 70px; }
.live-badge { background: var(--good-bg, var(--surface-2)); color: var(--good-text); }
.attn-list { display: flex; flex-direction: column; gap: 8px; }
.attn-row { text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid; border-radius: 10px; padding: 10px 12px; }
.attn-row:hover { background: var(--wash); }
.rated-list { margin: 6px 0 0; padding-left: 18px; }
.rated-list li { margin: 2px 0; }
.fleet-table.rank td .delta { margin: 2px 0 0; font-size: 11.5px; white-space: nowrap; }
.fleet-table.rank td { padding: 8px 10px; }

/* ---- Station page (preview of the SI design) ---- */
.tile.tile-hl { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 6px; }
.level-sub { font-size: 13px; color: var(--text-secondary); margin: 10px 0 4px; }
.now-card { display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: 4px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--sev-0); border-radius: 12px; padding: 12px 16px; }
.now-card.now-busy { border-left-color: var(--sev-1); }
.now-card.now-con { border-left-color: var(--sev-3); }
.now-card .now-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.now-card .now-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.now-card .small { grid-column: 1 / -1; }
.frame-ph { display: grid; place-items: center; min-height: 200px; padding: 16px; text-align: center; color: var(--text-muted); background: var(--surface-2); border-radius: 8px; }
.frame-caption { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.lane-map { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
ul.notes { margin: 0; padding-left: 18px; color: var(--text-secondary); font-size: 14px; }
ul.notes li + li { margin-top: 6px; }
@media (max-width: 680px) { .now-card { grid-template-columns: auto 1fr; } }

/* New (Fleet / Station) vs classic pages: the header week controls only drive the classic pages. */
body[data-ui="new"] .range-toggle, body[data-ui="new"] .week-picker { display: none; }
.view-link { color: var(--header-text); font-size: 13px; text-decoration: none; padding: 6px 10px; border: 1px solid var(--header-line); border-radius: 8px; white-space: nowrap; }
.view-link:hover { background: var(--header-wash); }

/* Export dialog (SI design) */
.export-dlg { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-primary); padding: 20px 22px; width: min(560px, calc(100vw - 32px)); }
.export-dlg::backdrop { background: rgba(0, 0, 0, 0.35); }
.export-dlg h2 { margin: 0 0 14px; }
.export-dlg .dlg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.export-dlg .dlg-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.export-dlg input[type="date"] { font: inherit; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-primary); }
.export-dlg .dlg-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); min-width: 64px; }
.export-dlg .dlg-stations { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; max-height: 220px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.export-dlg .chk { font-size: 14px; display: flex; align-items: center; gap: 4px; }
.export-dlg .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.fold-btn { white-space: nowrap; }
.legend-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.busy-ctl { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.busy-ctl input[type="range"] { width: 140px; accent-color: var(--sev-1); }
.busy-val { min-width: 3ch; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
.fold-head { flex-wrap: nowrap; }
.fold-head > div:first-child { flex-basis: 0; }

/* Station page zoom: presets, range strip, readout */
.zoom-status { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.zoom-reset { padding: 4px 10px; }
.strip-box { margin-top: 2px; }
.range-strip { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.range-strip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.rs-window { fill: transparent; stroke: var(--focus); stroke-width: 2; }
.rs-handle { fill: var(--focus); }
.zoom-hint { margin: 6px 0 0; }
.readout { display: block; line-height: 1.5; margin-top: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.rd-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--sev-0); }
.rd-dot.rd-busy { background: var(--sev-1); }
.rd-dot.rd-con { background: var(--sev-3); }
tr.row-sel td { background: color-mix(in srgb, var(--focus) 12%, transparent); }
