:root {
  --bg: #080b10;
  --bg-2: #0c1118;
  --panel: #10161f;
  --panel-2: #151c27;
  --panel-3: #1b2431;
  --line: #222c3a;
  --line-2: #2c394a;
  --text: #e7edf4;
  --muted: #8a97a8;
  --faint: #5d6a7b;
  --accent: #3ad1ff;
  --accent-2: #1f8fff;
  --ok: #34d399;
  --warn: #ffb020;
  --crit: #ff4d5e;
  --violet: #b48cff;
  --z-queue: #3ca0ff;
  --z-restricted: #eb3c3c;
  --z-danger: #ff5a00;
  --z-safe: #3cc85a;
  --z-loitering: #c85ac8;
  --z-crowd: #ffd200;
  --z-line: #ffffff;
  --z-door: #78dcff;
  --z-area: #3ad1ff;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(58, 209, 255, .07), transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-3); padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-3); border-color: #3a4a5e; }
.btn:active { transform: translateY(1px); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: linear-gradient(180deg, #43d6ff, #1fb3ea); color: #04121a; border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: #ff8b96; border-color: rgba(255, 77, 94, .35); }
.btn.danger-ghost:hover { background: rgba(255, 77, 94, .12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--panel-3); }
.icon-btn.off .sound-wave { opacity: 0; }
.icon-btn.off { color: var(--faint); }

/* ---------- top bar */
.topbar {
  height: 68px; display: flex; align-items: center; gap: 22px; padding: 0 18px;
  border-bottom: 1px solid var(--line); background: rgba(10, 14, 20, .85); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.brand-name { font-weight: 700; letter-spacing: .14em; font-size: 13.5px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.kpis { display: flex; gap: 10px; flex: 1; justify-content: center; min-width: 0; }
.kpi {
  display: flex; flex-direction: column; justify-content: center; min-width: 128px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2); }
.kpi.ok::before { background: var(--ok); }
.kpi.warn::before { background: var(--warn); }
.kpi.crit::before { background: var(--crit); }
.kpi.crit { animation: glow 1.6s ease-in-out infinite; }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.kpi-val { font: 600 20px/1.2 var(--mono); font-variant-numeric: tabular-nums; }
.top-right { display: flex; align-items: center; gap: 10px; }
.chip { font: 600 11px var(--mono); padding: 5px 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); text-transform: uppercase; }
.clock { font: 500 15px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--crit); box-shadow: 0 0 0 3px rgba(255, 77, 94, .15); }
.conn.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .15); }

@keyframes glow { 50% { box-shadow: inset 0 0 0 1px rgba(255, 77, 94, .55), 0 0 22px rgba(255, 77, 94, .18); } }

/* ---------- layout */
.layout { display: grid; grid-template-columns: 270px 1fr 360px; height: calc(100% - 68px); }
.rail, .feed { background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.rail { border-right: 1px solid var(--line); }
.feed { border-left: 1px solid var(--line); }
.rail-head, .feed-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
h3 { margin: 0; font-size: 16px; }

.cam-list { flex: 1; overflow: auto; padding: 4px 10px; display: flex; flex-direction: column; gap: 6px; }
.cam {
  display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; padding: 8px;
  border-radius: 10px; border: 1px solid transparent; background: transparent; text-align: left; width: 100%;
}
.cam:hover { background: var(--panel); border-color: var(--line); }
.cam.active { background: var(--panel-2); border-color: rgba(58, 209, 255, .4); }
.cam-thumb { width: 54px; height: 38px; border-radius: 6px; background: #000 center/cover; border: 1px solid var(--line); position: relative; }
.cam-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-meta { display: flex; gap: 8px; align-items: center; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.running { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.loading, .dot.starting { background: var(--warn); }
.dot.error, .dot.no-signal { background: var(--crit); }
.cam-alert { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--crit); font: 700 10px/16px var(--mono); text-align: center; padding: 0 4px; }

.rail-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.legend-title { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ---------- center */
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; gap: 12px; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tab { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); height: 32px; padding: 0 12px; border-radius: 8px; color: var(--muted); }
.tab svg { width: 15px; height: 15px; }
.tab.active { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.crumb-cam { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-cam:not(:empty)::before { content: "›"; color: var(--faint); margin: 0 8px 0 4px; }
.view-actions { display: flex; gap: 8px; }

.grid { flex: 1; overflow: auto; padding: 4px 18px 18px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); align-content: start; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: rgba(58, 209, 255, .45); transform: translateY(-1px); }
.tile.alarm { border-color: var(--crit); animation: glow 1.6s infinite; }
.tile-img { aspect-ratio: 16/9; background: #000; position: relative; }
.tile-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-badge { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge { font: 600 11px var(--mono); padding: 3px 7px; border-radius: 6px; background: rgba(0, 0, 0, .65); border: 1px solid rgba(255, 255, 255, .1); backdrop-filter: blur(4px); }
.badge.live { color: var(--crit); }
.badge.live::before { content: "●"; margin-right: 4px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.tile-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; gap: 10px; }
.tile-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-stats { display: flex; gap: 12px; font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
.tile-stats b { color: var(--text); font-weight: 600; }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; padding: 30px; }
.empty svg { color: var(--accent); opacity: .7; }
.empty h3 { color: var(--text); }
.empty p { max-width: 380px; margin: 0 0 8px; }

/* ---------- focus */
.focus { flex: 1; overflow: auto; padding: 0 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tool-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding-left: 4px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-size: 12.5px; }
.tool:hover { border-color: var(--line-2); }
.tool.active { border-color: var(--tc); box-shadow: inset 0 0 0 1px var(--tc); background: color-mix(in srgb, var(--tc) 14%, var(--panel-2)); }
.tool-hint { font-size: 12px; color: var(--faint); margin-left: auto; }
.stage-wrap { display: flex; justify-content: center; }
.stage { position: relative; width: 100%; max-height: calc(100vh - 340px); aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.stage img, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage img { object-fit: fill; }
.stage canvas { cursor: default; }
.stage.drawing canvas { cursor: crosshair; }
.stage-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.stage-status.err { color: #ff8b96; }

.zone-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.zchip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); font-size: 12.5px; }
.zchip:hover { border-color: var(--line-2); }
.zchip.sel { border-color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card-head .swatch { width: 8px; height: 8px; }
.card-head .name { color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13.5px; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big { font: 600 28px/1 var(--mono); font-variant-numeric: tabular-nums; }
.big small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.rows { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 12.5px; color: var(--muted); }
.rows b { color: var(--text); font: 500 12.5px var(--mono); text-align: right; }
.bar { height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 3px; background: var(--ok); transition: width .4s, background .4s; }
.spark { width: 100%; height: 54px; }
.spark path.area { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: none; }
.spark path.line { stroke: var(--accent); stroke-width: 1.6; }
.state-ok { color: var(--ok); }
.state-warn { color: var(--warn); }
.state-crit { color: var(--crit); }

/* ---------- feed */
.count-badge { font: 700 11px var(--mono); background: var(--crit); color: #fff; border-radius: 99px; padding: 2px 8px; }
.count-badge.zero { background: var(--panel-3); color: var(--muted); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; border-bottom: 1px solid var(--line); }
.filter { height: 26px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line); background: transparent; font-size: 12px; color: var(--muted); }
.filter.active { background: var(--panel-3); color: var(--text); border-color: var(--line-2); }
.events { flex: 1; overflow: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.ev { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 9px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); position: relative; animation: slidein .35s ease-out; }
.ev::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--faint); }
.ev.critical::before { background: var(--crit); }
.ev.warning::before { background: var(--warn); }
.ev.info::before { background: var(--accent); }
.ev.acked { opacity: .55; }
.ev.critical:not(.acked) { border-color: rgba(255, 77, 94, .35); background: linear-gradient(90deg, rgba(255, 77, 94, .08), var(--panel) 60%); }
@keyframes slidein { from { opacity: 0; transform: translateX(14px); } }
.ev-thumb { width: 84px; height: 56px; border-radius: 6px; background: #000 center/cover; border: 1px solid var(--line); cursor: zoom-in; }
.ev-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ev-top { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.ev-type { font: 700 10.5px var(--mono); text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: var(--panel-3); }
.ev.critical .ev-type { color: var(--crit); background: rgba(255, 77, 94, .12); }
.ev.warning .ev-type { color: var(--warn); background: rgba(255, 176, 32, .12); }
.ev-time { margin-left: auto; font-family: var(--mono); }
.ev-msg { font-size: 13px; line-height: 1.35; }
.ev-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--faint); }
.ev-ack { margin-left: auto; height: 22px; padding: 0 8px; font-size: 11px; border-radius: 6px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); }
.ev-ack:hover { color: var(--text); background: var(--panel-3); }
.feed-empty { color: var(--faint); text-align: center; padding: 40px 10px; font-size: 13px; }

/* ---------- alarm banner */
.alarm-banner {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 12px; background: linear-gradient(90deg, #4a0d16, #2a0a10); border: 1px solid var(--crit);
  box-shadow: 0 0 40px rgba(255, 77, 94, .35); max-width: min(820px, 90vw); animation: drop .3s ease-out;
}
.alarm-banner strong { color: #ffb3bb; letter-spacing: .08em; font-size: 12px; }
.alarm-banner #alarm-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--crit); box-shadow: 0 0 0 0 rgba(255, 77, 94, .7); animation: pulse 1.2s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(255, 77, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0); } }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -10px); } }

/* ---------- modal / drawer / popover */
.modal, .drawer, .lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(3, 6, 10, .66); backdrop-filter: blur(3px); }
.modal { display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.form-error { margin-right: auto; color: #ff8b96; font-size: 12.5px; }
.seg-tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg-tabs button { border: 0; background: transparent; height: 30px; border-radius: 7px; color: var(--muted); font-size: 13px; }
.seg-tabs button.active { background: var(--panel-3); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); outline: none; font-size: 13.5px;
}
.field textarea { height: 64px; padding: 8px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58, 209, 255, .15); }
.help { margin: 6px 0 0; font-size: 12px; color: var(--faint); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px; border: 1.5px dashed var(--line-2); border-radius: 12px; color: var(--muted); cursor: pointer; text-align: center; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); background: rgba(58, 209, 255, .05); }
.drop small { color: var(--faint); }
.progress { height: 6px; background: var(--panel-3); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.drawer { display: flex; justify-content: flex-end; }
.drawer-card { width: min(460px, 100%); height: 100%; background: var(--panel); border-left: 1px solid var(--line-2); padding: 18px; display: flex; flex-direction: column; gap: 14px; animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-body { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 18px; padding-right: 4px; }
.sect-title { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; margin-bottom: 8px; }
.sect { display: flex; flex-direction: column; gap: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--panel-3); border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.toggle input::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 { background: rgba(58, 209, 255, .25); border-color: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); background: var(--accent); }
.toggle small { display: block; color: var(--faint); font-size: 11.5px; }

.popover { position: fixed; z-index: 45; width: 290px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pop-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pop-foot { display: flex; gap: 6px; align-items: center; }
.spacer { flex: 1; }

.lightbox { display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lightbox figure { margin: 0; max-width: 92vw; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 10px; border: 1px solid var(--line-2); display: block; }
.lightbox figcaption { margin-top: 10px; color: var(--muted); text-align: center; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel-3); border: 1px solid var(--line-2); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow); font-size: 13px; animation: drop .25s; }
.toast.err { border-color: var(--crit); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232d3b; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- responsive */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 230px 1fr 320px; }
  .kpi { min-width: 0; padding: 6px 10px; }
  .brand { min-width: 0; }
  .brand-sub { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
@media (max-width: 960px) {
  body { overflow: auto; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .kpis { order: 3; width: 100%; overflow-x: auto; justify-content: flex-start; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .rail, .feed { border: 0; border-bottom: 1px solid var(--line); }
  .cam-list { flex-direction: row; overflow-x: auto; }
  .cam { min-width: 220px; }
  .rail-foot { display: none; }
  .events { max-height: 70vh; }
  .grid { padding: 4px 16px 16px; grid-template-columns: 1fr; }
  .focus { padding: 0 16px 16px; }
  .stage { max-height: none; }
  .tool-hint { display: none; }
}

/* ---------- overview */
.overview { flex: 1; overflow: auto; padding: 4px 18px 24px; display: flex; flex-direction: column; gap: 22px; }
.sect-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.muted-sm { color: var(--faint); font-size: 12px; }
.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.ins { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); position: relative; overflow: hidden; }
.ins::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.ins.crit::before { background: var(--crit); } .ins.warn::before { background: var(--warn); } .ins.ok::before { background: var(--ok); }
.ins.crit { background: linear-gradient(90deg, rgba(255, 77, 94, .08), var(--panel) 55%); }
.ins-ico { width: 30px; height: 30px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--panel-3); color: var(--accent); }
.ins.crit .ins-ico { color: var(--crit); } .ins.warn .ins-ico { color: var(--warn); } .ins.ok .ins-ico { color: var(--ok); }
.ins-ico svg { width: 17px; height: 17px; }
.ins-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ins-title { font-weight: 600; font-size: 13.5px; }
.ins-text { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.ins-actions { display: flex; gap: 6px; margin-top: 4px; }
.ins-empty { color: var(--faint); font-size: 13px; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius); }
.cat-sections { display: flex; flex-direction: column; gap: 22px; }
.cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cat-head h3 { font-size: 14px; }
.cat-total { font: 600 12px var(--mono); color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; }
.zones-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ztile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color .15s, transform .15s; }
.ztile:hover { border-color: rgba(58, 209, 255, .45); transform: translateY(-1px); }
.ztile.crit { border-color: rgba(255, 77, 94, .55); }
.ztile.warn { border-color: rgba(255, 176, 32, .45); }
.ztile.offline { opacity: .5; }
.zt-top { display: flex; align-items: center; gap: 8px; }
.zt-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zt-cam { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zt-status { margin-left: auto; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.zt-status.warn { background: var(--warn); } .zt-status.crit { background: var(--crit); box-shadow: 0 0 10px var(--crit); }
.zt-status.offline, .zt-status.idle { background: var(--faint); }
.zt-mid { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.trend { font: 600 12px var(--mono); }
.trend.up { color: var(--warn); } .trend.down { color: var(--ok); } .trend.flat { color: var(--faint); }
.zt-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.zt-foot b { color: var(--text); font-weight: 600; }
.stage img.heat { mix-blend-mode: screen; pointer-events: none; opacity: .9; }
#heat-btn.on { border-color: var(--warn); color: var(--warn); }
.pop-hint { font-size: 11.5px; color: var(--faint); margin-top: -4px; }

/* ---------- reports */
.report { flex: 1; overflow: auto; padding: 4px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.report-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rep-range { width: 320px; grid-template-columns: repeat(4, 1fr); }
.report-bar #rep-shift { margin-left: auto; }
a.btn { text-decoration: none; }
.rep-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.rep-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rep-table th { text-align: left; font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; white-space: nowrap; }
.rep-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rep-table td.num { font-family: var(--mono); text-align: right; }
.rep-table th.num { text-align: right; }
.rep-table tr:hover td { background: var(--panel-2); }
.rep-zone { display: flex; align-items: center; gap: 8px; }
.rep-zone small { color: var(--faint); display: block; }
.minibars { display: inline-flex; align-items: flex-end; gap: 2px; height: 22px; vertical-align: middle; }
.minibars i { width: 7px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; min-height: 1px; }
.hourbars i { width: 3px; }
.pill { font: 600 11px var(--mono); padding: 2px 7px; border-radius: 99px; background: var(--panel-3); }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.crit { color: var(--crit); }
.hist { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; align-items: end; height: 46px; }
.hist div { background: color-mix(in srgb, var(--accent) 60%, transparent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.hist-lbl { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 9.5px; color: var(--faint); text-align: center; margin-top: 2px; }

/* ---------- per-camera analyses */
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset { height: 26px; padding: 0 10px; border-radius: 99px; border: 1px dashed var(--line-2); background: transparent; color: var(--muted); font-size: 12px; }
.preset:hover { color: var(--text); border-color: var(--accent); }
.mod-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.mod { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font-size: 12.5px; transition: all .12s; }
.mod svg { width: 14px; height: 14px; }
.mod:hover { border-color: var(--line-2); color: var(--text); }
.mod.on { color: var(--text); border-color: var(--accent); background: rgba(58, 209, 255, .12); box-shadow: inset 0 0 0 1px rgba(58, 209, 255, .35); }
.mod.on svg { color: var(--accent); }
.modbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.modbar .tool-label { white-space: nowrap; }
.modbar .presets { margin-left: auto; }
.cam-mods { display: flex; gap: 3px; margin-top: 3px; }
.cam-mods i { width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center; background: var(--panel-3); color: var(--accent); }
.cam-mods i svg { width: 10px; height: 10px; }

.ev-thumbs { display: flex; flex-direction: column; gap: 4px; }
.ev-owner { width: 84px; height: 56px; border-radius: 6px; background: #000 center/contain no-repeat; border: 1px solid var(--warn); cursor: zoom-in; position: relative; }
.ev-owner::after { content: "vlasnik"; position: absolute; left: 3px; bottom: 2px; font: 600 9px var(--mono); color: var(--warn); background: rgba(0,0,0,.6); padding: 0 3px; border-radius: 3px; }

/* ---------- simplified editing & add wizard */
.editbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.purpose-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; flex: 1; }
.purpose-line .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.ppill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; background: rgba(58, 209, 255, .1); border: 1px solid rgba(58, 209, 255, .35); font-size: 12.5px; }
.ppill svg { width: 13px; height: 13px; color: var(--accent); }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 12.5px; padding: 2px 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.draw-btns { display: flex; gap: 8px; align-items: center; }
.btn.draw { height: 38px; padding: 0 16px; font-weight: 600; border-color: rgba(58, 209, 255, .45); background: rgba(58, 209, 255, .08); }
.btn.draw svg { width: 18px; height: 18px; color: var(--accent); }
.btn.draw.active { background: var(--accent); color: #04121a; border-color: transparent; }
.btn.draw.active svg { color: #04121a; }
.guide { display: flex; flex-wrap: wrap; gap: 8px; }
.guide:empty { display: none; }
.gstep { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border-radius: 10px; border: 1px dashed var(--line-2); background: var(--bg-2); font-size: 13px; }
.gstep .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 11px var(--mono); background: var(--panel-3); color: var(--accent); flex: none; }
.gstep.done { border-style: solid; opacity: .55; }
.gstep.done .n { background: rgba(52, 211, 153, .15); color: var(--ok); }
.draw-hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(8, 11, 16, .86); border: 1px solid var(--line-2); border-radius: 99px; padding: 7px 14px; font-size: 13px; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; box-shadow: var(--shadow); }
.draw-hint b { color: var(--accent); }
.zpop { width: 360px; max-height: calc(100vh - 24px); overflow: auto; }
.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tcard { display: flex; gap: 8px; align-items: flex-start; text-align: left; padding: 8px 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); }
.tcard:hover { border-color: var(--line-2); }
.tcard.on { border-color: var(--tc); box-shadow: inset 0 0 0 1px var(--tc); background: color-mix(in srgb, var(--tc) 12%, var(--panel-2)); }
.tcard i.swatch { margin-top: 3px; }
.tcard b { display: block; font-size: 12.5px; }
.tcard small { display: block; color: var(--muted); font-size: 11px; line-height: 1.3; }
.tcard.more { justify-content: center; align-items: center; color: var(--accent); font-size: 12px; border-style: dashed; }
details.adv { border-top: 1px dashed var(--line); padding-top: 8px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 12.5px; list-style: none; }
details.adv summary::before { content: "▸ "; }
details.adv[open] summary::before { content: "▾ "; }
details.adv > div { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
details.adv .mod-chips { flex-direction: row; }
#zone-params { display: flex; flex-direction: column; gap: 8px; }

.wiz { width: min(640px, 100%); }
.steps { display: flex; gap: 6px; margin-top: 6px; }
.step { font-size: 11.5px; color: var(--faint); padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); }
.step.on { color: var(--accent); border-color: rgba(58, 209, 255, .5); }
.drop.big { padding: 34px 20px; gap: 8px; }
.drop.big b { font-size: 15px; color: var(--text); }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 4px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.quick { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.sample-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sample { height: 26px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel-2); font-size: 12px; color: var(--muted); }
.sample:hover { color: var(--text); border-color: var(--accent); }
.picked { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; }
.picked svg { width: 18px; height: 18px; color: var(--ok); flex: none; }
.picked span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purposes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.pcard { position: relative; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); min-height: 104px; transition: border-color .12s, background .12s; }
.pcard:hover { border-color: var(--line-2); }
.pcard .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-3); color: var(--accent); }
.pcard .ic svg { width: 17px; height: 17px; }
.pcard b { font-size: 13.5px; }
.pcard small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.pcard.on { border-color: var(--accent); background: rgba(58, 209, 255, .09); box-shadow: inset 0 0 0 1px rgba(58, 209, 255, .5); }
.pcard.on::after { content: "✓"; position: absolute; top: 9px; right: 11px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #04121a; font: 700 12px/20px var(--mono); text-align: center; }
@media (max-width: 960px) { .type-cards { grid-template-columns: 1fr; } .zpop { width: calc(100vw - 24px); } }
.cam-purpose { font-size: 11.5px; color: var(--accent); opacity: .85; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- licence plates */
.search { height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); min-width: 240px; font: 500 13px var(--mono); }
.search:focus { outline: none; border-color: var(--accent); }
.plates-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.plate { display: inline-block; font: 700 14px var(--mono); letter-spacing: .06em; color: #111; background: #f4f6f8; border: 2px solid #1d2a3a; border-left: 10px solid #1f4fbf; border-radius: 5px; padding: 2px 9px; }
.plate.alarm { border-color: var(--crit); box-shadow: 0 0 0 2px rgba(255, 77, 94, .35); }
.plate.allow { border-color: var(--ok); }
.plate-img { height: 30px; max-width: 120px; border-radius: 4px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.watch { position: sticky; top: 0; }
.watch-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.watch-form input, .watch-form select { height: 32px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); font-size: 12.5px; min-width: 0; }
.watch-form #w-plate { font-family: var(--mono); text-transform: uppercase; }
.watch-form #w-note { grid-column: 1 / -1; }
.watch-form .btn { grid-column: 1 / -1; justify-content: center; }
.watch-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.wrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.wrow .plate { font-size: 12px; }
.wrow span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrow button { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; }
.wrow button:hover { color: var(--crit); }
@media (max-width: 1100px) { .plates-layout { grid-template-columns: 1fr; } }

/* ---------- auth & stop */
.pw-banner { display: flex; align-items: center; gap: 12px; padding: 8px 18px; background: linear-gradient(90deg, rgba(255, 176, 32, .18), rgba(255, 176, 32, .06)); border-bottom: 1px solid rgba(255, 176, 32, .4); color: #ffd28a; font-size: 13px; }
.pw-banner svg { color: var(--warn); flex: none; }
.pw-banner span { flex: 1; }
body:has(.pw-banner:not([hidden])) .layout { height: calc(100% - 68px - 45px); }
.usermenu { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; min-width: 180px; }
.menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; font-size: 13px; }
.menu button:hover { background: var(--panel-3); }
#btn-toggle.paused { border-color: var(--ok); color: var(--ok); }
.dot.stopped { background: var(--faint); box-shadow: none; }
.cam { position: relative; }
.cam-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-3); border: 1px solid var(--line-2); color: var(--muted); opacity: 0; transition: opacity .12s; }
.cam:hover .cam-toggle, .cam-toggle.paused { opacity: 1; }
.cam-toggle svg { width: 13px; height: 13px; }
.cam-toggle:hover { color: var(--text); border-color: var(--accent); }
.cam-toggle.paused { color: var(--ok); border-color: rgba(52, 211, 153, .5); }
.cam.off .cam-thumb, .cam.off .cam-name { opacity: .5; }

/* ---------- onboarding tour */
.tour { position: fixed; inset: 0; z-index: 80; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(3, 6, 10, .72), 0 0 0 2px var(--accent), 0 0 30px rgba(58, 209, 255, .35); transition: all .28s ease; pointer-events: none; }
.tour-spot.center { left: 50% !important; top: 42% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 9999px rgba(3, 6, 10, .78); }
.tour-card { position: fixed; width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); transition: top .28s ease, left .28s ease; }
.tour-card h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-card p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.tour-card p b { color: var(--text); }
.tour-step { font: 600 11px var(--mono); color: var(--accent); letter-spacing: .08em; }
.tour-foot { display: flex; align-items: center; gap: 8px; }
.menu .menu-link { text-align: left; padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text); text-decoration: none; }
.menu .menu-link:hover { background: var(--panel-3); }

/* ---------- locations */
.locs-head { display: flex; align-items: center; gap: 10px; }
.locs-head .lbl { font-size: 12px; color: var(--muted); }
.loc-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow: auto; }
.loc-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.loc-group .g { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); width: 100%; }
.loc-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-size: 12.5px; color: var(--text); }
.loc-chip svg { width: 14px; height: 14px; color: var(--accent); }
.loc-chip:hover { border-color: var(--accent); background: rgba(58, 209, 255, .08); }
.loc-empty { color: var(--faint); font-size: 12.5px; }
.loc-table { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.loc-row { display: grid; grid-template-columns: 1.3fr .8fr 1.6fr auto; gap: 6px; align-items: center; }
.loc-row input, .loc-add input { height: 32px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); font-size: 12.5px; min-width: 0; }
.loc-row input:focus, .loc-add input:focus { outline: none; border-color: var(--accent); }
.loc-row .del { background: none; border: 0; color: var(--faint); font-size: 18px; cursor: pointer; padding: 0 6px; }
.loc-row .del:hover { color: var(--crit); }
.loc-add { display: grid; grid-template-columns: 1.3fr .8fr 1.6fr; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.loc-add .file-btn { grid-column: 1 / 3; justify-content: center; cursor: pointer; }
.loc-add .file-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-add button[type=submit] { justify-content: center; }
@media (max-width: 700px) { .loc-row, .loc-add { grid-template-columns: 1fr; } .loc-add .file-btn { grid-column: auto; } }

/* ---------- language switch */
.langs { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.langs button { border: 0; background: transparent; color: var(--muted); font: 600 11.5px var(--mono); padding: 5px 9px; cursor: pointer; }
.langs button + button { border-left: 1px solid var(--line-2); }
.langs button:hover { color: var(--text); }
.langs button.active { background: rgba(58, 209, 255, .15); color: var(--accent); }
