/* Pipeline Radar dashboard. Colors are role tokens; stage colors are a validated ordinal blue
   ramp (darkest = earliest stage = most lead time). Text never wears a stage color. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f3f0; --hover: #f1f1ed;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, .10);
  --accent: #2a78d6; --focus: #2a78d6;
  --water: #e4eaef; --land: #f6f6f3; --land-ours: #fdfdfb; --county-line: #c9c7bf; --road-1: #b4b2aa; --road-2: #d3d1ca; --place: #6b6a66;
  --s-plan: #104281; --s-program: #1c5cab; --s-fund: #2a78d6; --s-solicit: #5598e7; --s-award: #86b6ef;
  --on-s-plan: #fff; --on-s-program: #fff; --on-s-fund: #fff; --on-s-solicit: #0b0b0b; --on-s-award: #0b0b0b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --water: #11161a; --land: #1c1c1b; --land-ours: #222220; --county-line: #3c3c39; --road-1: #55554f; --road-2: #393936; --place: #a3a29c;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --hover: #242422;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
    --accent: #3987e5; --focus: #6da7ec;
    --s-plan: #cde2fb; --s-program: #86b6ef; --s-fund: #3987e5; --s-solicit: #256abf; --s-award: #184f95;
    --on-s-plan: #0b0b0b; --on-s-program: #0b0b0b; --on-s-fund: #fff; --on-s-solicit: #fff; --on-s-award: #fff;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --water: #11161a; --land: #1c1c1b; --land-ours: #222220; --county-line: #3c3c39; --road-1: #55554f; --road-2: #393936; --place: #a3a29c;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --hover: #242422;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
  --accent: #3987e5; --focus: #6da7ec;
  --s-plan: #cde2fb; --s-program: #86b6ef; --s-fund: #3987e5; --s-solicit: #256abf; --s-award: #184f95;
  --on-s-plan: #0b0b0b; --on-s-program: #0b0b0b; --on-s-fund: #fff; --on-s-solicit: #fff; --on-s-award: #fff;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 1000; background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1440px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand > div { min-width: 0; }
#asOf { white-space: nowrap; }
.logo { width: 28px; height: 28px; flex: none; }
.brand h1 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; margin: 0; white-space: nowrap; }
.brand p { margin: 0; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 8px;
  height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12.5px; cursor: pointer; }
.icon-btn:hover { background: var(--hover); }

main { max-width: 1440px; margin: 0 auto; padding: 16px 24px 48px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input[type="search"] {
  height: 34px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 0 10px; font: inherit; font-size: 13px; }
.filters input[type="search"] { width: 240px; }
.filters select { max-width: 200px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; user-select: none; }
.toggle input { accent-color: var(--accent); margin: 0; }
.filters .count { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 0 4px; }

/* ---------- figures ---------- */
.figures { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.hero { padding: 18px 20px; }
.hero .label, .tile .label { color: var(--ink-2); font-size: 13px; }
.hero .value { font-size: 48px; line-height: 1.05; font-weight: 650; letter-spacing: -.02em; margin: 6px 0 4px; }
.hero .sub, .tile .sub { color: var(--muted); font-size: 12.5px; }
.tile { padding: 18px 20px; }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -.01em; margin: 6px 0 2px; }

/* ---------- main grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-head .spacer { flex: 1; }
#map { height: 560px; border-radius: 0 0 var(--radius) var(--radius); position: relative; z-index: 0; isolation: isolate; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; color: var(--ink-2); font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 550; }

/* pipeline bars */
.pipeline { padding: 4px 16px 8px; }
.prow { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; border-radius: 8px; }
.prow:hover .pbar-track { background: var(--hover); }
.prow[aria-pressed="true"] .pname { font-weight: 650; }
.pname { font-size: 12.5px; color: var(--ink); display: flex; align-items: center; gap: 7px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pbar-track { position: relative; height: 24px; border-radius: 4px; }
.pbar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; transition: width .35s ease; }
.pval { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; font-size: 12px; color: var(--ink-2);
  white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 8px; transition: left .35s ease; }
.pipe-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 14px; color: var(--muted); font-size: 12px; }
.ramp-legend { display: flex; align-items: center; gap: 8px; }
.ramp { display: flex; height: 8px; width: 120px; border-radius: 999px; overflow: hidden; gap: 2px; }
.ramp i { flex: 1; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 0 16px 14px; width: calc(100% - 32px); }
.mini-table th, .mini-table td { padding: 6px 4px; border-bottom: 1px solid var(--grid); text-align: left; }
.mini-table td.num, .mini-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.stage-explain { padding: 0 16px 16px; color: var(--ink-2); font-size: 12.5px; }
.stage-explain dl { display: grid; grid-template-columns: 76px 1fr; gap: 4px 10px; margin: 0; }
.stage-explain dt { color: var(--ink); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stage-explain dd { margin: 0; }

/* ---------- tabs + tables ---------- */
.tabs { display: flex; gap: 4px; padding: 6px 10px 0; border-bottom: 1px solid var(--border); }
.tab { border: 0; background: none; color: var(--ink-2); font: inherit; font-weight: 550; padding: 10px 12px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab .n { color: var(--muted); font-weight: 500; margin-left: 4px; font-size: 12px; }
.table-wrap { max-height: 640px; overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 550; color: var(--ink-2);
  font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; cursor: pointer; user-select: none; }
table.data th[aria-sort="ascending"]::after { content: " ↑"; }
table.data th[aria-sort="descending"]::after { content: " ↓"; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data tr.row { cursor: pointer; }
table.data tr.row:hover td, table.data tr.row:focus-visible td { background: var(--hover); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t1 { font-weight: 550; }
.t2 { color: var(--ink-2); font-size: 12.5px; }
.t3 { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; color: var(--ink); }
.pill i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; margin-left: 6px; white-space: nowrap; vertical-align: 1px; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.note { color: var(--muted); font-size: 12px; padding: 10px 16px 14px; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1500; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(640px, 100%); background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .24s ease; z-index: 1600; display: flex; flex-direction: column; }
.drawer.on { transform: none; }
.d-head { padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.d-head h3 { margin: 0 40px 4px 0; font-size: 19px; letter-spacing: -.01em; }
.d-close { position: absolute; top: 16px; right: 16px; }
.d-body { padding: 4px 22px 32px; overflow: auto; }
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 14px 0 6px; }
.step { font-size: 11px; font-weight: 650; letter-spacing: .02em; text-align: center; padding: 6px 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin-top: 14px; }
.facts .k { color: var(--muted); font-size: 12px; }
.facts .v { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.timeline { position: relative; margin-left: 6px; padding-left: 20px; border-left: 2px solid var(--grid); }
.ev { position: relative; padding: 2px 0 16px; }
.ev::before { content: ""; position: absolute; left: -27px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--surface); }
.ev .when { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ev .what { font-weight: 550; margin-top: 2px; }
.ev .desc { color: var(--ink-2); font-size: 12.5px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kv { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 14px; font-size: 13px; }
.kv .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- map ---------- */
.leaflet-container { background: var(--water); font: inherit; }
.place-label { color: var(--place); font-size: 11px; font-weight: 500; white-space: nowrap; text-shadow: 0 0 3px var(--land), 0 0 3px var(--land);
  transform: translate(-50%, -50%); pointer-events: none; }
.place-label.big { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
/* Street tiles: same treatment as the console - mostly desaturated, a hint of color kept (water, parks). */
.basemap { filter: grayscale(.85) contrast(.9) brightness(1.04); }
:root[data-theme="dark"] .basemap { filter: grayscale(1) invert(1) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .basemap { filter: grayscale(1) invert(1) brightness(.85) contrast(.9); } }
.map-note { background: var(--surface); color: var(--ink-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; line-height: 1.45; max-width: 300px; box-shadow: var(--shadow); }
.map-note b { color: var(--ink); }
.map-note button { border: 0; background: none; color: var(--muted); cursor: pointer; float: right; font-size: 14px; line-height: 1; padding: 0 0 0 8px; }
.leaflet-tooltip.tip { background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 8px 10px; font-size: 12.5px; }
.leaflet-tooltip.tip::before { display: none; }
.map-legend { background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.7; }
.map-legend .row { display: flex; align-items: center; gap: 8px; }
.map-legend .line { width: 18px; height: 3px; border-radius: 2px; }
.map-legend .dash { width: 18px; border-top: 2px dashed var(--ink-2); }
.leaflet-control-zoom a, .leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--border); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--ink-2); }

.tooltip { position: fixed; pointer-events: none; z-index: 2000; background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.12); opacity: 0; transition: opacity .1s; }
.tooltip.on { opacity: 1; }

footer { max-width: 1440px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .figures { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top-in, main, footer { padding-left: 16px; padding-right: 16px; }
  .brand p, #asOf { display: none; }
  .figures .tile:last-child { grid-column: 1 / -1; }
  .figures { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero { grid-column: 1 / -1; }
  .hero .value { font-size: 40px; }
  .filters input[type="search"] { width: 100%; }
  .filters select { flex: 1 1 140px; max-width: none; }
  .filters .count { margin-left: 0; width: 100%; }
  #map { height: 380px; }
  .map-legend { display: grid; grid-template-columns: auto auto; column-gap: 12px; font-size: 11px; line-height: 1.5; padding: 6px 8px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.data .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
