:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2330; --line: #2a3340; --text: #e6edf3; --muted: #8b98a8;
  --accent: #3b82f6; --ok: #2ea043; --warn: #d29922; --crit: #f85149; --unknown: #6e7681;
  --radius: 8px; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; }
nav.side .brand { font-weight: 700; font-size: 16px; padding: 4px 10px 18px; display: flex; gap: 8px; align-items: center; }
nav.side .brand i { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #3b82f633; }
nav.side a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
nav.side a:hover { background: var(--panel2); text-decoration: none; }
nav.side a.on { background: #1f6feb33; color: #fff; }
nav.side .foot { position: absolute; bottom: 14px; left: 10px; right: 10px; font-size: 12px; color: var(--muted); padding: 0 10px; }
main { padding: 22px 28px 60px; max-width: 1500px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card.click { cursor: pointer; }
.card.click:hover { border-color: #3d4a5c; }
.card .title { font-weight: 600; font-size: 15px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); box-shadow: 0 0 0 3px #f8514933; }
.pill { display: inline-flex; gap: 6px; align-items: center; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; }
.pill.ok { color: #7ee2a8; } .pill.warn { color: #f0c26a; } .pill.crit { color: #ff9b95; } .pill.unknown { color: var(--muted); }
.counts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.tree td:first-child { white-space: nowrap; }
.indent { display: inline-block; }

button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; font: inherit; cursor: pointer; }
button:hover { border-color: #46546a; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: #ff9b95; }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; width: 100%; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.form { max-width: 560px; }
.form .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.checks label { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; margin: 6px 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.badge { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; margin-left: 4px; }

.log { background: #0a0d12; border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 360px; overflow: auto; white-space: pre-wrap; }
.events .ev { display: grid; grid-template-columns: 14px 120px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.events .ev.supp { opacity: .55; }

.live { display: grid; gap: 4px; background: #000; padding: 4px; border-radius: var(--radius); }
.live.g1 { grid-template-columns: 1fr; } .live.g4 { grid-template-columns: repeat(2, 1fr); }
.live.g9 { grid-template-columns: repeat(3, 1fr); } .live.g16 { grid-template-columns: repeat(4, 1fr); }
.tile { position: relative; aspect-ratio: 16/9; background: #0b0b0b; overflow: hidden; cursor: pointer; }
.tile video-stream, .tile video { width: 100%; height: 100%; display: block; }
.tile video { object-fit: contain; }
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 12px; background: linear-gradient(transparent, #000c); pointer-events: none; }
.tile.empty { display: grid; place-items: center; color: var(--muted); cursor: default; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.chart { width: 100%; height: 90px; }
.chart path.l { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.chart path.a { fill: #3b82f622; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }

.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 340px; padding: 26px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--panel2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 6px; z-index: 9; max-width: 420px; }
.toast.err { border-color: var(--crit); }
.modal-bg { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 8; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; width: min(620px, 94vw); max-height: 90vh; overflow: auto; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } nav.side { position: static; height: auto; } nav.side .foot { position: static; } main { padding: 16px; } }
