/* ЩО: стилі порталу й адмін-панелі. Принципи (docs/design-research.md): інтерфейс — рамка навколо відео;
   нейтральні сірі, один приглушений акцент, статусні кольори лише для станів; без градієнтів і кольорових тіней;
   світла і темна тема (системна за замовчуванням, перемикач у профілі). */
:root {
  color-scheme: light;
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef0f3; --surface-3: #e4e7ec;
  --border: #d8dce2; --border-strong: #848c9a;
  --text: #1a1d23; --text-muted: #5b6270;
  --accent: #2f5d93; --accent-hover: #264d7c; --accent-contrast: #ffffff; --accent-soft: #e6edf7;
  --ok: #1a7045; --ok-bg: #e8f4ec;
  --warn: #8a5a00; --warn-bg: #fbf1dc;
  --danger: #b42318; --danger-bg: #fdecea;
  --info: #0b6b8a; --info-bg: #e6f2f7;
  --focus-ring: #2f5d93;
  --video-bg: #0b0c0f; --overlay: rgba(15, 17, 21, .72); --overlay-text: #f4f5f7;
  --tl-rec: #b9cbe6; --tl-event: #2f5d93; --tl-gap: #eef0f3;
  --r-sm: 4px; --r: 6px; --r-lg: 8px;
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, .14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --side-w: 232px;
  --zone-mask: rgba(214, 48, 39, .5); --zone-motion: rgba(255, 196, 0, .55); --zone-grid: rgba(255, 255, 255, .22);
  /* ряди графіків (dataviz, перевірено валідатором: CVD ΔE ≥ 9 між сусідніми) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --surface-3: #282d37;
    --border: #2b303a; --border-strong: #6b7280;
    --text: #e6e8ec; --text-muted: #9aa1ae;
    --accent: #7aa2e0; --accent-hover: #8fb2e8; --accent-contrast: #0f1115; --accent-soft: #1c2940;
    --ok: #5fbf8f; --ok-bg: #14281f; --warn: #e0a63a; --warn-bg: #2b2210;
    --danger: #f0786d; --danger-bg: #321a18; --info: #5bb3d6; --info-bg: #12262e;
    --focus-ring: #8fb2e8; --video-bg: #000; --tl-rec: #2d3f5c; --tl-event: #7aa2e0; --tl-gap: #1f232b;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --surface-3: #282d37;
  --border: #2b303a; --border-strong: #6b7280;
  --text: #e6e8ec; --text-muted: #9aa1ae;
  --accent: #7aa2e0; --accent-hover: #8fb2e8; --accent-contrast: #0f1115; --accent-soft: #1c2940;
  --ok: #5fbf8f; --ok-bg: #14281f; --warn: #e0a63a; --warn-bg: #2b2210;
  --danger: #f0786d; --danger-bg: #321a18; --info: #5bb3d6; --info-bg: #12262e;
  --focus-ring: #8fb2e8; --video-bg: #000; --tl-rec: #2d3f5c; --tl-event: #7aa2e0; --tl-gap: #1f232b;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: 20px; } h2 { font-size: 15px; } h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.num, time, .stat-value, td.num { font-variant-numeric: tabular-nums; }
.text-danger { color: var(--danger); }
.pad { padding: 12px 0; }
.lead { margin-bottom: 16px; max-width: 70ch; }
.spacer { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; opacity: 0; pointer-events: none; }
/* «До вмісту»: перший Tab на сторінці — одразу до вмісту, повз меню */
.skip-link { position: fixed; left: 8px; top: -48px; z-index: 200; padding: 8px 14px; border-radius: var(--r); background: var(--accent);
  color: #fff; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }
.ic { flex: none; }

/* ---------- оболонка ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 12px;
  background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; padding: 8px; color: var(--text); font-weight: 600; font-size: 15px; }
.brand:hover { text-decoration: none; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r);
  color: var(--text-muted); font-weight: 500; background: none; border: 0; font: inherit; cursor: pointer; width: 100%; text-align: left; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.side-foot { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 12px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 24px;
  background: var(--bg); border-bottom: 1px solid var(--border); }
.title-wrap { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.page-title { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.page-tip { display: contents; }
.page-actions { display: flex; gap: 8px; }
.content { padding: 20px 24px 40px; max-width: 1600px; width: 100%; }
.content:focus { outline: none; }
.bottom-nav { display: none; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 8px 12px; min-height: 52px; }
  .page-title { font-size: 16px; }
  .content { padding: 12px 12px 88px; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--text-muted);
    font: 500 11px/1.2 var(--font); background: none; border: 0; border-radius: var(--r); cursor: pointer; }
  .tab:hover { text-decoration: none; }
  .tab[aria-current="page"] { color: var(--accent); }
  .more-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column; }
  /* текст ховаємо з екрана, але не з дерева доступності: інакше кнопка лишилась би без назви для екранного читача */
  .page-actions .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .page-actions .btn { padding: 0 10px; }
}

/* ---------- кнопки й поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r);
  font: 500 14px/1 var(--font); cursor: pointer; border: 1px solid transparent; background: none; color: var(--text); white-space: nowrap;
  transition: background-color .12s ease-out, border-color .12s ease-out, color .12s ease-out; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn.ghost { color: var(--text-muted); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover:not(:disabled), .btn.danger-ghost.armed { background: var(--danger-bg); }
.btn.icon { width: 36px; padding: 0; }
.input { height: 36px; width: 100%; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
  color: var(--text); font: 14px var(--font); }
.input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 0; border-color: var(--focus-ring); }
.input[aria-invalid] { border-color: var(--danger); }
.input:disabled { background: var(--surface-2); color: var(--text-muted); }
.input.short { max-width: 120px; } .input.compact { width: auto; height: 32px; }
select.input { padding-right: 28px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 500; }
/* підказка «i» (ui.js infoTip): кнопка біля мітки/заголовка, вікно position: fixed */
.field-head { font-size: 13px; font-weight: 500; line-height: 22px; }
.field-head > label, .field-head > .field-label { display: inline; }
.field-head > .tip { margin-left: 2px; vertical-align: top; }
.tip { display: inline-flex; vertical-align: middle; }
.check-tip { display: flex; align-items: center; gap: 2px; }
.has-tip { display: flex; align-items: center; gap: 4px; }
.info-btn { position: relative; display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--text-muted); cursor: help; }
/* телефон: область натискання більша за значок (WCAG 2.5.8) */
@media (pointer: coarse) { .info-btn::after { content: ""; position: absolute; inset: -8px; } }
.info-btn:hover, .info-btn[aria-expanded=true] { background: var(--surface-2); color: var(--accent); }
.info-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.tip-pop { position: fixed; z-index: 90; width: max-content; max-width: min(340px, calc(100vw - 16px)); padding: 8px 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop);
  font: 400 13px/1.5 var(--font); text-align: left; white-space: normal; overflow-wrap: break-word; text-transform: none; letter-spacing: normal; }
.tip-pop[hidden] { display: none; }
.hint { font-size: 12px; color: var(--text-muted); }
.field-error:empty, .form-error:empty { display: none; }
.field-error, .form-error { color: var(--danger); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 28px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: 8px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.fieldset legend { font-size: 13px; font-weight: 500; padding: 0 4px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form.wide { max-width: 760px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.limits-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: end; }
@media (max-width: 560px) { .limits-grid { grid-template-columns: minmax(0, 1fr); } }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.row2 > .field:only-child { grid-column: 1 / -1; }
.card .row2, .form .row2 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 720px) { .input { font-size: 16px; height: 40px; } .btn { height: 40px; } }

/* ---------- блоки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack.narrow { max-width: 760px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2.wide-left { grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); }
@media (max-width: 1100px) { .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; } .grid-2.wide-left > :last-child { order: -1; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; } }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { position: relative; display: flex; align-items: center; min-width: 220px; flex: 0 1 320px; }
/* фільтри панелі — в один рядок поруч із пошуком (на вузькому екрані переносяться) */
.toolbar > select.input { width: auto; flex: 0 1 220px; min-width: 150px; max-width: 260px; }
@media (max-width: 720px) { .toolbar > .search { flex: 1 1 100%; } .toolbar > select.input { flex: 1 1 140px; max-width: none; } }
.search .ic { position: absolute; left: 10px; color: var(--text-muted); }
.search .input { padding-left: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted); background: var(--surface); font: 500 13px var(--font); cursor: pointer; }
.chip:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); white-space: nowrap; }
.badge.tiny { font-size: 11px; padding: 0 6px; border-radius: var(--r-sm); background: var(--surface-2); margin-left: 6px; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.badge.ok .dot { background: var(--ok); } .badge.warn .dot { background: var(--warn); } .badge.danger .dot { background: var(--danger); }
.badge.info .dot { background: var(--info); } .badge.info.tiny { background: var(--info-bg); color: var(--info); }
.badge.warn.tiny { background: var(--warn-bg); color: var(--warn); }
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); font-size: 13px; }
.notice .ic { margin-top: 2px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); } .notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.danger { background: var(--danger-bg); color: var(--danger); } .notice.info { background: var(--info-bg); color: var(--info); }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.content > .notice { margin-bottom: 12px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 48px 16px; color: var(--text-muted); }
.empty h3 { font-size: 16px; font-weight: 500; color: var(--text); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } * { transition: none !important; } }

/* ---------- таблиці (на телефоні — картки) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td time { white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table .num { text-align: right; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
/* сталі колонки (w у table()): кілька таблиць одна під одною вирівняні між собою */
.table.fixed { table-layout: fixed; }
.table.fixed td, .table.fixed th { overflow-wrap: anywhere; }
.table.fixed th { white-space: normal; }
@media (max-width: 720px) {
  .table colgroup { display: none; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 8px 12px; margin-bottom: 8px; background: var(--surface); }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--text-muted); text-align: left; flex: none; }
  .table td:empty, .table td[data-label=""]::before { display: none; }
}

/* ---------- статистика ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; color: var(--text); }
a.stat:hover { text-decoration: none; background: var(--surface-2); }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.stat-sub { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.stat.warn .stat-value { color: var(--warn); } .stat.ok .stat-value { color: var(--ok); }
.svc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.svc-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.svc-list li:last-child { border-bottom: 0; }

/* ---------- сітка камер ---------- */
.cam-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cam-grid[data-cols="1"] { grid-template-columns: 1fr; } .cam-grid[data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
.cam-grid[data-cols="3"] { grid-template-columns: repeat(3, 1fr); } .cam-grid[data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
/* «авто»: одна камера — на всю ширину, але так, щоб влазила у вікно; 2–4 — по дві в ряд; більше — скільки влізе */
.cam-grid[data-cols="auto"][data-n="1"] { grid-template-columns: minmax(0, min(100%, max(360px, calc((100vh - 340px) * 16 / 9)))); justify-content: center; }
.cam-grid[data-cols="auto"]:is([data-n="2"], [data-n="3"], [data-n="4"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .cam-grid, .cam-grid[data-cols], .cam-grid[data-cols][data-n] { grid-template-columns: 1fr; } .toolbar select.compact { display: none; } }
.tile { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--video-bg); border-radius: var(--r-lg); overflow: hidden; color: var(--overlay-text); }
.tile:hover { text-decoration: none; }
.tile:focus-visible { outline-offset: 2px; }
.tile-video, .tile-video video { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile video { object-fit: cover; }
.tile-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px;
  text-align: center; font-size: 13px; color: #a3a9b4; }
.tile-msg:empty { display: none; }
.tile.offline, .tile.disabled, .tile.over_limit, .tile.no_tariff, .tile.user_inactive { background: #1b1e24; }
.tile-top, .tile-bottom { position: absolute; left: 8px; right: 8px; display: flex; gap: 6px; justify-content: space-between; align-items: center; pointer-events: none; }
.tile-top { top: 8px; } .tile-bottom { bottom: 8px; justify-content: flex-start; }
.chip-over { display: inline-flex; align-items: center; gap: 5px; max-width: 70%; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  background: var(--overlay); color: var(--overlay-text); font: 500 12px/1 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-over.name { font-size: 13px; }
.chip-over .dot { width: 7px; height: 7px; border-radius: 50%; background: #a3a9b4; }
.chip-over.live .dot { background: #e5484d; }
.chip-over.ok .dot { background: #5fbf8f; } .chip-over.warn .dot { background: #e0a63a; }

/* ---------- сторінка камери ---------- */
.cam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .cam-layout { grid-template-columns: 1fr; } }
.player-col, .side-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* бічна панель — не вища за програвач: усе на одному екрані; події займають решту місця й прокручуються,
   збої зв'язку — компактний список з прокруткою */
.side-col .card h2 .count { font-weight: 400; font-size: 13px; }
.side-col .side-status .kv { gap: 3px 14px; font-size: 13px; }
.side-col .event-table .ev-row { padding: 5px 8px; }
.side-col .incident-list { max-height: 240px; }
.side-col .incident-list li { padding: 4px 0; }
@media (min-width: 1101px) {
  .cam-layout { align-items: stretch; }
  .cam-layout > .side-col { height: 0; min-height: 100%; }
  .side-col > .card { flex: none; }
  .side-col > .side-events { flex: 1 1 0; min-height: 200px; display: flex; flex-direction: column; overflow: hidden; }
  .side-events > #events { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .side-events .event-table { max-height: none; flex: 1; min-height: 0; }
  .side-col > .side-incidents { flex: 0 1 auto; min-height: 110px; max-height: 32%; display: flex; flex-direction: column; overflow: hidden; }
  .side-incidents .incident-list { max-height: none; flex: 1; min-height: 0; }
}
@media (max-width: 1100px) { .side-col .event-table { max-height: 320px; } }
.player-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.player-time { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 13px; }
.player { position: relative; aspect-ratio: 16 / 9; background: var(--video-bg); border-radius: var(--r-lg); overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; background: var(--video-bg); }
.player-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: #c4c9d2; font-size: 14px; text-align: center; padding: 24px; pointer-events: none; }
.player-msg:empty { display: none; }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.seg { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: none;
  color: var(--text-muted); font: 500 13px var(--font); cursor: pointer; }
.seg[aria-selected="true"], .seg[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.segmented.small .seg { height: 26px; padding: 0 10px; font-size: 12px; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.archive-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.day-nav { display: flex; align-items: center; gap: 2px; }
.day-label { min-width: 150px; font-variant-numeric: tabular-nums; }
.timeline { position: relative; height: 56px; cursor: pointer; user-select: none; }
.tl-track { position: absolute; left: 0; right: 0; top: 0; height: 32px; background: var(--tl-gap); border-radius: var(--r-sm); overflow: hidden; }
.tl-track .span { position: absolute; top: 0; bottom: 0; background: var(--tl-rec); }
.tl-track .ev { position: absolute; top: 0; bottom: 0; min-width: 2px; background: var(--tl-event); }
.tl-track .cursor { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--text); }
.tl-ticks { position: absolute; left: 0; right: 0; top: 36px; height: 18px; font-size: 11px; color: var(--text-muted); }
.tl-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }
.lg.rec { background: var(--tl-rec); } .lg.ev { background: var(--tl-event); }
.event-list, .incident-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.event-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: var(--r); background: none;
  color: var(--text); font: 14px var(--font); cursor: pointer; text-align: left; }
.event-list button:hover { background: var(--surface-2); }
.event-list button[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.ev-time { font-weight: 500; font-variant-numeric: tabular-nums; flex: 1; }
.incident-list li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.incident-list li:last-child { border-bottom: 0; }

/* ---------- форма камери ---------- */
.probe { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.probe-out { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 220px; }
.probe-out:empty { display: none; }
.probe-out > .spinner + span { margin-left: 6px; }

/* ---------- групи, користувачі ---------- */
.group-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.group-head { display: flex; align-items: center; gap: 8px; }
.grant-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: var(--r); background: none; color: var(--text);
  font: 13px var(--font); cursor: pointer; text-align: left; }
.pick:hover { background: var(--surface-2); }
.chosen { display: flex; flex-direction: column; gap: 4px; }
.chosen:empty { display: none; }
.map-rows { display: flex; flex-direction: column; gap: 6px; }
.map-row { display: grid; grid-template-columns: minmax(140px, 1fr) auto minmax(180px, 1.4fr) minmax(120px, 1fr) auto; gap: 8px; align-items: center; }
.map-head { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.map-head[hidden] { display: none; }
@media (max-width: 720px) { .map-row { grid-template-columns: 1fr auto; } .map-row > .ic { display: none; } .map-head { display: none; } }
.um-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; }
.um-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.um-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; flex: 1; min-width: 0; }
.um-actions { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- діалоги, сповіщення ---------- */
.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
.dialog::backdrop { background: rgba(10, 12, 16, .45); }
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { flex: 1; font-size: 16px; }
.dialog-body { padding: 16px; overflow: auto; max-height: calc(100vh - 180px); }
.dialog-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
@media (max-width: 720px) {
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 12px 12px 0 0; max-height: 92vh; }
}
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-pop); font-size: 13px; }
.toast .toast-x { margin: -4px -8px -4px auto; }
.toast.error { border-color: var(--danger); } .toast.error .ic { color: var(--danger); } .toast.ok .ic { color: var(--ok); }
@media (max-width: 720px) { .toasts { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; } }

/* ---------- вхід ---------- */
.standalone { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px;
  display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand { padding: 0; }
.auth-card h1 { font-size: 20px; }
.auth-card .btn.primary { width: 100%; }
.auth-foot { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
.auth-foot .input { width: auto; height: 32px; border-color: var(--border); }

/* ---------- графіки навантаження ---------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; transition: opacity .15s; }
.chart-grid.loading { opacity: .6; }
.chart { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart-head { display: flex; align-items: center; gap: 8px; }
.btn.small { height: 28px; padding: 0 8px; font-size: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-legend .band-key { width: 14px; height: 10px; border-radius: 2px; background: var(--text-muted); opacity: .3; }
.chart-box { position: relative; }
.chart-plot { position: relative; width: 100%; min-height: 168px; }
.chart-svg { display: block; overflow: visible; touch-action: pan-y; }
.chart-svg:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--r-sm); }
.chart-svg .grid { stroke: var(--surface-3); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border); stroke-width: 1; }
.chart-svg .ax { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .band { opacity: .14; stroke: none; }
.chart-svg .cross { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.line.s1 { stroke: var(--series-1); } .line.s2 { stroke: var(--series-2); } .line.s3 { stroke: var(--series-3); }
.band.s1, .dot.s1 { fill: var(--series-1); } .band.s2, .dot.s2 { fill: var(--series-2); } .band.s3, .dot.s3 { fill: var(--series-3); }
.key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; flex: none; }
.key.s1 { background: var(--series-1); } .key.s2 { background: var(--series-2); } .key.s3 { background: var(--series-3); }
.chart-tip { position: absolute; top: 4px; z-index: 2; min-width: 150px; padding: 8px 10px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop); font-size: 12px; }
.tip-time { margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-row b { font-variant-numeric: tabular-nums; }
.chart-empty { position: absolute; inset: 0 0 24px 52px; display: grid; place-items: center; font-size: 13px; }
.chart-table { max-height: 280px; overflow: auto; border-top: 1px solid var(--border); }
.chart-table .table { font-size: 12px; }
@media (max-width: 960px) { .chart-grid { grid-template-columns: minmax(0, 1fr); } }
#metrics-range { max-width: 100%; flex-wrap: wrap; }
#metrics-range .seg { flex: none; }

/* ---------- розкладка плиток (перетягування, розмір) ---------- */
.toolbar-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cam-grid { grid-auto-flow: row dense; }
.cam-grid[data-cols="2"] .tile.big, .cam-grid[data-cols="3"] .tile.big, .cam-grid[data-cols="4"] .tile.big { grid-column: span 2; grid-row: span 2; }
@media (min-width: 1180px) { .cam-grid[data-cols="auto"] .tile.big { grid-column: span 2; grid-row: span 2; } }
@media (max-width: 720px) { .cam-grid .tile.big { grid-column: auto !important; grid-row: auto !important; } }
.cam-grid.editing .tile { cursor: grab; -webkit-user-drag: none; user-select: none;
  outline: 1px dashed var(--border-strong); outline-offset: 2px; }
.cam-grid.editing .tile.dragging { cursor: grabbing; opacity: .75; outline: 2px solid var(--accent); z-index: 3; }
.arrange-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; display: flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: var(--r); background: var(--overlay); color: var(--overlay-text); }
.arrange-bar .grip { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; opacity: .85;
  touch-action: none; cursor: grab; }
.btn.icon.over { color: var(--overlay-text); background: transparent; border-color: transparent; }
.btn.icon.over:hover { background: rgba(255, 255, 255, .14); }
.btn.icon.over[aria-pressed="true"] { background: rgba(255, 255, 255, .2); }
#arrange[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---------- архів кількох камер ---------- */
.pb-tile { cursor: default; }
.pb-controls { display: flex; flex-direction: column; gap: 10px; --pb-label: 120px; }
.pb-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pb-clock { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 200px; }
.pb-timeline { position: relative; cursor: pointer; user-select: none; display: flex; flex-direction: column; gap: 4px; }
.pb-rows { display: flex; flex-direction: column; gap: 4px; }
.pb-row { display: grid; grid-template-columns: var(--pb-label) minmax(0, 1fr); align-items: center; gap: 8px; }
.pb-label { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-track.tl-track { position: relative; height: 16px; }
.pb-lane { position: absolute; top: -3px; bottom: -3px; left: calc(var(--pb-label) + 8px); right: 0; pointer-events: none; }
.pb-cursor { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); }
.pb-ticks.tl-ticks { position: relative; top: 0; margin-left: calc(var(--pb-label) + 8px); }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; margin-top: 8px; }
@media (max-width: 720px) { .pb-controls { --pb-label: 72px; } .pb-clock { min-width: 0; flex-basis: 100%; order: -1; } }
/* архів кількох камер: таблиця подій усіх камер */
.pb-events .ev-cam { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.pb-track .ev { opacity: .9; }
.pb-events button > .muted { white-space: nowrap; }
.pb-events .spacer { flex: 1; }

/* ---------- програвач архіву (views/archive.js): спільний для «Архіву» і сторінки камери ---------- */
.archive { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pb-toolbar { flex-wrap: wrap; }
.pb-stage { position: relative; min-width: 0; }
.pb-stage > .player { width: 100%; }
.pb-zoom { display: inline-flex; align-items: center; gap: 2px; }
.pb-zoom .btn.icon { width: 30px; height: 30px; }
.pb-timeline.pannable { cursor: grab; touch-action: pan-y; }
.pb-timeline.panning { cursor: grabbing; }
.pb-track .ev.current { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pb-help-btn { color: var(--text-muted); }
.help-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
@media (max-width: 720px) { .pb-fs-btn span, .pb-help-btn span { display: none; } }
/* таблиця подій: заголовок закріплений, колонки вирівняні */
.event-table { --ev-cols: 128px 72px minmax(0, 1fr) 92px; max-height: 420px; overflow: auto; position: relative; }
.event-table.single { --ev-cols: minmax(0, 1fr) 64px 84px; }
.event-table .ev-head, .event-table .ev-row { display: grid; grid-template-columns: var(--ev-cols); gap: 10px; align-items: center; }
.event-table .ev-head { position: sticky; top: 0; z-index: 1; padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted); }
.event-table .num, .event-table .ev-dur { text-align: right; }
.ev-rows { list-style: none; margin: 0; padding: 0; }
.event-table .ev-row { width: 100%; padding: 7px 8px; border: 0; border-radius: var(--r); background: none; color: var(--text);
  font: 14px var(--font); cursor: pointer; text-align: left; }
.event-table .ev-row:hover { background: var(--surface-2); }
.event-table .ev-row[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.event-table .ev-when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-table .ev-date { color: var(--text-muted); }
.event-table .ev-row[aria-current="true"] .ev-date { color: inherit; }
.event-table .ev-time { font-weight: 600; }
.event-table .ev-kind { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); font-size: 13px; }
.event-table .ev-cam, .event-table .ev-dur { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-table .ev-dur { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.event-table.single .ev-date { display: none; }
/* значок наближення відео */
.zoom-badge { position: absolute; right: 8px; bottom: 8px; z-index: 2; height: 24px; padding: 0 8px; border: 0; border-radius: var(--r-sm);
  background: var(--overlay); color: var(--overlay-text); font: 12px var(--font); cursor: pointer; }
.zoom-badge[hidden] { display: none; }
/* одна камера: доріжка без підпису, вища */
.archive.single .pb-controls { --pb-label: 0px; }
.archive.single .pb-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
.archive.single .pb-label { display: none; }
.archive.single .pb-lane { left: 0; }
.archive.single .pb-ticks.tl-ticks { margin-left: 0; }
.archive.single .pb-track.tl-track { height: 28px; }
.archive.single .pb-grid .tile, .live-box { border-radius: var(--r-lg); }
.archive.single .pb-grid .tile video { object-fit: contain; }
/* сторінка камери: архів того ж розміру, що й «Наживо»; на сторінці «Архів» одна камера — щоб шкала лишалась у вікні */
.archive.with-live .pb-grid[data-n="1"] { grid-template-columns: minmax(0, 1fr); }
/* цифрове наближення відео */
.tile-video, .player { overflow: hidden; }
.tile video, .player video { transform-origin: 50% 50%; }
.zoomed { cursor: grab; touch-action: none; }
.zoomed:active { cursor: grabbing; }
/* повний екран: відео, керування й події разом (Fullscreen API або на все вікно, де його немає) */
.archive.fs { position: fixed; inset: 0; z-index: 60; background: var(--bg); padding: 10px; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px; }
.archive.fs > .pb-toolbar { grid-column: 1 / -1; }
.archive.fs > .pb-stage { grid-column: 1; grid-row: 2; min-height: 0; overflow: auto; }
.archive.fs > .pb-controls { grid-column: 1; grid-row: 3; padding: 10px 12px; }
.archive.fs > .pb-events-card { display: none; }
.archive.fs > .pb-fs-side { grid-column: 2; grid-row: 2 / 4; min-height: 0; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; }
.archive.fs > .pb-fs-side[hidden] { display: none; }
.archive.fs > .pb-fs-side h2 { font-size: 14px; margin: 0; }
.archive.fs .pb-fs-side .event-table { max-height: none; flex: 1; min-height: 0; }
.archive.fs .pb-grid { height: 100%; grid-auto-rows: minmax(0, 1fr); }
.archive.fs .pb-grid[data-n="1"] { grid-template-columns: minmax(0, 1fr); }
.archive.fs .pb-grid .tile { aspect-ratio: auto; min-height: 120px; }
.archive.fs .pb-grid .tile video { object-fit: contain; }
.archive.fs .pb-stage > .player { aspect-ratio: auto; height: 100%; }
.archive.fs .pb-stage > .player video { object-fit: contain; }
@media (max-width: 900px) { .archive.fs { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .archive.fs > .pb-fs-side { grid-column: 1; grid-row: 4; max-height: 22vh; } }

/* детектор руху: чутливість і зони (views/zones.js) */
.range-row { display: flex; align-items: center; gap: 10px; }
.range { flex: 1; min-width: 0; accent-color: var(--accent); }
.range-out { font-size: 13px; }
.field-label { font-size: 13px; font-weight: 500; }
.zone-editor { margin-top: 6px; }
.zone-editor video { pointer-events: none; }
.zone-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.zone-meter { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 24px; font-size: 13px; margin-top: 6px; }
.zone-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }

/* ---------- групові дії над камерами ---------- */
.bulk-bar { position: sticky; bottom: 12px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
.bulk-bar[hidden] { display: none; }
.bulk-count { font-weight: 600; }
#select-mode[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tile-check { display: none; position: absolute; left: 8px; bottom: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%;
  align-items: center; justify-content: center; background: var(--overlay); color: transparent; border: 2px solid var(--overlay-text); }
.cam-grid.selecting .tile-check { display: inline-flex; }
.cam-grid.selecting .tile { cursor: pointer; }
.cam-grid.selecting .tile.selected { outline: 3px solid var(--accent); outline-offset: 2px; }
.cam-grid.selecting .tile.selected .tile-check { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.cam-grid.selecting .tile-bottom { left: 42px; }
.bulk-cb { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- відеореєстратори ---------- */
.cam-area { display: flex; flex-direction: column; gap: 10px; }
.cam-section-head { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cam-section-head h2 { font-size: 16px; margin: 0; }
.cam-section-head:first-child { margin-top: 0; }
.chip svg { margin-right: 4px; vertical-align: -2px; }
.nvr-channels { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.nvr-channels .check span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.nvr-no { font-variant-numeric: tabular-nums; min-width: 52px; }
.nvr-cam { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.nvr-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .nvr-layout { grid-template-columns: minmax(0, 1fr); } }
.small-head { font-size: 13px; margin: 14px 0 6px; color: var(--text-muted); }
.danger-text { color: var(--danger, #c0392b); }

/* ---------- налаштування сервера (адмін) ---------- */
.settings-page { max-width: 1100px; }
.settings-page .toolbar input[type=search] { max-width: 360px; }
.settings-group { padding: 0; }
.settings-summary { display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; list-style: none; border-radius: var(--r-lg); }
.settings-summary::-webkit-details-marker { display: none; }
.settings-summary:hover { background: var(--surface-2); }
.settings-summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.settings-summary h2 { margin: 0; font-size: 15px; }
.settings-summary > svg { flex: none; color: var(--text-muted); transition: transform .15s; }
.settings-group[open] > .settings-summary > svg { transform: rotate(90deg); }
.settings-group[open] > .settings-summary { border-bottom: 1px solid var(--border); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.settings-body { padding: 4px 16px 16px; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: 6px 32px; align-items: start;
  padding: 14px 0; border-top: 1px solid var(--border); }
.settings-body > .setting:first-child, .settings-file > summary + .setting { border-top: 0; }
.setting[hidden] { display: none; }
.setting-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.setting-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setting-head label, .setting-label { font-size: 14px; font-weight: 600; }
.setting .hint { max-width: 68ch; line-height: 1.5; }
.setting-control { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.setting-control > .input:not(.short), .setting-control > select.input { width: 100%; }
.setting-value { font-size: 13px; padding: 6px 0; overflow-wrap: anywhere; }
.with-unit { display: flex; align-items: center; gap: 8px; }
.settings-file { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.settings-file summary { cursor: pointer; font-weight: 500; padding: 6px 0; color: var(--text-muted); }
@media (max-width: 820px) { .setting { grid-template-columns: minmax(0, 1fr); gap: 8px; } }
/* підзаголовок усередині картки */
.sub-head { font-size: 13px; font-weight: 600; margin: 14px 0 2px; display: flex; align-items: center; gap: 6px; }
/* сесії: пристрій, IP, коли */
.session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.session-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.session-item:first-child { border-top: 0; }
.session-ic { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text-muted); }
.session-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.badge.tiny.ok { background: var(--ok-bg, var(--surface-2)); color: var(--ok, inherit); }
/* реєстратор: канали «у хмару» */
.nvr-cloud-list { display: flex; flex-direction: column; gap: 6px; }
.badge.tiny.src-web { background: var(--accent); color: var(--accent-contrast); }

/* ---------- відеостіна: вибір камер ---------- */
.wall-picker .pick-bar { display: flex; align-items: center; gap: 12px; }
.wall-picker .pick-bar .search { flex: 1; }
.wall-picker .pick-list { max-height: min(52vh, 520px); overflow: auto; border: 1px solid var(--border); border-radius: var(--r); padding: 6px 10px; }
.wall-picker .pick-owner { padding: 6px 0; border-bottom: 1px solid var(--border); }
.wall-picker .pick-owner:last-child { border-bottom: 0; }
.wall-picker .pick-cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; padding: 4px 0 0 26px; }

/* ---------- огляд адміністратора ---------- */
.dash { display: flex; flex-direction: column; gap: 14px; }
.dash-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-radius: var(--r-lg); border: 1px solid; font-size: 14px; }
.dash-strip.ok { background: var(--ok-bg); border-color: var(--ok-bg); }
.dash-strip.ok .ic { color: var(--ok); }
.dash-strip.warn { background: var(--warn-bg); border-color: var(--warn-bg); }
.dash-strip.warn .ic { color: var(--warn); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.card.kpi { display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none; padding: 14px 16px; }
a.card.kpi:hover { border-color: var(--border-strong); }
.kpi-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.kpi-main { font-size: 28px; font-weight: 650; line-height: 1.1; display: flex; align-items: baseline; gap: 6px; }
.kpi-of { font-size: 14px; font-weight: 400; }
.kpi-note { font-size: 12px; }
.kpi-rows { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 4px 0 0; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; }
.kpi-rows dt { color: var(--text-muted); } .kpi-rows dd { margin: 0; text-align: right; font-weight: 500; }
.kpi-rows dd.ok { color: var(--ok); } .kpi-rows dd.warn { color: var(--warn); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.warn > i { background: var(--warn); }
.dash-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1000px) { .dash-cols { grid-template-columns: 1fr; } }
.dash-empty { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-muted); }
.dash-empty .ic { color: var(--ok); }
.svc-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; }
.svc-name { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.svc-tip { display: flex; flex-direction: column; gap: 6px; }
.svc-grid li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
