:root {
  --bg: #f6f7f5; --surface: #ffffff; --text: #1b2420; --muted: #5d6a64; --line: #e1e6e3;
  --brand: #176b4d; --brand-soft: #e3f1ea;
  --band95: rgba(23, 107, 77, 0.12); --band80: rgba(23, 107, 77, 0.24);
  --hist: #1b2420; --crisis: #b42318; --abnormal: #e0730b; --elevated: #c9a40a; --normal: #7c8a84;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --surface: #19201d; --text: #e7ece9; --muted: #9aa7a1; --line: #2a3430;
    --brand: #4fbf8f; --brand-soft: #1f3a2f;
    --band95: rgba(79, 191, 143, 0.14); --band80: rgba(79, 191, 143, 0.28);
    --hist: #e7ece9; --crisis: #f0645a; --abnormal: #f29a3f; --elevated: #e2c13c; --normal: #8d9b95;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --surface: #19201d; --text: #e7ece9; --muted: #9aa7a1; --line: #2a3430;
  --brand: #4fbf8f; --brand-soft: #1f3a2f;
  --band95: rgba(79, 191, 143, 0.14); --band80: rgba(79, 191, 143, 0.28);
  --hist: #e7ece9; --crisis: #f0645a; --abnormal: #f29a3f; --elevated: #e2c13c; --normal: #8d9b95;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top {
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
  padding: 16px; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand svg rect { fill: var(--brand); }
.brand svg path { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 16px 0 4px; }
.sub, .run, .note { color: var(--muted); margin: 0; font-size: 13px; }
.note { margin-bottom: 10px; }

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: baseline; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.pickers { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 820px) { .pickers { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pickers label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px;
}

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 820px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .detail { font-size: 12px; color: var(--muted); }
.up { color: var(--crisis); } .down { color: var(--brand); }

.toggles, .range, .hz { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.range { margin: 8px 0; }
button {
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; min-height: 32px;
}
button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--text); font-weight: 600; }
button .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.chk { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; margin-left: 8px; }

.chart { width: 100%; height: 380px; }
@media (max-width: 600px) { .chart { height: 300px; } }
.map { width: 100%; height: 320px; border-radius: 8px; margin-bottom: 12px; z-index: 0; }

.bar { display: grid; grid-template-columns: 120px 1fr 52px; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; }
.bar .track { display: block; background: var(--bg); border-radius: 4px; height: 12px; overflow: hidden; }
.bar .fill { display: block; background: var(--brand); height: 100%; border-radius: 4px; }
.bar .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.slider { display: grid; grid-template-columns: 1fr 56px; gap: 4px 12px; align-items: center; margin: 10px 0; }
.slider label { grid-column: 1 / -1; font-size: 13px; }
.slider input { width: 100%; accent-color: var(--brand); }
.slider output { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.scenario { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 8px; font-size: 14px; }
.scenario table { width: 100%; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; }
tr.ens td { font-weight: 650; }
.hz { margin: 8px 0; }

.legend { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.dot.crisis { background: var(--crisis); } .dot.abnormal { background: var(--abnormal); } .dot.elevated { background: var(--elevated); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; }
.pill.crisis { background: var(--crisis); } .pill.abnormal { background: var(--abnormal); }
.pill.elevated { background: var(--elevated); color: #1b2420; } .pill.normal { background: var(--normal); }

footer { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 12px; }
footer a { color: var(--brand); }
.err { color: var(--crisis); }
