/* ===========================================================================
   Video Intellect — info-dense NOC/SOC interface (Phase 3 layout pass)
   Унаследовано от sense-hub стиля + расширения под наш функционал
   (статус-бар, command palette, мульти-камерная сетка).
   =========================================================================== */

:root,
[data-theme='dark'] {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d26;
  --bg-card: #1e2130;
  --bg-card-hover: #252840;
  --text-primary: #e4e6eb;
  --text-secondary: #8b8fa3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  /* Семантика событий детекции (используется в таймлайне, дашборде, карточках PSIM) */
  --event-motion: #3b82f6;
  --event-face: #a855f7;
  --event-alarm: #ef4444;
  --border: #2d3148;
  --sidebar-bg: #13151c;
  --header-bg: #161822;
  --statusbar-bg: #0a0c12;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  --radius: 10px;
  --radius-sm: 6px;
  --video-bg: #0a0c12;
  --sidebar-w: 232px;
  --statusbar-h: 26px;
  /* Spacing scale (Improvement 7) */
  --gap-xs: 4px;
  --gap-sm: 6px;
  --gap-md: 12px;
  --gap-lg: 18px;
  --gap-xl: 24px;
  /* Semantic font sizes */
  --fs-xs: 10px;
  --fs-sm: 11px;
  --fs-md: 12px;
  --fs-lg: 14px;
  --fs-xl: 17px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.45;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code, pre, .mono { font-family: 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace; }

/* =============== Auth =============== */
.auth-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--statusbar-bg); overflow: hidden; position: relative;
}
#neuroBg {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.auth-container { width: 100%; max-width: 380px; padding: 20px; perspective: 1200px; position: relative; z-index: 1; }
.auth-card {
  background: rgba(22, 25, 35, 0.85); backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(59, 130, 246, 0.15); border-radius: 16px;
  padding: 32px 26px; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 80px rgba(59, 130, 246, 0.06);
  transform-origin: center center;
}
@keyframes flipInY {
  0%   { transform: rotateY(90deg); opacity: 0; }
  40%  { transform: rotateY(-12deg); opacity: 1; }
  65%  { transform: rotateY(6deg); }
  85%  { transform: rotateY(-2deg); }
  100% { transform: rotateY(0); }
}
.auth-flip-y { animation: flipInY .8s ease-out both; }
.auth-logo {
  text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.auth-logo i { color: var(--accent); font-size: 26px; }
.auth-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 22px; font-size: 11px; }
.auth-card .form-control {
  background: var(--bg-secondary) !important; color: var(--text-primary) !important;
  border-color: var(--border); font-size: 13px;
}
.auth-card .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.auth-card .form-control::placeholder { color: var(--text-secondary); }
/* Chrome/Safari autofill — keep dark theme colors */
.auth-card .form-control:-webkit-autofill,
.auth-card .form-control:-webkit-autofill:hover,
.auth-card .form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-secondary) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--text-primary);
  transition: background-color 5000s ease-in-out 0s;
}
/* Global autofill fix for all inputs */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-secondary) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--text-primary);
}
.alert-sm { font-size: 11px; padding: 6px 10px; border-radius: var(--radius-sm); }

/* =============== Login Split Layout (Face ID + Form) =============== */
.login-split {
  display: flex; min-height: 100vh; position: relative; z-index: 1;
}
.login-face {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px; background: rgba(0,0,0,0.3);
}
.login-face-inner { width: 100%; max-width: 440px; }
.login-face-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px;
}
.login-face-header i { font-size: 16px; }

.login-face-viewport {
  position: relative; width: 100%; aspect-ratio: 4/3;
  border-radius: var(--radius); overflow: hidden;
  background: #000; border: 2px solid var(--border);
  transition: border-color 0.5s;
}
.login-face-viewport.face-scanning { border-color: var(--accent); box-shadow: 0 0 20px rgba(59,130,246,0.2); }
.login-face-viewport.face-matched { border-color: var(--success); box-shadow: 0 0 30px rgba(16,185,129,0.3); }
.login-face-viewport video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); filter: brightness(0.55) contrast(1.1); transition: filter 0.4s; }
.login-face-viewport.face-matched video { filter: brightness(0.7) contrast(1.15) saturate(1.1); }
.login-face-viewport canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; transform: scaleX(-1);
}

.face-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.face-scan-ring { width: 60px; height: 60px; opacity: 0.7; }
.face-scan-arc { animation: faceScanRotate 1.5s linear infinite; transform-origin: center; }
@keyframes faceScanRotate { 0% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -565; } }
.face-matched .face-scan-ring { display: none; }
.face-scanning .face-scan-ring { display: none; }

.face-status {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  padding: 6px 14px; border-radius: 20px; font-size: 11px;
  color: var(--text-secondary); white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.face-status.active { color: var(--accent); }
.face-status.success { color: var(--success); }
.face-status.error { color: var(--danger); }
.face-status i { font-size: 13px; }

.login-face-info {
  margin-top: 12px; font-size: 11px; color: var(--text-secondary);
  text-align: center; line-height: 1.5;
}
.login-face-info b { color: var(--success); }
.login-face-enter {
  width: 100%; margin-top: 12px; padding: 10px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm); animation: faceEnterPulse 2s ease-in-out infinite;
}
@keyframes faceEnterPulse { 0%,100% { box-shadow: 0 0 8px rgba(16,185,129,0.3); } 50% { box-shadow: 0 0 20px rgba(16,185,129,0.5); } }

.login-2fa-status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin: 4px 0 12px;
  background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25);
  border-left: 3px solid var(--success); border-radius: var(--radius-sm);
  font-size: 11px; color: var(--text-secondary);
  animation: face2faSlide 0.3s ease-out;
}
.login-2fa-status i { color: var(--success); font-size: 14px; }
.login-2fa-status b { color: var(--success); }
@keyframes face2faSlide { 0% { opacity: 0; transform: translateY(-6px); } 100% { opacity: 1; transform: none; } }

/* Right side: form */
.login-form-side {
  flex: 0 0 420px; display: flex; align-items: center; justify-content: center;
  padding: 40px; background: rgba(22,25,35,0.85); backdrop-filter: blur(16px);
  border-left: 1px solid rgba(59,130,246,0.1);
}
.login-form-inner { width: 100%; max-width: 320px; }
.login-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
}
.login-brand { font-size: 20px; font-weight: 700; }
.login-brand-sub { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.login-title { font-size: 16px; font-weight: 600; margin: 0 0 20px; }
.login-field { margin-bottom: 14px; }
.login-field label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px;
}
.login-field label i { font-size: 12px; color: var(--accent); }
.login-field .form-control {
  background: var(--bg-secondary) !important; color: var(--text-primary) !important;
  border-color: var(--border); font-size: 13px; padding: 10px 12px;
}
.login-field .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.login-submit {
  width: 100%; padding: 10px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius-sm); margin-top: 4px;
}
.login-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
  font-size: 10px; color: var(--text-secondary);
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.login-face-hint {
  text-align: center; font-size: 11px; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.login-face-hint i { color: var(--accent); font-size: 16px; }
.login-footer {
  margin-top: 28px; text-align: center; font-size: 10px; color: var(--text-secondary); opacity: 0.5;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.login-footer i { color: var(--success); }

@media (max-width: 900px) {
  .login-split { flex-direction: column-reverse; }
  .login-form-side { flex: none; border-left: none; border-top: 1px solid rgba(59,130,246,0.1); }
  .login-face { padding: 20px; }
  .login-face-inner { max-width: 320px; }
}

/* =============== Lock Screen =============== */
.lock-screen {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; padding: 40px;
}
.lock-time-block { text-align: center; margin-bottom: 12px; }
.lock-time {
  font-size: 96px; font-weight: 200; line-height: 1;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -2px;
}
.lock-date { font-size: 16px; color: var(--text-secondary); margin-top: 6px; text-transform: capitalize; }

.lock-user-block {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.lock-avatar {
  width: 70px; height: 70px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  box-shadow: 0 8px 32px rgba(59,130,246,0.4);
}
.lock-user-name { font-size: 18px; font-weight: 600; }
.lock-user-role { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.lock-status {
  font-size: 12px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}

.lock-actions { display: flex; gap: 12px; align-items: center; }
.lock-unlock-btn {
  padding: 14px 28px; font-size: 13px; font-weight: 600;
  border-radius: 50px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  box-shadow: 0 8px 32px rgba(59,130,246,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.lock-unlock-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(59,130,246,0.6); color: #fff; }
.lock-unlock-secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: none;
}
.lock-unlock-secondary:hover { background: rgba(255,255,255,0.15); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }

/* =============== Camera Control Modal — Actions tab v2 =============== */
.cam-actions-header {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.cam-actions-title { font-size: 16px; font-weight: 700; }
.cam-actions-sub { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.cam-actions-sub .badge { font-size: 9px; padding: 2px 6px; }
.cam-actions-sub .badge i { font-size: 9px; }

.cam-actions-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.cam-action-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s; text-align: left;
  min-height: 76px;
}
.cam-action-card:hover:not(:disabled) {
  border-color: var(--accent); transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}
.cam-action-card:disabled { opacity: 0.4; cursor: not-allowed; }
.cam-action-card i { font-size: 18px; }
.cam-action-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.cam-action-desc { font-size: 10px; color: var(--text-secondary); }
.cam-action-warning:hover:not(:disabled) { border-color: var(--warning); box-shadow: 0 4px 12px rgba(245,158,11,0.15); }
.cam-action-danger:hover:not(:disabled) { border-color: var(--danger); box-shadow: 0 4px 12px rgba(239,68,68,0.15); }
.cam-action-card.loading { opacity: 0.6; pointer-events: none; }

/* Offline state */
.cam-offline-state {
  text-align: center; padding: 32px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.cam-offline-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(239,68,68,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--danger);
}
.cam-offline-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.cam-offline-text { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.cam-offline-meta {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 12px; font-size: 11px; color: var(--text-secondary);
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  padding: 10px 14px; width: 100%; max-width: 320px;
}
.cam-offline-meta div { display: flex; justify-content: space-between; gap: 8px; }
.cam-offline-meta span { color: var(--text-secondary); opacity: 0.7; }
.cam-offline-meta code { color: var(--text-primary); font-size: 10px; }

.lock-fallback {
  position: absolute; bottom: 30px; font-size: 11px;
  color: var(--text-secondary); opacity: 0.5; text-decoration: none;
}
.lock-fallback:hover { opacity: 1; color: var(--text-primary); }

/* Face check modal on lock screen */
.lock-face-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(20px);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
}
.lock-face-modal.open { display: flex; }
.lock-face-viewport {
  width: 380px; max-width: 90vw; aspect-ratio: 4/3;
  border-radius: var(--radius); overflow: hidden;
  background: #000; border: 2px solid var(--accent);
  box-shadow: 0 0 40px rgba(59,130,246,0.4); position: relative;
}
.lock-face-viewport.matched { border-color: var(--success); box-shadow: 0 0 60px rgba(16,185,129,0.5); }
.lock-face-viewport video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); filter: brightness(0.5); }
.lock-face-viewport canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; transform: scaleX(-1);
}
.lock-face-status {
  font-size: 13px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: rgba(0,0,0,0.5);
  border-radius: 20px;
}
.lock-face-status.active { color: var(--accent); }
.lock-face-status.success { color: var(--success); }
.lock-face-status.error { color: var(--danger); }

/* Password unlock modal */
.lock-password-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(20px);
  display: none; align-items: center; justify-content: center;
}
.lock-password-modal.open { display: flex; }
.lock-password-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: 320px; max-width: 90vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: vmSlideIn 0.3s ease-out;
}
.lock-password-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  box-shadow: 0 8px 32px rgba(59,130,246,0.4);
}
.lock-password-name { font-size: 16px; font-weight: 700; }
.lock-password-status {
  font-size: 11px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
  text-align: center;
}
.lock-password-status.success { color: var(--success); }
.lock-password-status.error { color: var(--danger); }
.lock-password-card .form-control {
  width: 100%; padding: 10px 14px; font-size: 13px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
}
.lock-password-card .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); outline: none; }
.lock-password-card .btn-primary {
  width: 100%; padding: 10px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.lock-password-cancel {
  background: none; border: none; color: var(--text-secondary);
  font-size: 11px; cursor: pointer; padding: 4px;
}
.lock-password-cancel:hover { color: var(--text-primary); }

/* =============== Files navbar (back/fwd/up/home/refresh + breadcrumb) =============== */
.files-navbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.files-navbar .btn-icon { flex-shrink: 0; }
.files-navbar .btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.files-breadcrumb {
  flex: 1; min-width: 0; margin-left: 8px;
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center;
}
.files-breadcrumb a {
  color: var(--text-secondary); text-decoration: none;
  padding: 2px 4px; border-radius: 3px; transition: background 0.12s;
}
.files-breadcrumb a:hover { background: rgba(59,130,246,0.1); color: var(--text-primary); }
.files-navbar-spacer { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.files-navbar label.btn-icon { display: inline-flex; align-items: center; justify-content: center; }

/* CodeMirror tweaks for our theme */
.CodeMirror {
  font-size: 12px !important;
  font-family: 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace !important;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.cm-s-material-darker.CodeMirror { background: #0f111a !important; }
.cm-s-material-darker .CodeMirror-gutters { background: #0a0c12 !important; border-right: 1px solid var(--border); }
.cm-s-material-darker .CodeMirror-linenumber { color: #4a4f6a; }
.cm-s-material-darker .CodeMirror-cursor { border-left-color: var(--accent) !important; }
[data-theme='light'] .CodeMirror { border-color: var(--border); }

/* =============== Layout =============== */
.app-wrapper { display: flex; min-height: 100vh; }
.main-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  margin-left: var(--sidebar-w);
  padding-bottom: var(--statusbar-h);
}
.content-area { flex: 1; padding: 14px 18px; overflow-y: auto; }

/* =============== Sidebar =============== */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: var(--statusbar-h);
  z-index: 1040;
  transition: width 0.2s ease, transform 0.2s ease;
}
.sidebar-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Collapse toggle — circle centered on sidebar right edge, aligned with header */
.sidebar-collapse-btn {
  position: absolute; right: -12px; top: 11px; z-index: 1041;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--sidebar-bg); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, opacity 0.2s;
  opacity: 0; pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.sidebar:hover .sidebar-collapse-btn,
.sidebar-collapse-btn:focus-visible {
  opacity: 1; pointer-events: auto;
}
.sidebar-collapse-btn:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
[data-theme='light'] .sidebar-collapse-btn {
  background: #fff; border-color: #d1d5db; color: #6b7280;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
[data-theme='light'] .sidebar-collapse-btn:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Collapsed state — uses :is() to apply for both JS class and early HTML class */
.sidebar.collapsed,
.sidebar-is-collapsed .sidebar { width: 56px; }
.sidebar.collapsed .sidebar-brand span,     .sidebar-is-collapsed .sidebar .sidebar-brand span,
.sidebar.collapsed .sidebar-section-label,   .sidebar-is-collapsed .sidebar .sidebar-section-label,
.sidebar.collapsed .sidebar-group-head,       .sidebar-is-collapsed .sidebar .sidebar-group-head,
.sidebar.collapsed .sidebar-nav .nav-link span, .sidebar-is-collapsed .sidebar .sidebar-nav .nav-link span,
.sidebar.collapsed .sidebar-nav .nav-link .badge, .sidebar-is-collapsed .sidebar .sidebar-nav .nav-link .badge,
.sidebar.collapsed .user-info,               .sidebar-is-collapsed .sidebar .user-info,
.sidebar.collapsed .sidebar-logout,          .sidebar-is-collapsed .sidebar .sidebar-logout { display: none; }

/* В свёрнутом режиме группы ведут себя как иконочный список; между группами — разделитель */
.sidebar.collapsed .sidebar-group,            .sidebar-is-collapsed .sidebar .sidebar-group {
  padding: 0;
  margin-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 4px;
}
.sidebar.collapsed .sidebar-group:first-of-type, .sidebar-is-collapsed .sidebar .sidebar-group:first-of-type {
  border-top: none;
  margin-top: 6px;
}
.sidebar.collapsed .sidebar-group-body,       .sidebar-is-collapsed .sidebar .sidebar-group-body {
  max-height: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  /* В свёрнутом сайдбаре — никаких фонов/рамок/отступов, иконки идут сплошным списком */
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.sidebar.collapsed .sidebar-nav,             .sidebar-is-collapsed .sidebar .sidebar-nav { padding: 0 4px 2px; align-items: center; }
.sidebar.collapsed .sidebar-nav .nav-link,   .sidebar-is-collapsed .sidebar .sidebar-nav .nav-link { justify-content: center; padding: 10px 0; width: 40px; margin: 0 auto; }
.sidebar.collapsed .sidebar-nav .nav-link i, .sidebar-is-collapsed .sidebar .sidebar-nav .nav-link i { font-size: 17px; width: auto; }
.sidebar.collapsed .sidebar-header,          .sidebar-is-collapsed .sidebar .sidebar-header { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-brand,           .sidebar-is-collapsed .sidebar .sidebar-brand { gap: 0; }
.sidebar.collapsed .sidebar-collapse-btn,    .sidebar-is-collapsed .sidebar .sidebar-collapse-btn { right: -12px; opacity: 1; pointer-events: auto; }
.sidebar.collapsed .sidebar-footer,          .sidebar-is-collapsed .sidebar .sidebar-footer { padding: 10px 0; display: flex; justify-content: center; }
.sidebar.collapsed .user-card,               .sidebar-is-collapsed .sidebar .user-card { justify-content: center; gap: 0; }
.sidebar.collapsed .user-avatar,             .sidebar-is-collapsed .sidebar .user-avatar { width: 30px; height: 30px; font-size: 10px; }
.sidebar.collapsed .sidebar-collapse-btn i,  .sidebar-is-collapsed .sidebar .sidebar-collapse-btn i { transform: rotate(180deg); }
.sidebar.collapsed + .main-content,
.sidebar-is-collapsed .main-content { margin-left: 56px; }
.main-content { transition: margin-left 0.2s ease; }

.sidebar-header {
  height: 46px; padding: 0 16px;
  display: flex; align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 16px; font-weight: 700; color: var(--text-primary);
}
.sidebar-brand:hover { color: var(--text-primary); text-decoration: none; }
.sidebar-brand i { font-size: 22px; color: var(--accent); }
/* Старый class оставлен как fallback, но в новом sidebar не используется */
.sidebar-section-label {
  padding: 12px 16px 4px; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-secondary); opacity: 0.5;
}

.sidebar-nav { padding: 0 8px 2px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav.sidebar-top { padding-top: 6px; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 500; font-size: 12px;
  transition: all 0.15s;
}
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link:focus-visible {
  background: rgba(59, 130, 246, 0.08); color: var(--text-primary); outline: none;
}
.sidebar-nav .nav-link.active { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.sidebar-nav .nav-link i { font-size: 14px; width: 18px; text-align: center; }
.sidebar-nav .nav-link .badge {
  margin-left: auto; font-size: 9px; padding: 2px 5px;
}

/* ─── Группы (сворачиваемые секции) ─── */
.sidebar-group {
  margin-top: 6px;
  padding: 0 6px;
}
.sidebar-group-head {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.sidebar-group-head:hover {
  background: rgba(59, 130, 246, 0.06);
  color: var(--text-primary);
}
.sidebar-group-icon {
  font-size: 13px !important;
  width: 16px !important;
  text-align: center;
  color: var(--text-secondary);
  opacity: 0.7;
  transition: color 0.15s, opacity 0.15s;
}
.sidebar-group-head:hover .sidebar-group-icon,
.sidebar-group[data-has-active="1"] .sidebar-group-icon {
  color: var(--accent);
  opacity: 1;
}
.sidebar-group-label {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Счётчик вытащен из flex-цепочки, чтобы шевроны всегда стояли строго
 * у правого края, а счётчик не съедал место при скрытом состоянии. */
.sidebar-group-count {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 999px;
  color: var(--text-secondary);
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.sidebar-group-head:hover .sidebar-group-count { opacity: 1; }
.sidebar-group-chevron {
  font-size: 11px !important;
  width: 12px !important;
  text-align: center;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.15s;
}
.sidebar-group-head:hover .sidebar-group-chevron { opacity: 1; }

.sidebar-group-body {
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.25s ease, opacity 0.2s ease,
              margin 0.2s ease, padding 0.2s ease;
  opacity: 1;
  margin: 3px 4px 4px 4px;
  padding: 4px 4px;
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.10);
  border-radius: var(--radius-sm);
}
/* Активная группа — подсветка сильнее + акцентная полоска слева */
.sidebar-group[data-has-active="1"]:not(.collapsed) .sidebar-group-body {
  background: rgba(59, 130, 246, 0.09);
  border-color: rgba(59, 130, 246, 0.22);
  box-shadow: inset 2px 0 0 var(--accent);
}
/* Пункты внутри открытой группы — чуть более компактный отступ по левому краю,
 * чтобы визуально читались как "вложенные" в группу */
.sidebar-group-body .nav-link {
  padding-left: 10px;
  padding-right: 10px;
  font-size: 12px;
}
.sidebar-group.collapsed .sidebar-group-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  pointer-events: none;
}
.sidebar-group.collapsed .sidebar-group-chevron {
  transform: rotate(-90deg);
}

/* Акцент слева, если в группе активен пункт */
.sidebar-group[data-has-active="1"] > .sidebar-group-head {
  color: var(--text-primary);
  position: relative;
}
.sidebar-group[data-has-active="1"] > .sidebar-group-head::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.sidebar-footer {
  margin-top: auto; padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.user-card { display: flex; align-items: center; gap: 9px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11px; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 12px; color: #fff; text-decoration: none; }
a.user-name:hover { color: var(--accent); }
a.user-avatar { text-decoration: none; color: #fff; }
.user-role { font-size: 10px; color: rgba(255, 255, 255, 0.4); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-logout {
  color: rgba(255, 255, 255, 0.3); font-size: 14px; transition: color 0.15s;
  background: none; border: none; padding: 4px; cursor: pointer;
}
.sidebar-logout:hover { color: var(--danger); }

/* =============== Top Header =============== */
.top-header {
  height: 46px; padding: 0 18px;
  display: flex; align-items: center;
  background: var(--header-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1020;
}
.header-search {
  flex: 1; max-width: 360px; position: relative;
}
.header-search i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary); font-size: 13px;
}
.header-search input {
  width: 100%; padding: 6px 10px 6px 32px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-primary); color: var(--text-primary);
  font-size: 12px; outline: none; transition: border-color 0.15s;
}
.header-search input:focus { border-color: var(--accent); }
.header-search input::placeholder { color: var(--text-secondary); }
.header-search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-family: inherit;
}
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.header-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: none; border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; position: relative;
  transition: all 0.15s; font-size: 13px;
}
.header-icon:hover, .header-icon:focus-visible {
  background: var(--bg-card); color: var(--text-primary); outline: none;
}
.header-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* =============== Status Bar =============== */
.status-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--statusbar-h); padding: 0 12px;
  background: var(--statusbar-bg); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  font-size: 10px; font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary); z-index: 1050;
  letter-spacing: 0.2px;
}
.status-bar .sb-item { display: flex; align-items: center; gap: 5px; }
.status-bar .sb-item i { font-size: 11px; }
.status-bar .sb-spacer { flex: 1; }
.status-bar .sb-ok { color: var(--success); }
.sb-ok { color: var(--success); }
.status-bar .sb-warn { color: var(--warning); }
.status-bar .sb-bad { color: var(--danger); }
.status-bar .sb-accent { color: var(--accent); }
.sb-accent { color: var(--accent); }
.status-bar .sb-demo {
  background: rgba(245, 158, 11, 0.18); color: var(--warning);
  padding: 1px 6px; border-radius: 3px; font-weight: 700; letter-spacing: 0.5px;
}

/* =============== Page header =============== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.page-title { font-size: 17px; font-weight: 700; margin: 0; }
.page-subtitle { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 6px; }

/* =============== Cards =============== */
.card-custom {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-custom-header {
  padding: 9px 13px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-custom-title { font-size: 12px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 6px; }
.card-custom-title i { color: var(--accent); font-size: 13px; }
.card-custom-body { padding: 12px 13px; }

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 13px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.stat-value { font-size: 17px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 10px; color: var(--text-secondary); margin-top: 1px; text-transform: uppercase; letter-spacing: 0.4px; }

/* =============== Tables =============== */
.table-custom { color: var(--text-primary); margin: 0; }
.table-custom thead th {
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-secondary); padding: 7px 10px; white-space: nowrap;
}
.table-custom tbody td {
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle; font-size: 12px;
}
.table-custom tbody tr:hover { background: var(--bg-card-hover); }
.table-custom tbody tr:last-child td { border-bottom: none; }

/* =============== Nav tabs (dark theme) =============== */
.nav-tabs {
  border-bottom-color: var(--border);
}
.nav-tabs .nav-link {
  color: var(--text-secondary); font-size: 12px; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 6px 14px; transition: color 0.15s, background 0.15s;
}
.nav-tabs .nav-link:hover {
  color: var(--text-primary); border-color: transparent transparent var(--border);
  background: var(--bg-card-hover);
}
.nav-tabs .nav-link.active {
  color: var(--accent); background: var(--bg-card);
  border-color: var(--border) var(--border) var(--bg-card);
}
.nav-tabs .nav-link .badge { font-size: 10px; vertical-align: middle; margin-left: 4px; }

/* =============== User avatar (inline) =============== */
.user-avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-secondary); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; flex-shrink: 0;
}

/* =============== Status dots / badges =============== */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-offline { background: var(--text-secondary); }
.status-warning { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-error { background: var(--danger); box-shadow: 0 0 6px var(--danger); animation: pulse 2s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.badge { font-weight: 500; font-size: 10px; }
.bg-primary-subtle { background: rgba(59, 130, 246, 0.12) !important; color: var(--accent) !important; }
.bg-success-subtle { background: rgba(16, 185, 129, 0.12) !important; color: var(--success) !important; }
.bg-danger-subtle { background: rgba(239, 68, 68, 0.12) !important; color: var(--danger) !important; }
.bg-warning-subtle { background: rgba(245, 158, 11, 0.12) !important; color: var(--warning) !important; }
.bg-info-subtle { background: rgba(6, 182, 212, 0.12) !important; color: var(--info) !important; }
.bg-secondary-subtle { background: rgba(139, 143, 163, 0.12) !important; color: var(--text-secondary) !important; }

/* =============== Forms =============== */
.form-control, .form-select {
  background: var(--bg-card); border-color: var(--border); color: var(--text-primary); font-size: 12px;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-card); border-color: var(--accent); color: var(--text-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.form-label { color: var(--text-secondary); font-size: 11px; }

/* ─── Range sliders ──────────────────────────────────────────────────── */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  margin-top: -6px;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
input[type=range]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}
input[type=range]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent, #3b82f6);
}

/* =============== Buttons =============== */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-outline-secondary { border-color: var(--border); color: var(--text-secondary); }
.btn-outline-secondary:hover, .btn-outline-secondary:focus-visible {
  background: var(--bg-card); border-color: var(--accent); color: var(--text-primary);
}
.btn-xs { padding: 2px 8px; font-size: 10px; border-radius: 4px; }

/* =============== Error Page =============== */
.error-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; padding: 24px;
}
.error-card {
  text-align: center; max-width: 420px; width: 100%;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}
.error-icon { font-size: 48px; color: var(--warning); margin-bottom: 16px; }
.error-title { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.error-message { font-size: 13px; color: var(--text-secondary); margin: 0 0 20px; line-height: 1.5; }
.error-stack {
  text-align: left; margin: 16px 0; font-size: 10px; color: var(--text-secondary);
}
.error-stack summary {
  cursor: pointer; font-size: 11px; color: var(--text-secondary);
  margin-bottom: 6px;
}
.error-stack pre {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px;
  max-height: 200px; overflow: auto; font-size: 10px;
}
.error-actions { display: flex; gap: 8px; justify-content: center; }

/* =============== Info Banner (platform availability, etc.) =============== */
.info-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; margin: 20px 0;
  background: linear-gradient(135deg, rgba(6,182,212,0.06), rgba(59,130,246,0.06));
  border: 1px solid rgba(6,182,212,0.2);
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
}
.info-banner-icon {
  flex-shrink: 0; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(6,182,212,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--info);
}
.info-banner-content { flex: 1; min-width: 0; }
.info-banner-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.info-banner-text { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* =============== Page Transitions =============== */
.content-area {
  transition: opacity 0.12s ease, transform 0.12s ease;
}

/* =============== Page Help Tips =============== */
.page-tip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 14px;
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.15);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-secondary); line-height: 1.5;
}
.page-tip i:first-child { font-size: 16px; color: var(--warning); flex-shrink: 0; }
.page-tip span { flex: 1; }
.page-tip-close {
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  font-size: 14px; padding: 2px 4px; opacity: 0.4; transition: opacity 0.15s;
  flex-shrink: 0;
}
.page-tip-close:hover { opacity: 1; }
[data-theme='light'] .page-tip {
  background: rgba(245,158,11,0.05);
  border-color: rgba(245,158,11,0.2);
}

/* =============== Empty state =============== */
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-secondary); }
.empty-state i { font-size: 36px; margin-bottom: 12px; display: block; opacity: 0.4; }
.empty-state h3 { font-size: 14px; margin-bottom: 4px; color: var(--text-primary); }

/* =============== Command Palette =============== */
.cmd-palette-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 12vh; z-index: 2000;
}
.cmd-palette-backdrop.open { display: flex; }
.cmd-palette {
  width: 100%; max-width: 540px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); overflow: hidden;
}
.cmd-palette-input {
  width: 100%; padding: 14px 18px;
  background: transparent; border: none; outline: none;
  color: var(--text-primary); font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.cmd-palette-list { max-height: 50vh; overflow-y: auto; }
.cmd-palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 18px; cursor: pointer;
  font-size: 13px; color: var(--text-primary);
  border-left: 2px solid transparent;
}
.cmd-palette-item:hover, .cmd-palette-item.active {
  background: rgba(59, 130, 246, 0.1); border-left-color: var(--accent);
}
.cmd-palette-item i { font-size: 14px; color: var(--text-secondary); width: 20px; text-align: center; }
.cmd-palette-item .cmd-cat { margin-left: auto; font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.cmd-palette-empty { padding: 24px; text-align: center; color: var(--text-secondary); font-size: 12px; }
.cmd-palette-footer {
  padding: 8px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 16px; font-size: 10px; color: var(--text-secondary);
}
.cmd-palette-footer kbd {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-secondary);
  margin-right: 4px;
}

/* =============== Hotkeys help overlay =============== */
.hotkeys-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 2100;
  padding: 24px;
  animation: hkFade 0.18s ease;
}
.hotkeys-overlay.open { display: flex; }
@keyframes hkFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.hotkeys-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.hotkeys-modal-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.hotkeys-modal-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.hotkeys-modal-header h3 i { color: var(--primary); font-size: 16px; }
.hk-search {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hk-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.hk-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.hk-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}
.hotkeys-modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}
.hk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 760px) {
  .hk-grid { grid-template-columns: 1fr; }
}
.hk-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.hk-section:last-child { margin-bottom: 0; }
.hk-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
.hk-section-title i { color: var(--primary); font-size: 13px; }
.hk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 12px;
}
.hk-row + .hk-row { border-top: 1px dashed transparent; }
.hk-label {
  color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.hk-label i {
  color: var(--text-secondary);
  font-size: 13px;
  width: 16px; text-align: center;
}
.hk-keys {
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.hk-keys kbd, .hotkeys-modal kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  color: var(--text-primary);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  min-width: 18px;
  text-align: center;
}
.hk-top-tip {
  /* обычная подсказка как на страницах — без sticky, скроллится вместе с содержимым */
  margin-bottom: 14px;
}
.hk-top-tip kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  margin: 0 2px;
  color: var(--text-primary);
}

/* Индикатор ожидания второй клавиши после g */
.hk-pending-indicator {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 2050;
}
.hk-pending-indicator kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  color: var(--primary);
  font-weight: 600;
}
body.hk-pending .hk-pending-indicator {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =============== Scrollbar =============== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* =============== Bootstrap dark/unified fixes =============== */

/* --- Forms (global, theme-aware via variables) --- */
.form-control, .form-select {
  background: var(--bg-secondary); border-color: var(--border);
  color: var(--text-primary); font-size: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-secondary); border-color: var(--accent);
  color: var(--text-primary); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.form-control::placeholder { color: var(--text-secondary); }
.form-control:disabled, .form-control[readonly] {
  background: var(--bg-primary) !important; opacity: 0.55; cursor: not-allowed;
}
.form-select:disabled { background: var(--bg-primary) !important; opacity: 0.55; }
.form-select option { background: var(--bg-card); color: var(--text-primary); }
.form-label { color: var(--text-secondary); font-size: 11px; font-weight: 500; }
.form-check-label { color: var(--text-secondary); font-size: 12px; }
.form-check-input { background-color: var(--bg-secondary); border-color: var(--border); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
/* Custom toggle switch — replaces Bootstrap 5 form-switch completely */
.vi-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
}
.vi-toggle input {
  opacity: 0; width: 0; height: 0; position: absolute;
}
.vi-toggle-track {
  position: relative; display: inline-block;
  width: 40px; height: 22px; flex-shrink: 0;
  cursor: pointer;
  background: var(--border); border-radius: 11px;
  transition: background 0.2s;
}
.vi-toggle-track::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; top: 3px;
  background: #999; border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.vi-toggle input:checked + .vi-toggle-track {
  background: var(--accent);
}
.vi-toggle input:checked + .vi-toggle-track::after {
  transform: translateX(18px); background: #fff;
}
.vi-toggle input:focus-visible + .vi-toggle-track {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}
.vi-toggle input:disabled + .vi-toggle-track {
  opacity: 0.4; cursor: not-allowed;
}
[data-theme='light'] .vi-toggle-track { background: #d1d5db; }
[data-theme='light'] .vi-toggle-track::after { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
[data-theme='light'] .vi-toggle input:checked + .vi-toggle-track { background: var(--accent); }
.form-text { color: var(--text-secondary); font-size: 11px; }
.input-group-text {
  background: var(--bg-primary); border-color: var(--border);
  color: var(--text-secondary); font-size: 12px;
}

/* --- Tables --- */
.table { --bs-table-color: var(--text-primary); --bs-table-bg: transparent; --bs-table-border-color: var(--border); }
.table > :not(caption) > * > * { border-bottom-color: var(--border); }

/* --- Modals --- */
.modal-content {
  background: var(--bg-card); border-color: var(--border); color: var(--text-primary);
}
.modal-header { border-bottom-color: var(--border); }
.modal-header .modal-title { color: var(--text-primary); font-size: 15px; font-weight: 600; }
.modal-footer { border-top-color: var(--border); }
.modal-body { color: var(--text-primary); }
[data-theme='dark'] .btn-close { filter: invert(1) grayscale(1) brightness(0.8); }

/* --- Alerts --- */
.alert { font-size: 12px; border-radius: var(--radius-sm); }
.alert-danger {
  background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}
.alert-warning {
  background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.25);
  color: var(--warning);
}
.alert-info {
  background: rgba(6, 182, 212, 0.12); border-color: rgba(6, 182, 212, 0.25);
  color: var(--info);
}
.alert-success {
  background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.25);
  color: var(--success);
}

/* --- Buttons unified focus --- */
.btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}
.btn-outline-primary { border-color: var(--accent); color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-secondary { background: var(--bg-secondary); border-color: var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border); color: var(--text-primary); }

/* --- Dropdown menus --- */
.dropdown-menu {
  background: var(--bg-card); border-color: var(--border); color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}
.dropdown-item { color: var(--text-primary); font-size: 12px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-card-hover); color: var(--text-primary); }
.dropdown-divider { border-top-color: var(--border); }

/* --- Legacy toast (deprecated, replaced by toast-stack/toast-item in Improvement 7) ---
   Kept only .toast-success/.toast-error for backwards compat if used elsewhere */
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }

/* --- Accordion --- */
.accordion-item { background: var(--bg-card); border-color: var(--border); }
.accordion-button {
  background: var(--bg-card); color: var(--text-primary);
  box-shadow: none; font-size: 13px;
}
.accordion-button:not(.collapsed) { background: var(--bg-secondary); color: var(--accent); }
.accordion-button::after { filter: brightness(0) saturate(0) invert(0.6); }
[data-theme='dark'] .accordion-button::after { filter: invert(1) brightness(0.7); }

/* ============================================================
   LIGHT THEME — полный override всех переменных и фоновых хардкодов
   ============================================================ */
[data-theme='light'] {
  --bg-primary: #f5f6f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #eef0f4;
  --text-primary: #1a1d26;
  --text-secondary: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --border: #d1d5db;
  --sidebar-bg: #1e2130;
  --header-bg: #ffffff;
  --statusbar-bg: #1e2130;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --video-bg: #0a0c12;
}

/* Auth-страница на светлой теме */
[data-theme='light'] .auth-body {
  background: var(--bg-primary);
}
[data-theme='light'] .auth-card {
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(16px);
  border-color: rgba(37, 99, 235, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 0 60px rgba(37, 99, 235, 0.04);
}
[data-theme='light'] .auth-card .form-control {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

/* Sidebar остаётся тёмным (NOC-стиль), но текст ярче */
[data-theme='light'] .sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  border-right-color: rgba(255, 255, 255, 0.08);
}
[data-theme='light'] .sidebar-brand { color: #fff; }
[data-theme='light'] .sidebar-section-label { color: rgba(255, 255, 255, 0.4); }
[data-theme='light'] .sidebar-nav .nav-link { color: rgba(255, 255, 255, 0.7); }
[data-theme='light'] .sidebar-nav .nav-link:hover {
  background: rgba(59, 130, 246, 0.18);
  color: #fff;
}
[data-theme='light'] .sidebar-nav .nav-link.active {
  background: rgba(59, 130, 246, 0.28);
  color: #fff;
}
[data-theme='light'] .sidebar-footer { border-top-color: rgba(255, 255, 255, 0.08); }
[data-theme='light'] .user-name { color: #fff; }
[data-theme='light'] .user-role { color: rgba(255, 255, 255, 0.5); }
[data-theme='light'] .sidebar-logout { color: rgba(255, 255, 255, 0.5); }

/* Header */
[data-theme='light'] .top-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
[data-theme='light'] .header-search input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border);
}
[data-theme='light'] .header-search kbd {
  background: var(--bg-primary);
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme='light'] .header-icon {
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme='light'] .header-icon:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Status-bar (NOC-стиль, остаётся тёмным с monospace) */
[data-theme='light'] .status-bar {
  background: var(--statusbar-bg);
  color: rgba(255, 255, 255, 0.7);
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* Cards */
[data-theme='light'] .card-custom {
  background: var(--bg-card);
  border-color: var(--border);
}
[data-theme='light'] .card-custom-header {
  background: var(--bg-card);
  border-bottom-color: var(--bg-card-hover);
}
[data-theme='light'] .stat-card {
  background: var(--bg-card);
  border-color: var(--border);
}

/* Tables */
[data-theme='light'] .table-custom thead th {
  background: var(--bg-primary);
  border-bottom-color: var(--border);
  color: var(--text-secondary);
}
[data-theme='light'] .table-custom tbody td {
  border-bottom-color: var(--bg-card-hover);
}
[data-theme='light'] .table-custom tbody tr:hover {
  background: var(--bg-primary);
}

/* Forms */
[data-theme='light'] .form-control,
[data-theme='light'] .form-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border);
}
[data-theme='light'] .form-control:focus,
[data-theme='light'] .form-select:focus {
  background: var(--bg-secondary);
  border-color: var(--accent);
}
[data-theme='light'] .form-select option { background: var(--bg-secondary); color: var(--text-primary); }
[data-theme='light'] .form-check-input { background-color: #dde0e5; border-color: #bcc1ca; }
[data-theme='light'] .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
[data-theme='light'] .input-group-text {
  background: var(--bg-primary);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* Modals */
[data-theme='light'] .modal-content {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}
[data-theme='light'] .modal-header {
  border-bottom-color: var(--bg-card-hover);
}
[data-theme='light'] .modal-footer {
  border-top-color: var(--bg-card-hover);
}
[data-theme='light'] .btn-close-white {
  filter: none;
}

/* Subtle badges (фон чуть ярче, текст нативного цвета) */
[data-theme='light'] .bg-primary-subtle {
  background: rgba(37, 99, 235, 0.1) !important;
  color: var(--accent) !important;
}
[data-theme='light'] .bg-success-subtle {
  background: rgba(5, 150, 105, 0.12) !important;
  color: var(--success) !important;
}
[data-theme='light'] .bg-danger-subtle {
  background: rgba(220, 38, 38, 0.12) !important;
  color: var(--danger) !important;
}
[data-theme='light'] .bg-warning-subtle {
  background: rgba(217, 119, 6, 0.14) !important;
  color: var(--warning) !important;
}
[data-theme='light'] .bg-info-subtle {
  background: rgba(8, 145, 178, 0.12) !important;
  color: var(--info) !important;
}
[data-theme='light'] .bg-secondary-subtle {
  background: rgba(107, 114, 128, 0.12) !important;
  color: var(--text-secondary) !important;
}

/* Палитра командной палитры */
[data-theme='light'] .cmd-palette {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
}
[data-theme='light'] .cmd-palette-input {
  color: var(--text-primary);
  border-bottom-color: var(--bg-card-hover);
}
[data-theme='light'] .cmd-palette-item { color: var(--text-primary); }
[data-theme='light'] .cmd-palette-item:hover,
[data-theme='light'] .cmd-palette-item.active {
  background: rgba(37, 99, 235, 0.08);
}
[data-theme='light'] .cmd-palette-footer {
  border-top-color: var(--bg-card-hover);
}
[data-theme='light'] .hotkeys-modal {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}

/* Camera viewport остаётся тёмным (там видео или snapshot) */
[data-theme='light'] .cam-viewport,
[data-theme='light'] [class*='cam-cell'] {
  background: var(--video-bg) !important;
}

/* Buttons outline на светлой теме */
[data-theme='light'] .btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-secondary);
}
[data-theme='light'] .btn-outline-secondary:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* Scrollbar */
[data-theme='light'] ::-webkit-scrollbar-track { background: var(--bg-primary); }
[data-theme='light'] ::-webkit-scrollbar-thumb {
  background: var(--border);
}
[data-theme='light'] ::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Status dots в светлой теме чуть мягче */
[data-theme='light'] .status-online { box-shadow: 0 0 4px var(--success); }
[data-theme='light'] .status-error { box-shadow: 0 0 4px var(--danger); }

/* Empty state */
[data-theme='light'] .empty-state h3 { color: var(--text-primary); }

/* Editor textarea в file manager — светлый фон */
[data-theme='light'] #fileEditor {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

/* Journal pre block в /services modal */
[data-theme='light'] #svcJournalBody {
  background: var(--bg-primary) !important;
  color: var(--text-primary);
}

/* ============================================================
   CAMERA GRID — динамическая ресайзимая сетка (Improvement 2)
   ============================================================ */
/* Group of small layout/view-switcher buttons (используется в cameras + files) */
.cam-grid-toolbar,
.view-switcher {
  display: flex;
  gap: var(--gap-sm);
  align-items: center;
  flex-wrap: wrap;
}
.layout-btn {
  width: 32px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.15s;
  padding: 0;
}
.layout-btn:hover,
.layout-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.layout-btn i { font-size: 12px; }

/* Cameras page = grid main + right palette */
.cam-page {
  display: flex;
  gap: var(--gap-sm);
  width: 100%;
  height: calc(100vh - 110px);
}
.cam-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Right palette of available cameras */
.cam-palette {
  width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.cam-palette.collapsed {
  width: 36px;
}
.cam-palette.collapsed .cam-palette-title,
.cam-palette.collapsed .cam-palette-list,
.cam-palette.collapsed .cam-palette-search,
.cam-palette.collapsed .cam-palette-actions { display: none; }
.cam-palette-header {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.cam-palette-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
}
.cam-palette-toggle:hover { color: var(--text-primary); }
.cam-palette-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cam-palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cam-palette-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, transform 0.15s;
  user-select: none;
}
.cam-palette-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.cam-palette-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
}
.cam-palette-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--video-bg);
  border-radius: 4px;
  display: block;
  /* Не давать браузеру тащить картинку отдельно — drag должен идти от родителя */
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.cam-palette-meta {
  pointer-events: none;
}
.cam-palette-thumb-fallback {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--video-bg);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  pointer-events: none;
}
.cam-palette-thumb-fallback i { font-size: 24px; opacity: 0.4; }
.cam-palette-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: monospace;
  font-size: var(--fs-xs);
}
.cam-palette-id { font-weight: 600; color: var(--text-primary); }
.cam-palette-status { font-size: 9px; }
.cam-palette-status.online { color: var(--success); }
.cam-palette-status.offline { color: var(--text-secondary); }
.cam-palette-status.drift { color: var(--warning); }

#camGridDyn {
  display: grid;
  gap: 2px;
  background: var(--video-bg);
  width: 100%;
  flex: 1;
  min-height: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  position: relative;
}

.cam-tile {
  position: relative;
  background: var(--video-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 120px;
  min-height: 80px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.cam-tile:hover { border-color: var(--accent); }
.cam-tile.cam-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}
.cam-tile.cam-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999;
  border-radius: 0;
}
.cam-tile.cam-offline { background: var(--bg-secondary); }
.cam-tile.cam-alert {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5);
  animation: pulse 1.5s infinite;
}
.cam-tile.cam-warning {
  border-color: var(--warning);
}
.cam-tile-canvas,
.cam-tile-snap {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.cam-tile-canvas { background: var(--video-bg) !important; }
.cam-tile-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.85);
  color: var(--text-secondary);
  font-size: 11px;
  z-index: 4;
  pointer-events: none;
}
.cam-tile-error i { font-size: 24px; opacity: 0.5; margin-bottom: 4px; }
.cam-tile-overlay-top {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 3;
  font-size: 10px;
}
.cam-tile-overlay-bottom {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
  z-index: 3;
  font-size: 10px;
}
.cam-tile-tag {
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.cam-tile-tag.live {
  background: rgba(239, 68, 68, 0.85);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cam-tile-tag.live::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1s infinite;
}
.cam-tile-buttons {
  position: absolute;
  top: 4px;
  right: 4px;
  display: none;
  gap: 3px;
  z-index: 5;
  pointer-events: auto;
}
.cam-tile:hover .cam-tile-buttons,
.cam-tile.cam-fullscreen .cam-tile-buttons { display: flex; }
.cam-tile-btn {
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-tile-btn:hover { background: rgba(0, 0, 0, 0.85); color: #fff; }
.cam-tile-btn-remove:hover { background: var(--danger) !important; color: #fff; }
.cam-tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 11px;
  z-index: 2;
  pointer-events: none;
}
.cam-tile-placeholder i { font-size: 32px; opacity: 0.4; margin-bottom: 4px; }

/* Splitters — div'ы между ячейками для drag-resize */
.cam-splitter {
  background: transparent;
  position: absolute;
  z-index: 4;
}
.cam-splitter:hover { background: rgba(59, 130, 246, 0.4); }
.cam-splitter.dragging { background: var(--accent); }
.cam-splitter-col { cursor: col-resize; }
.cam-splitter-row { cursor: row-resize; }

/* Corner splitter — диагональный resize одновременно cols+rows (Improvement 9.B) */
.cam-splitter-corner {
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: transparent;
  border-radius: 50%;
  z-index: 5;
}
.cam-splitter-corner::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.5);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s;
}
.cam-splitter-corner:hover::after,
.cam-splitter-corner.dragging::after {
  transform: translate(-50%, -50%) scale(1);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

/* Drag-and-drop visual для перестановки камер */
.cam-tile.cam-drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}
.cam-tile.cam-dragging { opacity: 0.4; }

/* ============================================================
   FILE MANAGER — view modes (Improvement 3)
   ============================================================ */
.fm-grid {
  display: grid;
  gap: 6px;
  padding: 12px;
}
.fm-grid.fm-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fm-grid.fm-thumbs { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.fm-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  user-select: none;
  position: relative;
}
.fm-cell:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}
.fm-cell.fm-selected {
  background: rgba(59, 130, 246, 0.14);
  border-color: var(--accent);
}
.fm-cell-icon {
  font-size: 48px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.fm-grid.fm-thumbs .fm-cell-icon { font-size: 56px; }
.fm-cell-icon.fm-folder { color: var(--accent); }
.fm-cell-icon.fm-image { color: var(--info); }
.fm-cell-icon.fm-video { color: var(--warning); }
.fm-cell-icon.fm-audio { color: var(--success); }
.fm-cell-name {
  font-size: 12px;
  color: var(--text-primary);
  word-break: break-word;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.fm-cell-size {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-family: monospace;
}
.fm-cell-thumb {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-secondary);
  margin-bottom: 8px;
}
.fm-grid.fm-thumbs .fm-cell { padding: 12px 8px; }

/* =============== File preview modal (Improvement 5) =============== */
.fm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  padding: 24px;
}
.fm-modal-backdrop.open { display: flex; }
.fm-modal-backdrop.open .fm-modal {
  animation: animate__fadeInUp 0.25s ease;
}
.fm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1200px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}
.fm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.fm-modal-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.fm-modal-title .fm-modal-name {
  font-family: monospace;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fm-modal-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.fm-modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--video-bg);
}
[data-theme='light'] .fm-modal-body { background: var(--bg-primary); }

.fm-modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-sm);
}
.fm-modal-video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-sm);
  background: var(--video-bg);
}
.fm-modal-audio {
  width: 100%;
  max-width: 600px;
}
.fm-modal-pdf {
  width: 100%;
  height: 80vh;
  border: none;
}
.fm-modal-text {
  width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 12px;
  resize: none;
  outline: none;
  min-height: 60vh;
}
.fm-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}
.fm-modal-footer .fm-modal-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-family: monospace;
}
.fm-modal-nav {
  display: flex;
  gap: 4px;
}

/* ============================================================
   VOICE CONTROL (Improvement 8)
   ============================================================ */
/* =============== Voice Assistant v2 =============== */
/* Mic button in header */
.voice-mic-btn {
  position: relative; width: 32px; height: 32px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff;
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s; box-shadow: 0 2px 8px rgba(59,130,246,0.3);
  overflow: visible; z-index: 10; flex-shrink: 0;
  animation: vmicIdle 3s ease-in-out infinite;
}
.voice-mic-btn::before,
.voice-mic-btn::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid rgba(139,92,246,0.4); pointer-events: none;
  animation: vmicIdleRing 3s ease-out infinite;
}
.voice-mic-btn::after { animation-delay: 1s; }
@keyframes vmicIdle {
  0%,100% { box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
  50% { box-shadow: 0 2px 16px rgba(139,92,246,0.5), 0 0 24px rgba(59,130,246,0.15); }
}
@keyframes vmicIdleRing {
  0% { transform: scale(1); opacity: 0.5; }
  70% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}
.voice-mic-btn:hover { transform: scale(1.1); box-shadow: 0 4px 16px rgba(59,130,246,0.5); }
.voice-mic-btn:hover::before, .voice-mic-btn:hover::after { animation-duration: 1.5s; }
.voice-mic-btn i { position: relative; z-index: 2; }
.voice-mic-pulse {
  position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent;
  pointer-events: none;
}
/* Stop idle animation when active (recording uses its own) */
.voice-mic-btn.active { animation: vmicGlow 1.5s ease-in-out infinite; }
.voice-mic-btn.active::before, .voice-mic-btn.active::after { animation: vmicRing 1.5s ease-out infinite; border-color: rgba(239,68,68,0.4); }
.voice-mic-btn.active::after { animation-delay: 0.5s; }
.voice-mic-btn.active {
  background: linear-gradient(135deg, var(--danger), var(--warning));
  animation: vmicGlow 1.5s ease-in-out infinite;
}
.voice-mic-btn.active .voice-mic-pulse {
  border-color: rgba(239,68,68,0.4);
  animation: vmicRing 1.5s ease-out infinite;
}
.voice-mic-btn.active i { animation: vmicPulse 0.6s ease-in-out infinite alternate; }
@keyframes vmicGlow { 0%,100% { box-shadow: 0 0 10px rgba(239,68,68,0.4); } 50% { box-shadow: 0 0 24px rgba(239,68,68,0.7), 0 0 40px rgba(245,158,11,0.2); } }
@keyframes vmicRing { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes vmicPulse { 0% { transform: scale(1); } 100% { transform: scale(1.15); } }

/* Modal backdrop */
.voice-modal-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.voice-modal-backdrop.open { display: flex; }

/* Modal card */
.voice-modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; width: 420px; max-width: 90vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  overflow: hidden; animation: vmSlideIn 0.3s ease-out;
}
@keyframes vmSlideIn { 0% { opacity: 0; transform: translateY(20px) scale(0.95); } 100% { opacity: 1; transform: none; } }

.voice-modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.voice-modal-avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
}
.voice-modal-title { font-size: 14px; font-weight: 700; }
.voice-modal-status { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.voice-modal-close {
  margin-left: auto; background: none; border: none;
  color: var(--text-secondary); font-size: 14px; cursor: pointer; padding: 4px;
}
.voice-modal-close:hover { color: var(--text-primary); }

/* Body */
.voice-modal-body {
  padding: 24px 20px; min-height: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}

/* Sound waves */
.voice-waves {
  display: flex; align-items: center; justify-content: center;
  gap: 3px; height: 44px; opacity: 0.3;
}
.voice-waves.active { opacity: 1; }
.voice-waves span {
  width: 3px; border-radius: 2px;
  background: linear-gradient(to top, var(--accent), #8b5cf6);
  height: 3px; min-height: 3px;
  transition: height 0.06s ease-out;
}

/* Thinking state */
.voice-state-thinking .voice-modal-avatar { animation: vthink 1s ease-in-out infinite; }
.voice-state-thinking .voice-waves span {
  background: linear-gradient(to top, var(--warning), var(--danger));
  animation: vthinkDot 1.2s ease-in-out infinite;
}
.voice-state-thinking .voice-waves span:nth-child(odd) { animation-delay: 0.3s; }
@keyframes vthink { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes vthinkDot { 0%,100% { height: 4px; } 50% { height: 14px; } }

/* Transcript */
.voice-modal .voice-transcript {
  font-size: 16px; font-weight: 500; text-align: center;
  color: var(--text-primary); min-height: 24px;
  position: static; opacity: 1; transform: none; pointer-events: auto;
  background: none; border: none; box-shadow: none; backdrop-filter: none;
  max-width: 100%; white-space: normal; padding: 0; border-radius: 0;
}
.voice-modal .voice-transcript.interim { color: var(--text-secondary); }
.voice-modal .voice-transcript.final { color: var(--text-primary); }

/* Response */
.voice-response {
  font-size: 13px; color: var(--text-secondary); text-align: center;
  line-height: 1.5; min-height: 20px;
}
.voice-help-grid { text-align: left; font-size: 11px; display: flex; flex-direction: column; gap: 6px; }
.voice-help-grid b { color: var(--text-primary); }

/* Footer */
.voice-modal-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.voice-modal-mic {
  position: relative; width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border: none; color: #fff; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s; box-shadow: 0 4px 20px rgba(59,130,246,0.3);
}
.voice-modal-mic:hover { transform: scale(1.05); box-shadow: 0 6px 28px rgba(59,130,246,0.5); }
.voice-modal-mic.recording {
  background: linear-gradient(135deg, var(--danger), var(--warning));
  animation: vmicGlow 1.5s ease-in-out infinite;
}
.voice-modal-mic.recording i { animation: vmicPulse 0.6s ease-in-out infinite alternate; }
.voice-modal-mic-pulse {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid transparent; pointer-events: none;
}
.voice-modal-mic.recording .voice-modal-mic-pulse {
  border-color: rgba(239,68,68,0.3); animation: vmicRing 1.5s ease-out infinite;
}
.voice-modal-hints {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.voice-modal-hints span {
  font-size: 10px; color: var(--text-secondary);
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px 10px;
}

/* Light theme */
[data-theme='light'] .voice-modal { background: var(--bg-card); }

/* ============================================================
   Camera control modal tabs (Improvement 9.D)
   ============================================================ */
.cam-ctrl-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.cam-ctrl-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 10px 14px;
  font-size: var(--fs-md);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.cam-ctrl-tab:hover { color: var(--text-primary); }
.cam-ctrl-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.cam-ctrl-pane { display: none; }
.cam-ctrl-pane.active { display: block; }
.cam-ctrl-slider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.cam-ctrl-slider label {
  flex: 0 0 100px;
  font-size: var(--fs-md);
  color: var(--text-secondary);
}
.cam-ctrl-slider input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}
.cam-ctrl-slider .val {
  flex: 0 0 40px;
  text-align: right;
  font-family: monospace;
  font-size: var(--fs-md);
  color: var(--text-primary);
}

/* List view (компактный) */
.fm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.fm-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}
.fm-list-item:hover { background: var(--bg-card-hover); }
.fm-list-item.fm-selected {
  background: rgba(59, 130, 246, 0.12);
  border-left: 2px solid var(--accent);
}
.fm-list-item i { font-size: 14px; width: 18px; text-align: center; color: var(--text-secondary); flex-shrink: 0; }
.fm-list-item i.fm-folder { color: var(--accent); }
.fm-list-item .fm-list-name { flex: 1; min-width: 0; color: var(--text-primary); }
.fm-list-item .fm-list-meta { font-family: monospace; font-size: 10px; color: var(--text-secondary); flex-shrink: 0; }

/* Preview pane */
.fm-preview-image {
  max-width: 100%;
  max-height: 50vh;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  background: var(--video-bg);
}
.fm-preview-video,
.fm-preview-audio {
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--video-bg);
}
.fm-preview-meta {
  font-size: var(--fs-sm);
}
.fm-preview-meta .row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.fm-preview-meta .row:last-child { border-bottom: none; }
.fm-preview-meta .label { color: var(--text-secondary); }
.fm-preview-meta .value { color: var(--text-primary); font-family: monospace; }

/* Stat-grid card (унифицированные KPI-карточки) — оригинал в .stat-card,
   тут добавляем компактный вариант для маленьких блоков */
.stat-card.stat-card-sm {
  padding: 10px 12px;
  gap: 8px;
}
.stat-card.stat-card-sm .stat-icon { width: 28px; height: 28px; font-size: 14px; }
.stat-card.stat-card-sm .stat-value { font-size: var(--fs-lg); }

/* Camera detail viewport (snapshot/live frame) */
.cam-detail-viewport {
  background: var(--video-bg);
  aspect-ratio: 16 / 9;
  position: relative;
}
[data-theme='light'] .cam-detail-viewport { background: var(--video-bg); }

/* =============== Utilities =============== */
.text-muted-2 { color: var(--text-secondary) !important; }
.mono { font-feature-settings: 'tnum' 1; }
.no-select { user-select: none; }
.cursor-pointer { cursor: pointer; }

/* =============== Unified semantic classes (Improvement 7) =============== */
/* Иконочная кнопка — единый размер для всех кнопок-иконок в header/cards */
.btn-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--accent); }
.btn-icon.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-icon.btn-icon-sm { width: 26px; height: 26px; font-size: 11px; }
.btn-icon + .btn-icon { margin-left: 4px; }
.btn-icon.btn-icon-danger { color: var(--danger); }
.btn-icon.btn-icon-danger:hover { color: var(--danger); border-color: var(--danger); background: rgba(239,68,68,0.1); }
.btn-icon.btn-icon-success { color: var(--success); }
.btn-icon.btn-icon-success:hover { color: var(--success); border-color: var(--success); background: rgba(16,185,129,0.1); }
.btn-icon.btn-icon-warning { color: var(--warning); }
.btn-icon.btn-icon-warning:hover { color: var(--warning); border-color: var(--warning); background: rgba(245,158,11,0.1); }

/* Универсальная row пары label/value (используется в preview, system, camera detail) */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-md);
  padding: 3px 0;
}
.info-row + .info-row { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 1px; }
.info-row .info-label { color: var(--text-secondary); }
.info-row .info-value {
  font-family: monospace;
  text-align: right;
  word-break: break-all;
  max-width: 70%;
}

/* Code-pill — inline монопара (типа версии/IP/MAC) */
.code-pill {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: monospace;
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

/* Section title (NOC-стиль uppercase) */
.section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  opacity: 0.6;
  padding: var(--gap-md) 0 var(--gap-xs);
}

/* =============== Filter bar (унифицированный) =============== */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar .filter-input { flex: 0 1 auto; }
.filter-bar select.form-select-sm,
.filter-bar input.form-control-sm { font-size: 11px; padding: 4px 8px; }

/* =============== Process row highlights =============== */
.proc-row-hi-warn { background: rgba(245, 158, 11, 0.07); }
.proc-row-hi-warn:hover { background: rgba(245, 158, 11, 0.14); }
.proc-row-hi-bad { background: rgba(239, 68, 68, 0.08); }
.proc-row-hi-bad:hover { background: rgba(239, 68, 68, 0.16); }
[data-theme='light'] .proc-row-hi-warn { background: rgba(217, 119, 6, 0.08); }
[data-theme='light'] .proc-row-hi-warn:hover { background: rgba(217, 119, 6, 0.14); }
[data-theme='light'] .proc-row-hi-bad { background: rgba(220, 38, 38, 0.08); }
[data-theme='light'] .proc-row-hi-bad:hover { background: rgba(220, 38, 38, 0.16); }
.proc-state {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-family: monospace;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
}
.proc-state-R { background: rgba(16, 185, 129, 0.18); color: var(--success); }
.proc-state-S { background: rgba(107, 114, 128, 0.15); color: var(--text-secondary); }
.proc-state-D { background: rgba(245, 158, 11, 0.18); color: var(--warning); }
.proc-state-Z { background: rgba(239, 68, 68, 0.18); color: var(--danger); }
.proc-state-T { background: rgba(168, 85, 247, 0.18); color: var(--event-face); }

/* =============== Action dropdown menu (custom, без bootstrap.Dropdown) =============== */
.act-menu-wrap { position: relative; display: inline-block; }
.act-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 2px);
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 4px 0;
  min-width: 180px;
}
.act-menu.open { display: block; }
.act-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.act-menu-item:hover { background: var(--bg-card-hover); }
.act-menu-item.danger:hover { background: rgba(239, 68, 68, 0.12); color: var(--danger); }
.act-menu-item i { width: 14px; font-size: 12px; }
.act-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* =============== Toasts (унифицированные) =============== */
.toast-stack {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 10px 14px 10px 12px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: toast-in 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast-item.toast-success { border-left-color: var(--success); }
.toast-item.toast-success i { color: var(--success); }
.toast-item.toast-error { border-left-color: var(--danger); }
.toast-item.toast-error i { color: var(--danger); }
.toast-item.toast-warning { border-left-color: var(--warning); }
.toast-item.toast-warning i { color: var(--warning); }
.toast-item.toast-info { border-left-color: var(--info); }
.toast-item.toast-info i { color: var(--info); }
.toast-item i { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.toast-item .toast-msg { flex: 1; word-break: break-word; }
.toast-item .toast-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}
.toast-item.toast-leaving {
  animation: toast-out 0.2s forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Cloud Overview — #10 (full-screen launcher)
   ═══════════════════════════════════════════════════════════════════════════ */
.cloud-body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
#cloudRoot { display: flex; flex-direction: column; }

/* Header bar */
.cloud-header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cloud-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  white-space: nowrap; text-decoration: none;
}
.cloud-brand i { font-size: 18px; }
.cloud-header-center { flex: 1; display: flex; justify-content: center; }
.cloud-search {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 12px; color: var(--text-primary);
  font-size: 12px; width: 280px; outline: none;
}
.cloud-search:focus { border-color: var(--accent); }
.cloud-header-right { display: flex; align-items: center; gap: 8px; }
.cloud-select {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 8px; color: var(--text-primary);
  font-size: 11px; outline: none;
}
.cloud-btn {
  background: var(--accent); border: none; border-radius: 4px;
  padding: 5px 12px; color: #fff; font-size: 11px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.cloud-btn:hover { opacity: 0.9; }
.cloud-btn-icon {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 14px; padding: 2px;
}
.cloud-btn-icon:hover { color: var(--text-primary); }
.cloud-user { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.cloud-user-name { font-size: 11px; color: var(--text-secondary); }

/* Summary bar */
.cloud-summary {
  display: flex; gap: 24px; padding: 8px 24px;
  font-size: 12px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.cloud-summary-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: help;
  transition: background 0.15s, border-color 0.15s;
}
.cloud-summary-item:hover { background: var(--bg-card-hover); }
.cloud-summary-item .cs-lbl { color: var(--text-secondary); font-size: 11px; }
.cloud-summary-item span:not(.cs-lbl) { color: var(--text-primary); font-weight: 600; }
.cloud-summary-item i { font-size: 13px; color: var(--text-secondary); }
.cloud-summary-item.online { color: var(--success); border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.08); }
.cloud-summary-item.online i,
.cloud-summary-item.online span:not(.cs-lbl) { color: var(--success); }
.cloud-summary-item.cameras-online.cs-ok { border-color: rgba(16,185,129,0.35); background: rgba(16,185,129,0.08); }
.cloud-summary-item.cameras-online.cs-ok i,
.cloud-summary-item.cameras-online.cs-ok span:not(.cs-lbl) { color: var(--success); }
.cloud-summary-item.cameras-online.cs-warn { border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.08); }
.cloud-summary-item.cameras-online.cs-warn i,
.cloud-summary-item.cameras-online.cs-warn span:not(.cs-lbl) { color: var(--danger); }

/* Grid */
.cloud-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
  padding: 8px 24px 20px;
  align-content: start;
}
.cloud-loading {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--text-secondary); padding: 60px 0;
}

/* Card */
.cld-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.cld-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.cld-card.offline { opacity: 0.55; }
.cld-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cld-card-id { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.cld-card-tags { display: flex; gap: 3px; flex-wrap: wrap; }
.cld-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-secondary); flex-shrink: 0;
}
.cld-dot.on { background: var(--success); }
.cld-badge {
  font-size: 8px; padding: 1px 5px; border-radius: 3px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
}
.cld-badge.local { background: rgba(59,130,246,0.15); color: var(--accent); }
.cld-badge.remote { background: rgba(16,185,129,0.15); color: var(--success); }
.cld-tag {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: var(--bg-secondary); color: var(--text-secondary);
}

/* Gauges row */
.cld-gauges { display: flex; justify-content: space-around; align-items: center; }
.cld-gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cld-gauge-ring { position: relative; display: flex; align-items: center; justify-content: center; }
.cld-gauge-ring svg { display: block; }
.cld-gauge-fill { transition: stroke-dashoffset 0.8s ease; }
.cld-gauge-fill.cld-ok { stroke: var(--success); }
.cld-gauge-fill.cld-warn { stroke: var(--warning); }
.cld-gauge-fill.cld-danger { stroke: var(--danger); }
.cld-gauge-ring .cld-gauge-val {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.cld-gauge-val {
  font-size: 14px; font-weight: 700; font-family: monospace;
}
.cld-gauge-val.cld-ok { color: var(--success); }
.cld-gauge-val.cld-warn { color: var(--warning); }
.cld-gauge-val.cld-danger { color: var(--danger); }
.cld-gauge-label { font-size: 9px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.cld-uptime-box {
  width: 64px; height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
}
.cld-uptime-box i { font-size: 18px; color: var(--accent); }
.cld-uptime-val { font-size: 14px; font-weight: 700; font-family: monospace; color: var(--text-primary); }

/* Sparklines */
.cld-sparks { display: flex; gap: 10px; }
.cld-spark-box { flex: 1; display: flex; align-items: center; gap: 4px; }
.cld-spark-lbl { font-size: 9px; color: var(--text-secondary); width: 24px; flex-shrink: 0; text-transform: uppercase; }
.cld-spark { width: 100%; height: 40px; }

/* Device icons */
.cld-devices {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  padding: 4px 0;
}
.cld-dev {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 10px; width: 40px;
}
.cld-dev i { font-size: 16px; }
.cld-dev span { font-size: 9px; font-family: monospace; font-weight: 600; }
.cld-dev.on { color: var(--success); }
.cld-dev.off { color: var(--text-secondary); opacity: 0.5; }
.cld-nodevices { text-align: center; font-size: 11px; color: var(--text-secondary); padding: 4px 0; }

/* Footer */
.cld-card-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; color: var(--text-secondary);
  border-top: 1px solid var(--border); padding-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Global animate.css tweaks — faster defaults, subtle feel
   ═══════════════════════════════════════════════════════════════════════════ */
.animate__animated { --animate-duration: 0.35s; }

/* Page title icon subtle color */
.page-title i { color: var(--accent); margin-right: 4px; }

/* Card hover lift */
.card-custom { transition: border-color 0.15s, transform 0.12s; }
.card-custom:hover { transform: translateY(-1px); }

/* Sidebar nav link transition */
.sidebar-nav .nav-link { transition: background 0.15s, padding-left 0.15s; }
.sidebar-nav .nav-link:hover { padding-left: 18px; }
.sidebar-nav .nav-link i { transition: transform 0.15s; }
.sidebar-nav .nav-link:hover i { transform: scale(1.15); }

/* Toast entrance/exit already uses keyframes — speed up */
@keyframes animate__fadeInUp {
  from { opacity: 0; transform: translate3d(0, 20px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Table row hover */
.table-custom tbody tr { transition: background 0.1s; }

/* Status dot pulse for online */
.cld-dot.on { animation: dotPulse 2s infinite; }
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Cloud card staggered entrance */
.cld-card { animation: animate__fadeInUp 0.3s ease both; }
.cld-card:nth-child(2) { animation-delay: 0.05s; }
.cld-card:nth-child(3) { animation-delay: 0.1s; }
.cld-card:nth-child(4) { animation-delay: 0.15s; }
.cld-card:nth-child(5) { animation-delay: 0.2s; }
.cld-card:nth-child(6) { animation-delay: 0.25s; }

/* ═══════════════════════════════════════════════════════════════════════════
   Logs page — source list
   ═══════════════════════════════════════════════════════════════════════════ */
.logs-src-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.logs-src-item:hover { background: var(--bg-card-hover); }
.logs-src-item.logs-src-active { background: var(--accent); color: #fff; }
.logs-src-item i { font-size: 14px; flex-shrink: 0; }
.logs-src-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logs-src-del {
  background: none; border: none; color: inherit; opacity: 0.5;
  cursor: pointer; font-size: 12px; padding: 0;
}
.logs-src-del:hover { opacity: 1; }

/* =============== Settings =============== */
.settings-layout {
  display: flex; gap: var(--gap-md);
  min-height: 500px;
}
.settings-tabs {
  flex: 0 0 200px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; align-self: flex-start;
}
.settings-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font-size: var(--fs-md); font-weight: 500;
  cursor: pointer; color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  border: none; background: none; text-align: left; width: 100%;
}
.settings-tab:hover { background: rgba(59, 130, 246, 0.08); color: var(--text-primary); }
.settings-tab.active { background: var(--accent); color: #fff; }
.settings-tab i { font-size: 15px; width: 20px; text-align: center; }
.settings-tab .count { margin-left: auto; font-size: 10px; opacity: 0.5; }

.settings-content { flex: 1; min-width: 0; }
.settings-group { display: none; }
.settings-group.active { display: block; }
.settings-group-title {
  font-size: var(--fs-lg); font-weight: 600;
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.settings-group-title i { color: var(--accent); }

.setting-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; min-width: 0; }
.setting-label { font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); }
.setting-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }
.setting-key { font-size: var(--fs-xs); font-family: var(--font-mono, monospace); color: var(--text-secondary); opacity: 0.5; margin-top: 2px; }
.setting-control { flex: 0 0 220px; }
.setting-control input,
.setting-control select {
  width: 100%; font-size: var(--fs-md);
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.setting-control input:focus,
.setting-control select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,0.2); }
.setting-control input[type="number"] { max-width: 120px; }
.settings-changed { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* Settings — light theme */
[data-theme='light'] .settings-tab { color: var(--text-secondary); }
[data-theme='light'] .settings-tab:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
[data-theme='light'] .settings-tab.active { background: var(--accent); color: #fff; }
[data-theme='light'] .setting-row { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme='light'] .setting-control input,
[data-theme='light'] .setting-control select {
  background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border);
}

@media (max-width: 768px) {
  .settings-layout { flex-direction: column; }
  .settings-tabs { flex-direction: row; overflow-x: auto; flex: none; position: static; }
  .setting-row { flex-direction: column; }
  .setting-control { flex: none; width: 100%; }
}

/* =============== Profile =============== */
.profile-avatar-wrap {
  position: relative; display: inline-block;
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%; margin: 0 auto;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 28px; color: #fff;
  overflow: hidden; text-decoration: none;
}
.profile-avatar-edit {
  position: absolute; bottom: 0; right: -4px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.profile-avatar-edit:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* =============== Topology v2 =============== */
.topo-stats {
  display: flex; gap: 16px; padding: 0 0 12px; flex-wrap: wrap;
}
.topo-stat {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-secondary);
}
.topo-stat i { font-size: 13px; }
.topo-stat span { font-weight: 600; color: var(--text-primary); }
.topo-stat-ok i, .topo-stat-ok span { color: var(--success); }
.topo-stat-bad i, .topo-stat-bad span { color: var(--danger); }

.topo-layout {
  display: flex; gap: var(--gap-md); min-height: 500px;
}
.topo-graph-card { flex: 1; min-width: 0; }
#topoGraph { height: calc(100vh - 240px); min-height: 400px; }

/* Search overlay */
.topo-search {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 11px; box-shadow: var(--shadow); z-index: 5;
}
.topo-search i { color: var(--text-secondary); font-size: 11px; }
.topo-search input {
  border: none; background: none; color: var(--text-primary);
  font-size: 11px; width: 160px; outline: none;
}
.topo-search input::placeholder { color: var(--text-secondary); }

/* Legend */
.topo-legend {
  position: absolute; bottom: 10px; left: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 11px; display: flex; flex-direction: column; gap: 5px;
  box-shadow: var(--shadow); z-index: 5;
}
.topo-legend-title { font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 2px; }
.topo-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}

/* Detail sidebar */
.topo-detail {
  width: 260px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: none; flex-direction: column; gap: 14px;
  overflow-y: auto; max-height: calc(100vh - 240px);
}
.topo-detail.open { display: flex; }
.topo-detail-empty {
  text-align: center; color: var(--text-secondary); padding: 40px 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.topo-detail-empty i { font-size: 32px; opacity: 0.3; }
.topo-detail-header {
  display: flex; align-items: center; gap: 12px;
}
.topo-detail-ip { font-size: 16px; font-weight: 700; font-family: var(--font-mono, monospace); }
.topo-detail-status { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.topo-detail-rows { display: flex; flex-direction: column; gap: 6px; }
.topo-detail-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-size: 11px;
}
.topo-detail-label { color: var(--text-secondary); flex-shrink: 0; }
.topo-detail-value { font-family: var(--font-mono, monospace); text-align: right; word-break: break-all; color: var(--text-primary); }
.topo-detail-actions {
  display: flex; gap: 6px; flex-wrap: wrap; padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Empty state */
.topo-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; min-height: 300px; color: var(--text-secondary); gap: 8px;
}
.topo-empty i { font-size: 48px; opacity: 0.2; }

@media (max-width: 768px) {
  .topo-layout { flex-direction: column; }
  .topo-detail { width: 100%; max-height: none; }
}

/* =============== Camera Palette Tree View =============== */
.cam-palette-actions {
  margin-left: auto; display: flex; gap: 2px;
}
.cam-palette-search {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; margin: 0 6px 4px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 11px;
}
.cam-palette-search i { color: var(--text-secondary); font-size: 11px; flex-shrink: 0; }
.cam-palette-search input {
  border: none; background: none; color: var(--text-primary);
  font-size: 11px; width: 100%; outline: none;
}
.cam-palette-search input::placeholder { color: var(--text-secondary); }
.cam-tree-group { margin-bottom: 2px; }
.cam-tree-group-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; cursor: pointer; font-size: 11px; font-weight: 600;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  transition: background 0.15s;
  position: relative;
}
.cam-tree-group-header:hover { background: rgba(59,130,246,0.06); color: var(--text-primary); }
.cam-tree-chevron { font-size: 10px; width: 12px; text-align: center; flex-shrink: 0; transition: transform 0.15s; }
.cam-tree-group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-tree-group-count {
  font-size: 9px; color: var(--text-secondary); opacity: 0.6;
  background: var(--bg-secondary); border-radius: 8px; padding: 1px 5px;
}
.cam-group-actions {
  display: none; gap: 2px; margin-left: 4px;
}
.cam-tree-group-header:hover .cam-group-actions { display: flex; }
.cam-tree-group-body { padding-left: 8px; }
.cam-tree-group-body.collapsed { display: none; }
.cam-tree-group-body .cam-palette-item {
  padding: 4px 8px; margin: 1px 0; border-radius: var(--radius-sm);
}

/* Tree compact item (icon + name, no preview) */
.cam-tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 12px; cursor: grab; font-size: 11px;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
.cam-tree-item:hover { background: rgba(59,130,246,0.06); color: var(--text-primary); }
.cam-tree-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-tree-item.dragging { opacity: 0.4; }

/* Drop zone highlight */
.cam-drop-zone {
  min-height: 24px; transition: background 0.15s, outline 0.15s;
  border-radius: var(--radius-sm); margin: 0 4px;
}
.cam-drop-zone.cam-drop-highlight {
  background: rgba(59,130,246,0.08);
  outline: 1px dashed var(--accent); outline-offset: -1px;
}

/* =============== Archive page =============== */
.archive-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  grid-template-rows: 1fr;
  gap: 12px;
  height: calc(100vh - 200px);
  min-height: 560px;
}
@media (max-width: 1200px) {
  .archive-layout { grid-template-columns: 220px 1fr 240px; }
}
@media (max-width: 960px) {
  .archive-layout { grid-template-columns: 1fr; height: auto; }
}

.archive-cams,
.archive-events {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.archive-cams-head,
.archive-events-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-secondary);
}
.archive-cams-head strong,
.archive-events-head strong { font-size: 12px; }
.archive-cams-head .form-control-sm,
.archive-events-head .form-select-sm { flex: 1; }

.archive-cams-list { overflow-y: auto; flex: 1; }
.arch-cam-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.arch-cam-item:hover { background: rgba(59,130,246,0.06); }
.arch-cam-item.active {
  background: rgba(59,130,246,0.12);
  border-left: 3px solid var(--primary);
  padding-left: 9px;
}
.arch-cam-top {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  margin-bottom: 4px;
}
.arch-cam-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}
.arch-cam-dot.online  { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.6); }
.arch-cam-dot.offline { background: var(--danger); }
.arch-cam-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-cam-rec {
  font-size: 9px; font-weight: 700;
  padding: 2px 5px; border-radius: 3px;
  background: var(--danger);
  color: #fff;
  animation: archRecPulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes archRecPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.arch-cam-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; color: var(--text-secondary);
}
.arch-cam-icons { display: inline-flex; gap: 6px; }
.arch-cam-icons i { color: var(--accent); font-size: 12px; }

/* ─── Main (player + timeline) ─── */
.archive-main {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0; /* чтобы видео не раздувало grid */
}

.archive-player-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 280px;
}
.archive-player-bar {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.archive-player-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.archive-player-ctrls { display: flex; gap: 6px; align-items: center; }
.archive-player-video {
  flex: 1; position: relative;
  background: var(--video-bg, #000);
  min-height: 240px;
  display: flex; align-items: center; justify-content: center;
}
.archive-player-video video {
  max-width: 100%; max-height: 100%;
  display: none;
}
.archive-player-empty {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}
.archive-player-empty i {
  font-size: 48px; display: block; margin-bottom: 10px;
  opacity: 0.35;
}

/* ─── Timeline ─── */
.archive-timeline-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.archive-timeline-head {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.archive-timeline-legend { display: flex; gap: 10px; align-items: center; }
.arch-legend {
  font-size: 10px; color: var(--text-secondary);
  display: inline-flex; align-items: center; gap: 4px;
}
.arch-legend-dot {
  width: 10px; height: 10px; border-radius: 2px;
  display: inline-block;
}
.arch-legend-dot.rec    { background: var(--success); }
.arch-legend-dot.motion { background: var(--event-motion); }
.arch-legend-dot.face   { background: var(--event-face); }
.arch-legend-dot.alarm  { background: var(--danger); }
.archive-timeline-stats {
  margin-left: auto;
  font-size: 11px; color: var(--text-secondary);
}

.arch-zoom-ctrls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.arch-zoom-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-primary);
  min-width: 34px;
  text-align: center;
  font-weight: 600;
}

.archive-timeline-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  /* Плавный native-scroll */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.archive-timeline-scroll::-webkit-scrollbar { height: 8px; }
.archive-timeline-scroll::-webkit-scrollbar-track { background: transparent; }
.archive-timeline-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.archive-timeline-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

.archive-timeline {
  position: relative;
  padding: 20px 12px 12px;
  user-select: none;
  width: 100%; /* переопределяется inline через applyZoom() */
  min-width: 100%;
}
.archive-timeline-ruler {
  position: relative; height: 14px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.arch-ruler-tick {
  position: absolute; top: 0;
  font-size: 9px; color: var(--text-secondary);
  transform: translateX(-50%);
  white-space: nowrap;
  opacity: 0.55;
}
.arch-ruler-tick.arch-ruler-major {
  opacity: 1;
  color: var(--text-primary);
  font-weight: 600;
}
.arch-ruler-tick::after {
  content: ''; display: block;
  width: 1px; height: 4px;
  background: var(--border);
  margin: 0 auto;
}
.arch-ruler-tick.arch-ruler-major::after {
  height: 7px;
  background: var(--text-secondary);
}

.archive-timeline-track {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: crosshair;
}
.archive-timeline-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-secondary);
  font-size: 12px;
}

.arch-lane {
  position: relative;
  height: 18px;
  border-bottom: 1px dashed var(--border);
}
.arch-lane:last-child { border-bottom: none; }
.arch-lane-rec { background: rgba(16,185,129,0.05); }

.arch-seg {
  position: absolute; top: 2px; bottom: 2px;
  background: linear-gradient(180deg, var(--success) 0%, #059669 100%);
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 2px;
  min-width: 2px;
  cursor: pointer;
  transition: filter 0.12s, transform 0.12s;
}
.arch-seg:hover { filter: brightness(1.2); }
.arch-seg.active {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  z-index: 2;
}

.arch-ev {
  position: absolute; top: 4px;
  width: 6px; height: 10px;
  transform: translateX(-50%);
  border-radius: 2px;
  cursor: pointer;
  transition: transform 0.12s;
}
.arch-ev:hover { transform: translateX(-50%) scale(1.3); z-index: 3; }
.arch-ev-motion { background: var(--event-motion); }
.arch-ev-face   { background: var(--event-face); }
.arch-ev-alarm  {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(239,68,68,0.7);
  width: 8px; height: 14px; top: 2px;
}
.arch-ev.sev-high { box-shadow: 0 0 4px currentColor; }

.archive-timeline-cursor {
  position: absolute; top: 20px; bottom: 12px;
  width: 1px;
  background: var(--accent);
  pointer-events: none;
  display: none;
  z-index: 4;
}
.archive-timeline-cursor::after {
  content: attr(data-time);
  position: absolute; top: -18px; left: 2px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  padding: 1px 5px; border-radius: 3px;
  font-size: 9px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  white-space: nowrap;
}

/* ─── Events panel ─── */
.archive-events-list { overflow-y: auto; flex: 1; }
.arch-ev-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.arch-ev-item:hover { background: rgba(59,130,246,0.06); }
.arch-ev-item > i {
  font-size: 16px;
  margin-top: 1px;
  flex-shrink: 0;
}
.arch-ev-item.ev-motion > i   { color: var(--event-motion); }
.arch-ev-item.ev-face > i     { color: var(--event-face); }
.arch-ev-item.ev-alarm > i    { color: var(--danger); }
.arch-ev-item.ev-rec-start > i,
.arch-ev-item.ev-rec-stop > i { color: var(--success); }
.arch-ev-item-body { flex: 1; min-width: 0; }
.arch-ev-item-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px;
}
.arch-ev-item-type {
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-primary);
}
.arch-ev-item-time {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  font-size: 10px;
}
.arch-ev-item-label {
  font-size: 11px; color: var(--text-primary);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.arch-ev-item-conf {
  font-size: 9px; color: var(--text-secondary);
  margin-top: 2px;
}
.arch-ev-item.sev-high {
  border-left: 3px solid var(--danger);
  padding-left: 9px;
}
.arch-ev-item.sev-medium {
  border-left: 3px solid var(--warning);
  padding-left: 9px;
}

/* ─── REC badge (внутри overlay-top, inline) ─── */
.cam-tile-tag-rec {
  background: var(--danger) !important;
  color: #fff !important;
  font-weight: 700;
  letter-spacing: 0.3px;
  animation: archRecPulse 1.5s ease-in-out infinite;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
/* ─── Статус online/offline на тайле (внизу справа) ─── */
.cam-tile-tag-status {
  font-weight: 700;
  text-transform: lowercase;
}
.cam-tile-tag-status.is-online {
  background: rgba(16, 185, 129, 0.22) !important;
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.45);
}
.cam-tile-tag-status.is-offline {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #fca5a5 !important;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

/* =============== Camera Detectors tab =============== */
.cam-det-grid { display: flex; flex-direction: column; gap: 14px; }
.cam-det-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.cam-det-head {
  display: flex; align-items: flex-start; gap: 12px;
}
.cam-det-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 20px;
  flex-shrink: 0;
}
.cam-det-icon-rec    { background: rgba(239,68,68,0.12);  color: var(--danger);  }
.cam-det-icon-motion { background: rgba(59,130,246,0.12); color: var(--event-motion);         }
.cam-det-icon-face   { background: rgba(168,85,247,0.12); color: var(--event-face);         }
.cam-det-title { flex: 1; min-width: 0; }
.cam-det-title strong { display: block; font-size: 13px; color: var(--text-primary); margin-bottom: 2px; }
.cam-det-sub {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.cam-det-row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.cam-det-row label {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 160px;
  display: flex; justify-content: space-between;
}
.cam-det-row input[type="range"] {
  flex: 1; accent-color: var(--primary);
}
.cam-det-foot {
  display: flex; gap: 8px;
  padding-top: 4px;
}
.cam-det-badge {
  display: inline-block; font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.03em;
  vertical-align: middle; margin-left: 6px;
}
.cam-det-badge-ok   { background: rgba(34,197,94,0.22); color: #4ade80; }
.cam-det-badge-warn { background: rgba(234,179,8,0.22); color: #fbbf24; }
.cam-det-badge-off  { background: rgba(148,163,184,0.16); color: #94a3b8; }

/* .switch — алиас канонического .vi-toggle чтобы старый HTML не ломался.
 * Весь визуал задаётся в одном месте (.vi-toggle, см. выше). */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider {
  position: relative; display: inline-block;
  width: 40px; height: 22px; flex-shrink: 0;
  cursor: pointer;
  background: var(--border); border-radius: 11px;
  transition: background 0.2s;
}
.switch-slider::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; left: 3px; top: 3px;
  background: #999; border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-slider { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3); }
.switch input:disabled + .switch-slider { opacity: 0.4; cursor: not-allowed; }
[data-theme='light'] .switch-slider { background: #d1d5db; }
[data-theme='light'] .switch-slider::after { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }

/* =============== Camera viewer modal =============== */
.cam-viewer-modal {
  max-width: 1100px;
  width: calc(100vw - 48px);
}
.cam-viewer-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  padding: 0;
  background: var(--bg-card);
  overflow: hidden;
  min-height: 520px;
}
@media (max-width: 900px) {
  .cam-viewer-body { grid-template-columns: 1fr; }
}

.cam-viewer-stage {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  overflow: hidden;
  cursor: crosshair;
  user-select: none;
}
.cam-viewer-zoom-wrap {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  transition: transform 0.25s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-viewer-canvas {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0a0c12;
}
/* Синий пунктирный прямоугольник выделения + затемнение снаружи */
.cam-viewer-select {
  position: absolute;
  border: 2px dashed #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  display: none;
  z-index: 5;
}
.cam-viewer-select.active { display: block; }

/* Подсказка про выделение */
.cam-viewer-hint {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  display: inline-flex; align-items: center; gap: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 4;
}
.cam-viewer-stage:hover .cam-viewer-hint { opacity: 0.9; }
.cam-viewer-stage.is-zoomed .cam-viewer-hint { display: none; }

/* Кнопка сброса зума (видна только когда зум применён) */
.cam-viewer-zoom-reset {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(59, 130, 246, 0.9);
  backdrop-filter: blur(3px);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 6;
}
.cam-viewer-zoom-reset:hover { background: rgba(59, 130, 246, 1); }
.cam-viewer-stage.is-zoomed .cam-viewer-zoom-reset { display: inline-flex; }
.cam-viewer-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
  pointer-events: none;
}
.cam-viewer-empty i {
  font-size: 56px;
  opacity: 0.35;
  margin-bottom: 10px;
}
.cam-viewer-overlay {
  position: absolute;
  bottom: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between;
  pointer-events: none;
}
.cam-viewer-overlay .cam-tile-tag {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  color: #fff;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}

.cam-viewer-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cam-viewer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.cam-viewer-card-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.cam-viewer-card-title i { color: var(--primary); font-size: 12px; }
.cam-viewer-info {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.5;
}
.cam-viewer-info div { display: flex; justify-content: space-between; padding: 2px 0; }
.cam-viewer-info span:first-child { color: var(--text-secondary); }
.cam-viewer-info span:last-child { font-family: 'JetBrains Mono', monospace; }

.cam-viewer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.cam-viewer-actions-sm { gap: 4px; }
.cam-viewer-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
}
.cam-viewer-btn i { font-size: 15px; color: var(--primary); }
.cam-viewer-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-1px);
}
.cam-viewer-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.cam-viewer-btn-warn i { color: var(--warning); }
.cam-viewer-btn-warn:hover { border-color: var(--warning); }

.cam-viewer-toggles {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.cam-viewer-toggles + .cam-viewer-toggles {
  border-top: 1px dashed var(--border);
}
.cam-viewer-toggle-label {
  font-size: 12px;
  color: var(--text-primary);
  flex: 1;
}

/* =============== Roles & Permissions =============== */
/* --- Permissions grid (в модалке редактирования роли) --- */
#permissionsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.perm-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gc, var(--primary));
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s, background 0.15s;
}
.perm-group:hover { border-color: var(--gc, var(--primary)); }
.perm-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}
.perm-group-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--gc) 18%, transparent);
  color: var(--gc, var(--primary));
  border-radius: 6px;
  font-size: 13px;
  flex-shrink: 0;
}
.perm-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.perm-group-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.perm-group-toggle { flex-shrink: 0; }

.perm-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.perm-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
}
.perm-pill input { position: absolute; opacity: 0; pointer-events: none; }
.perm-pill:hover {
  background: color-mix(in srgb, var(--pc) 8%, var(--bg-card));
  color: var(--text-primary);
  border-color: var(--pc, var(--primary));
}
.perm-pill:active { transform: scale(0.97); }
.perm-pill.is-on {
  background: color-mix(in srgb, var(--pc) 22%, transparent);
  color: var(--pc, var(--primary));
  border-color: var(--pc, var(--primary));
  font-weight: 600;
}
.perm-pill.is-on::before {
  content: '\F270'; /* bi-check-lg */
  font-family: 'bootstrap-icons';
  font-size: 12px;
  line-height: 1;
}

/* --- Role cards (на странице /users вкладка Роли) --- */
.role-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.role-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.role-card-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.role-card-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.role-card-title-wrap { flex: 1; min-width: 0; }
.role-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.role-card-sys {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.18);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.45);
}
.role-card-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.role-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.role-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
}
.role-stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}
.role-stat-lbl {
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.role-card-progress {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}
.role-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent, #6366f1));
  transition: width 0.35s ease;
}
.role-card-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
}
.role-group-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.role-group-pill i { font-size: 10px; }
.role-card-actions {
  display: flex; gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.role-card-actions .btn { flex: 1; }

/* =============== PSIM: общие стили =============== */

/* ─── Инциденты: лента ─── */
.incidents-list { display: flex; flex-direction: column; gap: 8px; }
.inc-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.inc-card:hover {
  transform: translateX(3px);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.inc-card-sev-strip {
  width: 4px;
  flex-shrink: 0;
  background: var(--text-secondary);
}
.inc-card.sev-critical .inc-card-sev-strip { background: #dc2626; }
.inc-card.sev-high .inc-card-sev-strip     { background: #ef4444; }
.inc-card.sev-medium .inc-card-sev-strip   { background: #f59e0b; }
.inc-card.sev-low .inc-card-sev-strip      { background: #10b981; }
.inc-card-body { flex: 1; padding: 12px 14px; min-width: 0; }
.inc-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.inc-card-code {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}
.inc-card-status {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.inc-card.status-open .inc-card-status     { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.inc-card.status-inprogress .inc-card-status { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border-color: rgba(59, 130, 246, 0.4); }
.inc-card.status-escalated .inc-card-status { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border-color: rgba(245, 158, 11, 0.5); animation: pulse-warn 1.8s ease-in-out infinite; }
.inc-card.status-waiting .inc-card-status   { background: rgba(168, 85, 247, 0.15); color: #c084fc; border-color: rgba(168, 85, 247, 0.4); }
.inc-card.status-closed .inc-card-status    { background: rgba(16, 185, 129, 0.15); color: #34d399; border-color: rgba(16, 185, 129, 0.4); }
.inc-card.status-cancelled .inc-card-status { background: rgba(107, 114, 128, 0.15); color: #9ca3af; border-color: rgba(107, 114, 128, 0.4); }
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50%      { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}
.inc-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inc-card-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-secondary);
}
.inc-card-meta i { margin-right: 3px; }
.inc-sla-violated {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ─── Инцидент: detail страница ─── */
.incident-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  min-height: calc(100vh - 220px);
}
@media (max-width: 1100px) {
  .incident-layout { grid-template-columns: 1fr; }
}
.incident-left, .incident-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.incident-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.incident-card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.incident-card-title i { color: var(--primary); font-size: 13px; }

.incident-video-card { padding: 0; overflow: hidden; }
.incident-video-card .incident-card-title { padding: 14px 14px 8px 14px; margin-bottom: 0; }
.incident-video-stage {
  position: relative;
  background: #000;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.incident-video-canvas {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: none;
}
.incident-video-empty {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}
.incident-video-empty i {
  font-size: 48px;
  display: block;
  margin-bottom: 10px;
  opacity: 0.35;
}

.incident-info { font-size: 12px; line-height: 1.6; }
.incident-info div {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}
.incident-info span:first-child { color: var(--text-secondary); }
.incident-info span:last-child { color: var(--text-primary); }

.incident-history {
  font-size: 11px;
  max-height: 280px;
  overflow-y: auto;
}
.inc-history-item {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}
.inc-history-time { color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; font-size: 10px; }
.inc-history-action { color: var(--text-primary); }
.inc-history-actor { color: var(--primary); font-size: 10px; }

.incident-actions-card { }
.incident-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.incident-actions .btn {
  width: 100%;
  justify-content: center;
  white-space: nowrap;
  /* Фиксированная min-высота чтобы кнопки не плясали при разном тексте */
  min-height: 30px;
}
.inc-blockers {
  margin-top: 12px;
  padding: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--warning);
}
.inc-blockers ul { margin: 6px 0 0 20px; padding: 0; }
.inc-blockers li { margin: 2px 0; }

.inc-status-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.inc-sev-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  border: 1px solid;
}
.inc-sev-badge.sev-critical { background: rgba(220, 38, 38, 0.2); color: #f87171; border-color: rgba(220, 38, 38, 0.5); }
.inc-sev-badge.sev-high     { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.inc-sev-badge.sev-medium   { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); }
.inc-sev-badge.sev-low      { background: rgba(16, 185, 129, 0.2); color: #34d399; border-color: rgba(16, 185, 129, 0.4); }

.incident-tasks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inc-task-item {
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.inc-task-item:hover { background: var(--bg-card-hover); }
.inc-task-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.inc-task-top .mono { font-size: 10px; color: var(--text-secondary); }
.inc-task-status {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  text-transform: uppercase;
}
.inc-task-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.inc-task-meta { font-size: 10px; color: var(--text-secondary); margin-top: 3px; }
.inc-req-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

/* ─── SOP-степпер (внутри карточки инцидента и задачи) ─── */
.sop-instance-head {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sop-step {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: background 0.12s, border-color 0.12s;
}
.sop-step.sop-step-active {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
.sop-step.sop-step-done { opacity: 0.8; }
.sop-step.sop-step-skipped { opacity: 0.5; }
.sop-step.sop-step-blocked { opacity: 0.3; }
.sop-step-icon {
  width: 24px;
  font-size: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.sop-step.sop-step-active .sop-step-icon { color: var(--primary); animation: pulse-step 1.5s ease-in-out infinite; }
.sop-step.sop-step-done .sop-step-icon { color: var(--success); }
.sop-step.sop-step-skipped .sop-step-icon { color: var(--warning); }
@keyframes pulse-step {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.sop-step-body { flex: 1; min-width: 0; }
.sop-step-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.sop-step-desc { font-size: 11px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.5; }
.sop-step-answer {
  font-size: 11px;
  padding: 5px 8px;
  background: var(--bg-card);
  border-left: 2px solid var(--success);
  border-radius: 2px;
  color: var(--text-primary);
  margin: 6px 0;
}
.sop-input { margin-bottom: 8px; }
.sop-step-btns { display: flex; gap: 6px; }

/* ─── Задачи: лента ─── */
.tasks-list { display: flex; flex-direction: column; gap: 8px; }
.task-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, border-color 0.12s;
}
.task-card:hover { transform: translateX(3px); border-color: var(--primary); }
.task-card.sev-critical .inc-card-sev-strip { background: #dc2626; }
.task-card.sev-high     .inc-card-sev-strip { background: #ef4444; }
.task-card.sev-medium   .inc-card-sev-strip { background: #f59e0b; }
.task-card.sev-low      .inc-card-sev-strip { background: #10b981; }
.task-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.task-status {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.task-status.status-assigned { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border-color: rgba(245, 158, 11, 0.4); }
.task-status.status-accepted { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.task-status.status-in-progress { background: rgba(168, 85, 247, 0.15); color: #c084fc; border-color: rgba(168, 85, 247, 0.4); }
.task-status.status-done { background: rgba(16, 185, 129, 0.15); color: #34d399; border-color: rgba(16, 185, 129, 0.4); }
.task-status.status-failed, .task-status.status-cancelled { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.task-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin: 4px 0; }
.task-card-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-secondary);
}

/* ─── Задача: detail ─── */
.task-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
}
@media (max-width: 900px) { .task-layout { grid-template-columns: 1fr; } }
.task-main, .task-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ─── SOP-список ─── */
.sop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.sop-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.sop-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.sop-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sop-card-title-wrap { flex: 1; min-width: 0; }
.sop-card-title { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
.sop-card-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.sop-card-status {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}
.sop-card-status.status-draft { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.sop-card-desc { font-size: 11px; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.5; }
.sop-card-stats {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-secondary);
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.sop-card-stats strong { color: var(--text-primary); font-size: 14px; }
.sop-card-steps { display: flex; flex-direction: column; gap: 4px; }
.sop-card-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 3px;
  color: var(--text-secondary);
}
.sop-card-step.required { color: var(--text-primary); }
.sop-step-num {
  display: inline-flex;
  width: 18px;
  height: 18px;
  background: var(--bg-secondary);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
.sop-card-step > span:nth-child(2) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sop-step-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 1px 5px;
  background: var(--bg-secondary);
  border-radius: 2px;
  color: var(--text-secondary);
}

/* ─── Сценарии ─── */
.scenarios-list { display: flex; flex-direction: column; gap: 12px; }
.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.scenario-card-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.scenario-card-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.scenario-card-title-wrap { flex: 1; min-width: 0; }
.scenario-card-title { font-size: 11px; color: var(--text-secondary); }
.scenario-card-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.scenario-status {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.scenario-status.status-draft { background: rgba(107, 114, 128, 0.15); color: #9ca3af; }
.scenario-status.status-paused { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.scenario-card-desc { font-size: 11px; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.5; }
.scenario-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 700px) { .scenario-blocks { grid-template-columns: 1fr; } }
.scenario-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.scenario-block-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.scenario-cond {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  line-height: 1.7;
}
.cond-op   { color: var(--warning); font-weight: 700; }
.cond-field { color: var(--primary); }
.cond-val  { color: var(--success); }
.scenario-actions-list { display: flex; flex-direction: column; gap: 4px; }
.scenario-action {
  font-size: 11px;
  padding: 4px 6px;
  background: var(--bg-card);
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scenario-action i { color: var(--warning); }
.scenario-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-secondary);
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.scenario-meta strong { color: var(--text-primary); }

/* =============== VI Modal (unified prompt/confirm) =============== */
.vi-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  animation: viModalFadeIn 0.15s ease;
}
.vi-modal-backdrop.vi-modal-closing { animation: viModalFadeOut 0.15s ease forwards; }
@keyframes viModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes viModalFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.vi-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: viModalPop 0.18s ease;
}
@keyframes viModalPop {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.vi-modal-danger { border-color: rgba(239, 68, 68, 0.5); }
.vi-modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.vi-modal-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.vi-modal-title i { color: var(--primary); font-size: 16px; }
.vi-modal-danger .vi-modal-title i { color: var(--danger); }
.vi-modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 26px; height: 26px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: background 0.12s, color 0.12s;
}
.vi-modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.vi-modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.vi-modal-body .form-label {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.vi-modal-text {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 12px;
}
.vi-modal-body .is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}
.vi-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* =============== Dashboard: Security widgets =============== */
.stat-card-link {
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  cursor: pointer;
}
.stat-card-link:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  color: inherit;
}

/* Цветные состояния security-карточек */
.stat-card[data-sec-variant="incidents"] .stat-icon { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.stat-card[data-sec-variant="sla"] .stat-icon       { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-card[data-sec-variant="tasks"] .stat-icon     { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stat-card[data-sec-variant="cameras"] .stat-icon   { background: rgba(16, 185, 129, 0.15); color: #34d399; }

.stat-card.stat-alert {
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.15);
}
.stat-card.stat-alert .stat-value { color: #fca5a5; }
.stat-card.stat-danger {
  border-color: rgba(239, 68, 68, 0.6);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), transparent);
}
.stat-card.stat-danger .stat-value { color: #fca5a5; animation: pulse-danger 2s ease-in-out infinite; }
.stat-card.stat-warn {
  border-color: rgba(245, 158, 11, 0.4);
}
.stat-card.stat-warn .stat-value { color: #fbbf24; }
.stat-card.stat-ok {
  border-color: rgba(16, 185, 129, 0.4);
}
.stat-card.stat-ok .stat-value { color: #34d399; }
@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* ─── Dashboard: лента инцидентов ─── */
.dash-inc-feed { display: flex; flex-direction: column; }
.dash-inc-item {
  display: flex;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.dash-inc-item:last-child { border-bottom: none; }
.dash-inc-item:hover { background: rgba(59, 130, 246, 0.05); color: inherit; }
.dash-inc-strip { width: 3px; flex-shrink: 0; background: var(--text-secondary); }
.dash-inc-item.sev-critical .dash-inc-strip { background: #dc2626; }
.dash-inc-item.sev-high     .dash-inc-strip { background: #ef4444; }
.dash-inc-item.sev-medium   .dash-inc-strip { background: #f59e0b; }
.dash-inc-item.sev-low      .dash-inc-strip { background: #10b981; }
.dash-inc-body {
  flex: 1;
  padding: 10px 12px;
  min-width: 0;
}
.dash-inc-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.dash-inc-top .mono {
  font-size: 9px;
  color: var(--text-secondary);
  font-weight: 600;
}
.dash-inc-status {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.dash-inc-status.status-open      { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.dash-inc-status.status-in-progress { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.dash-inc-status.status-escalated { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border-color: rgba(245, 158, 11, 0.5); }
.dash-inc-status.status-waiting   { background: rgba(168, 85, 247, 0.15); color: #c084fc; border-color: rgba(168, 85, 247, 0.4); }
.dash-inc-sla {
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--danger);
  color: #fff;
  text-transform: uppercase;
}
.dash-inc-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.dash-inc-meta {
  font-size: 10px;
  color: var(--text-secondary);
}

/* =============== Video Analytics page =============== */
.analytics-list { display: flex; flex-direction: column; gap: 10px; }

.an-cam-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.an-cam-card:hover { border-color: var(--primary); }
.an-cam-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.an-cam-info { flex: 1; min-width: 0; }
.an-cam-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.an-cam-title strong { font-size: 13px; color: var(--text-primary); }
.an-cam-title .mono { font-size: 11px; }
.an-cam-meta {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-secondary);
}
.an-cam-meta i { margin-right: 3px; }
.an-cam-actions { flex-shrink: 0; }

.an-cam-detectors {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.an-det-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: border-color 0.12s, color 0.12s;
}
.an-det-chip.enabled {
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}
.an-det-chip.disabled { opacity: 0.5; }
.an-det-off {
  font-size: 8px;
  padding: 1px 4px;
  background: rgba(107, 114, 128, 0.2);
  color: var(--text-secondary);
  border-radius: 2px;
  text-transform: uppercase;
  margin-left: 2px;
}

/* ─── Modal: per-detector editor ─── */
.an-det-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.an-det-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.an-det-icon {
  width: 36px; height: 36px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.an-det-title-wrap { flex: 1; min-width: 0; }
.an-det-label { font-size: 12px; font-weight: 600; }
.an-det-sub {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
}

.an-det-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.an-det-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}
.an-det-row label {
  min-width: 140px;
  color: var(--text-secondary);
  font-size: 11px;
}
.an-det-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.an-det-val {
  min-width: 40px;
  text-align: right;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

.an-model-warn {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.5;
}
.an-model-warn i {
  color: var(--warning);
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}
.an-model-warn a { color: var(--primary); }

/* ─── Analytics: inline add-menu (вместо nested-prompt) ─── */
/* Centered picker overlay для каталога детекторов.
   z-index должен быть ВЫШЕ fm-modal-backdrop (8000), иначе picker
   откроется ПОЗАДИ модалки настройки детекторов и будет невидим. */
.an-picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
.an-picker {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  width: 760px;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}
.an-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.an-picker-head strong { font-size: 13px; }
.an-picker-head i.bi-radar { color: var(--primary); margin-right: 4px; }
.an-picker-body {
  padding: 8px 12px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.an-picker-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.an-add-cat { margin-bottom: 6px; }
.an-add-cat:last-child { margin-bottom: 0; }
.an-add-cat-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted-2);
  padding: 4px 4px 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.an-add-cat-head i { color: var(--primary); font-size: 11px; }
.an-add-cat-items {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
}
.an-add-item-state {
  display: inline-block;
  margin-left: 5px;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.an-add-item-state-ready    { background: rgba(34,197,94,0.22); color: #4ade80; }
.an-add-item-state-not-loaded { background: rgba(234,179,8,0.22); color: #fbbf24; }
.an-add-item-state-no-model { background: rgba(148,163,184,0.16); color: #94a3b8; }
.an-add-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  border: 1px solid transparent;
  min-width: 0;
}
.an-add-item:hover {
  background: rgba(59, 130, 246, 0.10);
  border-color: rgba(59, 130, 246, 0.35);
}
.an-add-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.an-add-item > i {
  font-size: 14px;
  color: var(--primary);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.an-add-item-body { flex: 1; min-width: 0; }
.an-add-item-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}
.an-add-item-desc {
  font-size: 9.5px;
  color: var(--text-secondary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Подсказка про загрузку модели */
.an-det-card .an-det-label {
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 6px;
  margin: -4px -6px;
  width: 100%;
}
.an-det-card .an-det-label:hover,
.an-det-card .an-det-label:focus {
  background: var(--bg-card);
  border-color: var(--border);
}

/* ─── AI Models page ──────────────────────────────────────────────────── */
.am-cat-head {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.am-cat-head i { color: var(--primary); }
.am-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.am-model {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-elev, var(--bg-card));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.am-model-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.am-model-name {
  font-size: 12.5px;
  font-weight: 600;
  flex: 1;
}
.am-model-meta {
  font-size: 10.5px;
  color: var(--text-muted-2);
  white-space: nowrap;
}
.am-model-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.am-covers {
  font-size: 10px;
  color: var(--text-muted-2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.am-cover {
  background: rgba(59, 130, 246, 0.10);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.am-model-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.am-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 6px;
}
.am-badge-ready    { background: rgba(34,197,94,0.22); color: #4ade80; }
.am-badge-missing  { background: rgba(234,179,8,0.22); color: #fbbf24; }
.am-badge-manual   { background: rgba(168,85,247,0.22); color: #c084fc; }
.am-badge-builtin  { background: rgba(148,163,184,0.18); color: #94a3b8; }

/* ─── Debug Logs page ─────────────────────────────────────────────────── */
.dl-log-view {
  max-height: calc(100vh - 430px);
  min-height: 420px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  background: var(--bg-card);
  border-radius: 0 0 8px 8px;
}
.dl-row {
  display: flex;
  gap: 8px;
  padding: 2px 10px;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
  align-items: baseline;
}
.dl-row:hover { background: rgba(127, 127, 127, 0.06); }
.dl-time {
  color: var(--text-muted-2);
  flex: 0 0 90px;
  font-variant-numeric: tabular-nums;
}
.dl-level {
  flex: 0 0 50px;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
}
.dl-level-fatal { background: #8b0000; color: #fff; }
.dl-level-error { background: #dc3545; color: #fff; }
.dl-level-warn  { background: #ffc107; color: #000; }
.dl-level-info  { background: #0d6efd; color: #fff; }
.dl-level-debug { background: #6c757d; color: #fff; }
.dl-level-trace { background: #495057; color: #adb5bd; }
.dl-row.dl-fatal,
.dl-row.dl-error { background: rgba(220, 53, 69, 0.06); }
.dl-row.dl-warn  { background: rgba(255, 193, 7, 0.06); }
.dl-msg {
  flex: 1 1 auto;
  color: var(--text);
}
.dl-ctx {
  flex: 0 1 auto;
  color: var(--text-muted);
  font-size: 10.5px;
  opacity: 0.85;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dl-level-filter {
  display: inline-flex;
  gap: 4px;
}
.dl-level-filter .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ─── Camera Profiles page (.cp-) ────────────────────────────────────── */
.cp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cp-cam-card {
  cursor: default;
}
.cp-cam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.cp-cam-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cp-cam-label {
  font-size: 13px;
}
.cp-no-profile {
  font-size: 11px;
  color: var(--text-muted-2);
}
.cp-cam-timeline-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cp-timeline-mini-bar {
  flex: 1;
}
.cp-timeline-mini-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.cp-timeline-mini-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
}
.cp-last-applied {
  font-size: 10.5px;
  margin-top: 4px;
}
.cp-timeline {
  margin-bottom: 10px;
}
.cp-timeline-bar {
  position: relative;
}
.cp-timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted-2);
  margin-bottom: 3px;
}
.cp-timeline-track {
  height: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.cp-timeline-seg {
  position: absolute;
  top: 0;
  height: 100%;
  opacity: 0.8;
  border-radius: 2px;
  transition: opacity 0.15s;
}
.cp-timeline-seg:hover { opacity: 1; }
.cp-slots-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.cp-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
}
.cp-slot-color {
  width: 10px;
  height: 28px;
  border-radius: 3px;
  flex-shrink: 0;
}
.cp-slot-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cp-slot-name {
  font-size: 12px;
  font-weight: 600;
}
.cp-slot-time {
  font-size: 11px;
}
.cp-slot-actions {
  display: flex;
  gap: 4px;
}
.cp-settings-block {
  background: var(--bg-input, var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.cp-settings-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cp-sliders {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cp-slider-row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  align-items: center;
  gap: 8px;
}
.cp-slider-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.cp-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.cp-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-body);
  box-shadow: 0 0 0 1px var(--primary);
}
.cp-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--bg-body);
}
.cp-slider-val {
  font-size: 11px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 24px;
}
.cp-extras {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cp-radio-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
}
.cp-radio-btn:has(input:checked) {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}
.cp-radio-btn input { display: none; }

/* ─── Backup page ─────────────────────────────────────────────────────── */
.bk-table { font-size: 12px; }
.bk-row {
  display: grid;
  grid-template-columns: 1fr 90px 160px 90px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.bk-row.bk-header {
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted-2);
  border-bottom: 2px solid var(--border);
}
.bk-name { word-break: break-all; }
.bk-actions { display: flex; gap: 4px; }

/* ─── Camera bbox overlay ─────────────────────────────────────────────── */
.cam-tile-bbox {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
.cam-tile-btn-active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* ─── Scheduler page (.sch-) ──────────────────────────────────────────── */
.sch-table { font-size: 12px; }
.sch-table thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted-2);
  border-bottom: 2px solid var(--border);
  padding: 8px 12px;
  font-weight: 700;
}
.sch-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.sch-task-name {
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sch-task-name i { color: var(--text-muted); font-size: 13px; }
.sch-type-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--bg-input, rgba(127,127,127,0.1));
  color: var(--text-muted);
  white-space: nowrap;
}
.sch-cron {
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
  background: var(--bg-input, rgba(127,127,127,0.1));
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary);
}
.sch-badge-idle {
  background: var(--bg-input, rgba(127,127,127,0.1));
  color: var(--text-muted);
}
.sch-badge-ok {
  background: rgba(25, 135, 84, 0.15);
  color: #198754;
}
.sch-badge-error {
  background: rgba(220, 53, 69, 0.15);
  color: #dc3545;
}
.sch-badge-running {
  background: rgba(13, 110, 253, 0.15);
  color: #0d6efd;
}
.sch-row-running td {
  background: rgba(13, 110, 253, 0.04);
}
@keyframes sch-spin { to { transform: rotate(360deg); } }
.sch-spin {
  display: inline-block;
  animation: sch-spin 1s linear infinite;
}

/* ─── Language switcher ───────────────────────────────────────────────── */
.lang-switcher {
  position: relative;
}
.lang-current {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lang-current img {
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}
.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 4px;
  min-width: 140px;
  z-index: 100;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
}
.lang-option:hover { background: rgba(59, 130, 246, 0.1); }
.lang-option.active { background: rgba(59, 130, 246, 0.15); font-weight: 600; }
.lang-option img { border-radius: 2px; }

/* ─── Auth lang switcher (login + lock) ───────────────────────────────── */
.auth-lang-switcher {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
}
.auth-lang-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: rgba(20, 22, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 120ms ease, border-color 120ms ease;
}
.auth-lang-current:hover {
  background: rgba(30, 34, 48, 0.75);
  border-color: rgba(255, 255, 255, 0.15);
}
.auth-lang-current img {
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.auth-lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(20, 22, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  padding: 4px;
  min-width: 160px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ─── Camera AI button ────────────────────────────────────────────────── */
.cam-tile-btn-ai {
  width: auto !important;
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
  padding: 3px 8px !important;
  background: rgba(0, 0, 0, 0.7) !important;
}
.cam-tile-btn-ai.cam-tile-btn-active {
  background: rgba(59, 130, 246, 0.9) !important;
  color: #fff !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}
