:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2333;
  --ink: #e6edf3;
  --muted: #8b949e;
  --line: rgba(240, 246, 252, 0.1);
  --accent: #3fb950;
  --accent-dim: rgba(63, 185, 80, 0.15);
  --radius: 10px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; }

body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

#map { position: fixed; inset: 0; background: var(--bg); }

/* ---- top bar ---- */
.topbar {
  position: fixed; top: 12px; left: 12px; right: 12px; z-index: 1000;
  display: flex; align-items: center; gap: 16px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px;
}
.brand { display: flex; flex-direction: column; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink); text-decoration: none; }
.brand-name:hover { color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--muted); }
.totals { display: flex; gap: 18px; margin-left: 8px; }
.totals .t { display: flex; flex-direction: column; }
.totals .t b { font-size: 15px; font-variant-numeric: tabular-nums; }
.totals .t span { font-size: 11px; color: var(--muted); }
.toggles { display: flex; gap: 10px; margin-left: auto; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  padding: 6px 12px; font-size: 12px; border: none; cursor: pointer;
  background: var(--bg-elev-2); color: var(--muted); font-weight: 500;
  transition: all 0.2s var(--ease);
}
.seg button.active { background: var(--accent); color: #06130a; font-weight: 600; }
#search {
  width: 180px; padding: 8px 12px;
  background: var(--bg-elev-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; outline: none;
}
#search:focus { border-color: var(--accent); }

/* ---- category pills ---- */
.pills {
  position: fixed; top: var(--pills-top, 68px); left: 12px; right: 12px; z-index: 1000;
  display: flex; gap: 8px; flex-wrap: wrap; max-height: 108px; overflow-y: auto;
}
.pill {
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line); color: var(--ink);
  font-size: 12.5px; font-weight: 500; transition: all 0.2s var(--ease);
}
.pill:hover { border-color: var(--accent); }
.pill.active { background: var(--accent); color: #06130a; border-color: var(--accent); font-weight: 600; }
.pill .amt { opacity: 0.65; font-variant-numeric: tabular-nums; margin-left: 5px; }
.pill-dot {
  display: inline-block; width: 7px; height: 7px; margin-right: 5px;
  border-radius: 50%; background: var(--category-color); vertical-align: 1px;
}
.pill.active .pill-dot { background: #06130a; }

/* ---- insights for media page ---- */
#insights-view {
  position: fixed; inset: var(--content-top, 84px) 12px 12px; z-index: 500;
  overflow-y: auto; scrollbar-gutter: stable; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg);
}
.insights-content { width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px; }
#insights-page-title { display: flex; align-items: center; gap: 12px; font-size: clamp(24px, 2.5vw, 36px); line-height: 1.15; letter-spacing: -0.035em; margin: 12px 0; font-weight: 650; }
#insights-close {
  flex-shrink: 0; background: var(--bg-elev-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 16px; font: inherit; font-size: 13px; cursor: pointer;
  transition: border-color 0.2s var(--ease);
}
#insights-close:hover { border-color: var(--accent); }
.insights-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 20px 0 18px; }
.insights-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
#insights-council, #insights-year, #insights-category {
  padding: 8px 28px 8px 10px; min-height: 38px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg-elev-2); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer;
}
.insights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.insight {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px; padding: 18px;
}
.ai-badge {
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: #d29922; border: 1px solid color-mix(in srgb, #d29922 45%, transparent);
  border-radius: 999px; padding: 2px 8px;
}
.insight-stat { font-size: 28px; color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.insight p { font-size: 13px; line-height: 1.5; }
.insight-actions { display: flex; gap: 8px; margin-top: auto; }
.insight-actions button {
  background: var(--bg-elev-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 11px; font: inherit; font-size: 11.5px; cursor: pointer;
  transition: border-color 0.2s var(--ease);
}
.insight-actions button:hover { border-color: var(--accent); }
#insights-status { min-height: 18px; margin-top: 10px; color: var(--accent); font-size: 12px; }
#insights-status:empty { display: none; }
.insights-empty { color: var(--muted); font-size: 13px; grid-column: 1 / -1; padding: 12px 0; }
.insights-caveat { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-top: 14px; max-width: 720px; }

/* ---- left panel ---- */
.panel {
  position: fixed; left: 12px; top: var(--content-top, 116px); bottom: 66px; width: 440px; z-index: 900;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 14px; font-weight: 600; }
.panel-head span { font-size: 11.5px; color: var(--muted); }
.panel-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.list-columns {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px 58px 64px;
  gap: 8px; padding: 6px 16px 3px; color: var(--muted);
  font-size: 10px; text-align: right; text-transform: uppercase; letter-spacing: 0.04em;
}
.list-columns span:first-child { text-align: left; }
.list-columns.single { grid-template-columns: minmax(0, 1fr) max-content; }
.comparison-note {
  min-height: 30px; padding: 7px 16px 6px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 11px; line-height: 1.35;
}
.comparison-note.hidden { display: none; }
.comparison-popover {
  position: fixed; left: calc(12px + 440px + 12px); top: var(--content-top, 116px);
  width: min(430px, calc(100vw - 476px)); max-height: calc(100vh - var(--content-top, 116px) - 24px);
  display: flex; flex-direction: column;
  z-index: 1100; overflow: hidden; pointer-events: auto;
  background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
  backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}
.comparison-popover.hidden { display: none; }
.comparison-popover-head {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px;
  border-bottom: 1px solid var(--line);
}
.comparison-popover-head b { font-size: 14px; padding-right: 28px; }
.comparison-popover-head span { color: var(--muted); font-size: 10.5px; }
.comparison-popover-head label { color: var(--muted); font-size: 11px; }
#comparison-metric { background: var(--bg-elev-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px; width: 100%; font: inherit; font-size: 12px; }
#comparison-close { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; }
#comparison-summary { font-size: 12px; line-height: 1.5; }
.comparison-footer { flex-shrink: 0; padding: 12px 16px; border-top: 1px solid var(--line); }
.comparison-footer p { color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.comparison-footer button, .benchmark button, .evidence-actions button, .activity-compare {
  background: var(--bg-elev-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 12px; cursor: pointer;
}
.comparison-footer button:hover, .benchmark button:hover, .evidence-actions button:hover, .activity-compare:hover { border-color: var(--accent); }
.comparison-popover-columns, .comparison-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 80px 68px;
  align-items: baseline; gap: 10px;
}
.comparison-popover-columns {
  padding: 7px 14px 4px; color: var(--muted); font-size: 9px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.comparison-popover-columns span:not(:first-child) { text-align: right; }
.comparison-popover-list { min-height: 48px; overflow-y: auto; padding: 0 0 5px; }
.comparison-row {
  position: relative; width: 100%; padding: 8px 14px; color: var(--ink); font: inherit; font-size: 11.5px;
  background: none; border: none; text-align: left; cursor: pointer; flex-shrink: 0;
}
.comparison-row:hover, .comparison-row.active { background: var(--accent-dim); }
.comparison-row .comparison-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comparison-row .comparison-value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.comparison-row .comparison-multiple { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.list { list-style: none; overflow-y: auto; flex: 1; padding: 4px 0; }
.list li { padding: 9px 16px; cursor: pointer; transition: background 0.15s var(--ease); }
.list li:hover, .list li.sel { background: var(--accent-dim); }
.list li .row1 {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px 58px 64px;
  align-items: baseline; gap: 8px;
}
.list.cc-list li .row1 { grid-template-columns: minmax(0, 1fr) max-content; }
.list li .nm { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .row-amount { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.list li .row-amount.population { color: var(--muted); font-weight: 500; }
.list li .row-amount.per-person { color: var(--muted); }
.list li .row-amount.budget-share { color: #d29922; }
.list li .row-amount.total { color: var(--accent); }
.list li .bar { height: 3px; margin-top: 5px; background: var(--line); border-radius: 2px; }
.list li .bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }

/* ---- year controls ---- */
#year, #rank-by {
  min-width: 0; flex: 0 1 230px; padding: 6px 26px 6px 8px; cursor: pointer;
  background: var(--bg-elev-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12px;
}
#year:focus-visible, #rank-by:focus-visible { border-color: var(--accent); }
#year { flex-basis: 200px; }
#rank-by { flex-basis: 190px; }
#rank-by:disabled { cursor: not-allowed; opacity: 0.55; }

/* ---- detail ---- */
.detail {
  position: fixed; right: 12px; top: var(--content-top, 116px); width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - var(--content-top, 116px) - 12px);
  z-index: 1050; overflow-y: auto;
  background: color-mix(in srgb, var(--bg-elev) 93%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.detail.hidden { display: none; }
.detail h3 { font-size: 17px; margin-bottom: 2px; }
.detail-eyebrow { color: var(--muted); padding-right: 24px; margin-bottom: 4px; font-size: 11px; }
.benchmark { background: var(--accent-dim); border: 1px solid var(--line); padding: 12px; border-radius: 8px; margin: 12px 0 20px; }
.benchmark b { font-size: 15px; }
.benchmark p { color: var(--muted); font-size: 11.5px; margin: 8px 0 12px; }
.cost-columns, .cost-row, .cost-total { display: grid; grid-template-columns: minmax(0, 1fr) 76px 64px; gap: 4px 8px; align-items: baseline; }
.cost-columns { font-size: 10px; color: var(--muted); padding: 12px 0 4px; }
.cost-columns span:not(:first-child), .cost-row b, .cost-row > span:nth-child(3), .cost-total b, .cost-total > span:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.cost-row { padding: 8px 0; font-size: 12px; }
.cost-row > span:first-child { display: flex; align-items: center; }
.cost-row > span:nth-child(3) { color: var(--muted); }
.cost-total { border-top: 1px solid var(--line); padding: 10px 0; font-size: 12px; }
.cost-track { grid-column: 1 / -1; background: var(--line); height: 3px; border-radius: 2px; overflow: hidden; }
.cost-track i { height: 100%; display: block; }
.cost-swatch { width: 7px; height: 7px; flex-shrink: 0; display: inline-block; border-radius: 50%; margin-right: 6px; }
.cost-table .purch, .cost-stack .purch { background: #3fb950; }
.cost-table .staff, .cost-stack .staff { background: #58a6ff; }
.cost-table .da, .cost-stack .da { background: #8b949e; }
.cost-table .int, .cost-stack .int { background: #d29922; }
.cost-table .grants, .cost-stack .grants { background: #bc8cff; }
.reconciliation { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 4px 0 12px; }
.reconciliation.mismatch, .reconciliation.incomplete { color: #e3b341; }
.activity-costs { border-bottom: 1px solid var(--line); }
.activity-costs summary { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 12px 16px 12px 0; cursor: pointer; font-size: 12px; list-style: none; }
.activity-costs summary::-webkit-details-marker { display: none; }
.activity-costs summary::after { content: "+"; position: absolute; top: 12px; right: 0; color: var(--muted); }
.activity-costs[open] summary::after { content: "−"; }
.activity-costs summary b { font-variant-numeric: tabular-nums; }
.activity-costs summary small { grid-column: 1 / -1; color: var(--muted); font-size: 10.5px; }
.cost-stack { grid-column: 1 / -1; display: flex; height: 5px; overflow: hidden; border-radius: 2px; margin-top: 4px; }
.cost-tooltip {
  position: fixed; z-index: 1150; width: min(400px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); overflow-y: auto; padding: 16px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.cost-tooltip[hidden] { display: none; }
.cost-tooltip-title { font-size: 13px; }
.cost-tooltip-context { color: var(--muted); font-size: 11px; margin-top: 4px; }
.cost-tooltip .cost-columns, .cost-tooltip .cost-row, .cost-tooltip .cost-total {
  grid-template-columns: minmax(0, 1fr) max-content 56px;
}
.cost-tooltip .cost-row { padding: 8px 4px; margin-inline: -4px; border-radius: 4px; }
.cost-tooltip .cost-row.active { background: var(--accent-dim); }
.cost-tooltip .cost-track { display: none; }
.cost-tooltip .reconciliation { margin-bottom: 0; }
.activity-compare { margin-bottom: 12px; width: 100%; }
.detail-evidence { border-top: 1px solid var(--line); margin-top: 16px; }
.evidence-actions { display: flex; gap: 8px; margin: 12px 0; }
#evidence-status { font-size: 11px; color: var(--accent); overflow-wrap: anywhere; margin-bottom: 12px; }
.detail .dtotal { font-size: 24px; font-weight: 700; color: var(--accent); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.detail .dsub { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }
.detail .dhead { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 14px 0 2px; }
.detail .breakdown-note { margin: 0 0 7px; }
.detail .cat { margin: 10px 0; }
.detail .cat .row1 { display: flex; justify-content: space-between; font-size: 12.5px; }
.detail .cat .row1 .nm { display: flex; align-items: center; min-width: 0; }
.category-swatch { flex: 0 0 auto; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; }
.detail .cat .row1 .val { font-variant-numeric: tabular-nums; color: var(--muted); }
.detail .cat .bar { height: 5px; margin-top: 4px; background: var(--line); border-radius: 3px; }
.detail .cat .bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s var(--ease); }
.detail .close {
  position: absolute; top: 10px; right: 12px; cursor: pointer;
  background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1;
}
.detail .close:hover { color: var(--ink); }

.detail .spark { margin: 10px 0 4px; }
.detail .spark svg { width: 100%; height: 34px; display: block; }
.detail .spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.detail .spark .spark-l { font-size: 10.5px; color: var(--muted); }
.detail .dstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.detail .dstats div {
  background: var(--bg-elev-2); border-radius: 8px; padding: 8px 10px;
  display: flex; flex-direction: column;
}
.detail .dstats b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.detail .dstats span { font-size: 10.5px; color: var(--muted); }
.detail .cat .bar i.staff { background: #58a6ff; }
.detail .cat .bar i.da { background: #8b949e; }
.detail .cat .bar i.int { background: #d29922; }
.detail .cat .bar i.grants { background: #bc8cff; }
.detail .cat .bar i.resid { background: var(--line); }
.detail .split-note { margin: 8px 0 2px; }

/* ---- legend ---- */
.legend {
  position: fixed; right: 12px; bottom: 12px; z-index: 1000;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 6px; min-width: 180px;
}
.legend b { font-size: 12px; }
.legend .lg-row { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--muted); }
.legend .lg-bar {
  flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #8ff0a6, #5fca74, #45b35c, #37954b, #2f7a43, #275a36);
}
.legend .lg-note { font-size: 10px; color: var(--muted); }

/* ---- central govt empty-state note ---- */
.map-note {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 800;
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 22px; max-width: 420px; text-align: center;
  display: flex; flex-direction: column; gap: 6px;
}
.map-note.hidden { display: none; }
.map-note b { font-size: 14px; }
.map-note span { font-size: 12.5px; color: var(--muted); }

/* ---- sources modal ---- */
#src-btn, #about-btn {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-elev-2); color: var(--ink); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: border-color 0.2s var(--ease);
}
#src-btn:hover, #about-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(3, 6, 12, 0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(620px, calc(100vw - 24px)); max-height: 82vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; position: relative;
}
.modal-card h3 { font-size: 17px; margin-bottom: 4px; padding-right: 28px; }
.modal-card h4 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 16px 0 6px;
}
.modal-card p { font-size: 13px; margin: 6px 0; color: var(--ink); }
.modal-card p b { color: var(--ink); }
.modal-card .about-credit a { color: var(--accent); text-decoration: none; }
.modal-card .about-credit a:hover { text-decoration: underline; }
.modal-card .dsub { margin-bottom: 10px; }
.modal-card .close {
  position: absolute; top: 10px; right: 12px; cursor: pointer;
  background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1;
}
.modal-card .close:hover { color: var(--ink); }
.modal-card .nm a { color: var(--accent); text-decoration: none; }

/* ---- Auckland suppliers ---- */
.seg.small button { padding: 4px 9px; font-size: 11px; }
#akl-view .seg { display: inline-flex; margin: 4px 8px; }
#akl-view .dsub { padding: 2px 8px 6px; }
#akl-bars, #akl-trend { width: 100%; }
#akl-bars .blab { fill: var(--ink); font-size: 15px; }
#akl-bars .bval { fill: var(--accent); font-size: 15px; font-weight: 600; }
#akl-bars .pct { fill: var(--muted); font-size: 12px; }
#akl-bars .crow:hover .blab { fill: var(--accent); }
#akl-trend .tlab { fill: var(--muted); font-size: 13px; }
#akl-close {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font-size: 12px; padding: 5px 11px; cursor: pointer;
  transition: all 0.2s var(--ease);
}
#akl-close:hover { border-color: var(--accent); color: var(--accent); }
.akl-link {
  margin-top: 14px; width: 100%; padding: 9px 12px; cursor: pointer;
  background: var(--bg-elev-2); color: var(--accent);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; font-weight: 600; transition: all 0.2s var(--ease);
}
.akl-link:hover { border-color: var(--accent); }
.detail-sources {
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline;
  margin: 10px 0 14px; font-size: 11px; color: var(--muted);
}
.detail-sources a { color: var(--accent); text-decoration: none; }
.detail-sources a:hover { text-decoration: underline; }
.modal-card .nm a:hover { text-decoration: underline; }

/* ---- supplier chart ---- */
.hidden { display: none; }
#akl-view {
  position: fixed; inset: var(--content-top, 116px) 0 0 464px; z-index: 500;
  padding: 0 24px 12px 12px; overflow-y: auto;
}
.chart-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 8px 6px; }
.chart-head h3 { font-size: 15px; font-weight: 600; }
.trend h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 8px 2px; }

/* ---- agency spending ledger ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.agency-mode .totals { display: none; }
#agency-view {
  position: fixed; inset: var(--content-top, 84px) 12px 12px; z-index: 500;
  overflow-y: auto; scrollbar-gutter: stable; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg);
}
.agency-content { width: 100%; max-width: 1320px; margin: 0 auto; padding: 32px; }
.agency-intro { display: flex; justify-content: space-between; gap: 32px; align-items: flex-start; }
.agency-eyebrow { color: var(--accent); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.agency-intro h1 { font-size: clamp(24px, 2.5vw, 36px); line-height: 1.15; letter-spacing: -0.035em; margin: 12px 0; font-weight: 650; }
.agency-intro p { font-size: 14px; max-width: 640px; line-height: 1.6; }
.agency-intro .agency-scope { font-size: 12px; color: var(--muted); margin-top: 4px; }
.agency-year-control { display: flex; flex-direction: column; gap: 8px; min-width: 224px; font-size: 12px; }
#agency-period { color: var(--muted); font-size: 11px; }
#agency-year, #agency-sort {
  padding: 10px 32px 10px 12px; min-height: 44px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg-elev-2); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer;
}
.agency-summary { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 12px; margin: 28px 0 16px; }
.agency-metric {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px; padding: 20px;
  font: inherit; color: var(--ink); cursor: pointer;
}
.agency-metric:hover { border-color: var(--muted); }
.agency-metric.active { border-color: var(--accent); background: var(--accent-dim); }
.agency-metric-label { width: 100%; display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; }
.agency-metric-label small { font-size: 10px; color: var(--muted); font-weight: 500; }
.agency-metric b { font-size: 32px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.agency-metric.active b { color: var(--accent); }
.agency-metric-description { font-size: 11px; color: var(--muted); }
.agency-metric-action { font-size: 11px; color: var(--muted); margin-top: 8px; }
.agency-metric.active .agency-metric-action { color: var(--accent); }
.agency-rounding { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.agency-explainer { margin-bottom: 28px; font-size: 12px; color: var(--muted); }
.agency-explainer summary { padding: 8px 0; cursor: pointer; color: var(--ink); }
.agency-explainer > div { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 12px 0; max-width: 1000px; }
.agency-explainer b { display: block; color: var(--ink); margin-bottom: 4px; }
.agency-ledger { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-elev); overflow: hidden; }
.agency-ledger-head { padding: 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.agency-ledger-head h2 { font-size: 17px; font-weight: 600; }
.agency-ledger-head p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.agency-ledger-head label { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.agency-sort-context { padding: 0 20px 16px; font-size: 11px; color: var(--muted); }
.agency-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.agency-table th, .agency-table td { text-align: right; vertical-align: middle; border-top: 1px solid var(--line); padding: 16px; }
.agency-table thead th { font-size: 12px; font-weight: 500; background: var(--bg-elev-2); color: var(--ink); }
.agency-table thead th span { display: block; font-size: 10px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.agency-table th:first-child { width: 38%; text-align: left; }
.agency-table td { font-size: 14px; font-variant-numeric: tabular-nums; }
.agency-table .selected-measure { background: rgba(63, 185, 80, 0.04); }
.agency-table td.selected-measure > span:not(.agency-unavailable) { color: var(--accent); font-weight: 600; }
.agency-table tbody tr:hover, .agency-table tbody tr.selected { background: var(--accent-dim); }
.agency-open {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  padding: 0; border: 0; font: inherit; font-size: 13px; font-weight: 500; text-align: left; color: var(--ink);
  background: none; cursor: pointer; min-height: 28px; overflow-wrap: anywhere;
}
.agency-open > span:last-child { color: var(--muted); flex-shrink: 0; }
.agency-row-source { display: block; font-size: 10px; color: var(--muted); font-weight: 400; margin-top: 4px; }
.government-breakdown { margin: 0 0 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-elev); }
.government-costs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; padding: 0 20px 16px; }
.expense-category { border-top: 1px solid var(--line); min-width: 0; }
.expense-category summary, .expense-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 48px; gap: 8px; align-items: baseline; padding: 12px 0; font-size: 12px; }
.expense-category summary { cursor: pointer; }
.expense-category summary::marker { color: var(--accent); }
.expense-category summary > span::before { content: "+ "; color: var(--accent); }
.expense-category[open] > summary > span::before { content: "− "; }
.expense-category b, .expense-category small, .expense-line b, .expense-line small { font-variant-numeric: tabular-nums; text-align: right; }
.expense-category small, .expense-line small { color: var(--muted); font-size: 10px; }
.expense-children { padding: 0 8px 12px; }
.expense-children .expense-line { border-top: 1px solid var(--line); font-size: 11px; }
.expense-children p { color: var(--muted); font-size: 10px; margin: 8px 0; }
.agency-costs.agency-expense-categories { display: block; }
.agency-psc-reference { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.agency-psc-reference summary { font-size: 12px; cursor: pointer; }
.agency-psc-reference p, .agency-psc-reference a { font-size: 11px; color: var(--muted); }
.agency-psc-reference a { color: var(--accent); display: block; margin-top: 8px; }
.agency-change small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.agency-change.increase > span { color: #d29922; }
.agency-change.decrease > span { color: #79b8ff; }
.agency-unavailable { color: var(--muted); font-size: 11px; font-weight: 400; }
.agency-empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.agency-footnote { display: flex; justify-content: space-between; gap: 24px; padding: 20px 0 0; color: var(--muted); font-size: 11px; }
.agency-footnote p { max-width: 760px; }
.agency-footnote a { color: var(--accent); flex-shrink: 0; }
.agency-detail { background: var(--bg-elev); box-shadow: -16px 0 48px rgba(0, 0, 0, 0.4); padding: 24px; }
.agency-detail h3 { padding-right: 24px; font-size: 20px; }
.agency-detail-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
.agency-detail-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--muted); }
.agency-detail-controls select { width: 100%; min-width: 0; min-height: 44px; padding: 8px; font: inherit; font-size: 12px; color: var(--ink); background: var(--bg-elev-2); border: 1px solid var(--line); border-radius: 6px; }
.agency-detail-period { margin-top: 8px; }
.agency-costs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.agency-cost-entry { padding: 12px; border: 1px solid var(--line); border-radius: 6px; display: flex; flex-direction: column; gap: 8px; }
.agency-cost-entry > span { font-size: 12px; }
.agency-cost-entry small { display: block; font-size: 10px; color: var(--muted); }
.agency-cost-entry b { font-size: 20px; font-variant-numeric: tabular-nums; }
.agency-cost-entry p { color: var(--muted); font-size: 11px; }
.agency-detail-change { border-block: 1px solid var(--line); padding: 16px 0; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.agency-detail-change > span { font-size: 11px; color: var(--muted); }
.agency-detail-change b { font-size: 20px; font-variant-numeric: tabular-nums; }
.agency-detail-change small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 2px; }
.agency-history { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.agency-history td, .agency-history th { padding: 10px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.agency-history th:first-child { text-align: left; }
.agency-history thead th { color: var(--muted); font-weight: 400; }
.agency-history .selected { background: var(--accent-dim); }
.agency-detail-scope { color: var(--muted); font-size: 11px; margin-top: 20px; }
.agency-detail-scope p + p { margin-top: 8px; }

/* ---- leaflet overrides ---- */
.leaflet-container { font: inherit; }
.leaflet-control-attribution { background: rgba(13,17,23,0.8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, li:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
@media (max-width: 1500px) {
  .topbar { flex-wrap: wrap; }
  .totals { order: 3; width: 100%; margin-left: 0; }
}
@media (max-width: 900px) {
  .agency-content { padding: 24px; }
  .agency-intro { gap: 24px; }
  .agency-intro h1 { font-size: 28px; }
  .agency-year-control { min-width: 192px; }
  .agency-metric { padding: 16px; }
  .agency-table th, .agency-table td { padding: 12px; }
  .agency-table th:first-child { width: 34%; }
  .agency-footnote { flex-direction: column; gap: 12px; }
}
@media (max-width: 760px) {
  .government-costs { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .agency-content { padding: 20px 16px; }
  .agency-intro { flex-direction: column; gap: 20px; }
  .agency-year-control { width: 100%; }
  .agency-intro h1 { font-size: 28px; }
  .agency-intro p { font-size: 13px; }
  .agency-summary { grid-template-columns: 1fr 1fr; margin-top: 24px; gap: 8px; }
  .agency-metric:first-child { grid-column: 1 / -1; }
  .agency-metric { padding: 16px 12px; }
  .agency-metric b { font-size: 26px; }
  .agency-metric-label { flex-wrap: wrap; gap: 4px; }
  .agency-metric-description { line-height: 1.5; }
  .agency-metric-action { font-size: 10px; }
  .agency-explainer { margin-bottom: 16px; }
  .agency-explainer > div { grid-template-columns: 1fr; gap: 16px; }
  .agency-ledger-head { flex-direction: column; align-items: stretch; padding: 16px; }
  .agency-ledger-head label { justify-content: space-between; }
  .agency-sort-context { padding: 0 16px 16px; }
  .agency-table, .agency-table tbody { display: block; }
  .agency-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .agency-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; padding: 16px; gap: 12px 16px; border-top: 1px solid var(--line); }
  .agency-table th:first-child { width: auto; grid-column: 1 / -1; padding: 0; border: 0; }
  .agency-open { min-height: 44px; font-size: 14px; }
  .agency-table td { display: block; padding: 0; border: 0; text-align: left; font-size: 16px; background: none; }
  .agency-table td::before { content: attr(data-label); display: block; font-size: 10px; color: var(--muted); font-weight: 400; margin-bottom: 4px; }
  .agency-change small { margin-top: 2px; }
  .totals, .brand-sub { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .brand { margin-right: auto; }
  .toggles { order: 2; width: 100%; flex-wrap: wrap; margin-left: 0; gap: 6px; }
  .toggles > button { flex: 1; }
  #search { width: 140px; }
  .panel { width: min(440px, calc(100vw - 24px)); }
  .panel-controls { flex-wrap: nowrap; }
  .panel-controls select { flex: 1; width: 50%; }
  .list-columns, .list li .row1 { grid-template-columns: minmax(0, 1fr) 68px 48px 58px; gap: 6px; }
  .list-columns { font-size: 9px; }
  .list li .nm { font-size: 12px; }
  .pills { max-height: 92px; gap: 6px; }
  .pill { font-size: 11px; padding: 6px 10px; }
  .detail { background: var(--bg-elev); }
  .detail .close, #comparison-close { min-width: 44px; min-height: 44px; }
  .comparison-popover {
    left: 12px; right: 12px; top: var(--content-top, 116px); width: auto;
    max-height: calc(100vh - var(--content-top, 116px) - 24px);
  }
  .comparison-popover-head { gap: 4px; padding: 12px 16px; }
  .comparison-row { min-height: 44px; }
  .comparison-footer p { font-size: 10px; }
  .evidence-actions button, .benchmark button, .activity-compare { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
