:root {
  color-scheme: light;
}

.viz-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);

  --series-blue:    #2a78d6;   /* Revenue */
  --series-orange:  #eb6834;   /* Outlays */
  --series-aqua:    #1baf7a;   /* GDP */
  --series-yellow:  #eda100;
  --series-magenta: #e87ba4;
  --series-green:   #008300;
  --series-violet:  #4a3aa7;   /* Debt */
  --series-red:     #e34948;   /* Deficit / tax increase */

  --divergent-blue: #2a78d6;   /* surplus / tax cut */
  --divergent-red:  #e34948;   /* deficit / tax increase */
  --divergent-mid:  #f0efec;   /* mixed / neutral */
  --neutral-mixed:  #898781;

  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    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);

    --series-blue:    #3987e5;
    --series-orange:  #d95926;
    --series-aqua:    #199e70;
    --series-yellow:  #c98500;
    --series-magenta: #d55181;
    --series-green:   #008300;
    --series-violet:  #9085e9;
    --series-red:     #e66767;

    --divergent-blue: #3987e5;
    --divergent-red:  #e66767;
    --divergent-mid:  #383835;
    --neutral-mixed:  #898781;

    --good:           #0ca30c;
    --warning:        #fab219;
    --serious:        #ec835a;
    --critical:       #e66767;
  }
}

:root[data-theme="dark"] .viz-root {
  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);

  --series-blue:    #3987e5;
  --series-orange:  #d95926;
  --series-aqua:    #199e70;
  --series-yellow:  #c98500;
  --series-magenta: #d55181;
  --series-green:   #008300;
  --series-violet:  #9085e9;
  --series-red:     #e66767;

  --divergent-blue: #3987e5;
  --divergent-red:  #e66767;
  --divergent-mid:  #383835;
  --neutral-mixed:  #898781;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

header.hero {
  padding: 28px 4px 20px;
}

header.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 8px;
  line-height: 1.15;
}

header.hero p.lede {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 760px;
  margin: 0 0 6px;
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 18px 0 32px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.stat-tile .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-tile .value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-tile .value.red { color: var(--divergent-red); }
.stat-tile .value.blue { color: var(--divergent-blue); }

.stat-tile .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 20px 12px;
  margin-bottom: 28px;
  scroll-margin-top: 16px;
}

.card.quick-take {
  border-left: 4px solid var(--series-blue);
}

.jump-links {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.jump-links a {
  color: var(--series-blue);
  text-decoration: none;
}
.jump-links a:hover {
  text-decoration: underline;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.card p.caption {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 800px;
}

.chart-holder {
  position: relative;
  width: 100%;
}
.chart-holder.tall { height: 380px; }
.chart-holder.short { height: 200px; }
.chart-holder.timeline { height: 140px; }
.chart-holder.admin { height: 720px; }

.legend-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 10px 0 4px;
}
.legend-row .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-row .swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}
.legend-row .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.table-scroll {
  overflow-x: auto;
  max-height: 560px;
  overflow-y: auto;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
table.admin-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  background: var(--surface-1);
  z-index: 2;
  box-shadow: 0 1px 0 var(--gridline);
}
table.admin-table td.num-red { color: var(--divergent-red); }
table.admin-table td.num-blue { color: var(--divergent-blue); }
table.admin-table .acts-cell {
  max-width: 260px;
}
.act-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  margin: 1px 3px 1px 0;
  color: #fff;
}
.act-tag.cut { background: var(--divergent-blue); }
.act-tag.increase { background: var(--divergent-red); }
.act-tag.mixed { background: var(--neutral-mixed); }

.analysis h3 {
  font-size: 17px;
  margin: 22px 0 8px;
}
.analysis p {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 15px;
}
.analysis ul {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 15px;
  padding-left: 20px;
}
.analysis .verdict {
  background: var(--page-plane);
  border-left: 4px solid var(--series-blue);
  padding: 14px 18px;
  border-radius: 6px;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.6;
}

.callout {
  background: var(--page-plane);
  border-left: 4px solid var(--series-blue);
  padding: 14px 18px;
  border-radius: 6px;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.6;
  margin: 4px 0 8px;
}

footer {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 20px;
  line-height: 1.6;
}

.gap-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

@media (max-width: 600px) {
  .chart-holder.tall { height: 300px; }
  .chart-holder.admin { height: 640px; }
}

/* loading wheel */
@keyframes spin-wheel { to { transform: rotate(360deg); } }
.loading-wheel {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid rgba(123, 63, 242, 0.18); border-top-color: #7B3FF2;
  animation: spin-wheel 0.8s linear infinite;
}
#pageLoader { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(255,255,255,.88); color: #445; font: 600 .95rem system-ui, sans-serif; transition: opacity .25s; }
:root[data-theme="dark"] #pageLoader { background: rgba(14,16,24,.9); color: #ccd; }
#pageLoader.done { opacity: 0; pointer-events: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #pageLoader { background: rgba(14,16,24,.9); color: #ccd; }
}
