﻿/* ═══════════════════════════════════════════════════════════════
   style.css — RTSP Camera Monitor & YOLO Analyzer
   Dark / Light theme via CSS custom properties on [data-theme]
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

/* ── Theme variables ────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg-primary:    #060d1f;
  --bg-secondary:  #0a1628;
  --bg-card:       rgba(13,27,53,0.82);
  --bg-card-solid: #0d1b35;
  --bg-card-hover: rgba(20,40,80,0.9);
  --bg-input:      rgba(6,13,31,0.95);
  --text-primary:  #e2eaf5;
  --text-secondary:#7da0c4;
  --text-muted:    #3d5a80;
  --accent:        #0ea5e9;
  --accent-hover:  #0284c7;
  --accent-light:  rgba(14,165,233,0.13);
  --accent-glow:   rgba(14,165,233,0.4);
  --danger:        #ef4444;
  --danger-hover:  #dc2626;
  --danger-light:  rgba(239,68,68,0.13);
  --success:       #22c55e;
  --success-hover: #16a34a;
  --success-light: rgba(34,197,94,0.12);
  --warning:       #f59e0b;
  --warning-hover: #d97706;
  --warning-light: rgba(245,158,11,0.12);
  --border:        rgba(255,255,255,0.07);
  --border-light:  rgba(255,255,255,0.03);
  --border-glow:   rgba(14,165,233,0.3);
  --shadow:        0 8px 32px rgba(0,0,0,0.65);
  --shadow-sm:     0 2px 16px rgba(0,0,0,0.45);
  --shadow-glow:   0 0 24px rgba(14,165,233,0.18);
  --navbar-bg:     #040b18;
  --sidebar-bg:    #040b18;
  --sidebar-width: 220px;
  --sidebar-col:   64px;
  --topbar-h:      52px;
  --radius:        10px;
  --scrollbar-bg:  #0a1628;
  --scrollbar-thumb: #1e3a5f;
  --overlay-bg:    rgba(0,0,0,0.78);
  color-scheme: dark;
  /* C2: spacing / radius / shadow design tokens */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;  --space-4: 16px;  --space-6: 24px;
  --radius-sm: 4px; --radius-lg: 12px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.2);
  --shadow-2: 0 4px 12px rgba(0,0,0,.25);
}

[data-theme="light"] {
  --bg-primary:    #edf2f8;
  --bg-secondary:  #dde5f0;
  --bg-card:       rgba(255,255,255,0.9);
  --bg-card-solid: #ffffff;
  --bg-card-hover: #f4f7fb;
  --bg-input:      #ffffff;
  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --accent:        #0284c7;
  --accent-hover:  #0369a1;
  --accent-light:  rgba(2,132,199,0.10);
  --accent-glow:   rgba(2,132,199,0.25);
  --danger:        #dc2626;
  --danger-hover:  #b91c1c;
  --danger-light:  rgba(220,38,38,0.10);
  --success:       #16a34a;
  --success-hover: #15803d;
  --success-light: rgba(22,163,74,0.10);
  --warning:       #d97706;
  --warning-hover: #b45309;
  --warning-light: rgba(217,119,6,0.10);
  --border:        rgba(0,0,0,0.10);
  --border-light:  rgba(0,0,0,0.05);
  --border-glow:   rgba(2,132,199,0.25);
  --shadow:        0 4px 20px rgba(0,0,0,0.12);
  --shadow-sm:     0 2px 8px  rgba(0,0,0,0.07);
  --shadow-glow:   0 0 20px rgba(2,132,199,0.12);
  --navbar-bg:     #1e293b;
  --sidebar-bg:    #1e293b;
  --sidebar-width: 220px;
  --sidebar-col:   64px;
  --topbar-h:      52px;
  --radius:        10px;
  --scrollbar-bg:  #e2e8f0;
  --scrollbar-thumb: #94a3b8;
  --overlay-bg:    rgba(0,0,0,0.55);
  color-scheme: light;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb  { background: var(--scrollbar-thumb); border-radius: 3px; }

/* ── Base ────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.25s, color 0.25s;
}
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 90% 40% at 50% -5%, rgba(14,165,233,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 40% 50% at 100% 75%, rgba(99,102,241,0.05) 0%, transparent 50%);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 150;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1.25rem;
  height: var(--topbar-h);
  background: rgba(4,11,24,0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}
[data-theme="light"] .topbar { background: rgba(30,41,59,0.97); }
.topbar-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 1.2rem;
  padding: 0.3rem 0.5rem; border-radius: 6px; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.topbar-menu-btn:hover { background: var(--accent-light); color: var(--text-primary); }
.topbar-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); flex: 1; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.55rem; }
.topbar-icon-btn {
  position: relative;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  cursor: pointer; font-size: 1rem; padding: 0.38rem 0.55rem;
  border-radius: 8px; color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: inline-flex; align-items: center; gap: 0.2rem;
}
.topbar-icon-btn:hover {
  background: var(--accent-light); color: var(--text-primary); border-color: var(--border-glow);
}
.topbar-badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: #fff;
  border-radius: 999px; padding: 0 4px;
  font-size: 0.6rem; font-weight: 700; min-width: 16px;
  height: 16px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #040b18;
}
/* Keep .navbar-clock IDs wired in app.js */
.navbar-clock {
  display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1.15; user-select: none;
}
.navbar-clock-time {
  font-size: 0.9rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--text-primary); font-variant-numeric: tabular-nums;
}
.navbar-clock-date { font-size: 0.65rem; color: var(--text-muted); letter-spacing: 0.02em; }
/* Keep .btn-icon for modals/forms */
.btn-icon {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.1rem; padding: 0.35rem; border-radius: 6px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--accent-light); color: var(--text-primary); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1rem; border-radius: 7px; border: none;
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent);   color: #fff; }
.btn-primary:hover   { background: var(--accent-hover); }
.btn-secondary { background: var(--border);   color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-card-hover); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover    { background: var(--danger-hover); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover   { background: var(--success-hover); }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-warning:hover   { background: var(--warning-hover); }
.btn-sm        { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-icon {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.1rem; padding: 0.35rem; border-radius: 6px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--accent-light); color: var(--text-primary); }
.btn-group { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* ── App shell (wraps topbar + main, offset by sidebar) ─────── */
.app-shell {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left 0.25s ease;
  position: relative; z-index: 1;
}
body.sidebar-collapsed .app-shell { margin-left: var(--sidebar-col); }
/* ── Main content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 1.5rem 1.5rem 3rem;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-actions { display: flex; gap: 0.5rem; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-sm), 0 0 20px rgba(14,165,233,0.06);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.form-row {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start;
}
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.flex-1 { flex: 1; min-width: 150px; }
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); }
.form-input {
  padding: 0.45rem 0.75rem; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-primary);
  font-size: 0.875rem; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-range {
  width: 100%; accent-color: var(--accent); cursor: pointer;
}
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.help-text { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; cursor: pointer; gap: 0.5rem; }
.toggle input { display: none; }
.toggle-slider {
  width: 40px; height: 22px; background: var(--border);
  border-radius: 11px; position: relative; transition: background 0.2s;
}
.toggle-slider::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; top: 3px; left: 3px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); }

/* ── Badge ───────────────────────────────────────────────────── */
.badge {
  padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.75rem;
  font-weight: 600; background: var(--accent-light); color: var(--accent);
}
.badge-info   { background: rgba(56,189,248,0.15); color: #38bdf8; }
.badge-sdk    { background: rgba(249,115,22,0.15);  color: #f97316; font-size: 0.68rem; vertical-align: middle; }
.badge-online { background: rgba(34,197,94,0.15);   color: #22c55e; }
.badge-offline{ background: rgba(107,114,128,0.15); color: #6b7280; }

/* ── NVR device cards ─────────────────────────────────────────── */
.nvr-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 0.5rem; background: var(--bg-body);
}
.nvr-card-info   { flex: 1; min-width: 0; }
.nvr-card-name   { font-weight: 600; font-size: 0.95rem; }
.nvr-card-meta   { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.nvr-card-actions{ display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ── Channel grid ─────────────────────────────────────────────── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.channel-card {
  border: 2px solid var(--border); border-radius: 8px; overflow: hidden;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bg-body);
}
.channel-card:hover          { border-color: var(--accent); }
.channel-card.ch-selected    { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.channel-card.ch-added       { border-color: #22c55e; }
.channel-card-thumb {
  position: relative; width: 100%; aspect-ratio: 16/9;
  background: #111; overflow: hidden;
}
.channel-card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.channel-card-thumb .ch-status-dot {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.4);
}
.ch-status-dot.online  { background: #22c55e; }
.ch-status-dot.offline { background: #6b7280; }
.ch-status-dot.loading { background: #f59e0b; animation: pulse 1s infinite; }
.channel-card-body {
  padding: 0.4rem 0.5rem;
}
.channel-card-title {
  font-size: 0.78rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.channel-card-sub {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 1px;
}
.channel-card-footer {
  display: flex; align-items: center; gap: 4px; padding: 0 0.5rem 0.4rem;
}
.channel-card-footer label {
  font-size: 0.72rem; display: flex; align-items: center; gap: 3px; cursor: pointer;
}
.ch-preview-btn {
  margin-left: auto; padding: 2px 6px; font-size: 0.7rem;
  border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  cursor: pointer; flex-shrink: 0;
}
.ch-preview-btn:hover { border-color: var(--accent); color: var(--accent); }
.ch-thumb-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; color: var(--text-muted); font-size: 1.5rem;
}

/* ── Dashboard ───────────────────────────────────────────────── */
.controls-bar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem; margin-bottom: 1rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; flex-wrap: wrap;
}
.controls-left, .controls-right { display: flex; align-items: center; gap: 0.5rem; }
.controls-center { flex: 1; text-align: center; color: var(--text-secondary); font-size: 0.875rem; }
.label { font-size: 0.82rem; color: var(--text-secondary); }
.btn-layout {
  padding: 0.3rem 0.65rem; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  font-size: 0.8rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.btn-layout:hover, .btn-layout.active {
  background: var(--accent-light); color: var(--accent);
  border-color: var(--accent);
}

/* Camera grid */
.camera-grid {
  display: grid; gap: 10px;
}
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Camera tile */
.camera-tile {
  position: relative; background: #000;
  border-radius: 10px; overflow: hidden;
  border: 2px solid var(--border);
  aspect-ratio: 16/9;
  transition: border-color 0.2s;
}
.camera-tile:hover { border-color: var(--accent); }
.camera-tile.detecting { border-color: var(--warning); }
.camera-tile canvas { width: 100%; height: 100%; display: block; }

/* Tile overlays */
.tile-overlay-top,
.tile-overlay-bottom {
  position: absolute; left: 0; right: 0;
  display: flex; align-items: center;
  padding: 6px 8px; gap: 6px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: none;
}
.tile-overlay-top    { top: 0; }
.tile-overlay-bottom {
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  pointer-events: auto; justify-content: space-between;
}
.tile-cam-name { font-size: 0.8rem; font-weight: 600; color: #fff; text-shadow: 0 1px 3px #000; flex: 1; }
.tile-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.dot-online    { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-offline   { background: var(--danger); }
.dot-detecting { background: var(--warning); box-shadow: 0 0 6px var(--warning); animation: pulse 1.5s infinite; }
.dot-inactive  { background: var(--text-muted); }
.tile-fps      { font-size: 0.7rem; color: #aaa; }
.tile-ai-badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.03em;
  background: rgba(99,102,241,0.85); color: #fff;
  border-radius: 3px; padding: 1px 4px;
  pointer-events: none; flex-shrink: 0;
  text-shadow: none; white-space: nowrap;
}
.tile-profile-badge {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.03em;
  background: rgba(16,185,129,0.85); color: #fff;
  border-radius: 3px; padding: 1px 5px;
  pointer-events: none; flex-shrink: 0;
  text-shadow: none; white-space: nowrap;
}
.tile-counts   { font-size: 0.72rem; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000; max-width: 60%; }
/* C3: CSS-driven count flash — replaces inline style colour toggling */
@keyframes tileCountsFlash {
  0%, 100% { color: #ff4444; }
  50%       { color: #ff8888; }
}
.tile-counts.flash { animation: tileCountsFlash 0.6s ease-in-out; }
/* Detect button always centred at bottom — independent of counts text length */
/* ── Per-camera state pill ──────────────────────────────────── */
.tile-cam-pill {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  z-index: 2; pointer-events: auto;
  display: flex; align-items: center; gap: 0;
  border-radius: 6px; overflow: hidden;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
  transition: background 0.2s;
}
/* idle = gray */
.tile-cam-pill.state-idle   { background: rgba(255,255,255,0.10); }
/* counting = blue */
.tile-cam-pill.state-counting { background: rgba(50,130,220,0.28); }
/* monitor = red */
.tile-cam-pill.state-monitor  { background: rgba(220,50,50,0.30); }

.pill-seg {
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem; font-weight: 600; color: #fff;
  cursor: pointer; white-space: nowrap;
  border: none; background: transparent;
  transition: background 0.15s;
  line-height: 1.4;
}
.pill-seg:hover { background: rgba(255,255,255,0.18); }
.tile-cam-pill.state-counting .pill-seg.pill-active { background: rgba(80,160,255,0.55); }
.tile-cam-pill.state-monitor  .pill-seg.pill-active { background: rgba(240,60,60,0.55); }
.pill-seg.pill-active { background: rgba(255,255,255,0.28); }
.pill-seg-divider {
  width: 1px; background: rgba(255,255,255,0.2); align-self: stretch;
}
.tile-btn-fullscreen {
  padding: 0.2rem 0.35rem; border-radius: 5px; border: none;
  font-size: 0.85rem; cursor: pointer;
  background: rgba(255,255,255,0.15); color: #fff;
  backdrop-filter: blur(2px);
}
.tile-no-signal {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #111; color: var(--text-muted); gap: 0.5rem;
}
.tile-no-signal-icon { font-size: 2rem; }
.tile-no-signal-text { font-size: 0.8rem; }
.tile-retry-btn {
  margin-top: 0.6rem; padding: 0.3rem 1rem;
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1); color: #fff;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(2px); transition: background 0.15s;
}
.tile-retry-btn:hover { background: rgba(255,255,255,0.28); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem 1rem; text-align: center; color: var(--text-muted);
  gap: 0.5rem;
}
.empty-icon  { font-size: 2.5rem; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-subtitle { font-size: 0.875rem; }

/* ── Camera list table ───────────────────────────────────────── */
.camera-table { width: 100%; border-collapse: collapse; }
.camera-table th, .camera-table td {
  padding: 0.65rem 0.75rem; text-align: left; font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}
.camera-table th { color: var(--text-secondary); font-weight: 600; }
.camera-table tr:last-child td { border-bottom: none; }
.camera-table tr:hover td { background: var(--bg-card-hover); }
.camera-draggable { cursor: grab; }
.camera-draggable.dragging { opacity: 0.5; }
.camera-table .camera-draggable.drag-over-top td { border-top: 2px solid var(--accent); }
.camera-table .camera-draggable.drag-over-bottom td { border-bottom: 2px solid var(--accent); }
.url-masked { font-family: monospace; font-size: 0.8rem; color: var(--text-secondary); }
.action-btns { display: flex; gap: 0.4rem; }
.cam-order-cell { display: inline-flex; align-items: center; gap: 0.4rem; }
.drag-handle { color: var(--text-muted); user-select: none; }
.camera-draggable:hover .drag-handle { color: var(--accent); }
.mode-badge {
  padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.72rem; font-weight: 600;
}
.mode-off  { background: var(--border); color: var(--text-muted); }
.mode-roi  { background: var(--accent-light); color: var(--accent); }
.mode-line { background: var(--success-light); color: var(--success); }
.mode-both { background: var(--warning-light); color: var(--warning); }

/* ── Camera list — name cell with thumbnail ─────────────────── */
.cam-name-cell { display: flex; align-items: center; gap: 0.55rem; }
.cam-thumb {
  width: 60px; height: 42px; object-fit: cover;
  border-radius: 5px; border: 1px solid var(--border);
  cursor: pointer; flex-shrink: 0;
  transition: transform 0.15s, border-color 0.15s;
}
/* canvas variant — object-fit is N/A but all other rules apply */
canvas.cam-thumb { display: block; }
.cam-thumb:hover { transform: scale(1.06); border-color: var(--accent); }
.cam-no-thumb { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; }

/* ── Camera header right (count + toggle) ───────────────────── */
.cam-header-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; }

/* ── View toggle buttons ─────────────────────────────────────── */
.view-toggle { display: flex; gap: 0.2rem; }
.view-toggle .btn-icon {
  font-size: 1rem; padding: 0.3rem 0.45rem; border-radius: 6px;
}
.view-toggle .btn-icon.active {
  background: var(--accent-light); color: var(--accent);
}

/* ── Camera grid ─────────────────────────────────────────────── */
.cam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}
.cam-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.cam-card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.cam-card.drag-over-top,
.cam-card.drag-over-bottom {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.cam-card-img {
  width: 100%; aspect-ratio: 16/9; background: var(--bg-card);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.cam-card-img img {
  width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer;
  transition: transform 0.2s;
}
.cam-card-img img:hover { transform: scale(1.03); }
/* canvas variant used when zone overlays are rendered */
.cam-card-img canvas.cam-card-img-canvas {
  width: 100%; height: 100%; display: block; cursor: pointer;
  transition: transform 0.2s;
}
.cam-card-img canvas.cam-card-img-canvas:hover { transform: scale(1.03); }
.cam-no-capture {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  color: var(--text-muted);
}
.cam-no-capture span:first-child { font-size: 2rem; }
.cam-no-capture span:last-child  { font-size: 0.7rem; }
.cam-card-body {
  padding: 0.75rem; display: flex; flex-direction: column; gap: 0.45rem; flex: 1;
}
.cam-card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.cam-card-title { font-weight: 600; font-size: 0.9rem; }
.cam-card-meta  { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.cam-card-capture-time { font-size: 0.7rem; color: var(--text-muted); }
.cam-card-actions {
  display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.35rem;
}

/* ── Color picker swatch ─────────────────────────────────────── */
.color-swatch {
  -webkit-appearance: none;
  appearance: none;
  width: 2.4rem; height: 2.4rem;
  padding: 0; border: 2px solid var(--border);
  border-radius: 6px; cursor: pointer;
  background: none;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 2px; border-radius: 4px; }
.color-swatch::-webkit-color-swatch        { border: none; border-radius: 3px; }

/* ── Test result banner ──────────────────────────────────────── */
.test-result {
  margin-top: 0.75rem; padding: 0.6rem 1rem;
  border-radius: 7px; font-size: 0.875rem;
}
.test-result.success { background: var(--success-light); color: var(--success); }
.test-result.error   { background: var(--danger-light);  color: var(--danger);  }

/* ── Modal ───────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay-bg); backdrop-filter: blur(2px); }
.modal-dialog {
  position: relative; z-index: 1;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-large  { max-width: 820px; }
.modal-xlarge { max-width: 1100px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body   { padding: 1.25rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 0.75rem 1.25rem; border-top: 1px solid var(--border);
}

/* ── Counting editor canvas ──────────────────────────────────── */
.counting-editor { display: flex; flex-direction: column; gap: 1rem; }
.canvas-container {
  position: relative; width: 100%; background: #000;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
}
.counting-canvas { display: block; width: 100%; cursor: crosshair; }
.canvas-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); color: var(--text-secondary); font-size: 0.9rem;
}
.zone-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.drawing-help { font-size: 0.82rem; color: var(--text-secondary); }

/* ── Settings ────────────────────────────────────────────────── */
.model-status {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.8rem; background: var(--bg-secondary);
  border-radius: 7px; margin-bottom: 1rem; font-size: 0.875rem;
}
.model-list { display: flex; flex-direction: column; gap: 0.35rem; }
.model-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.75rem; border-radius: 7px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  font-size: 0.85rem;
}
.model-list-item.active-model { border-color: var(--accent); background: var(--accent-light); }
.model-name { font-family: monospace; }
.model-meta { color: var(--text-muted); font-size: 0.78rem; }
.progress-bar-container {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.progress-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.class-filter-bar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; }
.class-list {
  max-height: 200px; overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0.5rem; background: var(--bg-secondary);
  border-radius: 7px; border: 1px solid var(--border);
}
.class-chip {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.5rem; border-radius: 20px;
  background: var(--border); font-size: 0.78rem; cursor: pointer;
  transition: background 0.15s;
}
.class-chip input { cursor: pointer; }
.class-chip:has(input:checked) { background: var(--accent-light); color: var(--accent); }

/* ── Alarm watch-class grouped selector ─────────────────────── */
.alarm-class-container {
  background: var(--bg-secondary); border-radius: 7px;
  border: 1px solid var(--border); padding: 0.75rem 0.85rem;
}
.alarm-class-group { margin-bottom: 0.85rem; }
.alarm-class-group:last-child { margin-bottom: 0; }
.alarm-class-group-header {
  font-size: 0.73rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.alarm-class-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.alarm-class-collapse-toggle {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); font-size: 0.8rem; cursor: pointer;
  padding: 0.25rem 0.8rem; transition: background 0.15s, color 0.15s;
}
.alarm-class-collapse-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.alarm-class-collapse { display: none; }
.alarm-class-collapse.open { display: block; }

/* ── Stats bar (captures) ────────────────────────────────────── */
.stats-bar {
  display: flex; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.stat-item {
  flex: 1; min-width: 140px;
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px;
}
.stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }

/* ── Capture gallery ─────────────────────────────────────────── */
.capture-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 1rem;
}
.capture-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.capture-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.capture-card.selected { border-color: var(--accent); background: var(--accent-light); }
.capture-img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.capture-info { padding: 0.5rem; }
.capture-class { font-size: 0.82rem; font-weight: 600; }
.capture-meta  { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.capture-checkbox {
  position: absolute; top: 6px; left: 6px;
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
}
.capture-conf {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.65); color: #fff;
  padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.7rem;
}

/* ── Bulk actions ────────────────────────────────────────────── */
.bulk-actions {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem;
  padding: 0.5rem 0.75rem; background: var(--accent-light);
  border-radius: 7px; font-size: 0.875rem;
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex; gap: 0.35rem; justify-content: center; flex-wrap: wrap;
  margin: 1rem 0;
}
.page-btn {
  min-width: 36px; height: 36px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-primary); font-size: 0.875rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover { background: var(--accent-light); border-color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Lightbox ────────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 600; display: flex; align-items: center; justify-content: center; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.9); }
.lightbox-dialog {
  position: relative; z-index: 1; max-width: 90vw; max-height: 90vh;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.lightbox-close {
  position: absolute; top: -2.5rem; right: 0;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 1.2rem;
}
.lightbox-img { max-width: 100%; max-height: 80vh; border-radius: 8px; object-fit: contain; }
.lightbox-info {
  background: rgba(0,0,0,0.6); color: #fff; padding: 0.6rem 0.8rem;
  border-radius: 7px; font-size: 0.85rem; display: flex; gap: 1.5rem; flex-wrap: wrap;
}
.lightbox-info span { color: #aaa; }

/* ── Text colour utilities ──────────────────────────────────── */
.text-success  { color: var(--success)  !important; }
.text-danger   { color: var(--danger)   !important; }
.text-warning  { color: var(--warning)  !important; }
.text-accent   { color: var(--accent)   !important; }
.text-muted    { color: var(--text-muted)    !important; }
.text-secondary{ color: var(--text-secondary) !important; }

/* Dashboard controls-bar summary text */
.status-summary { font-size: 0.875rem; color: var(--text-secondary); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 900;
  display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
}
.toast {
  min-width: 240px; max-width: 360px;
  padding: 0.7rem 1rem; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow); pointer-events: auto;
  animation: slideIn 0.25s ease;
}
.toast-success { background: #15803d; color: #fff; }
.toast-error   { background: #b91c1c; color: #fff; }
.toast-info    { background: #1d4ed8; color: #fff; }
.toast-warning { background: #b45309; color: #fff; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { from { transform: none; opacity: 1; } to { transform: translateX(100px); opacity: 0; } }
.toast.closing { animation: slideOut 0.25s ease forwards; }

/* ── Text utilities ──────────────────────────────────────────── */
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }
.text-accent    { color: var(--accent); }

/* ── Loading skeletons (C6) ──────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton-row {
  height: 2.25rem; border-radius: 6px; margin-bottom: 0.5rem;
  background: linear-gradient(90deg,
    var(--bg-secondary, #1e2130) 25%,
    var(--border, #2a2f45) 50%,
    var(--bg-secondary, #1e2130) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

/* ── API error pill (C6) ─────────────────────────────────────── */
.api-error {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; border-radius: 8px;
  background: rgba(185, 28, 28, 0.12); border: 1px solid rgba(185, 28, 28, 0.35);
  color: var(--danger, #f87171); font-size: 0.875rem;
}
.api-error-msg { flex: 1; min-width: 0; word-break: break-word; }
.api-error .btn-retry {
  flex-shrink: 0; padding: 0.25rem 0.75rem; border-radius: 6px;
  background: transparent; border: 1px solid var(--danger, #f87171);
  color: var(--danger, #f87171); font-size: 0.8rem; cursor: pointer;
}
.api-error .btn-retry:hover { background: rgba(185,28,28,0.2); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell { margin-left: 0 !important; }
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { padding: 1rem 0.75rem 5rem; }
  .controls-bar { flex-direction: column; align-items: flex-start; }
  .camera-grid { grid-template-columns: 1fr !important; }
  .mobile-bottom-nav { display: flex; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
@media (max-width: 900px) {
  .dash-right { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   Alarm / Monitoring System
   ═══════════════════════════════════════════════════════════════ */

/* ── Mode Bar ───────────────────────────────────────────────── */
.mode-bar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.65rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 3px solid var(--border);
  transition: border-color 0.4s;
  margin-bottom: 0;
}
.mode-bar-label {
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap;
}
.mode-bar-buttons { display: flex; gap: 0.4rem; }
.mode-btn {
  padding: 0.4rem 1.1rem; border-radius: 8px; border: 2px solid transparent;
  font-size: 0.85rem; font-weight: 700; cursor: pointer; letter-spacing: 0.02em;
  transition: all 0.2s;
  background: var(--bg-secondary); color: var(--text-muted);
}
.mode-btn:hover { filter: brightness(1.2); color: var(--text-primary); }

/* IDLE active */
.mode-btn-idle.active {
  background: var(--bg-secondary); color: var(--text-primary);
  border-color: var(--border);
}
/* COUNTING active */
.mode-btn-counting.active {
  background: #14532d; color: #86efac;
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34,197,94,0.35);
}
/* MONITORING active */
.mode-btn-monitoring.active {
  background: #7f1d1d; color: #fca5a5;
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239,68,68,0.45);
  animation: monitoringBtnPulse 2s ease-in-out infinite;
}
@keyframes monitoringBtnPulse {
  0%,100% { box-shadow: 0 0 10px rgba(239,68,68,0.45); }
  50%      { box-shadow: 0 0 20px rgba(239,68,68,0.75); }
}
.mode-bar-status {
  font-size: 0.8rem; color: var(--text-muted); margin-left: auto;
  font-style: italic;
}

/* Body-level mode tinting — mode-bar bottom border + main-content top stripe */
body[data-mode="counting"] .mode-bar  { border-bottom-color: #22c55e; }
body[data-mode="monitoring"] .mode-bar {
  border-bottom-color: #ef4444;
  animation: modeBarMonPulse 2s ease-in-out infinite;
}
@keyframes modeBarMonPulse {
  0%,100% { border-bottom-color: #ef4444; }
  50%      { border-bottom-color: #ff8888; }
}
body[data-mode="counting"]   .main-content { border-top: 2px solid #22c55e; }
body[data-mode="monitoring"] .main-content { border-top: 2px solid #ef4444; }

/* ── Alarm badge (unhandled count on drawer toggle) ─────────── */
.alarm-badge {
  display: inline-block; background: var(--danger); color: #fff;
  border-radius: 999px; padding: 0 5px; font-size: 0.68rem;
  font-weight: 700; line-height: 1.5; min-width: 18px; text-align: center;
  margin-left: 4px; vertical-align: middle;
}

/* tile-btn-arm replaced by .tile-cam-pill — kept as no-op to avoid any stale refs */
.tile-btn-arm { display: none; }

/* ── Tile alarm flash ────────────────────────────────────────── */
.alarm-triggered {
  outline: 3px solid var(--danger) !important;
  animation: alarmPulse 0.9s ease-in-out 2;
}

/* Persistent alarm state — stays until cleared */
.camera-tile.alarm-active {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.35), inset 0 0 0 2px rgba(239,68,68,0.15);
  animation: alarmActivePulse 2s ease-in-out infinite;
}

@keyframes alarmActivePulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(239,68,68,0.35), inset 0 0 0 2px rgba(239,68,68,0.12); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0.55), inset 0 0 0 2px rgba(239,68,68,0.25); }
}

/* Alarm banner — compact badge above the bottom bar, left-anchored */
.tile-alarm-banner {
  position: absolute; bottom: 0; left: 0;
  background: rgba(220, 38, 38, 0.88);
  color: #fff; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.25rem 0.65rem 0.25rem 0.5rem;
  border-radius: 0 6px 0 0;
  display: inline-flex; align-items: center; gap: 0.4rem;
  animation: bannerSlideIn 0.25s ease;
  z-index: 10; backdrop-filter: blur(2px);
  max-width: 85%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes bannerSlideIn { from { transform: translateY(100%); opacity: 0; } to { transform: none; opacity: 1; } }
.tile-alarm-icon { font-size: 0.85rem; animation: bellShake 0.6s ease 3; }
@keyframes bellShake {
  0%,100% { transform: rotate(0); }
  20%     { transform: rotate(-18deg); }
  40%     { transform: rotate(18deg); }
  60%     { transform: rotate(-10deg); }
  80%     { transform: rotate(10deg); }
}

@keyframes alarmPulse {
  0%,100% { outline-color: var(--danger);  box-shadow: 0 0 0 0 transparent; }
  50%      { outline-color: #ff8888;        box-shadow: 0 0 20px 6px rgba(239,68,68,0.65); }
}

/* ── Alarm drawer backdrop ────────────────────────────────── */
.alarm-drawer-backdrop {
  position: fixed; inset: 0;
  z-index: 999;                        /* just below the drawer (z:1000) */
  background: rgba(0,0,0,0);
  pointer-events: none;
  transition: background 0.25s ease;
}
.alarm-drawer-backdrop.open {
  background: rgba(0,0,0,0.45);
  pointer-events: auto;
}

/* ── Alarm drawer (bottom sheet) ─────────────────────────────── */
.alarm-drawer {
  position: fixed; bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  max-height: 300px;
  background: var(--bg-card); border-top: 2px solid var(--danger);
  z-index: 1000; display: flex; flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.45);
  transform: translateY(100%); transition: transform 0.25s ease, left 0.25s ease;
}
body.sidebar-collapsed .alarm-drawer { left: var(--sidebar-col); }
@media (max-width: 768px) { .alarm-drawer { left: 0; } }
.alarm-drawer.open { transform: translateY(0); }

.alarm-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.alarm-drawer-title {
  font-weight: 700; color: var(--danger); font-size: 0.9rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.alarm-drawer-actions { display: flex; gap: 0.5rem; align-items: center; }
.alarm-drawer-list {
  overflow-y: auto; flex: 1; padding: 0.5rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.alarm-drawer-empty {
  color: var(--text-muted); text-align: center;
  padding: 1.25rem; font-size: 0.85rem;
}

/* ── Alarm cards (inside the drawer) ────────────────────────── */
.alarm-card {
  display: flex; gap: 0.75rem; align-items: center;
  background: var(--bg-secondary); border-radius: var(--radius, 8px);
  padding: 0.45rem 0.75rem;
  border-left: 3px solid var(--danger);
  animation: alarmCardIn 0.2s ease;
}
@keyframes alarmCardIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

.alarm-drawer-thumb {
  width: 60px; height: 42px; object-fit: cover;
  border-radius: 4px; flex-shrink: 0; background: #111;
}
.alarm-card-body {
  display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; flex: 1;
}
.alarm-card-cam  { font-weight: 700; font-size: 0.82rem; color: var(--text-primary); }
.alarm-card-class {
  background: var(--danger-light); color: #ff7070;
  border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.75rem; font-weight: 600;
}
.alarm-card-conf  { color: var(--text-muted); font-size: 0.75rem; }
.alarm-card-time  { color: var(--text-muted); font-size: 0.72rem; }
.alarm-card-link  {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: 0.75rem; text-decoration: none;
  margin-left: auto; white-space: nowrap; cursor: pointer;
}
.alarm-card-link:hover { text-decoration: underline; }
.alarm-card-handled {
  color: #86efac; font-size: 0.73rem; margin-left: auto;
  white-space: nowrap; font-weight: 600;
}

/* ═══════════════════════════════════════════════
   Handle Alarm Modal
   ═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
  animation: modalFadeIn 0.15s ease;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  max-width: 540px; width: 92%; max-height: 90vh;
  overflow-y: auto; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-weight: 700; font-size: 1rem; color: var(--danger); }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.15rem; padding: 0.1rem 0.35rem;
  line-height: 1; border-radius: 4px;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-secondary); }
.modal-footer {
  display: flex; gap: 0.75rem; justify-content: flex-end;
  padding: 0.9rem 1.25rem; border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Mode profile modal (dashboard) */
.mode-profile-modal .modal-title {
  color: var(--accent);
}
.mode-profile-body {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Handle-alarm modal inner sections */
.alarm-handle-snapshot-wrap {
  background: #0a0a0a; text-align: center;
  max-height: 210px; overflow: hidden; flex-shrink: 0;
}
.alarm-handle-snapshot-wrap img {
  max-width: 100%; max-height: 210px; object-fit: contain; display: block; margin: 0 auto;
}
.alarm-handle-no-snap {
  color: var(--text-muted); font-size: 0.82rem; padding: 1.75rem;
}
.alarm-handle-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center;
  padding: 0.7rem 1.25rem; border-bottom: 1px solid var(--border);
}
.alarm-handle-meta .meta-cam   { font-weight: 700; color: var(--text-primary); font-size: 0.9rem; }
.alarm-handle-meta .meta-class {
  background: rgba(239,68,68,0.15); color: #f87171;
  border-radius: 4px; padding: 0.15rem 0.5rem; font-size: 0.76rem; font-weight: 600;
}
.alarm-handle-meta .meta-conf  { color: var(--text-muted); font-size: 0.78rem; }
.alarm-handle-meta .meta-time  { color: var(--text-muted); font-size: 0.76rem; margin-left: auto; }
.alarm-handle-body {
  padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.45rem;
}
.alarm-handle-body label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em;
}
.alarm-handle-textarea {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text-primary); font-size: 0.88rem;
  padding: 0.6rem 0.85rem; resize: vertical; font-family: inherit; min-height: 70px;
}
.alarm-handle-textarea:focus {
  outline: none; border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.18);
}

/* ═══════════════════════════════════════════════
   NVR Playback Modal  (shared across all pages)
   ═══════════════════════════════════════════════ */
.playback-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.88); backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center; justify-content: center;
  animation: modalFadeIn 0.15s ease;
}
.playback-overlay.open { display: flex; }

.playback-dialog {
  background: #0c0c0c; border: 1px solid #333;
  border-radius: 12px; overflow: hidden;
  width: 95vw; max-width: 1100px;
  max-height: 95vh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 60px rgba(0,0,0,0.8);
}

/* ── Header ── */
.playback-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1rem;
  background: #141414; border-bottom: 1px solid #333;
  flex-shrink: 0;
}
.playback-title {
  font-weight: 700; font-size: 0.95rem; color: #e2e8f0;
  display: flex; align-items: center; gap: 0.5rem;
}
.playback-title .pb-cam-name { color: #60a5fa; }
.playback-close {
  background: none; border: none; color: #888;
  cursor: pointer; font-size: 1.3rem; line-height: 1;
  padding: 0.15rem 0.4rem; border-radius: 4px;
}
.playback-close:hover { color: #fff; background: #333; }

/* ── Video area ── */
.playback-video-wrap {
  position: relative; background: #000;
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; flex: 1;
  overflow: hidden;
}
.playback-video-wrap img {
  max-width: 100%; max-height: 70vh;
  object-fit: contain; display: block;
}
.playback-video-wrap .pb-no-signal {
  color: #555; font-size: 1.1rem; text-align: center;
}
/* OSD time overlay */
.playback-osd {
  position: absolute; bottom: 8px; left: 12px;
  background: rgba(0,0,0,0.7); color: #0f0;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.05em;
}
/* Status overlay (loading / finished) */
.playback-status-overlay {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
  color: #ccc; font-size: 1rem;
}
.playback-status-overlay.visible { display: flex; }

/* ── Transport bar (NVR-style) ── */
.playback-transport {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: #141414; border-top: 1px solid #333;
  flex-shrink: 0; flex-wrap: wrap;
}
.pb-btn {
  background: #1e1e1e; border: 1px solid #444;
  color: #ddd; cursor: pointer;
  font-size: 1rem; padding: 0.35rem 0.65rem;
  border-radius: 6px; line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.pb-btn:hover { background: #2a2a2a; border-color: #666; }
.pb-btn.active { background: #1a5276; border-color: #2980b9; color: #fff; }
.pb-btn:disabled { opacity: 0.35; cursor: default; }

.pb-speed-group {
  display: flex; gap: 2px;
}
.pb-speed-group .pb-btn { font-size: 0.78rem; padding: 0.3rem 0.5rem; border-radius: 4px; }

.pb-time-display {
  font-family: 'Consolas', monospace; font-size: 0.82rem;
  color: #94a3b8; margin-left: auto;
}

/* ── Date/Time picker row (for dashboard camera playback) ── */
.playback-datetime-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 1rem;
  background: #181818; border-top: 1px solid #333;
  flex-shrink: 0; flex-wrap: wrap;
}
.playback-datetime-row label {
  font-size: 0.78rem; color: #94a3b8; font-weight: 600;
}
.playback-datetime-row input[type="datetime-local"] {
  background: #1e1e1e; border: 1px solid #444; color: #ddd;
  border-radius: 5px; padding: 0.3rem 0.5rem; font-size: 0.82rem;
  font-family: inherit;
}
.playback-datetime-row input:focus {
  outline: none; border-color: #2980b9;
}
.pb-btn-go {
  background: #1a5276; border: 1px solid #2980b9; color: #fff;
  font-size: 0.82rem; font-weight: 600; padding: 0.35rem 0.8rem;
  border-radius: 5px; cursor: pointer;
}
.pb-btn-go:hover { background: #21618c; }

/* ── Seek bar row ── */
.pb-seekbar-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.4rem 1rem;
  background: #141414; border-top: 1px solid #2a2a2a;
  flex-shrink: 0;
}
.pb-seek-label {
  font-family: 'Consolas', monospace; font-size: 0.76rem;
  color: #94a3b8; white-space: nowrap; min-width: 2.8rem;
  text-align: center;
}
.pb-seekbar {
  flex: 1; height: 6px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background: transparent; outline: none; border: none;
}
.pb-seekbar::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(
    to right,
    #2980b9 var(--seek-pct, 0%),
    #3a3a3a var(--seek-pct, 0%)
  );
}

.pb-download-row {
  display: flex; align-items: center;
  padding: 0.45rem 1rem;
  background: #121212; border-top: 1px solid #232323;
  flex-shrink: 0;
}
.pb-download-status {
  font-size: 0.78rem; color: #93c5fd;
  font-family: 'Consolas', monospace;
}
.pb-seekbar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #2980b9; cursor: pointer; margin-top: -5px;
  box-shadow: 0 0 0 2px #141414, 0 0 6px rgba(41,128,185,0.6);
}
.pb-seekbar::-moz-range-track {
  height: 4px; border-radius: 2px; background: #3a3a3a;
}
.pb-seekbar::-moz-range-progress {
  height: 4px; border-radius: 2px; background: #2980b9;
}
.pb-seekbar::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #2980b9; border: 2px solid #141414; cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════
   Sidebar Navigation
   ═══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(0,0,0,0.35);
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-col); }
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-divider,
body.sidebar-collapsed .sidebar-section-label { opacity: 0; pointer-events: none; }
.sidebar-brand {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 1.1rem 0.9rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; min-width: 0;
}
.sidebar-logo { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.sidebar-brand-text {
  font-size: 0.82rem; font-weight: 700; color: var(--text-primary);
  line-height: 1.3; white-space: nowrap; transition: opacity 0.2s;
}
.sidebar-brand-text em {
  font-style: normal;
  background: linear-gradient(135deg, #0ea5e9, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 0.5rem;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-divider {
  height: 1px; background: var(--border);
  margin: 0.35rem 0.4rem; transition: opacity 0.2s;
}
.sidebar-section-label {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 0.45rem 0.7rem 0.15rem; white-space: nowrap; transition: opacity 0.2s;
}
.nav-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.62rem 0.85rem; border-radius: 8px;
  color: var(--text-secondary); font-size: 0.975rem; font-weight: 500;
  text-decoration: none; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  position: relative; border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--accent-light); color: var(--text-primary); text-decoration: none;
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(14,165,233,0.18) 0%, rgba(14,165,233,0.07) 100%);
  color: #0ea5e9; border-color: rgba(14,165,233,0.22);
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 0 2px 2px 0;
  background: #0ea5e9; box-shadow: 0 0 8px rgba(14,165,233,0.5);
}
.nav-icon { flex-shrink: 0; width: 22px; display: flex; align-items: center; justify-content: center; }
.nav-label { transition: opacity 0.2s; overflow: hidden; }
.sidebar-bottom {
  padding: 0.45rem 0.5rem; border-top: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.62); z-index: 190;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.open { display: block; }

/* ═══════════════════════════════════════════════════════════════
   Mobile Bottom Navigation
   ═══════════════════════════════════════════════════════════════ */
.mobile-bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px; z-index: 300;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  flex-direction: row; align-items: stretch;
}
.mbn-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--text-muted); text-decoration: none;
  font-size: 0.6rem; font-weight: 600; letter-spacing: 0.03em;
  transition: color 0.15s;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mbn-item.active { color: var(--accent); }
.mbn-item:hover { color: var(--text-primary); text-decoration: none; }
.mbn-icon { font-size: 1.1rem; line-height: 1; }

/* ═══════════════════════════════════════════════════════════════
   Dashboard Right Panel
   ═══════════════════════════════════════════════════════════════ */
.dash-right {
  width: 270px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 0.85rem;
  position: fixed;
  right: 1rem;
  top: calc(var(--topbar-h) + 0.75rem);
  max-height: calc(100vh - var(--topbar-h) - 1.5rem);
  overflow-y: auto;
  z-index: 50;
}
.dash-right::-webkit-scrollbar { width: 3px; }
.dash-right::-webkit-scrollbar-thumb { background: var(--border); }
/* Give main content right-margin when right panel is visible */
@media (min-width: 1380px) {
  .has-right-panel .main-content { padding-right: calc(270px + 2rem); }
}
@media (max-width: 1379px) {
  .dash-right { display: none; }
}
.dash-panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.dash-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary);
}
.dash-panel-header a { font-size: 0.7rem; font-weight: 500; text-transform: none; color: var(--accent); }
.dash-analytics-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
}
.dash-stat-cell { background: var(--bg-card); padding: 0.7rem 0.85rem; }
.dash-stat-label {
  font-size: 0.62rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.dash-stat-value {
  font-size: 1.4rem; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.dash-stat-delta { font-size: 0.62rem; font-weight: 600; color: var(--success); }
.dash-alert-list {
  display: flex; flex-direction: column;
  max-height: 300px; overflow-y: auto;
}
.dash-alert-item {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.85rem; border-bottom: 1px solid var(--border);
  font-size: 0.78rem; cursor: pointer; transition: background 0.15s;
}
.dash-alert-item:hover { background: var(--bg-card-hover); }
.dash-alert-item:last-child { border-bottom: none; }
.dash-alert-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--danger); box-shadow: 0 0 5px rgba(239,68,68,0.5);
}
.dash-alert-cam { font-weight: 600; color: var(--text-primary); flex: 1; font-size: 0.78rem; }
.dash-alert-class {
  background: var(--danger-light); color: var(--danger);
  border-radius: 3px; padding: 0.08rem 0.3rem; font-size: 0.68rem; font-weight: 600;
}
.dash-alert-time { color: var(--text-muted); font-size: 0.65rem; white-space: nowrap; }
.dash-alert-empty { padding: 1.25rem; text-align: center; color: var(--text-muted); font-size: 0.8rem; }

/* ── Dashboard thumbnail grids (detection + alarm snapshots) ── */
.dash-thumb-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0.32rem; padding: 0.6rem 0.65rem;
}
.dash-thumb-empty {
  grid-column: 1 / -1; padding: 1.1rem 0.65rem;
  text-align: center; color: var(--text-muted); font-size: 0.78rem;
}
.dash-thumb {
  aspect-ratio: 1; overflow: hidden; border-radius: 0.35rem; cursor: pointer;
  position: relative; background: var(--bg-primary);
  border: 2px solid transparent; transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.dash-thumb:hover { border-color: var(--accent); transform: scale(1.04); }
.dash-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: opacity 0.4s;
}
.dash-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: var(--text-muted);
}
.dash-thumb-badge {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.72); color: #fff; font-size: 0.55rem;
  padding: 0.15rem 0.25rem; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-transform: capitalize; font-weight: 600; letter-spacing: 0.02em;
  z-index: 2;
}
.dash-thumb.alarm-thumb { border-color: rgba(239,68,68,0.35); }
.dash-thumb.alarm-thumb:hover { border-color: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.3); }
/* pending: orange pulsing border */
.dash-thumb.pending-thumb {
  border-color: #f97316;
  animation: pendingPulse 1.8s ease-in-out infinite;
}
@keyframes pendingPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.0); }
  50%      { box-shadow: 0 0 0 3px rgba(249,115,22,0.35); }
}
/* done flash: green */
.dash-thumb.done-thumb {
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34,197,94,0.55);
  animation: donePop 0.4s ease;
}
@keyframes donePop { 0%{transform:scale(1)} 50%{transform:scale(1.08)} 100%{transform:scale(1)} }

/* ── In-card analysis overlay ── */
.dash-thumb-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.28rem; background: rgba(0,0,0,0.58); padding: 0.25rem;
  pointer-events: none;
}
.dto-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #f97316; border-top-color: transparent;
  animation: aiSpin 0.75s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }
.dto-bar {
  width: 78%; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.18);
}
.dto-bar-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #f97316, #fbbf24);
  transition: width 0.7s ease;
}
.dto-label {
  font-size: 0.5rem; color: #fff; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.dash-thumb-overlay.dto-done .dto-spinner { border-color: #22c55e; }
.dash-thumb-overlay.dto-done .dto-bar-fill { background: #22c55e; }
.dash-thumb-overlay.dto-done .dto-label   { color: #86efac; }

/* ═══════════════════════════════════════════════════════════════
   Shared VA Lightbox (vision_analytics + dashboard)
   ═══════════════════════════════════════════════════════════════ */
.va-lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.va-lightbox-inner {
  background: var(--bg-card); border-radius: var(--radius); overflow: hidden;
  max-width: 700px; width: 92%; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.va-lightbox-img { width: 100%; max-height: 420px; object-fit: contain; background: #111; }
.va-lightbox-body { padding: 1.25rem; overflow-y: auto; }
.va-lightbox-close {
  position: absolute; top: 1rem; right: 1rem; background: rgba(0,0,0,0.5);
  border: none; color: #fff; font-size: 1.4rem; width: 2.2rem; height: 2.2rem;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.va-lb-nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,0.5); border: none; color: #fff; font-size: 2.6rem;
  width: 3rem; height: 5rem; border-radius: 0.5rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 1001;
  transition: background 0.15s; line-height: 1;
}
.va-lb-nav-btn:hover:not(:disabled) { background: rgba(0,0,0,0.8); }
.va-lb-nav-btn:disabled { opacity: 0.15; cursor: default; }
.va-lb-prev { left: 0.4rem; }
.va-lb-next { right: 0.4rem; }
.va-lb-pos {
  position: absolute; bottom: 0.7rem; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.8); font-size: 0.8rem; pointer-events: none;
  white-space: nowrap; background: rgba(0,0,0,0.4);
  padding: 0.15rem 0.6rem; border-radius: 1rem;
}
.va-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; font-size: 0.83rem; }
.va-meta-key { color: var(--text-muted); }
.va-meta-val { font-weight: 600; }
.va-lb-playback-row {
  margin-top: 0.85rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.6rem;
}
.va-lb-playback-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1.1rem; border-radius: 0.45rem; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
  transition: background 0.15s, transform 0.1s;
}
.va-lb-playback-btn:hover { background: linear-gradient(135deg, #3b82f6, #2563eb); transform: translateY(-1px); }
.va-lb-playback-hint { font-size: 0.73rem; color: var(--text-muted); }

/* Raw JSON viewer inside lightbox */
.va-lb-raw-json-btn { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.15); color: var(--text-secondary); font-size: 0.78rem; font-weight: 600; padding: 0.3rem 0.75rem; border-radius: 0.35rem; cursor: pointer; transition: background 0.15s; }
.va-lb-raw-json-btn:hover { background: rgba(255,255,255,0.13); }
.va-lb-raw-json-pre { margin-top: 0.5rem; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.1); border-radius: 0.4rem; padding: 0.75rem; font-size: 0.74rem; line-height: 1.5; color: #86efac; overflow-x: auto; white-space: pre; max-height: 320px; overflow-y: auto; }

/* Counted / not-counted badges (shared by lightbox and VA search table) */
.va-badge { padding: 0.15rem 0.45rem; border-radius: 0.3rem; font-size: 0.7rem; font-weight: 600; }
.va-badge-counted     { background: #14532d; color: #4ade80; }
.va-badge-not-counted { background: #1f2937; color: #6b7280; }

/* ═══════════════════════════════════════════════════════════════
   ═══════════════════════════════════════════════════════════════ */
.glow-accent { box-shadow: var(--shadow-glow); }
.det-label {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: #fff;
}
.det-person    { background: #1d4ed8; box-shadow: 0 0 8px rgba(29,78,216,0.55); }
.det-vehicle   { background: #c2410c; box-shadow: 0 0 8px rgba(194,65,12,0.55); }
.det-intrusion { background: #b91c1c; box-shadow: 0 0 8px rgba(185,28,28,0.65); }
/* Camera tile active-stream glow */
.camera-tile.stream-active { border-color: rgba(14,165,233,0.5); box-shadow: 0 0 18px rgba(14,165,233,0.18); }
/* Neon stat values */
.stat-value-glow {
  background: linear-gradient(135deg, #0ea5e9 0%, #818cf8 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; font-weight: 800;
}
