:root {
  --bg: #0f1216; --panel: #171b21; --line: #262c35; --text: #e6e9ee; --muted: #8b94a3;
  --accent: #e0483e; --ok: #35b56a; --bad: #e0483e; --warn: #d8a23a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--accent); border: 0; color: #fff; padding: 7px 14px; border-radius: 6px; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.ghost, .seg-btn { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.small, .small { font-size: 12px; }
input, select { background: #0c0f13; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0; }
input:focus, select:focus { outline: 2px solid #3b6fd4; outline-offset: 0; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
h3 { margin: 0 0 12px; font-size: 15px; } h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

header { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--accent); }
.brand.big { font-size: 22px; text-align: center; margin-bottom: 8px; }
nav { display: flex; gap: 4px; }
nav button { background: transparent; color: var(--muted); }
nav button.active { background: #232933; color: var(--text); }
.who { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); }

main { padding: 14px 16px 40px; }
.bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.seg-btn.active { border-color: var(--accent); color: #fff; }
.grid { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.tile { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); }
.grid .tile { cursor: pointer; }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile .lbl { position: absolute; left: 8px; top: 6px; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.tile .st { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.tile.big { max-height: calc(100vh - 170px); width: 100%; }
.single .tile.big { aspect-ratio: auto; height: calc(100vh - 150px); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: flex-end; margin: 10px 0; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.seglist { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow: auto; padding: 6px 0; }
.seg { background: #232933; color: var(--text); padding: 4px 9px; font-size: 12px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl td button { padding: 3px 9px; font-size: 12px; margin-right: 4px; }
.scroll { max-height: 60vh; overflow: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; }
.pill.ok { background: rgba(53,181,106,.15); color: var(--ok); }
.pill.bad { background: rgba(224,72,62,.15); color: var(--bad); }
.pill.warn { background: rgba(216,162,58,.15); color: var(--warn); }
.cams { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.cams label { flex-direction: row; align-items: center; color: var(--text); font-size: 13px; }
.msg { color: var(--bad); min-height: 1em; margin: 8px 0 0; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog label { margin-bottom: 10px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px; width: min(340px, 92vw); display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr !important; }
  .who { margin-left: 0; }
  .single .tile.big { height: auto; aspect-ratio: 16 / 9; }
}
