:root {
  --bg: #0b1014;
  --panel: #111820;
  --panel-2: #151f28;
  --panel-3: #0e151b;
  --line: #263541;
  --line-strong: #3d5363;
  --text: #dce5e8;
  --muted: #91a0a8;
  --faint: #64737c;
  --good: #62b58f;
  --warn: #d7a84b;
  --bad: #d46a5f;
  --blue: #6aa4c8;
  --cyan: #78b9b2;
  --ink: #071015;
  --row: rgba(255,255,255,.026);
  --row-hover: rgba(106,164,200,.08);
  --font-ui: "Aptos", "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.side-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #081016;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.system-mark {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  letter-spacing: .04em;
}
.system-mark strong { display: block; font-size: 13px; }
.system-mark small { display: block; color: var(--muted); font: 11px/1.2 var(--font-mono); margin-top: 2px; }
.mark-grid {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(90deg, transparent 10px, var(--line) 11px, transparent 12px),
    linear-gradient(0deg, transparent 10px, var(--line) 11px, transparent 12px),
    #0d151b;
  display: inline-block;
}

.mode-nav { display: grid; gap: 6px; }
.nav-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 10px;
  font: 12px/1.25 var(--font-mono);
  cursor: pointer;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-btn.active {
  color: var(--text);
  border-color: var(--line-strong);
  background: #121b22;
}
.nav-btn span { display: block; color: var(--faint); margin-top: 3px; font-size: 10px; }

.rail-note {
  margin-top: auto;
  border: 1px solid var(--line);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  display: inline-block;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}
.status-dot.green { background: var(--good); }
.status-dot.amber { background: var(--warn); }
.status-dot.red { background: var(--bad); }

.main-frame { min-width: 0; padding: 20px 22px 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font: 11px/1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .12em;
}
h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  font-weight: 640;
  letter-spacing: -.035em;
}
.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 560px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--panel-3);
  padding: 7px 9px;
  color: var(--muted);
  font: 11px/1.1 var(--font-mono);
  white-space: nowrap;
}
.chip strong { color: var(--text); font-weight: 600; }
.chip.good { border-color: rgba(98,181,143,.45); color: #a9d4c1; }
.chip.warn { border-color: rgba(215,168,75,.55); color: #dfc482; }
.chip.bad { border-color: rgba(212,106,95,.55); color: #dfaaa3; }

.view-frame { padding-top: 16px; }
.grid { display: grid; gap: 10px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.main-layout { grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); align-items: start; }
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
}
.panel-title {
  margin: 0;
  font: 12px/1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text);
}
.panel-subtitle { color: var(--muted); font: 11px var(--font-mono); }
.panel-body { padding: 10px; }

.metric {
  border: 1px solid var(--line);
  background: var(--panel-3);
  padding: 10px;
  min-height: 84px;
}
.metric .label { color: var(--muted); font: 11px var(--font-mono); text-transform: uppercase; }
.metric .value { font-size: 24px; line-height: 1.15; margin-top: 6px; letter-spacing: -.04em; font-weight: 650; }
.metric .delta { margin-top: 5px; font: 12px var(--font-mono); color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

.opinion-box {
  border-left: 3px solid var(--warn);
  background: #121a20;
  padding: 10px 12px;
  color: var(--text);
}
.opinion-box strong { display: block; margin-bottom: 4px; }
.command-line {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  background: #071015;
  color: #bfd2db;
  font: 11px/1.45 var(--font-mono);
  overflow: auto;
}

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: right;
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
th {
  color: var(--muted);
  font: 10px/1.2 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #0c141a;
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:nth-child(even) td { background: var(--row); }
tr:hover td { background: var(--row-hover); }
td a { color: var(--blue); text-decoration: none; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  font: 10px var(--font-mono);
}
.status-pill.good { color: var(--good); border-color: rgba(98,181,143,.35); }
.status-pill.warn { color: var(--warn); border-color: rgba(215,168,75,.35); }
.status-pill.bad { color: var(--bad); border-color: rgba(212,106,95,.35); }

.chart {
  width: 100%;
  min-height: 240px;
  display: block;
}
.chart svg { width: 100%; height: auto; display: block; }
.axis text, .chart-label { fill: var(--muted); font-family: var(--font-mono); font-size: 10px; }
.grid-line { stroke: #263541; stroke-width: 1; }
.series-line { fill: none; stroke-width: 2; }
.series-dot { stroke: var(--panel); stroke-width: 1; }
.bar { fill: #315d76; }
.bar.alt { fill: #2f827c; }
.bar.warn { fill: #b58635; }
.bar.bad { fill: #a94f4a; }

.footnotes {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.footnotes div { border-top: 1px solid var(--line); padding-top: 6px; }
.empty-state {
  border: 1px dashed var(--line-strong);
  padding: 18px;
  background: #0c1419;
  color: var(--muted);
}
.empty-state strong { color: var(--text); display: block; margin-bottom: 6px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-rail { position: relative; height: auto; }
  .mode-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .rail-note { margin-top: 0; }
  .grid.main-layout, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .main-frame { padding: 14px; }
  .topbar { flex-direction: column; }
  .status-stack { justify-content: flex-start; }
  .mode-nav { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
}
.map-layout { display: grid; grid-template-columns: minmax(320px, .75fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.map-wrap { border: 1px solid var(--line); background: #071117; padding: 8px; }
.arg-outline { fill: #0c1a22; stroke: #44606d; stroke-width: 2; }
.city-dot { stroke: #061015; stroke-width: 2; cursor: pointer; opacity: .88; }
.city-dot:hover, .city-dot:focus { opacity: 1; stroke: #fff; outline: none; }
.city-dot.hot { fill: var(--warn); }
.city-dot.mid { fill: var(--blue); }
.city-dot.cool { fill: var(--good); }
.city-label { fill: var(--text); font: 10px var(--font-mono); letter-spacing: .02em; pointer-events: none; paint-order: stroke; stroke: #071117; stroke-width: 3px; stroke-linejoin: round; }
.map-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.map-filters button { background: #0a1117; color: var(--muted); border: 1px solid var(--line); padding: 6px 8px; font: 11px var(--font-mono); cursor: pointer; }
.map-filters button.active { color: var(--text); border-color: var(--blue); }
.map-readout { border: 1px solid var(--line); padding: 10px; background: #0b141b; margin-bottom: 10px; }
.map-readout strong { display: block; font-size: 19px; margin-bottom: 3px; }
.map-readout span { display: block; color: var(--muted); font: 12px var(--font-mono); margin-top: 3px; }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; } }
