/* Dark-only dashboard. Colors are the validated dark-mode steps of the
   reference palette; the four vault hues are categorical slots 1–4. */
:root {
  color-scheme: dark;

  --plane:          #0d0d0d;
  --surface-1:      #1a1a19;
  --surface-2:      #232322;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255, 255, 255, 0.10);

  --series-1: #3987e5; /* Aerodrome  */
  --series-2: #d95926; /* Velodrome  */
  --series-3: #199e70; /* Pharaoh    */
  --series-4: #c98500; /* Blackhole  */

  --good:     #0ca30c;
  --warning:  #fab219;
  --critical: #d03b3b;

  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 clamp(12px, 3vw, 32px) 48px;
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  color: var(--text-secondary);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

h1 { font-size: clamp(20px, 3.4vw, 26px); margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -0.005em; }

.muted { color: var(--text-muted); }
.hidden { display: none !important; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.topbar .sub {
  margin: 6px 0 0;
  color: var(--text-secondary);
  max-width: 68ch;
  font-size: 13.5px;
}
.topbar-meta { font-size: 12.5px; white-space: nowrap; }

/* ---------- vault cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 120ms ease, background 120ms ease;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}
.card:hover { background: var(--surface-2); }
.card.on { border-color: var(--accent); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.card-name { font-weight: 600; font-size: 14px; }
.card-chain { font-size: 11.5px; color: var(--text-muted); }

.card-value {
  font-size: clamp(24px, 4.4vw, 30px);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.card-value.zero { color: var(--text-muted); }

.card-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.state-dry  { color: var(--text-muted); }
.state-dry  .dot { background: var(--text-muted); }
.state-thin { color: var(--warning); }
.state-thin .dot { background: var(--warning); }
.state-open { color: var(--good); }
.state-open .dot { background: var(--good); }

.card-rows { display: grid; gap: 3px; font-size: 12.5px; }
.card-row { display: flex; justify-content: space-between; gap: 10px; }
.card-row span:first-child { color: var(--text-muted); }
.card-row span:last-child { font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ---------- panels ---------- */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head.column { display: block; }
.panel-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 5px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}
.seg button:hover { color: var(--text-primary); }
.seg button.on { background: var(--plane); color: var(--text-primary); }

.toggle, .field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 11px;
  min-height: 34px;
  cursor: pointer;
}
.field input {
  font: inherit;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  width: 82px;
  background: var(--plane);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
}
.btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-primary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 13px;
  min-height: 34px;
  cursor: pointer;
}
.btn:hover { background: var(--plane); }

/* ---------- chart ---------- */

.chart { width: 100%; min-height: 300px; }
.chart-panel { position: relative; }

.empty {
  position: absolute;
  inset: auto 16px 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
  top: 50%;
  transform: translateY(-20%);
  height: max-content;
}
.empty strong { font-size: 16px; color: var(--text-secondary); }
.empty span { font-size: 12.5px; color: var(--text-muted); }

.footnote { margin: 10px 0 0; font-size: 11.5px; color: var(--text-muted); }

.u-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.u-tooltip .tt-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.u-tooltip .tt-time { color: var(--text-muted); }

/* ---------- bar panels ---------- */

.bars { display: grid; gap: 6px; }
.bar-row {
  display: grid;
  grid-template-columns: 34px 1fr 74px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.bars-dense .bar-row { grid-template-columns: 34px 1fr 74px; gap: 6px; }
.bar-label { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-track {
  display: block;
  background: var(--surface-2);
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: var(--series-1);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.bar-row.best .bar-label, .bar-row.best .bar-value { color: var(--text-primary); font-weight: 600; }

/* ---------- stats + table ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.stat-label { font-size: 11.5px; color: var(--text-muted); }
.stat-value {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.table-wrap { overflow-x: auto; max-height: 380px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  color: var(--text-muted);
  font-weight: 550;
  font-size: 11.5px;
}
td { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
td.num, th.num { text-align: right; }
td.peak { color: var(--text-primary); font-weight: 600; }
.table-empty { padding: 20px 10px; color: var(--text-muted); font-size: 13px; text-align: center; }

footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  max-width: 90ch;
}
footer p { margin: 0; }
