/* URP economy panel. Colours are the validated data-viz palette: series and
   diverging poles are stepped separately for light and dark surfaces. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --pos: #2a78d6;
  --neg: #e34948;
  --good-text: #006300;
  --critical: #d03b3b;
  --warning: #fab219;
  --accent: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --pos: #3987e5;
    --neg: #e66767;
    --good-text: #0ca30c;
    --accent: #3987e5;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --pos: #3987e5;
  --neg: #e66767;
  --good-text: #0ca30c;
  --accent: #3987e5;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--text-secondary); }

/* ------------------------------------------------------------- sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow);
}
.login-card .brand { font-size: 16px; }
.login-note { margin: 0; color: var(--text-secondary); font-size: 13px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.login-card input {
  font: inherit; color: var(--text-primary); background: var(--page); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.login-card button[type=submit] {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px; font-weight: 600;
}
.login-card button[disabled] { opacity: .6; cursor: default; }
.login-error { margin: 0; min-height: 1em; color: var(--critical); font-size: 13px; }

/* -------------------------------------------------------------- chrome */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.top {
  display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { color: var(--text-secondary); font-size: 13px; margin-right: 4px; }
.ghost { background: none; border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; font-size: 13px; color: var(--text-secondary); }
.ghost:hover { background: var(--surface-2); }
.live { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-secondary); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on .dot { background: #0ca30c; box-shadow: 0 0 0 3px color-mix(in srgb, #0ca30c 25%, transparent); }
.live.stale .dot { background: var(--warning); }

.filters { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 24px 0; max-width: 1400px; margin: 0 auto; }
.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--text-secondary); }
.seg button:hover { background: var(--surface-2); }
.seg button[aria-checked="true"] { background: var(--surface-2); color: var(--text-primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
.range-note { color: var(--muted); font-size: 12px; }

.notice {
  max-width: 1400px; margin: 12px auto 0; padding: 10px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--warning) 50%, transparent);
  background: color-mix(in srgb, var(--warning) 12%, var(--surface-1));
}

.grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
  padding: 16px 24px 24px; max-width: 1400px; margin: 0 auto;
  transition: opacity .2s;
}
.grid.loading { opacity: .55; }
.span-all { grid-column: 1 / -1; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; min-width: 0; box-shadow: var(--shadow);
}
.card-head { margin-bottom: 12px; }
.card-head p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; max-width: 80ch; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 16px; }
.foot { max-width: 1400px; margin: 0 auto; padding: 0 24px 32px; color: var(--muted); font-size: 12px; }

/* --------------------------------------------------------- hero, tiles */
.hero { display: grid; grid-template-columns: minmax(240px, auto) 1fr; gap: 28px; align-items: center; }
.label { color: var(--text-secondary); font-size: 13px; }
.hero-value { font-size: 48px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0; }
.hero-sub { color: var(--text-secondary); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface-2); border-radius: 9px; padding: 12px 14px; min-width: 0; }
.tile .v { font-size: 22px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiles.small .tile .v { font-size: 19px; }
.tile .d { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.tile .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ------------------------------------------------------------- charts */
.chart { position: relative; width: 100%; height: 280px; }
.chart.short { height: 200px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.crosshair { stroke: var(--muted); stroke-width: 1; pointer-events: none; }
.endlabel { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 3px; }
.legend i.line { height: 2px; border-radius: 1px; }

.tip {
  position: fixed; z-index: 20; pointer-events: none; min-width: 150px; max-width: 280px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .row b { font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 12px; }
.tip .row i { width: 10px; height: 2px; border-radius: 1px; display: inline-block; }

/* ------------------------------------------------------ ranked bars */
.rank { display: grid; gap: 10px; }
.rank .r { display: grid; grid-template-columns: minmax(110px, 170px) 1fr auto; gap: 10px; align-items: center; }
.rank .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .name small { color: var(--muted); font-size: 11px; display: block; }
.rank .bar { height: 12px; background: var(--surface-2); border-radius: 0 4px 4px 0; position: relative; }
.rank .bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; }
.rank .val { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank .val small { display: block; color: var(--muted); font-size: 11px; }
.rank .none { color: var(--muted); font-size: 13px; }
.chg { color: var(--text-secondary); }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.group td { font-weight: 600; color: var(--text-secondary); background: var(--surface-2); font-size: 12px; }
.tbl .muted { color: var(--muted); }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.pill.staff { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.pos { color: var(--text-primary); }
.neg { color: var(--text-primary); }
details.data { margin-top: 10px; }
details.data summary { cursor: pointer; color: var(--text-secondary); font-size: 12px; }
details.data .tbl { margin-top: 8px; }

/* -------------------------------------------------------------- phone */
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 20px; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .hero-value { font-size: clamp(26px, 8.5vw, 40px); }
  .tile .v, .tiles.small .tile .v { font-size: 18px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .who { display: none; }
  .filters { padding: 12px 16px 0; }
  .seg { overflow-x: auto; max-width: 100%; }
  .seg button { padding: 5px 9px; white-space: nowrap; }
  .notice { margin: 12px 16px 0; }
  .foot { padding: 0 16px 24px; }
  .chart { height: 240px; }
  .rank .r { grid-template-columns: minmax(90px, 120px) 1fr auto; }
}

/* Money supply: one small chart per measure, each on its own scale. */
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 24px; }
.multiples h3 .chg { font-weight: 500; color: var(--muted); }
