:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel2: #1c2330;
  --border: #262d3a;
  --text: #dce3ec;
  --muted: #8b96a5;
  --accent: #4c8dff;
  --green: #3fb27f;
  --red: #e5534b;
  --yellow: #d4a72c;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
canvas { max-width: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  min-height: 100vh;
}
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 17px; margin: 4px 0 10px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: 11.5px; font-weight: 400; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-host { font-size: 11.5px; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 12px; font-size: 12.5px; white-space: nowrap;
}
.chip b { font-weight: 650; }
.chip.warn { border-color: var(--yellow); }
.chip.crit { border-color: var(--red); color: #ffb3ae; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.chart-wrap { min-width: 0; }
.row.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ranges { display: flex; gap: 4px; }
.ranges button {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 7px; padding: 3px 10px; cursor: pointer; font-size: 12.5px;
}
.ranges button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.cards { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 16px; min-width: 130px;
}
.stat .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 21px; font-weight: 650; margin-top: 2px; }
.stat .value.warn { color: var(--yellow); }
.stat .value.crit { color: var(--red); }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

table.sites { width: 100%; border-collapse: collapse; }
table.sites th {
  text-align: left; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .4px; padding: 4px 8px; border-bottom: 1px solid var(--border);
}
table.sites td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.sites tr:last-child td { border-bottom: none; }
table.sites tr.site-row { cursor: pointer; }
table.sites tr.site-row:hover { background: var(--panel2); }
table.sites td.num, table.sites th.num { text-align: right; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: baseline; }
.cpubar {
  position: relative; background: var(--panel2); height: 8px; border-radius: 4px;
  width: 110px; display: inline-block; vertical-align: middle; overflow: hidden; margin-left: 8px;
}
.cpubar > span { position: absolute; inset: 0 auto 0 0; border-radius: 4px; }
.site-name { font-weight: 600; }
.site-domain { color: var(--muted); font-size: 12px; }

ul.events { list-style: none; margin: 0; padding: 0; }
ul.events li { padding: 7px 4px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; }
ul.events li:last-child { border-bottom: none; }
ul.events .when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
ul.events .sev { font-size: 11px; border-radius: 5px; padding: 1px 7px; font-weight: 600; }
ul.events .sev.warning { background: rgba(212,167,44,.15); color: var(--yellow); }
ul.events .sev.critical { background: rgba(229,83,75,.15); color: #ff9a93; }
ul.events .empty { color: var(--muted); }

ul.kvlist { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
ul.kvlist li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 2px; border-bottom: 1px solid var(--border); font-size: 13px;
}
ul.kvlist li:last-child { border-bottom: none; }
ul.kvlist .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.kvlist .v { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
ul.kvlist .empty { color: var(--muted); }

.btn {
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; }

.login-overlay {
  position: fixed; inset: 0; background: rgba(8,10,14,.82);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(3px);
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 30px 34px; width: 320px; text-align: center;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { color: var(--muted); margin: 4px 0 18px; }
.login-card input {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none; margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button { width: 100%; padding: 9px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; }
.login-error { color: #ff9a93; font-size: 13px; margin-top: 10px; }
.hidden { display: none !important; }

footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 18px 0 26px; }
.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;line-height: 1.5;width: min-content;}.u-title {text-align: center;font-size: 18px;font-weight: bold;}.u-wrap {position: relative;user-select: none;}.u-over, .u-under {position: absolute;}.u-under {overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.u-axis {position: absolute;}.u-legend {font-size: 14px;margin: auto;text-align: center;}.u-inline {display: block;}.u-inline * {display: inline-block;}.u-inline tr {margin-right: 16px;}.u-legend th {font-weight: 600;}.u-legend th > * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;}
