/* cctv-tracker admin — operator console. Restrained: tinted-graphite neutrals +
   one iris accent + semantic status. Dark primary (control room), light kept. */
:root {
  /* commercial-VMS dark: near-black, cool, steel-blue accent (Genetec/Milestone-like) */
  --bg:        oklch(0.145 0.008 250);
  --surface:   oklch(0.165 0.009 250);   /* sidebar / panels — second layer */
  --panel:     oklch(0.185 0.009 250);
  --panel-2:   oklch(0.225 0.010 250);   /* hover / raised */
  --line:      oklch(0.275 0.012 250);
  --line-soft: oklch(0.235 0.011 250);
  --fg:        oklch(0.92 0.006 250);
  --muted:     oklch(0.67 0.013 250);
  --faint:     oklch(0.58 0.013 250);
  --accent:    oklch(0.70 0.125 233);
  --accent-fg: oklch(0.99 0.01 233);
  --accent-dim:oklch(0.70 0.125 233 / 0.16);
  --live:      oklch(0.75 0.17 148);
  --warn:      oklch(0.78 0.13 78);
  --danger:    oklch(0.63 0.21 22);
  --video:     oklch(0.09 0.006 250);    /* tile background */
  --shadow: 0 1px 0 oklch(0 0 0 / 0.25);

  --r-sm: 5px; --r: 8px; --r-lg: 11px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 22px; --s6: 30px;
  --sidebar-w: 208px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "D2Coding", monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg:        oklch(0.975 0.004 250);
  --surface:   oklch(0.955 0.005 250);
  --panel:     oklch(1 0 0);
  --panel-2:   oklch(0.965 0.005 250);
  --line:      oklch(0.89 0.006 250);
  --line-soft: oklch(0.925 0.005 250);
  --fg:        oklch(0.23 0.009 250);
  --muted:     oklch(0.46 0.012 250);
  --faint:     oklch(0.44 0.012 250);
  --accent:    oklch(0.52 0.15 233);
  --accent-fg: oklch(0.99 0.01 233);
  --accent-dim:oklch(0.52 0.15 233 / 0.12);
  --live:      oklch(0.55 0.16 148);
  --warn:      oklch(0.66 0.14 70);
  --danger:    oklch(0.55 0.21 22);
  --video:     oklch(0.16 0.008 250);
  --shadow: 0 1px 2px oklch(0.2 0.02 250 / 0.08), 0 8px 24px oklch(0.2 0.02 250 / 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: oklch(0.975 0.004 250); --surface: oklch(0.955 0.005 250); --panel: oklch(1 0 0);
    --panel-2: oklch(0.965 0.005 250); --line: oklch(0.89 0.006 250); --line-soft: oklch(0.925 0.005 250);
    --fg: oklch(0.23 0.009 250); --muted: oklch(0.48 0.012 250); --faint: oklch(0.60 0.012 250);
    --accent: oklch(0.52 0.15 233); --accent-dim: oklch(0.52 0.15 233 / 0.12);
    --live: oklch(0.55 0.16 148); --warn: oklch(0.66 0.14 70); --danger: oklch(0.55 0.21 22);
    --video: oklch(0.16 0.008 250);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
  /* Korean typography: break lines at spaces (word boundaries), never mid-word;
     overflow-wrap keeps long unbroken tokens (URLs/hashes) from overflowing. */
  word-break: keep-all; overflow-wrap: anywhere;
}
.hidden { display: none !important; }
.grow { flex: 1; }
.hint { color: var(--muted); font-size: 12.5px; }
.sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.mt { margin-top: var(--s4); }
.empty { color: var(--faint); }
h1 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 620; margin: 0 0 var(--s4); letter-spacing: -0.005em; }
h3 { font-size: 11px; font-weight: 700; color: var(--muted); margin: 0 0 var(--s2); text-transform: uppercase; letter-spacing: 0.06em; }

/* keyboard focus — visible on the near-black surface */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--mono); font-size: 12px; }

.app { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column; padding: var(--s4) var(--s3);
  height: 100%; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s5); }
.brand .logo { font-size: 18px; }
.brand .name { font-weight: 680; letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  padding: 9px var(--s3); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: 13.5px;
  cursor: pointer; text-align: left; transition: background .15s, color .15s;
}
.nav-item .ic { width: 16px; text-align: center; opacity: .8; font-size: 13px; }
.nav-item:hover { background: var(--panel); color: var(--fg); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-item.active .ic { opacity: 1; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: var(--s4); }
.dot-line { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: 12px; }
.dot-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); }
.icon-btn {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: transparent; color: var(--fg); cursor: pointer; font-size: 14px;
  display: grid; place-items: center; transition: border-color .15s;
}
.icon-btn:hover { border-color: var(--accent); }

/* ---------- main ---------- */
.main { min-width: 0; padding: var(--s4) var(--s5); height: 100%; overflow-y: auto; }
.bar { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s5); min-height: 34px; }
.bar .sub { margin: 0; }

/* segmented + switch */
.seg { display: inline-flex; gap: 2px; background: var(--surface); border: 1px solid var(--line-soft); padding: 3px; border-radius: var(--r); }
.seg button {
  min-width: 32px; padding: 4px 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--fg); }
.seg button.active { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }
.bar h1 { white-space: nowrap; }
.switch input { accent-color: var(--accent); }

/* ---------- live video wall (fills the viewport, VMS-style) ---------- */
#tab-live { height: 100%; display: flex; flex-direction: column; }
.wall-layout { display: grid; grid-template-columns: 236px 1fr; gap: var(--s4); height: 100%; }
.wall { display: flex; flex-direction: column; min-width: 0; }
.wall .bar { margin-bottom: var(--s3); }

/* camera tree */
.tree { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: var(--s3); min-height: 0; }
.tree-search { margin-bottom: var(--s2); }
.tree-list { overflow-y: auto; min-height: 0; flex: 1; }
.tree-group { margin-bottom: var(--s2); }
.tree-group > .g-head { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.tree-group > .g-head:hover { color: var(--fg); background: var(--panel-2); }
.tree-group > .g-head.active { color: var(--accent); }
.tree-group > .g-head .n { margin-left: auto; color: var(--faint); font-weight: 400; }
.tree-group > .g-head .caret { display: inline-block; width: 11px; color: var(--faint); font-size: 9px; }
.tree-group > .g-head .caret.sp { visibility: hidden; }
.tree-cam { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 6px 8px 6px 22px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.tree-cam:hover { background: var(--accent-dim); color: var(--accent); }
.tree-cam .st { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.tree-cam .st.on { background: var(--live); box-shadow: 0 0 6px var(--live); }
.tree-cam .cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* pager */
.pager { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: 12.5px; }
.pager button { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; color: var(--fg); cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }

.grid { display: grid; gap: 3px; flex: 1; min-height: 0; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
.grid.g1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid.g2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.grid.g4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid.g8 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); }
.tile { position: relative; min-height: 0; background: var(--video); overflow: hidden; }
.tile.filled { cursor: context-menu; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.tile video.cover { object-fit: cover; }
/* thin overlay bars, VMS-style */
.tile .cap {
  position: absolute; left: 0; bottom: 0; max-width: 72%; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 26px 4px 9px; font-size: 11.5px; font-weight: 500; color: oklch(0.96 0.006 250);
  background: linear-gradient(to top, oklch(0.08 0.006 250 / 0.85), transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .cap .live { font-size: 10px; font-weight: 800; letter-spacing: 0.04em; color: var(--live); }
.tile .rec {
  position: absolute; left: var(--s2); top: var(--s2); display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; color: #fff;
  background: oklch(0.08 0.006 250 / 0.55); border-radius: 3px;
}
.tile .rec i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); animation: rec 1.6s ease-in-out infinite; }
@keyframes rec { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
.tile .ts {
  position: absolute; right: 0; bottom: 0; padding: 4px 9px; font-family: var(--mono);
  font-size: 11px; color: #cfe0ef;
  background: linear-gradient(to top, oklch(0.08 0.006 250 / 0.85), transparent);
}
.tile.empty { display: grid; place-items: center; color: var(--faint); font-size: 12px; background: var(--video); }
.crowd-badge {
  position: absolute; right: var(--s2); top: var(--s2); padding: 2px 8px; font-size: 11.5px; font-weight: 600;
  color: #fff; background: oklch(0.08 0.006 250 / 0.6); border-radius: 3px;
}

/* timeline scrubber (VMS) — live-edge placeholder; recording scrub is future */
.timeline-bar { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); padding: 7px var(--s3); background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); }
.tl-controls { display: inline-flex; gap: 4px; }
.tl-btn { width: 28px; height: 26px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; color: var(--fg); cursor: pointer; font-size: 10px; display: grid; place-items: center; }
.tl-btn:hover { border-color: var(--accent); color: var(--accent); }
.tl-track {
  position: relative; flex: 1; height: 30px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: visible;
  cursor: pointer; touch-action: none;
  background:
    repeating-linear-gradient(90deg, oklch(0.3 0.012 250 / 0.5) 0 1px, transparent 1px calc(100% / 12)),
    linear-gradient(180deg, oklch(0.26 0.02 233 / 0.35), oklch(0.2 0.015 233 / 0.35));
}
.tl-track.dragging { cursor: grabbing; }
.tl-tooltip {
  position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); font-family: var(--mono); font-size: 11px;
  padding: 3px 7px; border-radius: var(--r-sm); white-space: nowrap; pointer-events: none;
  z-index: 5; opacity: 0; transition: opacity .1s;
}
.tl-tooltip::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: var(--fg);
}
.tl-tooltip.show { opacity: 1; }
.tl-track.seeking .tl-playhead { animation: tl-pulse 0.8s ease-in-out infinite; }
@keyframes tl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.tl-bm { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--warn, oklch(0.8 0.15 85)); cursor: pointer; z-index: 2; }
.tl-bm::after { content: ""; position: absolute; top: -2px; left: -3px; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--warn, oklch(0.8 0.15 85)); }
.tl-bm:hover { box-shadow: 0 0 6px var(--warn, oklch(0.8 0.15 85)); }
.tl-playhead { position: absolute; top: -1px; bottom: -1px; right: 8px; width: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); z-index: 3; }
.tl-playhead::after { content: ""; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tl-live { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--live); color: var(--live); background: transparent; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; cursor: pointer; white-space: nowrap; }
.tl-live.active { background: var(--live); color: oklch(0.16 0.04 148); border-color: var(--live); }
.tl-clock { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 150px; text-align: right; white-space: nowrap; }
.timeline-bar { flex-wrap: wrap; }
.tl-btn:disabled { opacity: .45; cursor: default; }
.tl-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

/* saved views control */
.views { display: inline-flex; align-items: center; gap: var(--s2); }
.views select { width: auto; min-width: 118px; padding: 5px 9px; font-size: 12.5px; }

/* tile hover toolbar (actions discoverable without right-click) */
.tile-tools { position: absolute; top: var(--s2); right: var(--s2); display: flex; gap: 3px; opacity: 0; transition: opacity .15s ease-out; z-index: 2; }
.tile:hover .tile-tools, .tile:focus-within .tile-tools { opacity: 1; }
.tile:hover .crowd-badge, .tile:focus-within .crowd-badge { opacity: 0; }
.tile-tools button { width: 24px; height: 22px; border: 0; border-radius: 3px; background: oklch(0.08 0.006 250 / 0.74); color: oklch(0.9 0.006 250); cursor: pointer; font-size: 11px; display: grid; place-items: center; }
.tile-tools button:hover { background: var(--accent); color: var(--accent-fg); }
.tile .nosig { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 12px; letter-spacing: 0.08em; background: var(--video); z-index: 1; }
/* freeze/connect states over a still-buffered frame: translucent so the last frame shows */
.tile .nosig.sig-frozen, .tile .nosig.sig-connecting { background: color-mix(in oklch, var(--video) 55%, transparent); }
.tile .nosig.sig-frozen { color: var(--warn, oklch(0.8 0.15 85)); font-weight: 700; }
.tile .nosig.sig-nosignal { color: var(--danger); font-weight: 700; }
/* live detection box overlay */
.det-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.det-box { fill: none; stroke: var(--live); stroke-width: 2; opacity: 0.95; }
.det-label { fill: oklch(0.98 0.02 148); font: 700 11px var(--mono); paint-order: stroke; stroke: oklch(0.08 0.006 250 / 0.85); stroke-width: 3px; }
/* stage-2 pose skeleton + fall */
.pose-line { stroke: oklch(0.78 0.14 200); fill: oklch(0.78 0.14 200); stroke-width: 2; opacity: 0.9; }
.pose-fall { stroke: var(--danger); fill: var(--danger); stroke-width: 2.5; }
.fall-box { fill: none; stroke: var(--danger); stroke-width: 2.5; }
.fall-label { fill: oklch(0.98 0.05 25); font: 700 12px var(--font); paint-order: stroke; stroke: oklch(0.08 0.006 250 / 0.9); stroke-width: 3px; }

/* bottom status bar */
.statusbar { flex: none; display: flex; align-items: center; gap: var(--s5); padding: 6px var(--s5); background: var(--surface); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.statusbar .grow { flex: 1; }
.statusbar .sb { display: inline-flex; align-items: center; gap: 6px; }
.statusbar .sb .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 6px var(--live); }

/* context menu (VMS right-click) */
.ctxmenu {
  position: fixed; z-index: 100; min-width: 184px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); font-size: 13px;
}
.ctxmenu button {
  display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg); font: inherit;
  cursor: pointer; text-align: left;
}
.ctxmenu button:hover { background: var(--accent-dim); color: var(--accent); }
.ctxmenu button .k { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: 11px; }
.ctxmenu .sep { height: 1px; background: var(--line-soft); margin: 5px 6px; }
.ctxmenu .title { padding: 6px 10px 8px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.tile:fullscreen { border-radius: 0; }
.tile:fullscreen video { object-fit: contain; }

/* ---------- panels / split ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }
.split.narrow-left { grid-template-columns: minmax(220px, 320px) 1fr; }
.panel { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow); }
.list { display: flex; flex-direction: column; }

/* rows (cameras / processes) */
.row { display: flex; align-items: center; gap: var(--s3); padding: 11px 2px; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row .st { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.row .st.on { background: var(--live); box-shadow: 0 0 8px var(--live); }
.row .st.err { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.row .meta { flex: 1; min-width: 0; }
.row .meta b { display: block; font-weight: 550; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta code { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons */
.btn { border: 1px solid var(--line); background: transparent; color: var(--fg); border-radius: var(--r-sm); padding: 6px 13px; font: inherit; font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* forms */
.form { display: flex; flex-direction: column; gap: var(--s3); }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); }
input, select { width: 100%; padding: 8px 11px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; font-size: 13.5px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.check { display: flex; align-items: center; gap: var(--s2); color: var(--fg); font-size: 13px; cursor: pointer; }
.check input { width: auto; accent-color: var(--accent); }
.check em { color: var(--faint); font-style: normal; }
.actions { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); }

/* people / timeline */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--fg); font: inherit; font-size: 13px; cursor: pointer; transition: border-color .15s, color .15s; }
.chip:hover { border-color: var(--accent); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 168px 1fr; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.tl:last-child { border-bottom: 0; }
.tl .t { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.tl .c { font-weight: 550; }

/* events */
.events { display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 168px 96px 1fr; gap: var(--s3); align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ev:last-child { border-bottom: 0; }
.ev.sr { grid-template-columns: 168px 96px 1fr auto; }
.ev.al { grid-template-columns: 150px 118px 1fr auto auto auto; position: relative; cursor: pointer; padding-left: 10px; }
.ev.al .ev-type { display: inline-flex; align-items: center; gap: 6px; }
.ev-count { font-size: 11px; font-weight: 800; color: var(--danger); }
.ev-cand { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 6px;
           color: var(--muted); border: 1px solid var(--line); opacity: 0.85; }
.ev-ref { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 6px;
          color: var(--accent); border: 1px solid color-mix(in oklch, var(--accent) 40%, transparent); }
.ev-age { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ev-age.over { color: #fff; background: var(--danger); padding: 1px 6px; border-radius: 6px; font-weight: 700; }
/* full-height severity band down the left edge of an alert-severity incident */
.ev.al.sev-alert::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--danger); border-radius: 2px; }
.ev.al.sev-warn::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--warn, oklch(0.8 0.15 85)); border-radius: 2px; }
.ev.al.sel { background: var(--accent-dim); outline: 1px solid var(--accent); border-radius: 6px; }
.ev.al.overdue { background: var(--danger); background: color-mix(in oklch, var(--danger) 10%, transparent); }
.kbd-hint { margin: 2px 0 8px; }
.kbd-hint b { color: var(--fg); background: var(--panel-2); padding: 0 4px; border-radius: 4px; border: 1px solid var(--line); }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ev.al .st { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; }
.ev.al.st-new { background: oklch(0.8 0.15 85 / 0.07); }
.ev.al.st-new .st { color: var(--warn, oklch(0.8 0.15 85)); }
.ev.al.st-cleared { opacity: 0.55; }
.ev.al.st-ack .st, .ev.al.st-assigned .st { color: var(--accent); }
.al-actions { display: flex; gap: 6px; }
select.btn { padding-right: 8px; }
.map-canvas { position: relative; width: 100%; min-height: 220px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: oklch(0.22 0.01 250 / 0.5); }
.map-canvas .empty { padding: 60px 20px; text-align: center; }
.map-img { display: block; width: 100%; height: auto; }
.map-pin { position: absolute; transform: translate(-50%, -100%); cursor: pointer; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.map-pin span { background: var(--accent); color: var(--accent-fg); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.map-pin::after { content: "▾"; color: var(--accent); font-size: 20px; line-height: 0.7; margin-top: -1px; }
.map-pin:hover span { filter: brightness(1.12); }
.disc-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.disc-row:last-child { border-bottom: 0; }
.disc-row .hint { display: block; margin-top: 2px; }
.rule-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rule-add input { flex: 1; min-width: 150px; padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: transparent; color: var(--fg); font: inherit; font-size: 13px; }
.mask-editor { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: oklch(0 0 0 / 0.25); }
.mask-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--panel); font-size: 12px; }
.mask-surface { position: relative; flex: 1; cursor: crosshair; }
.mask-box { position: absolute; background: oklch(0 0 0 / 0.55); border: 1.5px solid var(--warn, oklch(0.8 0.15 85)); cursor: pointer; }
.mask-box:hover { background: oklch(0 0 0 / 0.72); }
.health-bar { height: 18px; border-radius: 999px; background: oklch(0.3 0.01 250 / 0.4); overflow: hidden; }
.health-bar > div { height: 100%; background: var(--accent); transition: width .3s, background .3s; min-width: 2px; }
.health-bar.warn > div { background: var(--warn, #e0a800); }
.health-bar.crit > div { background: var(--danger, #e03131); }
.ev .tag.off { background: oklch(0.4 0.01 250 / 0.3); color: var(--muted); }
.settings-panel { display: flex; flex-direction: column; max-width: 640px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); }
.set-row:last-child { border-bottom: 0; }
.set-row b { display: block; font-size: 14px; }
.set-row .hint { display: block; margin-top: 3px; }
.search-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin-bottom: 16px; }
.search-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.search-form input, .search-form select { padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-soft, transparent); color: var(--fg); font: inherit; font-size: 13px; }
.ev .t { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.ev .tag { justify-self: start; padding: 2px 9px; font-size: 11.5px; font-weight: 600; border-radius: 999px; background: var(--accent-dim); color: var(--accent); text-transform: uppercase; letter-spacing: 0.03em; }
.ev .tag.alert { background: oklch(0.66 0.19 25 / 0.16); color: var(--danger); }
.ev .tag.warn { background: oklch(0.78 0.13 78 / 0.16); color: var(--warn); }

/* processes */
.proc-group { margin-bottom: var(--s4); }
.proc-group .cnt { color: var(--muted); font-weight: 400; font-size: 12px; }
.tag-accel { padding: 1px 8px; font-size: 11px; font-family: var(--mono); background: var(--bg); border: 1px solid var(--line-soft); border-radius: 5px; color: var(--muted); margin-left: 6px; }

/* accel options */
.opts { display: flex; flex-direction: column; gap: var(--s2); }
.opt { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--fg); font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover:not(.disabled) { border-color: var(--accent); }
.opt.active { border-color: var(--accent); background: var(--accent-dim); }
.opt.disabled { opacity: .5; cursor: not-allowed; }
.opt b { font-weight: 600; font-size: 13.5px; }
.opt .note { font-size: 11.5px; color: var(--muted); }

/* cameras table (at scale) */
.cam-search { width: 190px; padding: 6px 10px; font-size: 13px; }
#cam-group-filter { width: auto; padding: 6px 10px; font-size: 13px; }
.tablewrap { padding: 0; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px var(--s3); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px var(--s3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl .chk { width: 34px; }
.tbl .chk input, .tbl thead .chk input { accent-color: var(--accent); }
.tbl .st { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.tbl .st.on { background: var(--live); box-shadow: 0 0 8px var(--live); }
.tbl td.src { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.src code { color: var(--muted); }
.tbl td.act { text-align: right; white-space: nowrap; }
.bulkbar { display: flex; align-items: center; gap: var(--s2); padding: 8px var(--s4); margin-bottom: var(--s3); background: var(--accent-dim); border: 1px solid var(--accent); border-radius: var(--r); font-size: 13px; }
.drawer { margin-top: var(--s4); max-width: 560px; }

/* login overlay */
.login-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--bg); }
.login-card { width: 320px; max-width: 90vw; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s6); display: flex; flex-direction: column; gap: var(--s3); box-shadow: var(--shadow); }
.login-brand { font-weight: 700; font-size: 16px; }
.login-card h2 { margin: 0 0 var(--s2); }
.login-card .btn { margin-top: var(--s2); text-align: center; padding: 9px; }

/* sidebar user */
.side-user { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s2) 0; margin-top: var(--s3); border-top: 1px solid var(--line-soft); }
.side-user .su-info { flex: 1; min-width: 0; }
.side-user .su-info b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* role gating — hide admin/config nav for operator & viewer */
body:not([data-role="admin"]):not([data-role="owner"]) .need-config,
body:not([data-role="admin"]):not([data-role="owner"]) .need-users,
body:not([data-role="admin"]):not([data-role="owner"]) .need-audit { display: none !important; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; padding-top: 0; }
  .main { padding: var(--s4); }
  #tab-live { height: auto; }
  .wall-layout { grid-template-columns: 1fr; height: auto; }
  .tree { max-height: 180px; }
  .grid { aspect-ratio: 16 / 9; }
  .split, .split.narrow-left { grid-template-columns: 1fr; }
  .grid.g8 { grid-template-columns: repeat(2, 1fr); }
}

/* phones: single-column everything, wrapping bars, scrollable wide tables */
@media (max-width: 560px) {
  .main { padding: 12px; }
  .bar { flex-wrap: wrap; gap: 8px; row-gap: 6px; }
  .bar h1 { font-size: 18px; }
  .bar .sub { flex-basis: 100%; }
  .grid, .grid.g2, .grid.g4, .grid.g8 { grid-template-columns: 1fr; }  /* one tile per row */
  .grid { aspect-ratio: auto; }
  .timeline-bar { flex-wrap: wrap; row-gap: 8px; }
  .tl-track { order: 3; flex-basis: 100%; }
  .tablewrap { overflow-x: auto; }
  .tbl { min-width: 620px; }                       /* wide tables scroll instead of squashing */
  .nav-item { font-size: 12px; padding: 6px 9px; }
  .ev, .ev.sr, .ev.al { grid-template-columns: 1fr; gap: 4px; align-items: start; }
  .ev .tag, .ev .st { justify-self: start; }
  .al-actions, .disc-row { flex-wrap: wrap; }
  .search-form, .rule-add { flex-direction: column; align-items: stretch; }
  .search-form label, .search-form input, .search-form select, .rule-add input { width: 100%; }
  .set-row { flex-wrap: wrap; row-gap: 8px; }
  .cam-search { width: 100%; }
}
.chip.watched { border-color: var(--warn, oklch(0.8 0.15 85)); color: var(--warn, oklch(0.8 0.15 85)); font-weight: 600; }

/* ---------- global alarm badge + toasts ---------- */
.nav-badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  color: #fff; background: var(--danger); border-radius: 9px;
  animation: badge-pulse 1.6s ease-in-out infinite;
}
.nav-badge[hidden] { display: none; }
@keyframes badge-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--fg, #fff); background: var(--panel-2); border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgb(0 0 0 / 0.35);
  opacity: 0; transform: translateX(24px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.alert {
  color: #fff; background: var(--danger); border-color: var(--danger);
}
@media (prefers-reduced-motion: reduce) {
  .nav-badge { animation: none; }
  .toast { transition: opacity .2s; transform: none; }
}

.search-presets { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }

/* ---------- operations dashboard (exception-first) ---------- */
.dash-stale { font-size: 12px; color: var(--faint); font-family: var(--mono); }
.dash-stale.warn { color: var(--warn); font-weight: 700; }

/* 3 primary exception KPIs — large, hierarchy on top */
.kpi-primary { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s3); }
.pkpi { position: relative; background: var(--panel); border: 1px solid var(--line-soft); border-left: 4px solid var(--line);
        border-radius: var(--r-lg); padding: var(--s4) var(--s5); }
.pk-v { font-family: var(--mono); font-size: 46px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; color: var(--fg); }
.pk-l { margin-top: 10px; font-size: 15px; font-weight: 700; color: var(--fg); }
.pk-s { margin-top: 3px; font-size: 13px; color: var(--muted); }
.pkpi.ok { border-left-color: var(--live); }
.pkpi.warn { border-left-color: var(--warn); }
.pkpi.warn .pk-v { color: var(--warn); }
.pkpi.crit { border-left-color: var(--danger); background: color-mix(in oklch, var(--danger) 8%, var(--panel)); }
.pkpi.crit .pk-v { color: var(--danger); }
.pkpi.crit { animation: kpi-pulse 1.8s ease-in-out infinite; }
@keyframes kpi-pulse { 50% { border-left-color: color-mix(in oklch, var(--danger) 45%, transparent); } }

/* secondary metrics — smaller strip */
.kpi-secondary { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.skpi { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--r); padding: var(--s3) var(--s4); }
.sk-v { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--fg); }
.sk-v .of { font-size: 14px; color: var(--faint); }
.sk-l { margin-top: 3px; font-size: 12px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); align-items: start; }
@media (max-width: 980px) {
  .kpi-primary, .kpi-secondary { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

/* camera EXCEPTION list — problems stand OUT (never faded); healthy folded */
.cam-status { display: flex; flex-direction: column; gap: 2px; }
.camrow { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: var(--s3);
          padding: 10px var(--s3); border-radius: var(--r-sm); font-size: 14px; border-left: 3px solid transparent; }
.camrow.crit { background: color-mix(in oklch, var(--danger) 12%, transparent); border-left-color: var(--danger); }
.camrow.warn { background: color-mix(in oklch, var(--warn) 12%, transparent); border-left-color: var(--warn); }
.camrow .cs { font-size: 11px; font-weight: 800; letter-spacing: 0.03em; }
.camrow.crit .cs { color: var(--danger); }
.camrow.warn .cs { color: var(--warn); }
.camrow .cn { font-weight: 650; }
.camrow .csub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.camrow .rp { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 6px; background: var(--accent-dim); color: var(--accent); }
.camrow .ca { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--danger); }
.ok-note { color: var(--live); font-weight: 600; font-size: 13.5px; padding: 6px 4px; }
.ok-fold { margin-top: 8px; font-size: 12.5px; color: var(--faint); padding: 6px 4px; border-top: 1px solid var(--line-soft); }

/* alarm sparkline — zero baseline (0 = nothing), last bar accented */
.spark { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 92px; padding: var(--s2) 0 0;
         border-bottom: 1px solid var(--line-soft); margin-bottom: var(--s3); }
.spark .bar { flex: 1; background: linear-gradient(var(--accent), color-mix(in oklch, var(--accent) 40%, transparent)); border-radius: 2px 2px 0 0; transition: height .3s; }
.spark .bar.now { background: linear-gradient(var(--warn), color-mix(in oklch, var(--warn) 40%, transparent)); }
.spark-now { position: absolute; top: 0; right: 0; font-size: 11px; color: var(--faint); font-family: var(--mono); }
.dash-types { display: flex; flex-direction: column; gap: 8px; }
.trow { display: grid; grid-template-columns: 68px 34px 1fr 46px; align-items: center; gap: var(--s2); font-size: 13px; }
.trow .tsev { font-size: 11px; font-weight: 700; color: var(--muted); }
.trow .tbar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.trow .tbar i { display: block; height: 100%; background: var(--muted); border-radius: 4px; }
.trow .tbar i.alert { background: var(--danger); }
.trow .tbar i.warn { background: var(--warn); }
.trow b { font-family: var(--mono); text-align: right; color: var(--fg); font-size: 12px; }
.trow .topen { color: var(--danger); }

/* a live-wall tile whose camera has an unacked critical alarm */
.tile.alarm { outline: 2px solid var(--danger); outline-offset: -2px; animation: tile-alarm 1.1s ease-in-out infinite; z-index: 2; }
.tile.alarm::after { content: "⚠ 알람"; position: absolute; top: 8px; left: 8px; z-index: 3;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em; color: #fff; background: var(--danger);
  padding: 2px 7px; border-radius: 6px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.4); }
@keyframes tile-alarm { 50% { outline-color: color-mix(in oklch, var(--danger) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { .tile.alarm, .pkpi.crit { animation: none; } }

/* ---------- cross-camera journey (investigation) ---------- */
.journey-sum { margin: 0 0 12px; font-family: var(--mono); font-size: 12px; }
.vitals { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; margin-bottom: 14px;
          background: color-mix(in oklch, var(--danger) 8%, var(--panel)); border: 1px solid var(--line-soft);
          border-left: 3px solid var(--danger); border-radius: var(--r); }
.vitals .hr { font-family: var(--mono); font-size: 22px; font-weight: 800; color: var(--danger); }
.vitals .hr small { font-size: 12px; font-weight: 500; }
.vitals .hr.rmssd { font-size: 16px; font-weight: 700; color: var(--accent); }
.vitals .lowq { color: var(--warn); font-weight: 700; margin-left: 4px; }
.journey { position: relative; padding-left: 6px; }
.jnode { display: grid; grid-template-columns: 16px 1fr; gap: 12px; align-items: start; }
.jnode .jdot { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; border: 2px solid var(--bg); }
.jnode.face .jdot { background: var(--live); box-shadow: 0 0 0 3px color-mix(in oklch, var(--live) 25%, transparent); }
.jnode.body .jdot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in oklch, var(--warn) 22%, transparent); }
.jbody { padding-bottom: 4px; }
.jcam { font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.jmeta { font-size: 12px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }
.conf { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 8px; letter-spacing: 0.02em; }
.conf.face { color: var(--live); background: color-mix(in oklch, var(--live) 15%, transparent); }
.conf.body { color: var(--warn); background: color-mix(in oklch, var(--warn) 15%, transparent); }
.jhop { margin: 2px 0 6px 22px; padding-left: 6px; font-size: 11.5px; color: var(--faint);
        border-left: 2px dashed var(--line); font-family: var(--mono); }

.journey { list-style: none; margin: 0; padding-left: 6px; }
.conf.unknown { color: var(--faint); background: color-mix(in oklch, var(--faint) 15%, transparent); }
.jnode.unknown .jdot { background: var(--faint); box-shadow: 0 0 0 3px color-mix(in oklch, var(--faint) 20%, transparent); }
.jhop.overlap { color: var(--muted); border-left-style: dotted; }
.jnode time { font-family: var(--mono); }

.tile .cap .cap-grp { font-size: 10px; color: var(--faint); background: color-mix(in oklch, var(--bg) 55%, transparent); padding: 0 5px; border-radius: 4px; }

.conf.track { color: var(--muted); background: color-mix(in oklch, var(--muted) 12%, transparent); }
.jnode.track .jdot { background: var(--muted); box-shadow: 0 0 0 3px color-mix(in oklch, var(--muted) 18%, transparent); }
.jnode { cursor: pointer; border-radius: var(--r-sm); transition: background .12s; }
.jnode:hover, .jnode:focus-visible { background: var(--panel-2); outline: none; }
.jgo { color: var(--accent); font-size: 11px; opacity: 0; transition: opacity .12s; margin-left: 6px; }
.jnode:hover .jgo, .jnode:focus-visible .jgo { opacity: 1; }

/* incident-command: lifecycle trail + resolution disposition */
.ev.al .lifecycle { display: block; font-size: 11px; color: var(--faint); font-family: var(--mono); margin-top: 2px; }
.dispo { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 6px; }
.dispo.genuine { color: #fff; background: var(--danger); }
.dispo.false { color: var(--muted); border: 1px solid var(--line); }
.dispo.handled { color: var(--live); background: color-mix(in oklch, var(--live) 15%, transparent); }
.ev.al.st-dispatched { background: color-mix(in oklch, var(--accent) 6%, transparent); }
.ev.al.st-on_scene .st { color: var(--accent); }

/* ---------- person search (find a missing person by photo) ---------- */
.person-search { margin-bottom: var(--s4); }
.person-search h2 .hint { font-weight: 400; margin-left: 6px; }
.ps-row { display: flex; align-items: center; gap: var(--s3); margin: var(--s3) 0; flex-wrap: wrap; }
.ps-row input[type=file] { font-size: 13px; color: var(--muted); }
.ps-results { display: flex; flex-direction: column; gap: 8px; }
.ps-cand { display: grid; grid-template-columns: 68px 1fr auto; align-items: center; gap: var(--s3);
  width: 100%; text-align: left; padding: 10px var(--s3); border: 1px solid var(--line-soft);
  border-radius: var(--r); background: var(--panel); color: var(--fg); cursor: pointer; transition: border-color .12s, background .12s; }
.ps-cand:hover, .ps-cand:focus-visible { border-color: var(--accent); background: var(--panel-2); outline: none; }
.ps-score { text-align: center; }
.ps-score b { font-family: var(--mono); font-size: 22px; font-weight: 800; color: var(--accent); display: block; line-height: 1; }
.ps-score small { font-size: 10px; color: var(--faint); }
.ps-hd { font-weight: 650; font-size: 14px; }
.ps-mode { color: var(--accent); font-weight: 700; }
.ps-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.ps-go { color: var(--accent); font-size: 12px; white-space: nowrap; }

.nav-sec { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--faint);
  text-transform: uppercase; padding: 14px 12px 5px; }
.nav-sec:first-child { padding-top: 4px; }

/* ---------- 상황판: 지금 조치할 사건 (command cards) ---------- */
.command-cards { margin-bottom: var(--s4); }
.cmd-h { font-size: 15px; font-weight: 700; color: var(--danger); margin-bottom: var(--s3); }
.cmd-h.ok { color: var(--live); }
.cmd-h b { font-family: var(--mono); }
.cmd-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s3); }
.cmd-card { background: color-mix(in oklch, var(--danger) 8%, var(--panel)); border: 1px solid var(--line-soft);
  border-left: 4px solid var(--danger); border-radius: var(--r-lg); padding: var(--s3) var(--s4); }
.cmd-card.over { animation: kpi-pulse 1.6s ease-in-out infinite; }
.cmd-top { display: flex; align-items: center; justify-content: space-between; }
.cmd-age { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.cmd-age.over { color: #fff; background: var(--danger); padding: 1px 6px; border-radius: 6px; font-weight: 700; }
.cmd-cam { font-size: 16px; font-weight: 700; margin: 8px 0 10px; }
.cmd-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.cmd-acts .btn { flex: 1; min-width: 52px; }
@media (prefers-reduced-motion: reduce) { .cmd-card.over { animation: none; } }

/* ---------- task modal (replaces browser prompt/confirm) ---------- */
.modal-back { position: fixed; inset: 0; z-index: 1100; background: oklch(0 0 0 / 0.55);
  display: grid; place-items: center; padding: var(--s4); animation: mb-in .15s ease; }
@keyframes mb-in { from { opacity: 0; } }
.modal { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: 0 20px 60px oklch(0 0 0 / 0.5); padding: var(--s5); }
.modal h3 { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.mf-desc { color: var(--muted); font-size: 13px; margin: 0 0 var(--s4); }
.mf-body { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s5); }
.mf-l { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.modal input[type=text], .modal textarea { width: 100%; padding: 9px 11px; font: inherit; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--fg); }
.modal input:focus, .modal textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.mf-radios { display: flex; flex-direction: column; gap: 7px; }
.mf-radio { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.mf-radio input { accent-color: var(--accent); }
.modal-acts { display: flex; justify-content: flex-end; gap: var(--s2); }
@media (prefers-reduced-motion: reduce) { .modal-back { animation: none; } }

/* ---------- DVR timeline event markers + playback situation readout ---------- */
.tl-track { position: relative; }
.tl-mark { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; border-radius: 2px;
  background: var(--muted); cursor: pointer; z-index: 2; opacity: 0.85; }
.tl-mark:hover { opacity: 1; transform: scaleX(1.6); }
.tl-mark.sev-alert { background: var(--danger); }
.tl-mark.sev-warn { background: var(--warn); }
.tl-mark.sev-info { background: var(--accent); }
.tl-situation { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 6px; white-space: nowrap;
  color: #fff; background: var(--muted); }
.tl-situation.sev-alert { background: var(--danger); }
.tl-situation.sev-warn { background: var(--warn); color: #1a1a1a; }
.tl-situation.sev-info { background: var(--accent); }
.tl-situation[hidden] { display: none; }

/* buttons never wrap their label (출동/새로고침 등) */
.btn { white-space: nowrap; }
.cmd-acts .btn { min-width: 60px; padding-left: 8px; padding-right: 8px; }

/* ---------- 가이드 투어 (CCTV 데모 에이전트) ---------- */
.tour-launch {
  margin: 10px 12px 4px; padding: 9px 12px; width: calc(100% - 24px);
  background: linear-gradient(180deg, var(--accent), oklch(0.60 0.13 233));
  color: #fff; border: 0; border-radius: 9px; font-weight: 700; font-size: 13px;
  cursor: pointer; letter-spacing: .2px; box-shadow: 0 2px 10px oklch(0.70 0.125 233 / 0.35);
}
.tour-launch:hover { filter: brightness(1.08); }
.tour { position: fixed; inset: 0; z-index: 3000; pointer-events: none; }
.tour.hidden { display: none; }
.tour::before {                                   /* soft dim so the card reads, screen still visible */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 100%, oklch(0 0 0 / 0.42), oklch(0 0 0 / 0.12));
}
.tour-card {
  pointer-events: auto; position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%);
  width: min(520px, calc(100vw - 40px)); background: var(--panel); color: var(--fg);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 16px;
  box-shadow: 0 18px 50px oklch(0 0 0 / 0.5), 0 0 0 1px oklch(0.70 0.125 233 / 0.15);
  animation: tourPop .28s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes tourPop { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.tour-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tour-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: oklch(0.62 0.14 150 / 0.18); color: oklch(0.72 0.15 150); }
.tour-badge.seed { background: oklch(0.70 0.125 233 / 0.18); color: var(--accent); }
.tour-badge.soon { background: var(--warn, oklch(0.66 0.14 70) / 0.18); color: var(--warn, oklch(0.72 0.14 70)); }
.tour-step { font-size: 12px; color: var(--muted); }
.tour-x { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 4px; }
.tour-x:hover { color: var(--fg); }
.tour-card h3 { margin: 2px 0 6px; font-size: 17px; }
.tour-card p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.tour-dots { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); cursor: pointer; transition: background .2s, transform .2s; }
.tour-dots i.on { background: var(--accent); transform: scale(1.25); }
.tour-dots i.done { background: oklch(0.62 0.14 150); }
.tour-acts { display: flex; align-items: center; gap: 8px; }
/* spotlight the real UI element the current tour step is narrating — page underneath stays fully
   clickable (outline/box-shadow don't affect hit-testing), click on it advances the tour itself. */
.tour-target { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px;
  animation: tour-target-pulse 1.4s ease-in-out infinite; }
@keyframes tour-target-pulse {
  50% { outline-color: color-mix(in oklch, var(--accent) 30%, transparent);
        box-shadow: 0 0 0 6px color-mix(in oklch, var(--accent) 14%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .tour-target { animation: none; } }
/* brief "got it" acknowledgment right after the user clicks the spotlighted element, before the
   tour advances to the next step (see _tourHighlight's click handler) */
.tour-target.tour-target-hit { animation: none; outline-color: oklch(0.62 0.14 150); }
.btn.sm.ghost { background: transparent; }

/* read-only viewer: hide write/command controls so they never 403 in the partner's face */
body[data-role="viewer"] .wbtn { display: none !important; }
/* DVR: seeking before the live recording buffer began (seeded past events) — a labelled
   notice instead of a frozen/no-signal tile that reads as a broken product */
.tile .archive-gap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 0 18px; background: oklch(0.12 0.006 250 / 0.86);
  color: var(--muted); font-size: 12.5px; line-height: 1.6; z-index: 4;
}
.tile .archive-gap b { color: var(--fg); display: block; margin-bottom: 4px; font-size: 13px; }

/* AI 요약 — deterministic metadata narration (no vision model, no hallucination) */
.ai-sum { margin-top: 6px; font-size: 12.5px; color: var(--fg); line-height: 1.5;
  background: var(--accent-dim); border-left: 2px solid var(--accent);
  padding: 6px 9px; border-radius: 0 6px 6px 0; }
.cmd-card .ai-sum { margin: 6px 0 8px; }
.ai-tag { font-size: 10px; font-weight: 700; color: var(--accent); margin-right: 6px;
  text-transform: uppercase; letter-spacing: .04em; vertical-align: 1px; }

/* incident command-card thumbnail — the moment at a glance (like a real VMS) */
.cmd-thumb { position: relative; margin: -2px -2px 8px; height: 92px; border-radius: 8px 8px 0 0;
  overflow: hidden; background: var(--video); }
.cmd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cmd-thumb-cam { position: absolute; left: 6px; bottom: 5px; font-size: 10.5px; font-weight: 600;
  color: #fff; background: oklch(0 0 0 / 0.55); padding: 1px 6px; border-radius: 4px; }

/* selected live tile — the DVR timeline / bookmarks target this camera */
.tile.filled.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.tile.filled.sel::after { content: "선택"; position: absolute; top: 6px; left: 6px; z-index: 3;
  font-size: 10px; font-weight: 700; color: var(--accent-fg); background: var(--accent);
  padding: 1px 6px; border-radius: 4px; }

/* ---------- Uface AI brand ---------- */
.brand .logo { color: var(--accent); font-size: 17px; }
.brand .name { font-weight: 720; letter-spacing: -0.01em; }
.brand-ai { color: var(--accent); font-weight: 800; margin-left: 2px; }
.login-brand { font-size: 20px; font-weight: 720; }
.login-brand .brand-ai { font-size: 20px; }
.login-tag { color: var(--muted); font-size: 12.5px; margin: 4px 0 14px; }

/* persistent demo-data indicator (only when the data dir is a seeded demo) */
.demo-chip { display: none; }
body.is-demo .demo-chip { display: inline-block; margin-left: 6px; font-size: 9.5px; font-weight: 700;
  letter-spacing: .02em; color: var(--warn); border: 1px solid var(--warn); border-radius: 999px;
  padding: 1px 6px; vertical-align: 2px; opacity: .85; }

/* person-search honesty disclaimer */
.ps-disclaimer { font-size: 11.5px; color: var(--warn); background: oklch(0.66 0.14 70 / 0.1);
  border-left: 2px solid var(--warn); padding: 7px 10px; border-radius: 0 6px 6px 0; margin: 0 0 10px; line-height: 1.5; }
