:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --good: #0ca30c;
  --good-ink: #006300;
  --warn: #fab219;
  --serious: #ec835a;
  --bad: #d03b3b;
  --none: #e1e0d9;
  --accent: #2a78d6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --good-ink: #0ca30c;
    --none: #2c2c2a;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --good-ink: #0ca30c;
  --none: #2c2c2a;
  --accent: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 0 16px; flex-wrap: wrap;
}
header.top h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
header.top h1 span { color: var(--muted); font-weight: 450; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 13px; color: var(--ink-2);
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted); }
.dot.up { background: var(--good); }
.dot.down { background: var(--bad); }
.dot.pending { background: var(--warn); }
.dot.paused { background: var(--axis); }
.dot.live { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.5); } 70% { box-shadow: 0 0 0 7px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }

section { margin-top: 20px; }
h2 { font-size: 15px; font-weight: 620; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .grid3, .grid2 { grid-template-columns: 1fr; } }

.tile .label { color: var(--ink-2); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.tile .label i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.tile .ip { color: var(--muted); font-variant-numeric: tabular-nums; }
.tile .vals { display: flex; gap: 20px; margin-top: 8px; }
.tile .v { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 450; margin-left: 2px; }
.tile .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }

.chart { position: relative; height: 240px; }
.chart.sm { height: 180px; }
.chart canvas { display: block; width: 100%; height: 100%; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.14); padding: 8px 10px; font-size: 12px; min-width: 140px;
  white-space: nowrap;
}
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip .r span:first-child { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

.tabs { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.tabs button {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 12.5px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }

.bars { display: flex; gap: 2px; height: 26px; align-items: stretch; }
.bars span { flex: 1; border-radius: 2px; background: var(--none); min-width: 2px; }
.bars span.g { background: var(--good); }
.bars span.w { background: var(--warn); }
.bars span.s { background: var(--serious); }
.bars span.b { background: var(--bad); }
.bars.sm { height: 16px; gap: 1px; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }

.svc { display: grid; grid-template-columns: minmax(140px, 1.2fr) 2.5fr auto; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.svc:first-child { border-top: 0; }
.svc .name { display: flex; align-items: center; gap: 8px; font-weight: 550; min-width: 0; }
.svc .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc .nums { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.svc .nums div { text-align: right; }
.svc .nums em { display: block; font-style: normal; color: var(--muted); font-size: 11px; }
@media (max-width: 760px) { .svc { grid-template-columns: 1fr; gap: 8px; } .svc .nums { justify-content: space-between; } }

.status-txt { font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
footer { margin-top: 32px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---- admin ---- */
nav.main { display: flex; gap: 4px; }
button, .btn {
  font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); border-radius: 7px; padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
button.icon { padding: 4px 8px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.tgt { color: var(--muted); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.tablewrap { overflow-x: auto; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.err { color: var(--bad); font-size: 12.5px; }
.good { color: var(--good-ink); }
.bad { color: var(--bad); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 450; }

.events { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.events li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--border); }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 130px; }

dialog {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink);
  padding: 0; width: min(520px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 20px; }
dialog h3 { margin: 0 0 14px; font-size: 16px; }
label.f { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-2); }
label.f input, label.f select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px;
}
label.f .hint { color: var(--muted); font-size: 11.5px; margin-top: 3px; display: block; }
label.c { display: inline-flex; align-items: center; gap: 7px; margin-right: 18px; font-size: 13px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.formfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.login { max-width: 360px; margin: 14vh auto 0; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login input { display: block; width: 100%; font: inherit; font-size: 15px; padding: 10px 12px; margin: 14px 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--page); color: var(--ink); }
.login button { width: 100%; padding: 10px; }
.hidden { display: none !important; }
.back { margin-bottom: 8px; }
