:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e3e2de;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --power: #2a78d6;
  --cadence: #eb6834;
  --good: #1b7f3b;
  --idle: #8a8983;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #2c2c2a;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #94938a;
    --power: #3987e5;
    --cadence: #d95926;
    --good: #3fb760;
    --idle: #77766f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --border: #2c2c2a;
  --grid: #262624;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #94938a;
  --power: #3987e5;
  --cadence: #d95926;
  --good: #3fb760;
  --idle: #77766f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }

header.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 16px 0; margin-bottom: 8px;
}
header.top .brand { font-weight: 700; letter-spacing: -0.01em; text-decoration: none; }
header.top nav { display: flex; gap: 16px; }
header.top nav a { color: var(--text-secondary); text-decoration: none; }
header.top nav a[aria-current="page"] { color: var(--text-primary); font-weight: 600; }

h1 { font-size: 22px; margin: 8px 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--text-secondary); font-weight: 600; }

.status { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 14px; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--idle); }
.status.live .dot { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--text-secondary); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile .swatch { width: 10px; height: 10px; border-radius: 2px; }
.tile .value { font-size: 40px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.tile .value small { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; letter-spacing: 0; }
.tile.compact .value { font-size: 26px; }

/* Grid children may shrink below their content (charts resize to fit). */
.tile, .card, .charts > * { min-width: 0; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.chart-box { position: relative; height: 240px; }
.charts { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 900px) { .charts.two { grid-template-columns: 1fr 1fr; gap: 16px; } }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; font-size: 13px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: color-mix(in srgb, var(--power) 7%, transparent); }

.muted { color: var(--text-muted); }
.note { color: var(--text-muted); font-size: 13px; margin-top: 8px; }
.empty { color: var(--text-muted); padding: 24px 0; text-align: center; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.row input { flex: 1 1 200px; min-width: 0; }
input, button { font: inherit; color: inherit; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); padding: 10px 14px; }
button { cursor: pointer; font-weight: 600; }
button.primary { background: var(--power); border-color: var(--power); color: #fff; padding: 14px 22px; font-size: 17px; }
.error { color: #c62828; margin-bottom: 0; }
details summary { cursor: pointer; color: var(--text-secondary); font-weight: 600; }
.log { font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; max-height: 240px; overflow: auto; color: var(--text-secondary); }
