.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --good-text: #0ca30c;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.06);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --good-text: #0ca30c;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.viz-root { min-height: 100vh; background: var(--page); color: var(--text-primary); }
.wrap { padding: 20px clamp(12px, 3vw, 32px) 40px; max-width: 1280px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 13px; margin: 0 0 6px; font-weight: 600; color: var(--text-secondary); }
a { color: inherit; }
.muted { color: var(--muted); }
.sub { margin: 2px 0 0; color: var(--text-secondary); }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.controls { display: flex; gap: 8px; align-items: center; }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--wash); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible,
.cell:focus-visible, .plot:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
button.ghost { border-color: transparent; background: transparent; }
a.button {
  border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 6px 12px;
  text-decoration: none; color: inherit;
}
a.button:hover { background: var(--wash); }
.relay-line { flex-basis: 100%; font-size: 13px; color: var(--text-secondary); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-1); }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; background: transparent; }
.seg button[aria-checked="true"] { font-weight: 700; background: var(--wash); }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.fleet { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.hero { font-size: 32px; font-weight: 700; }

.instance { transition: opacity 0.2s; }
.loading .instance, .loading .fleet { opacity: 0.6; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip { font-size: 12px; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; color: var(--text-secondary); }
.meta { color: var(--text-secondary); font-size: 13px; }
.meta a { color: var(--text-secondary); }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status.up .dot { background: var(--good); }
.status.degraded .dot, .status.stale .dot { background: var(--warning); }
.status.down .dot { background: var(--critical); }
.status.unknown .dot { background: var(--axis); }
.status .icon { font-size: 12px; }

.backends { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0 4px; font-size: 13px; color: var(--text-secondary); }
.backends .ok::before { content: "✓ "; color: var(--good-text); font-weight: 700; }
.backends .bad::before { content: "✕ "; color: var(--critical); font-weight: 700; }
.error { margin: 8px 0 0; color: var(--critical); font-size: 13px; overflow-wrap: anywhere; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 14px 0; }
.tile { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 22px; font-weight: 650; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--muted); }

.rotation { border-top: 1px solid var(--grid); margin-top: 6px; padding-top: 12px; }
.rotation .facts { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.rotation .facts div { min-width: 120px; }
.rotation .facts strong { display: block; font-size: 15px; }
.progress { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; margin: 6px 0 10px; max-width: 520px; }
.progress span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
pre.log {
  margin: 6px 0 0; padding: 10px; border-radius: 8px; background: var(--wash); max-height: 220px; overflow: auto;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; color: var(--text-secondary);
}
details > summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px 24px; margin-top: 12px; }
.chart { min-width: 0; }
.chart.wide { grid-column: 1 / -1; }
.plot { position: relative; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; }
.plot .baseline { stroke: var(--axis); stroke-width: 1; }
.plot .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .crosshair { stroke: var(--axis); stroke-width: 1; }
.plot .marker { stroke: var(--surface-1); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); margin: 2px 0 6px; }
.legend .key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: middle; margin-right: 6px; }
.empty { color: var(--muted); font-size: 13px; padding: 18px 0; }

.strip { display: flex; gap: 2px; height: 26px; align-items: stretch; }
.strip .cell { flex: 1 1 0; border-radius: 3px; background: var(--grid); min-width: 2px; }
.strip .cell.good { background: var(--good); }
.strip .cell.warning { background: var(--warning); }
.strip .cell.critical { background: var(--critical); }
.strip .cell:hover { opacity: 0.75; }
.strip-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

table.data { border-collapse: collapse; font-size: 12px; margin-top: 6px; width: 100%; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 2px 8px; border-bottom: 1px solid var(--grid); }
table.data th:first-child, table.data td:first-child { text-align: left; }
.table-wrap { max-height: 240px; overflow: auto; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); min-width: 140px;
}
.tooltip .when { color: var(--muted); margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .row strong { font-variant-numeric: tabular-nums; }
.tooltip .row span { color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.tooltip .key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }

.playground form { display: grid; gap: 10px; margin-top: 10px; }
.playground .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.playground label { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.playground label.grow { flex: 1 1 220px; }
.playground label.check { display: flex; align-items: center; gap: 6px; }
select, input[type="password"], textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--page);
}
textarea { width: 100%; resize: vertical; }
.out { display: block; white-space: pre-wrap; min-height: 1.5em; padding: 10px; border-radius: 8px; background: var(--wash); }
.out:empty { display: none; }
.foot { text-align: center; font-size: 12px; margin-top: 24px; }

@media (forced-colors: active) {
  .strip .cell, .status .dot { forced-color-adjust: none; border: 1px solid CanvasText; }
}
