:root {
  color-scheme: dark;
  --bg: #121211;
  --panel: #1a1a19;
  --panel-2: #262624;
  --text: #ffffff;
  --muted: #c3c2b7;
  --line: #383835;
  --up: #0ca30c;
  --degraded: #fab219;
  --down: #d03b3b;
  --asleep: #7b8aa8;
  --unknown: #8b8a84;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f3f1;
    --panel: #fcfcfb;
    --panel-2: #f0efec;
    --text: #0b0b0b;
    --muted: #52514e;
    --line: #dddcd7;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.1rem; margin: 0; letter-spacing: 0.02em; }
.summary { display: flex; gap: 0.75rem; flex: 1; font-size: 0.85rem; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; display: inline-block; flex: none; background: var(--unknown); }
.dot.up, .dot.pass { background: var(--up); }
.dot.degraded { background: var(--degraded); }
.dot.down, .dot.fail { background: var(--down); }
.dot.asleep { background: var(--asleep); }
.link { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; }
.link:hover { color: var(--text); }
.banner { margin: 1rem 1.5rem 0; padding: 0.6rem 0.9rem; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--degraded); font-size: 0.9rem; }
main { padding: 0.5rem 1.5rem 2rem; }
.meter-track { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--series-1); border-radius: 0 3px 3px 0; }
.meter-fill.warm { background: var(--degraded); }
.facts { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font-size: 0.75rem; color: var(--muted); margin-top: 0.5rem; }
table.fleet { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.88rem; }
table.fleet thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
table.fleet .group-row th { text-align: left; padding: 1.1rem 0.6rem 0.35rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
table.fleet td { padding: 0.42rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.host-row { cursor: pointer; }
.host-row:hover, .host-row:focus-visible { background: var(--panel); outline: none; }
.host-row.down td { background: color-mix(in srgb, var(--down) 12%, transparent); }
.host-row.degraded td { background: color-mix(in srgb, var(--degraded) 10%, transparent); }
.host-row.asleep td, .host-row.unknown td { color: var(--muted); }
.status-cell { width: 7.5rem; }
.status-cell .dot { margin-right: 0.5rem; vertical-align: middle; }
.name-cell { font-weight: 600; width: 11rem; }
.metric { width: 10.5rem; }
.metric .meter-track { display: inline-block; width: 5.5rem; vertical-align: middle; margin-right: 0.5rem; }
.metric .meter-value { display: inline-block; width: 2.6rem; text-align: right; font-variant-numeric: tabular-nums; }
.metric.empty { color: var(--muted); }
.note-cell { color: var(--muted); white-space: normal; }
.extra-cell { color: var(--muted); font-size: 0.8rem; }
.checks-cell .dot { margin-right: 0.4rem; vertical-align: middle; }
.checks-cell .check-count { font-variant-numeric: tabular-nums; }
.checks-cell .failing { margin-left: 0.5rem; color: var(--text); white-space: normal; }
.num-cell { font-variant-numeric: tabular-nums; }
.dot.unknown { background: var(--unknown); }
.note { font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }
dialog { width: min(960px, 94vw); max-height: 90vh; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.4rem; }
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.detail-head { display: flex; align-items: center; justify-content: space-between; }
.detail-head h2 { margin: 0; font-size: 1.1rem; }
.detail-section { margin-top: 1rem; }
.detail-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.4rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ranges { display: flex; gap: 0.4rem; margin: 1rem 0 0.5rem; }
.ranges button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 0.25rem 0.7rem; cursor: pointer; }
.ranges button[aria-pressed="true"] { border-color: var(--series-1); }
.chart { margin-top: 0.8rem; }
.chart h4 { margin: 0 0 0.3rem; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.uplot .u-legend { color: var(--text); font-size: 0.78rem; }
.muted { color: var(--muted); }
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.6rem; width: min(340px, 92vw); display: grid; gap: 0.9rem; }
.login h1 { margin: 0; font-size: 1.2rem; }
.login label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.login input { padding: 0.5rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; }
.login button { padding: 0.55rem; border-radius: 6px; border: none; background: var(--series-1); color: #fff; font: inherit; cursor: pointer; }
.error { color: var(--down); margin: 0; font-size: 0.85rem; }
