:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #14181f; --muted: #5d6675; --line: #dfe3ea;
  --ok: #12804a; --ok-bg: #e3f4ea; --bad: #c2281d; --bad-bg: #fde8e6; --warn: #96600a; --warn-bg: #fdf1d8;
  --accent: #1554c4; --series: #2a78d6; --series-soft: #cde2fb; --grid: #e6e9ee;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --card: #181c22; --ink: #e8ebf0; --muted: #98a2b3; --line: #2a303a;
    --ok: #4cc38a; --ok-bg: #12301f; --bad: #ff7b6e; --bad-bg: #3a1614; --warn: #f0b955; --warn-bg: #33270d;
    --accent: #7aa7ff; --series: #3987e5; --series-soft: #17324f; --grid: #262c35; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 2; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
section { margin-bottom: 28px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; }
.right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.muted { color: var(--muted); }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.card.down { border-color: var(--bad); }
.card header, .card .head { all: unset; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.off { color: var(--muted); background: var(--line); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.meter { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.hot i { background: var(--bad); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.tile b { display: block; font-size: 22px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.small b { font-size: 13px; font-weight: 600; padding-top: 5px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; }
.row h2 { margin: 0; }
input[type=search], input[type=password] { font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; flex: 1 1 240px; max-width: 420px; }
.check { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }
.svc { display: inline-block; margin: 0 6px 2px 0; white-space: nowrap; }
.svc.dead { color: var(--bad); font-weight: 600; }
.cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
ul.list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 340px; overflow-y: auto; }
ul.list li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--line); }
ul.list li span:first-child { overflow-wrap: anywhere; }
button { font: inherit; cursor: pointer; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
.login { max-width: 320px; margin: 14vh auto; padding: 0 16px; }
.login form { display: grid; gap: 10px; }
.login input { max-width: none; flex: none; }
.login button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px; font-weight: 600; }
@media (prefers-color-scheme: dark) { .login button { color: #0f1216; } }
.err { color: var(--bad); margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.panel .head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.panel svg { display: block; width: 100%; height: auto; }
#map text, #chart text { fill: var(--muted); font-size: 12px; }
#map .name { fill: var(--ink); font-size: 14px; font-weight: 600; }
#map .link { fill: none; stroke: var(--series-soft); stroke-width: 6; stroke-linecap: round; }
#map .link.down { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 5 6; }
#map .dot { fill: var(--series); }
#map .box { fill: var(--card); stroke: var(--line); stroke-width: 1.5; }
#map .box.up { stroke: var(--ok); }
#map .box.down { stroke: var(--bad); stroke-width: 2.5; }
#map .state.up { fill: var(--ok); font-weight: 600; }
#map .state.down { fill: var(--bad); font-weight: 600; }
#chart .grid { stroke: var(--grid); stroke-width: 1; }
#chart .area { fill: var(--series); opacity: .16; }
#chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; }
#chart .cross { stroke: var(--muted); stroke-width: 1; }
#chart .mark { fill: var(--series); stroke: var(--card); stroke-width: 2; }
.chartwrap { position: relative; }
.tip { position: absolute; top: 4px; pointer-events: none; background: var(--ink); color: var(--bg); padding: 5px 9px;
  border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translateX(-50%); }
.toplist { display: grid; gap: 2px; }
.toprow { display: grid; grid-template-columns: minmax(120px, 230px) 1fr 110px 70px; gap: 12px; align-items: center; padding: 5px 0;
  border-bottom: 1px solid var(--line); }
.toprow:last-child { border-bottom: 0; }
.toprow .host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toprow .bar { height: 10px; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.toprow .n { text-align: right; font-variant-numeric: tabular-nums; }
.toprow svg { width: 110px; height: 24px; }
.spark { stroke: var(--series); fill: none; stroke-width: 1.5; }
.sparkrow { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.sparkrow svg { width: 90px; height: 22px; flex: none; }
@media (max-width: 640px) { .toprow { grid-template-columns: 1fr 70px; } .toprow .barcell, .toprow svg { display: none; } }

.panel.wide { grid-column: 1 / -1; }
.live { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
#map { max-height: 340px; }
#map .dot { filter: drop-shadow(0 0 4px var(--series)); }
.toprow { grid-template-columns: minmax(110px, 190px) 1fr 80px 44px; }
.toprow svg { width: 80px; }
.live { grid-template-columns: 3fr 2fr; }
@media (max-width: 860px) { .live { grid-template-columns: 1fr; } }
