:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --fund-node:      #b9b8b0;

  --rev-1: #0d366b; --rev-2: #163e72; --rev-3: #1e4678; --rev-4: #274d7f;
  --rev-5: #305585; --rev-6: #395d8c; --rev-7: #416592; --rev-8: #4a6d99;
  --rev-9: #53759f; --rev-10: #5c7ca6; --rev-11: #6484ac; --rev-12: #6d8cb3;
  --rev-13: #7694ba; --rev-14: #7e9cc0; --rev-15: #87a3c7; --rev-16: #90abcd;
  --rev-17: #99b3d4; --rev-18: #a1bbda; --rev-19: #aac3e1; --rev-20: #b3cbe7;
  --rev-21: #bcd2ee; --rev-22: #c4daf4; --rev-23: #cde2fb;

  --exp-gov:   #eb6834; --exp-safe:  #1baf7a; --exp-serv:  #eda100;
  --exp-urban: #e87ba4; --exp-intgv: #008300; --exp-intgv2: #33a333; --exp-intgv3: #6dbf6d; --exp-cap:   #4a3aa7; --exp-debt:  #e34948;
  --exp-debt-principal: #a53430; --exp-debt-interest: #e34948; --exp-debt-issuance: #f2a09e;

  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;

  --status-good: #0ca30c;
  --status-warn: #fab219;
  --status-crit: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --fund-node:      #55544e;
    --rev-1: #184073; --rev-2: #214879; --rev-3: #2a507f; --rev-4: #335785;
    --rev-5: #3c5f8c; --rev-6: #456792; --rev-7: #4d6f98; --rev-8: #56769e;
    --rev-9: #5f7ea4; --rev-10: #6886aa; --rev-11: #718eb0; --rev-12: #7a96b6;
    --rev-13: #839dbd; --rev-14: #8ca5c3; --rev-15: #95adc9; --rev-16: #9eb5cf;
    --rev-17: #a7bcd5; --rev-18: #afc4db; --rev-19: #b8cce1; --rev-20: #c1d4e8;
    --rev-21: #cadbee; --rev-22: #d3e3f4; --rev-23: #dcebfa;
    --exp-gov: #d95926; --exp-safe: #199e70; --exp-serv: #c98500;
    --exp-urban: #d55181; --exp-intgv: #008300; --exp-intgv2: #33a333; --exp-intgv3: #6dbf6d; --exp-cap: #9085e9; --exp-debt: #e66767;
    --exp-debt-principal: #e66767; --exp-debt-interest: #ee8987; --exp-debt-issuance: #f5b6b4;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --status-good: #0ca30c; --status-warn: #fab219; --status-crit: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --fund-node:      #55544e;
  --rev-1: #184073; --rev-2: #214879; --rev-3: #2a507f; --rev-4: #335785;
  --rev-5: #3c5f8c; --rev-6: #456792; --rev-7: #4d6f98; --rev-8: #56769e;
  --rev-9: #5f7ea4; --rev-10: #6886aa; --rev-11: #718eb0; --rev-12: #7a96b6;
  --rev-13: #839dbd; --rev-14: #8ca5c3; --rev-15: #95adc9; --rev-16: #9eb5cf;
  --rev-17: #a7bcd5; --rev-18: #afc4db; --rev-19: #b8cce1; --rev-20: #c1d4e8;
  --rev-21: #cadbee; --rev-22: #d3e3f4; --rev-23: #dcebfa;
  --exp-gov: #d95926; --exp-safe: #199e70; --exp-serv: #c98500;
  --exp-urban: #d55181; --exp-intgv: #008300; --exp-intgv2: #33a333; --exp-intgv3: #6dbf6d; --exp-cap: #9085e9; --exp-debt: #e66767;
  --exp-debt-principal: #e66767; --exp-debt-interest: #ee8987; --exp-debt-issuance: #f5b6b4;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --status-good: #0ca30c; --status-warn: #fab219; --status-crit: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page-plane);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }

header.site-header h1 { font-size: 1.5rem; margin: 0 0 4px; }
header.site-header p.tagline { color: var(--text-secondary); font-size: 0.95rem; margin: 0 0 18px; max-width: 760px; }

nav.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
nav.tabs button {
  font: inherit;
  font-size: 0.88rem;
  padding: 9px 14px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
nav.tabs button:hover { color: var(--text-primary); }
nav.tabs button.active {
  color: var(--text-primary);
  border-bottom-color: var(--series-1);
  font-weight: 600;
}

.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 2px; }
.panel p.desc { color: var(--text-secondary); font-size: 0.85rem; margin: 0 0 14px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .panel { flex: 1 1 420px; min-width: 0; }

.controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.controls span.label { color: var(--text-muted); font-size: 0.82rem; margin-right: 4px; }
.pill-btn {
  font: inherit; font-size: 0.85rem; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.pill-btn:hover { color: var(--text-primary); }
.pill-btn.active { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }

.stat-row { display: flex; gap: 24px; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
.stat-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.axis text { fill: var(--text-muted); font-size: 10.5px; }
.axis path, .axis line { stroke: var(--gridline); }
.axis.baseline path { stroke: var(--baseline); }
.gridline { stroke: var(--gridline); stroke-width: 1; }

.node rect { stroke: var(--border); stroke-width: 1; }
.node text { fill: var(--text-primary); font-size: 12px; }
.node .node-value { fill: var(--text-muted); font-size: 10.5px; }
.link { mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { .link { mix-blend-mode: screen; } }
:root[data-theme="dark"] .link { mix-blend-mode: screen; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.78rem; color: var(--text-secondary); margin-top: 10px; }
.legend-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend-title { color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
.swatch { display: inline-flex; align-items: center; gap: 5px; }
.swatch i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.swatch.line i { height: 3px; border-radius: 2px; }

.tooltip {
  position: fixed; pointer-events: none; background: var(--text-primary); color: var(--surface-1);
  padding: 6px 10px; border-radius: 6px; font-size: 12.5px; line-height: 1.4; opacity: 0;
  transition: opacity 0.1s; z-index: 20; max-width: 280px;
}

.hover-dot { fill: var(--surface-1); stroke-width: 2; }
.hover-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }

footer.site-footer {
  margin-top: 8px; font-size: 0.76rem; color: var(--text-muted); line-height: 1.55;
}
footer.site-footer a { color: var(--text-secondary); }

.dept-toggle { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  min-height: 20px;
}
.breadcrumb .crumb {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.breadcrumb .crumb:hover { background: var(--border); color: var(--text-primary); }
.breadcrumb .crumb.current { color: var(--text-primary); font-weight: 600; cursor: default; }
.breadcrumb .crumb.current:hover { background: none; }
.breadcrumb .sep { color: var(--text-muted); }

.treemap rect { stroke: var(--surface-1); stroke-width: 1.5px; }
.treemap rect.has-children { stroke-width: 2px; }
.treemap rect:hover { filter: brightness(1.15); }
.treemap text {
  fill: #fff;
  font-size: 9.5px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.treemap .header-text { font-size: 9.5px; font-weight: 600; }
.treemap .value-text { font-size: 8.5px; opacity: 0.85; }

@media (max-width: 640px) {
  .row { flex-direction: column; }
}
