/* Tokens — light default; dark via OS preference or the in-app toggle
   (data-theme wins in both directions, per the reference-palette pattern) */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --good: #006300;
  --bad: #d03b3b;
  --navy: #1e3a5f;
  --navy-ink: #ffffff;
  --chip-ops: #008300;
  --chip-blend: #eda100;
  --chip-fin: #1e3a5f;
  --chip-riders: #4a3aa7;
  --chip-runs: #0e7490;
  --chip-flows: #b45309;
  --side: #14243a;
  --side-ink: #cfd8e6;
  --side-ink-dim: #8595ab;
  --side-active: rgba(255, 255, 255, 0.10);
  --accent: #2a78d6;
  --cat2: #eb6834;
  --cat3: #1baf7a;
  --cat4: #eda100;
  --ord1: #cfe3f7; --ord2: #9cc4ee; --ord3: #5f9ade; --ord4: #2a78d6; --ord5: #17498f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --good: #0ca30c;
    --bad: #e66767;
    --navy: #24466f;
    --chip-fin: #5b83b3;
    --side: #10131a;
    --accent: #3987e5;
    --cat2: #d95926;
    --cat3: #199e70;
    --cat4: #c98500;
    --ord1: #2b3c52; --ord2: #2e5480; --ord3: #3470ae; --ord4: #3987e5; --ord5: #8ec0f5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --hairline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --good: #0ca30c;
  --bad: #e66767;
  --navy: #24466f;
  --chip-fin: #5b83b3;
  --side: #10131a;
  --accent: #3987e5;
  --cat2: #d95926;
  --cat3: #199e70;
  --cat4: #c98500;
  --ord1: #2b3c52; --ord2: #2e5480; --ord3: #3470ae; --ord4: #3987e5; --ord5: #8ec0f5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- shell: sidebar + content ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: none; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 14px 10px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; justify-content: center; padding: 2px 4px 10px; }
.sidebar .logochip { background: #fff; border-radius: 10px; padding: 6px 12px; width: 100%; display: flex; justify-content: center; }
.sidebar .logochip img { display: block; height: 38px; width: auto; max-width: 100%; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sidebar a.nav, .sidebar button.nav {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: 8px;
  color: var(--side-ink); text-decoration: none; font-size: 13.5px; border: none;
  background: none; cursor: pointer; font-family: inherit; text-align: left; width: 100%;
}
.sidebar a.nav:hover, .sidebar button.nav:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar a.nav.active { background: var(--side-active); color: #fff; font-weight: 600; }
.sidebar a.nav svg, .sidebar button.nav svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.sidebar .nav .soon {
  margin-left: auto; font-size: 10px; color: var(--side-ink-dim);
  border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 20px; padding: 1px 7px;
}
.sidebar a.nav.disabled { pointer-events: none; color: var(--side-ink-dim); }
.sidebar .grow { flex: 1; min-height: 12px; }
/* The page list scrolls on short screens; the utility buttons and freshness
   note stay pinned at the bottom instead of clipping or overlapping. */
.sidebar nav.main { overflow-y: auto; min-height: 0; scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent; margin-right: -6px; padding-right: 6px; }
.sidebar .sidefoot { display: flex; align-items: center; gap: 4px; }
.sidebar .sidefoot .foot-note { flex: 1; min-width: 0; padding: 4px 6px 2px 10px; }
.sidebar .iconbtn { flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  background: none; border: none; border-radius: 7px; color: var(--side-ink-dim); cursor: pointer; }
.sidebar .iconbtn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar .iconbtn svg { width: 15px; height: 15px; }
.sidebar .foot-note { color: var(--side-ink-dim); font-size: 10.5px; line-height: 1.35; padding: 6px 6px 2px 10px; }

.content { flex: 1; min-width: 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 24px 64px; }

/* content header */
.appbar { display: flex; align-items: center; gap: 14px; padding: 6px 0 10px; flex-wrap: wrap; }
.appbar h1 { font-size: 18px; font-weight: 650; margin: 0; }
.appbar .sub { color: var(--muted); font-size: 13px; }
.appbar .spacer { flex: 1; }
.appbar select {
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
}

/* segmented FY control */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; padding: 5px 12px; border: none; border-radius: 7px;
  background: none; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: var(--navy); color: #fff; font-weight: 600; }

/* banners */
.banner {
  background: var(--navy); color: var(--navy-ink);
  border-radius: 10px; padding: 12px 18px; margin: 22px 0 14px;
  font-size: 14px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
}

/* sections + cards */
.section { margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.section .chip { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.section h2 { font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin: 0; }
.section .note { color: var(--muted); font-size: 12px; margin-left: 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px 11px; min-height: 86px; color: inherit; text-decoration: none;
  display: flex; flex-direction: column; justify-content: space-between;
}
a.card, .card.clickable { cursor: pointer; transition: border-color 0.12s, transform 0.12s; }
a.card:hover, .card.clickable:hover { border-color: var(--accent); transform: translateY(-1px); }
a.card .label::after, .card.clickable .label::after { content: " ›"; color: var(--muted); }
.card .label { font-size: 12px; color: var(--ink-2); }
.card .value { font-size: 26px; font-weight: 600; line-height: 1.15; margin: 4px 0 2px; }
.card .delta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.card .delta .arrow { font-size: 11px; }
.card .delta.good { color: var(--good); }
.card .delta.bad { color: var(--bad); }
.card .delta .vs { color: var(--muted); }

.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.strip .cell {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.strip .cell .k { font-size: 12px; color: var(--ink-2); }
.strip .cell .v { font-size: 15px; font-weight: 600; }

/* ---- trips heatmap ---- */
.callout {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 18px; margin: 14px 0; display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
}
.callout .big { font-size: 32px; font-weight: 650; }
.callout .lbl { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.callout .delta { font-size: 13px; color: var(--muted); }
.callout .delta.good { color: var(--good); }
.callout .delta.bad { color: var(--bad); }

.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.heat { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
table.heat th, table.heat td { padding: 6px 8px; text-align: right; white-space: nowrap; }
table.heat thead th {
  position: sticky; top: 0; background: var(--surface); color: var(--muted);
  font-weight: 600; font-size: 11px; letter-spacing: 0.04em; border-bottom: 1px solid var(--hairline); z-index: 2;
}
table.heat td.rowhead, table.heat th.rowhead {
  position: sticky; left: 0; background: var(--surface); text-align: left;
  color: var(--ink-2); z-index: 1; min-width: 150px; border-right: 1px solid var(--hairline);
}
table.heat tr.sect td { padding-top: 10px; font-weight: 650; font-size: 11px; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--muted); text-align: left; }
table.heat tr.total td { font-weight: 650; border-top: 1px solid var(--hairline); }
table.heat td.num { font-variant-numeric: tabular-nums; }
table.heat td.annual { font-weight: 650; border-left: 1px solid var(--hairline); }
table.heat td.heatcell { color: #0b0b0b; }
table.heat td.dim { color: var(--muted); }

.hovertip {
  position: fixed; pointer-events: none; z-index: 50; background: var(--ink); color: var(--page);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; line-height: 1.5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); max-width: 240px;
}
.hovertip .k { opacity: 0.7; }

/* alerts (status = icon + text, never color alone) */
.alerts { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px 5px 9px; color: var(--ink-2);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pill.ok .dot { background: #0ca30c; }
.pill.watch .dot { background: #fab219; }
.pill.act .dot { background: #d03b3b; }
.pill.act { border-color: rgba(208, 59, 59, 0.4); }

/* sparkline inside cards */
.card .spark { width: 100%; height: 22px; margin: 2px 0 3px; display: block; }

/* line chart */
.chartbox { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.chartbox .legend { display: flex; gap: 16px; margin: 2px 2px 8px; font-size: 12px; color: var(--ink-2); }
.chartbox .legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chartbox .legend .swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.linechart { width: 100%; height: auto; display: block; }
.linechart .tick { font-size: 9.5px; fill: var(--muted); }

/* plain (non-heatmap) detail tables */
table.heat.plain td { border-bottom: 1px solid var(--hairline); }
table.heat.plain tr.sect td { border-bottom: none; }
table.heat.plain .code { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 2px; }
table.heat tr.hoverable:hover td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
table.heat tr.net td { border-top: 2px solid var(--ink-2); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; margin-top: 8px; }

/* takeaways */
.takeaways {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--chip-blend);
  border-radius: 12px; padding: 12px 18px; margin: 16px 0 4px;
}
.takeaways .tk-title { font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.takeaways ul { margin: 0; padding-left: 18px; }
.takeaways li { font-size: 13.5px; line-height: 1.55; color: var(--ink); margin: 3px 0; }

/* drill-down drawer */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(500px, 94vw); background: var(--page); border-left: 1px solid var(--border);
  padding: 18px 20px; overflow-y: auto; box-shadow: -12px 0 32px rgba(0, 0, 0, 0.25);
}
.drawer.wide { width: min(820px, 94vw); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.drawer-title { font-size: 16px; font-weight: 650; }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawer-x { font: inherit; font-size: 14px; border: none; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; }
.drawer-x:hover { color: var(--ink); }
.drawer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 14px; }
/* Stacked label-over-value, mirroring the KPI cards: side-by-side flex broke
   whenever either span wrapped (labels colliding with values, mashed text). */
.drawer-stats > div {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.drawer-stats > div > span:first-child,
.drawer-stats .k { font-size: 11.5px; color: var(--ink-2); line-height: 1.35; }
.drawer-stats .v { font-size: 15.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.drawer table.mini { margin-top: 14px; width: 100%; }
td.clickable { cursor: pointer; }
td.clickable:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.legend .swatch.bandkey { width: 14px; height: 10px; border-radius: 2px; background: var(--muted); opacity: 0.3; }

/* county map */
.mapgrid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(230px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .mapgrid { grid-template-columns: 1fr; } }
.mapbox { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.countymap { width: 100%; height: auto; display: block; }
.countymap .county { cursor: pointer; transition: opacity 0.1s; }
.countymap .county:hover { opacity: 0.82; stroke: var(--ink); stroke-width: 2; }
.countymap .clabel { font-size: 11px; }
.countymap .clabel tspan:first-child { font-size: 9.5px; opacity: 0.85; }
.ranklist { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px; }
.rankrow {
  /* the trailing column grows for longer context strings (fleet drawers) but
     never shrinks below the width that keeps short percentages aligned */
  display: grid; grid-template-columns: 26px 1fr auto minmax(52px, auto); gap: 8px; align-items: baseline;
  padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.rankrow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rankrow:hover, .rankrow.on { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.rankrow .rk { color: var(--muted); font-size: 11px; }
.rankrow .nm { color: var(--ink); }
.rankrow .vl { font-weight: 600; font-variant-numeric: tabular-nums; }
.rankrow .pc { color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }

.ranklist .rankhead { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; }
.profile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 0; }
.profile .prow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 14px; font-size: 13px; }
.profile .prow:not(:last-child) { border-bottom: 1px solid var(--hairline); }
.profile .k { color: var(--ink-2); }
.profile .v { font-weight: 600; font-variant-numeric: tabular-nums; }

/* actionable insights */
.jumpbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 18px; }
.jump {
  font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 13px; display: inline-flex; align-items: center; gap: 7px;
}
.jump:hover { border-color: var(--accent); color: var(--ink); }
.jump .jn {
  font-size: 10.5px; font-weight: 650; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 10px; padding: 1px 7px;
}
.ins-group { margin-bottom: 26px; scroll-margin-top: 14px; }
.ins-group-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; border-bottom: 1px solid var(--hairline); padding-bottom: 7px; }
.ins-group-head h2 { font-size: 15px; font-weight: 650; margin: 0; }
.ins-group-head .aud { font-size: 12px; color: var(--muted); }
.insights { display: grid; gap: 10px; }
.insight {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--chip-riders); border-radius: 12px; padding: 13px 18px;
}
.ins-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.ins-cat {
  font-size: 10px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--chip-riders); border: 1px solid color-mix(in srgb, var(--chip-riders) 35%, transparent);
  border-radius: 20px; padding: 2px 9px; flex: none;
}
.ins-title { font-size: 14.5px; font-weight: 650; }
.ins-link { margin-left: auto; font-size: 12px; color: var(--accent); text-decoration: none; flex: none; }
.ins-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.ins-body { font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.ins-rec { font-size: 13.5px; line-height: 1.5; margin-top: 7px; color: var(--ink); }
.ins-rec span {
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--good); margin-right: 7px;
}

/* events */
.eventform { display: grid; grid-template-columns: 150px 1.2fr 1.6fr auto; gap: 8px; }
@media (max-width: 800px) { .eventform { grid-template-columns: 1fr; } }
.eventform input {
  font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
}
.eventform button {
  font: inherit; font-size: 13px; font-weight: 600; padding: 8px 16px; border: none;
  border-radius: 8px; background: var(--navy); color: #fff; cursor: pointer;
}
button.linkish { font: inherit; font-size: 12px; color: var(--muted); background: none; border: none; cursor: pointer; }
button.linkish.danger:hover { color: var(--bad); }
.hovertip .ev { color: var(--chip-blend); }

/* login + misc */
.login { max-width: 340px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px; }
.login h1 { font-size: 17px; margin: 0 0 4px; }
.login p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login label { display: block; font-size: 12px; color: var(--ink-2); margin: 12px 0 4px; }
.login input { width: 100%; font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--page); color: var(--ink); }
.login button { width: 100%; margin-top: 18px; font: inherit; font-weight: 600; font-size: 14px; padding: 10px; border: none; border-radius: 9px; background: var(--navy); color: #fff; cursor: pointer; }
.login .err { color: var(--bad); font-size: 13px; margin-top: 12px; }
.loading, .fatal { margin: 16vh auto; text-align: center; color: var(--muted); font-size: 14px; }
.fatal { color: var(--bad); max-width: 480px; }
.foot { margin-top: 34px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--hairline); padding-top: 12px; }

@media (max-width: 840px) {
  .sidebar { width: 56px; padding: 14px 6px; }
  .sidebar .brand, .sidebar .nav span.lbl, .sidebar .nav .soon, .sidebar .foot-note { display: none; }
  .sidebar a.nav, .sidebar button.nav { justify-content: center; padding: 10px 0; }
}

/* ---- motion (all gated by prefers-reduced-motion at the bottom) ---- */
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.rise { animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.linechart .drawin { stroke-dasharray: 1; animation: draw 0.9s ease-out both; }
.card .spark polyline { stroke-dasharray: none; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.drawer { animation: slidein 0.22s ease-out both; }
.backdrop { animation: fadein 0.18s ease-out both; }
.countymap .county { transition: fill 0.45s ease; }
.banner .badge {
  display: inline-block; margin-left: 12px; padding: 2px 10px; border-radius: 20px;
  background: var(--chip-blend); color: #1e1a0a; font-size: 10.5px; font-weight: 650;
  letter-spacing: 0.02em; text-transform: none; vertical-align: 2px;
}

/* skeleton shimmer */
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk {
  border-radius: 12px;
  background: linear-gradient(100deg, var(--surface) 40%, var(--hairline) 50%, var(--surface) 60%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.sk-title { height: 26px; width: 240px; margin: 12px 0 18px; }
.sk-banner { height: 44px; margin-bottom: 14px; }
.sk-card { height: 100px; }

/* ranked-list proportional bars */
.rankrow { position: relative; overflow: hidden; }
.rankrow .bar {
  position: absolute; left: 0; top: 0; bottom: 0; z-index: 0; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.rankrow .bar.neg { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.rankrow > :not(.bar) { position: relative; z-index: 1; }

/* delta pills */
.card .delta {
  align-self: flex-start; padding: 2.5px 9px; border-radius: 20px;
  background: color-mix(in srgb, var(--muted) 10%, transparent);
}
.card .delta.good { background: color-mix(in srgb, var(--good) 11%, transparent); }
.card .delta.bad { background: color-mix(in srgb, var(--bad) 11%, transparent); }

/* login branding */
.loginlogo { display: block; width: 190px; margin: 0 auto 6px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .loginlogo { background: #fff; border-radius: 10px; padding: 8px 12px; }
}
:root[data-theme="dark"] .loginlogo { background: #fff; border-radius: 10px; padding: 8px 12px; }
.login p { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .rise, .drawer, .backdrop, .linechart .drawin, .sk { animation: none; }
  .countymap .county { transition: none; }
}


/* ---- viz primitives (slope, sharebars, dotplot, dumbbell, scatter) ---- */
.vizbox { position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px 10px; }
.vizbox svg { display: block; width: 100%; height: auto; }
.vizbox .legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.cellbar { position: relative; display: inline-block; height: 8px; border-radius: 4px;
  background: var(--accent); opacity: 0.75; vertical-align: middle; margin-right: 7px; }
.cellbar.div-neg { background: var(--bad); }
.cellbar.div-pos { background: var(--good); }

/* ---- "Ask about this page" chat (v1 prototype) ---- */
.askbtn {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--accent); background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 8px; padding: 5px 12px; transition: border-color 0.12s;
}
.askbtn:hover { border-color: var(--accent); }
.chatpanel { display: flex; flex-direction: column; height: calc(100vh - 92px); }
.chatlog { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 12px; }
.msg { max-width: 92%; border-radius: 12px; padding: 9px 13px; font-size: 13.5px; line-height: 1.5; }
.msg.user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.dim { color: var(--muted); }
.chatempty { color: var(--ink-2); font-size: 13.5px; }
.chatsuggs { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sugg {
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 13px; transition: border-color 0.12s;
}
.sugg:hover { border-color: var(--accent); }
.chatin { display: flex; gap: 8px; padding-top: 10px; }
.chatin input {
  flex: 1; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
.chatin input:focus { outline: none; border-color: var(--accent); }
.chatin button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--navy-ink); background: var(--accent); border: none; border-radius: 10px; padding: 9px 16px;
}
.chatin button:disabled { opacity: 0.45; cursor: default; }
.chaterr { color: var(--bad); font-size: 12.5px; }
.chatkey p { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.chatfoot { font-size: 11.5px; color: var(--muted); padding-top: 8px; line-height: 1.5; }
.chatfoot a { color: var(--muted); }
.unverified { border-bottom: 1.5px dotted var(--bad); cursor: help; }
.chatlbl { display: block; font-size: 12px; color: var(--ink-2); margin: 10px 0 4px; }
.chatsel {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}

.navgroup {
  font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--side-ink-dim); padding: 8px 14px 2px;
}
nav .navgroup:first-child { padding-top: 2px; }

/* ---- command palette ---- */
.palette-back { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,0.35); display: flex; justify-content: center; padding-top: 12vh; }
.palette { width: min(560px, 92vw); height: fit-content; background: var(--page); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,0.35); overflow: hidden; }
.palette input { width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: none; border-bottom: 1px solid var(--border); padding: 14px 16px; outline: none; }
.palette-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.palette-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.palette-row.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.palette-row .pk { flex: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); width: 74px; }
.palette-row .pl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-row .ph { color: var(--muted); font-size: 12px; }
.palette-empty { padding: 16px; color: var(--muted); font-size: 13px; }
.palette-foot { padding: 8px 14px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); }
.kbd { font-size: 10px; border: 1px solid var(--side-ink-dim); border-radius: 4px; padding: 0 4px; margin-left: 4px; opacity: 0.8; }

.attention { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--chip-blend); border-radius: 12px; padding: 12px 18px; margin: 10px 0 14px; }
.attention .att-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--chip-blend); margin-bottom: 6px; }
.attention ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.55; }

.chartbox, .vizbox { position: relative; }
.pngbtn { position: absolute; top: 6px; right: 6px; z-index: 3; width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-3); font-size: 13px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.chartbox:hover .pngbtn, .vizbox:hover .pngbtn { opacity: 1; }
.pngbtn:hover { color: var(--accent); border-color: var(--accent); }

.linkbtn { border: 1px solid var(--border); background: var(--surface); color: var(--ink-3); border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.linkbtn:hover { color: var(--accent); border-color: var(--accent); }

.goalchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.goalchip { display: inline-flex; align-items: baseline; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; text-decoration: none; color: var(--ink-2); }
.goalchip .gc-name { font-weight: 600; }
.goalchip .gc-target { color: var(--muted); font-size: 11.5px; }
.goalchip.met { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.goalchip.met .gc-val { color: var(--good); font-weight: 700; }
.goalchip.miss { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.goalchip.miss .gc-val { color: var(--bad); font-weight: 700; }
.goalform { display: grid; grid-template-columns: 2fr 1fr 1fr 2fr auto; gap: 8px; margin-top: 10px; }
.goalform select, .goalform input { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-1); font-size: 13px; }
@media (max-width: 760px) { .goalform { grid-template-columns: 1fr 1fr; } }

/* General ledger: let the year fit without horizontal scrolling. The page
   escapes the 1080px column and the table compacts its type and padding. */
.wrap:has(.gl-full) { max-width: none; }
.gl-full table.heat td, .gl-full table.heat th { padding: 4px 5px; font-size: 11px; }
.gl-full table.heat td.rowhead { font-size: 11.5px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-full table.heat { width: 100%; }
@supports not (selector(:has(*))) { /* older browsers keep the scroll fallback */ }

/* ---- branding wordmark (fallback when an agency logo isn't loaded yet) ---- */
.wordmark { font-weight: 750; font-size: 15px; letter-spacing: 0.2px; color: #1a2b45;
  text-align: center; padding: 6px 4px; line-height: 1.25; }
.wordmark.loginlogo { width: 190px; margin: 0 auto 6px; font-size: 20px; background: none; }
