:root {
  --bg: #0f1115; --panel: #171a21; --line: #262b36; --text: #e6e8ec; --muted: #8b93a3;
  --accent: #3d8bfd; --ok: #30a46c; --bad: #e5484d; --warn: #f5a524;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
header { display: flex; align-items: center; gap: 20px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 600; color: var(--bad); }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
nav a.active, nav a:hover { color: var(--text); background: var(--line); }
.me { color: var(--muted); }
main { padding: 16px; max-width: 1600px; margin: 0 auto; }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 16px 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile .n { font-size: 26px; font-weight: 600; }
.tile .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; min-width: 0; }
input[type=checkbox] { width: auto; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; }
button.ghost { background: var(--line); color: var(--text); }
button.danger { background: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
.err { color: var(--bad); min-height: 1em; margin: 0; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--line); color: var(--muted); }
.badge.online { background: color-mix(in srgb, var(--ok) 25%, transparent); color: #7ee2a8; }
.badge.offline { background: color-mix(in srgb, var(--bad) 25%, transparent); color: #ff9592; }
.badge.rec { background: color-mix(in srgb, var(--bad) 25%, transparent); color: #ff9592; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.grid { display: grid; gap: 8px; }
.grid.g1 { grid-template-columns: 1fr; }
.grid.g4 { grid-template-columns: repeat(2, 1fr); }
.grid.g9 { grid-template-columns: repeat(3, 1fr); }
.grid.g16 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .grid.g4, .grid.g9, .grid.g16 { grid-template-columns: 1fr; } }
.cell { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16/9; }
.cell video { width: 100%; height: 100%; object-fit: contain; display: block; }
.cell .cap { position: absolute; left: 0; right: 0; top: 0; padding: 6px 10px; display: flex; justify-content: space-between; gap: 8px; background: linear-gradient(#000a, #0000); font-size: 13px; }
.cell .msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 16px; pointer-events: none; }
.cell button.fs { position: absolute; right: 8px; bottom: 8px; padding: 4px 8px; background: #0008; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.seglist { max-height: 60vh; overflow: auto; }
.seglist button { display: block; width: 100%; text-align: left; margin-bottom: 4px; }
.split { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
pre { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 8px; border-radius: 6px; }
.toast { position: fixed; bottom: 16px; right: 16px; background: var(--panel); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; max-width: 420px; z-index: 10; }
