:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f252d;
  --surface-3: #262d37;
  --border: #2b323c;
  --text: #e8ecf1;
  --muted: #9aa5b1;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --accent-soft: rgba(59, 130, 246, .15);
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --info: #38bdf8;
  --radius: 10px;
  --side-w: 248px;
  --bar-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
p { margin: 0 0 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card, .card + .row, .card + .grid2, .grid2 + .card, .grid2 + .grid2, .kpis + .card, .note-banner + .card, .tabs + .card { margin-top: 16px; }
.card.narrow { max-width: 860px; }
.card.dim { opacity: .7; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3, .card-head h2 { margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 13px; }
.mono { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; justify-content: center; }
.pad { padding: 12px 14px; }
.pad-y { padding: 8px 0; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.row.wrap { flex-wrap: wrap; margin-top: 8px; }
.row:first-child { margin-top: 0; }
.stack { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > .card + .card { margin-top: 0; }
.danger-text { color: #fca5a5 !important; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 14px;
  cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: #3d4652; background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: #7f1d1d; border-color: #991b1b; color: #fee2e2; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.active { border-color: var(--accent); background: var(--accent-soft); }
.btn.big { font-size: 18px; padding: 14px 32px; }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn.loading { cursor: progress; }
.btn.icon { width: 40px; height: 40px; padding: 0; }
.btn.icon.sm { width: 30px; height: 30px; }
.btn.icon svg { width: 20px; height: 20px; fill: currentColor; }
.btn.icon .i-play { display: none; }
.btn.icon.paused .i-play { display: block; }
.btn.icon.paused .i-pause { display: none; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn.icon .ico { width: 20px; height: 20px; fill: none; }
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* каркас */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: var(--bar-h) 1fr; min-height: 100vh; }
.menu-collapsed .app { --side-w: 64px; }
.appbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(15, 18, 22, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
#btn-menu { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); letter-spacing: .02em; text-decoration: none !important; white-space: nowrap; }
.brand-sub { color: var(--muted); font-weight: 500; }
.brand-mark { width: 30px; height: 30px; flex: none; display: inline-grid; place-items: center; color: var(--accent); }
.brand-mark svg { width: 100%; height: 100%; }
.brand-mark.big { width: 48px; height: 48px; }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bell-wrap, .user-wrap { position: relative; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--err);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; pointer-events: none; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent; color: var(--text); font: inherit;
  padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.user-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.popover { position: absolute; right: 0; top: calc(100% + 6px); width: 340px; max-height: 70vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 16px 40px rgba(0,0,0,.45); z-index: 30; }
.popover-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.popover-head.col { flex-direction: column; align-items: flex-start; gap: 2px; }
.popover-foot { display: block; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 14px; }
.alert-item { display: flex; gap: 10px; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none !important; }
.alert-item:hover { background: var(--surface-2); }
.alert-item.unread { background: rgba(239, 68, 68, .06); }
.alert-item .plate-text { font-size: 12px; padding: 0 5px; }
.alert-item .alert-fields { margin-top: 2px; }
.sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--muted); }
.sev.alarm { background: var(--err); } .sev.warn { background: var(--warn); } .sev.info { background: var(--info); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: none; border: 0; color: var(--text); font: inherit;
  text-align: left; cursor: pointer; text-decoration: none !important; }
.menu-item:hover { background: var(--surface-2); }

.sidebar { position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h)); overflow-y: auto; display: flex; flex-direction: column;
  justify-content: space-between; padding: 12px 10px; border-right: 1px solid var(--border); background: var(--surface); }
.nav-list { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--muted); background: none;
  border: 0; font: inherit; font-size: 14px; text-align: left; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: #fff; background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-group .ico:last-child { margin-left: auto; width: 14px; transition: transform .15s; }
.nav-group.open .ico:last-child { transform: rotate(90deg); }
.nav-sub { display: grid; gap: 2px; padding-left: 12px; }
.nav-collapse .ico { transform: rotate(180deg); }
.menu-collapsed .nav-label, .menu-collapsed .nav-group .ico:last-child { display: none; }
.menu-collapsed .nav-sub { padding-left: 0; }
.menu-collapsed .nav-collapse .ico { transform: none; }
.menu-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.view { padding: 22px 24px 48px; min-width: 0; outline: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title p { margin: 4px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.page-title h1 .chip { vertical-align: middle; font-size: 12px; }
.empty-state { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty-state h2 { color: var(--text); }
.note-banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 14px; border-radius: 8px; font-size: 13px; color: #c7d2fe;
  background: rgba(99, 102, 241, .1); border: 1px dashed rgba(129, 140, 248, .45); }
.note-dot { width: 8px; height: 8px; border-radius: 50%; background: #818cf8; flex: none; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 10%, rgba(59,130,246,.12), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; display: grid; gap: 14px; padding: 28px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.login-title { font-size: 20px; font-weight: 700; }
.login-error { color: #fecaca; background: #2a1414; border: 1px solid #7f1d1d; border-radius: 8px; padding: 8px 12px; font-size: 14px; }

/* формы */
.input { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.input:focus { outline: none; border-color: var(--accent); }
.input:disabled { opacity: .6; }
.input.sm { padding: 5px 8px; font-size: 13px; }
.input.color { padding: 2px; height: 38px; }
select.input { padding-right: 28px; }
textarea.input { resize: vertical; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-bottom: 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; padding: 3px 0; }
.check input { accent-color: var(--accent); margin-top: 3px; width: 16px; height: 16px; flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }
.check-grid.disabled { opacity: .55; }
.check-list { display: grid; gap: 6px; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { width: 36px; height: 20px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); position: relative; flex: none; transition: background .15s; }
.toggle-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle input:disabled + .toggle-track { opacity: .5; }

/* вкладки, фильтры, таблицы */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; padding: 10px 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tabbtn:hover { color: var(--text); }
.tabbtn.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { font-size: 11px; padding: 0 7px; border-radius: 9px; background: var(--surface-3); color: var(--muted); }
.filters, .toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters .input { width: auto; min-width: 150px; flex: 0 1 auto; }
.toolbar .input { max-width: 360px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card .table-wrap { border: 0; border-radius: 0; background: none; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover { background: var(--surface-2); }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table th.right, .table td.right { text-align: right; }
.table tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.table tr.sev-row-alarm td:first-child { box-shadow: inset 3px 0 0 var(--err); }
.table tr.sev-row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chip { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.running, .chip.starting, .chip.finalizing, .chip.reconnecting { color: var(--warn); background: rgba(245, 158, 11, .12); }
.chip.done { color: var(--ok); background: rgba(34, 197, 94, .12); }
.chip.error { color: #fca5a5; background: rgba(239, 68, 68, .14); }
.chip.info { color: var(--info); background: rgba(56, 189, 248, .12); }
.chip.muted { opacity: .5; text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sev-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--info); }
.sev-dot.alarm { background: var(--err); } .sev-dot.warn { background: var(--warn); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin: 8px 0 12px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 4px; }
.meter.warn > div { background: var(--warn); } .meter.crit > div { background: var(--err); }
.banner { margin-bottom: 14px; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.banner.error { color: #fecaca; border-color: #7f1d1d; background: #2a1414; }
.banner.warn { color: #fde68a; border-color: #78350f; background: #2a2010; }
.banner.ok { color: #bbf7d0; border-color: #14532d; background: #0f2418; }

/* модалка, боковая панель, тосты */
.modal-back, .drawer-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); }
.modal-back { display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal.wide { max-width: 820px; }
.modal-head, .drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2, .drawer-head h2 { margin: 0; }
.modal-body, .drawer-body { padding: 18px; overflow-y: auto; }
.modal-foot, .drawer-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--border); animation: slidein .18s ease-out; }
.drawer-body { flex: 1; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--ok);
  box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 14px; transition: opacity .35s, transform .35s; }
.toast.err { border-left-color: var(--err); } .toast.info { border-left-color: var(--info); } .toast.warn { border-left-color: var(--warn, #f59e0b); }
.toast { display: flex; align-items: center; gap: 10px; }
.toast-body { flex: 1; }
.toast-link { pointer-events: auto; white-space: nowrap; font-size: 13px; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* номера */
.plate-text { display: inline-block; background: #fff; color: #000; border: 2px solid #000; border-radius: 4px; padding: 0 8px;
  font: 700 15px/1.55 "DejaVu Sans Mono", Menlo, Consolas, monospace; letter-spacing: .04em; white-space: nowrap; }

/* источники */
.thumb { width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.offline { background: repeating-linear-gradient(135deg, #1a1f26 0 6px, #14181d 6px 12px); }
.test-out:empty { display: none; }
.test-out { margin-top: 12px; }
.test-ok { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 8px; background: #0f2418; border: 1px solid #14532d; }
.test-ok img { width: 160px; border-radius: 6px; }
.tab-body > .card + .card { margin-top: 16px; }
.detect-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.video-idle { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; background: rgba(10, 12, 15, .82); color: var(--text); }
.video-idle .row { justify-content: center; flex-wrap: wrap; }
.sched { display: grid; grid-template-columns: 32px repeat(24, minmax(0, 1fr)); gap: 2px; margin: 14px 0 8px; user-select: none; touch-action: none; }
.sched.disabled { opacity: .4; pointer-events: none; }
.sched-h { font-size: 10px; color: var(--muted); }
.sched-d { font-size: 12px; color: var(--muted); align-self: center; }
.sched-c { height: 20px; border-radius: 3px; background: var(--surface-3); cursor: pointer; }
.sched-c.on { background: var(--accent); }

/* зоны */
.zones { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.zones-stage { position: relative; aspect-ratio: 16 / 9; background: #05070a; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.zones-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.zones-img.broken { display: none; }
.zones-noframe { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; padding: 16px; text-align: center;
  background: repeating-linear-gradient(135deg, #12161b 0 10px, #0e1115 10px 20px); }
.zones-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.zones-stage.drawing .zones-svg { cursor: crosshair; }
.zones-handles { position: absolute; inset: 0; pointer-events: none; }
.zh { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; border: 3px solid; pointer-events: none; }
.zh.first { width: 16px; height: 16px; margin: -8px 0 0 -8px; }
.zh.drag { pointer-events: auto; cursor: grab; touch-action: none; }
.zones-hint { margin-top: 8px; }
.zones-list { display: grid; gap: 6px; margin: 14px 0; }
.zone-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 14px; }
.zone-item.active { border-color: var(--accent); }
.zone-item.muted { color: var(--muted); grid-template-columns: 12px 1fr; cursor: default; }
.zone-main { display: grid; gap: 2px; min-width: 0; }
.zone-extra { grid-column: 2 / -1; display: flex; gap: 8px; align-items: center; }

/* мониторинг */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi.alarm .kpi-value { color: #fca5a5; }
.kpi.warn .kpi-value { color: #fcd34d; }
.mon { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.mon-grid { display: grid; gap: 10px; }
.mon-tile { position: relative; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  color: var(--text); text-decoration: none !important; }
.mon-tile:hover { border-color: var(--accent); }
.mon-shot { position: relative; aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; }
.mon-shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.mon-off { display: grid; justify-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.mon-off .ico { width: 28px; height: 28px; }
.mon-shot.offline { background: repeating-linear-gradient(135deg, #12161b 0 10px, #0e1115 10px 20px); }
.mon-cap { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; font-size: 14px; }
.mon-cap b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.mon-cap .hint { margin-left: auto; }
.mon-tile .live-badge { background: var(--warn); color: #111; }
.feed-card { padding: 14px; position: sticky; top: calc(var(--bar-h) + 16px); }
.feed { display: grid; gap: 4px; max-height: calc(100vh - 220px); overflow-y: auto; }
.feed-item { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; padding: 6px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.feed-item:hover { background: var(--surface-2); }
.feed-item.sev-alarm { box-shadow: inset 3px 0 0 var(--err); background: rgba(239,68,68,.05); }
.feed-item.sev-warn { box-shadow: inset 3px 0 0 var(--warn); }
.feed-thumb, .ev-thumb { width: 72px; aspect-ratio: 16 / 9; border-radius: 5px; overflow: hidden; background: #000; }
.feed-thumb img, .ev-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-thumb.real, .ev-thumb.real { background: #fff; display: grid; place-items: center; }
.feed-thumb.real img, .ev-thumb.real img { object-fit: contain; }
.feed-main { display: grid; gap: 2px; font-size: 14px; min-width: 0; justify-items: start; }
.feed-title { display: flex; gap: 6px; align-items: center; }
.feed-main .plate-text { font-size: 13px; padding: 0 6px; }
.ev-big { border-radius: 8px; overflow: hidden; background: #000; }
.ev-big img { width: 100%; display: block; }
.ev-big.real { background: #fff; padding: 16px; text-align: center; }
.ev-big.real img { max-height: 140px; width: auto; max-width: 100%; margin: 0 auto; }
.ev-big.real .hint { color: #555; margin: 8px 0 0; }

/* полоска доли (хранилище) */
.barlist-track { height: 12px; }
.barlist-bar { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }

/* администрирование */
.sysgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.sysgrid > .card + .card { margin-top: 0; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.perm-grid > .card + .card { margin-top: 0; }
.perm-head { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 6px; }

/* загрузка файлов (из прежнего демо) */
.upload-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.upload-list li { display: grid; grid-template-columns: 1fr 160px auto; gap: 12px; align-items: center; padding: 8px 12px;
  background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.upload-list .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .ustate { color: var(--muted); font-size: 13px; min-width: 70px; text-align: right; }
.upload-list .ustate.err { color: var(--err); }
.upload-list .ustate.ok { color: var(--ok); }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 14px; }
.group { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; user-select: none; font-size: 14px; }
.group input { accent-color: var(--accent); width: 16px; height: 16px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(255,255,255,.25); }
.switch { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: 14px; cursor: pointer; }
.switch input { accent-color: var(--accent); margin-top: 3px; }

.dropzone { display: flex; align-items: center; justify-content: center; min-height: 110px; border: 2px dashed var(--border);
  border-radius: var(--radius); color: var(--muted); cursor: pointer; text-align: center; padding: 16px; }
.dropzone.over { border-color: var(--accent); color: var(--text); }
.upload-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.upload-list li { display: grid; grid-template-columns: 1fr 160px auto; gap: 12px; align-items: center; padding: 8px 12px;
  background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.upload-list .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .ustate { color: var(--muted); font-size: 13px; min-width: 70px; text-align: right; }
.upload-list .ustate.err { color: var(--err); }
.upload-list .ustate.ok { color: var(--ok); }

/* плеер */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.player { padding: 0; overflow: hidden; }
.video-wrap { position: relative; background: #000; aspect-ratio: 16 / 9; }
.video-wrap video { width: 100%; height: 100%; display: block; object-fit: contain; }
.video-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted);
  background: rgba(0,0,0,.35); pointer-events: none; font-size: 15px; text-align: center; padding: 16px; }
.live-badge { position: absolute; top: 12px; left: 12px; background: var(--err); color: #fff; font-weight: 700; font-size: 12px;
  padding: 2px 8px; border-radius: 4px; letter-spacing: .08em; }
.controls { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--border); }
.timeline { position: relative; flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; cursor: pointer; overflow: hidden; }
.tl-processed { position: absolute; inset: 0 auto 0 0; width: 0; background: #334155; }
.tl-played { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); }
.timeline.live { cursor: default; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 96px; text-align: right; }
.side { display: grid; gap: 16px; }
.stat { padding: 14px 16px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.progress div { height: 100%; width: 0; background: var(--ok); transition: width .3s; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.counts, .plates { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.counts li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.counts li b { margin-left: auto; font-variant-numeric: tabular-nums; }
.plates { max-height: 420px; overflow-y: auto; }
.plates li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 6px 8px;
  border-radius: 8px; cursor: pointer; }
.plates li:hover { background: var(--surface-2); }
.plates li img { grid-column: 1 / -1; height: 32px; max-width: 100%; object-fit: contain; justify-self: start; border-radius: 3px; }
.plate-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.plates .empty, .counts .empty { color: var(--muted); font-size: 14px; cursor: default; }


/* адаптивность */
@media (max-width: 1200px) {
  .mon { grid-template-columns: 1fr; }
  .feed-card { position: static; }
  .feed { max-height: none; }
  .zones { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  #btn-menu { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: var(--bar-h); bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: auto; }
  .menu-open .sidebar { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .menu-collapsed .app { --side-w: 0; }
  .menu-collapsed .nav-label, .menu-collapsed .nav-group .ico:last-child { display: inline; }
  .menu-collapsed .nav-item { justify-content: flex-start; padding: 9px 12px; }
  .nav-collapse { display: none; }
  .viewer, .grid2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-name, .brand-sub { display: none; }
}
@media (max-width: 600px) {
  .view { padding: 16px; }
  .brand { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .upload-list li { grid-template-columns: 1fr auto; }
  .upload-list progress { display: none; }
  .controls { flex-wrap: wrap; }
  .filters .input { min-width: 0; flex: 1 1 140px; }
  .mon-grid { grid-template-columns: 1fr !important; }
  .popover { position: fixed; left: 8px; right: 8px; width: auto; top: calc(var(--bar-h) + 4px); }
  .table th, .table td { padding: 8px; }
}
.side > .card + .card { margin-top: 0; }

/* ---- Смотритель: вход ---- */
.login-forgot { justify-self: center; font-size: 14px; color: var(--muted); }
.login-forgot:hover { color: var(--accent); }
.brand-name { font-size: 17px; }
