/* CCTV SLM — Modern Enterprise Design System */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  /* Light Theme Palette */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-card: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --line: #e2e8f0;
  --text-primary: #0f172a;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --muted: #64748b;
  
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-light: #eff6ff;
  --brand-border: #bfdbfe;
  --soft: #eff6ff;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-text: #047857;
  
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-text: #b45309;
  
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-text: #b91c1c;

  color-scheme: light;
  font-size: 14px;
}

.dark {
  /* Dark Theme Palette (Deep Obsidian) */
  --bg: #090d16;
  --surface: #101726;
  --surface-card: #131c2e;
  --surface-hover: #1b263b;
  --border: #1e293b;
  --line: #1e293b;
  --text-primary: #f8fafc;
  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --muted: #94a3b8;
  
  --brand: #3b82f6;
  --brand-hover: #60a5fa;
  --brand-light: rgba(59, 130, 246, 0.16);
  --brand-border: rgba(59, 130, 246, 0.35);
  --soft: rgba(59, 130, 246, 0.16);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.16);
  --success-text: #6ee7b7;
  
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.16);
  --warning-text: #fde68a;
  
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.16);
  --danger-text: #fca5a5;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  text-decoration: underline;
}

/* Typography */
h1, h2, h3, h4, p {
  margin-top: 0;
}
h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
  line-height: 1.3;
}
h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 14px;
}
h3 {
  font-size: 14px;
  font-weight: 600;
}
p {
  line-height: 1.65;
  color: var(--text-primary);
}
small, .muted, .text-muted {
  color: var(--text-muted);
}
small {
  line-height: 1.5;
}

/* Button System */
button, .button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #ffffff;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.4;
  transition: all 0.15s ease;
  font-family: inherit;
  outline-offset: 3px;
}
button:hover, .button:hover, .btn:hover {
  filter: brightness(0.95);
  text-decoration: none;
}
button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
}

button.secondary, .button.secondary, .btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}
button.secondary:hover, .button.secondary:hover, .btn-secondary:hover {
  background: var(--surface-hover);
  filter: none;
}

button.danger, .button.danger, .btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #ffffff;
}

button.ghost, .btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
button.ghost:hover, .btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-sm, button.sm {
  padding: 7px 11px;
  font-size: 12px;
  border-radius: 7px;
}
.btn-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Form Controls */
input, select, textarea {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  min-height: 42px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
  outline: none;
}
textarea {
  resize: vertical;
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
input[type=file] {
  padding: 8px;
}

label, .form-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}
.form-group {
  margin-bottom: 16px;
}
.form-row, .row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-row > div, .row > div {
  flex: 1;
  min-width: 180px;
}
.form-row label, .row label {
  margin-top: 0;
}
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
  display: block;
}

/* App Shell & Layout */
.app-shell {
  margin-left: 270px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 30px 20px;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.03em;
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--brand);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-mark svg {
  width: 24px;
  height: 24px;
}
.brand-light {
  font-weight: 450;
  opacity: 0.85;
}
.brand small {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  margin-top: 2px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-caption {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 40px 14px 14px;
  text-transform: uppercase;
}
nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-link {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text-secondary);
  padding: 11px 14px;
  border-radius: 9px;
  font-weight: 550;
  font-size: 13.5px;
  transition: all 0.15s ease;
}
.nav-link:hover {
  background: var(--surface-hover);
  text-decoration: none;
  color: var(--text-primary);
}
.nav-link.active {
  background: var(--soft);
  color: var(--brand);
  font-weight: 600;
}
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  margin-left: auto;
}

.sidebar-foot {
  margin-top: auto;
  padding: 18px 14px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.sidebar-foot p {
  font-size: 11.5px;
  margin: 10px 0;
  color: var(--text-secondary);
  line-height: 1.5;
}
.sidebar-foot small {
  font-size: 10px;
}

/* Topbar */
.topbar {
  height: 76px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-button {
  width: 38px;
  height: 38px;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.icon-button:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.header-context {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.header-context span {
  margin: 0 8px;
  color: var(--border);
}
.header-date {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--brand);
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-menu {
  position: relative;
}
.user-menu summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}
.user-menu summary::-webkit-details-marker {
  display: none;
}
.user-name {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-primary);
}
.user-name small {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 1px;
}
.user-dropdown {
  position: absolute;
  right: 0;
  top: 50px;
  background: var(--surface);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  z-index: 45;
  min-width: 220px;
}
.user-dropdown button {
  margin-top: 12px;
  width: 100%;
}

/* ERP Health Pill */
.erp-health-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.erp-health-pill.good {
  background: var(--success-light);
  color: var(--success-text);
  border-color: rgba(16, 185, 129, 0.3);
}
.erp-health-pill.warn {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: rgba(245, 158, 11, 0.3);
}
.erp-health-pill.bad {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.3);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulse-glow 2s infinite ease-in-out;
}
@keyframes pulse-glow {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

/* Main Content Area */
.main-content {
  padding: 32px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 6px;
}

/* Breadcrumb Component */
.breadcrumb-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 22px;
  color: var(--text-muted);
}
.breadcrumb-nav svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  vertical-align: middle;
}
.breadcrumb-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}
.breadcrumb-nav a:hover {
  color: var(--brand);
  text-decoration: none;
}
.breadcrumb-nav .separator {
  color: var(--text-muted);
  opacity: 0.45;
  font-size: 12px;
  user-select: none;
  display: inline-flex;
  align-items: center;
}
.breadcrumb-nav .current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  font-weight: 600;
}

/* Status Pill Group */
.status-pill-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Unified Action Card & Split Sections */
.card-flush {
  padding: 0;
  overflow: hidden;
}
.card-flush .card-header {
  padding: 20px 24px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}
.card-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.card-section:last-child {
  border-bottom: none;
}
.card-section-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.meta-label {
  color: var(--text-muted);
  font-weight: 500;
}
.meta-value {
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}
.action-bar-footer {
  background: var(--surface-bg);
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* OCR & Evidence Media */
.evidence-media-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.evidence-media-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 440px;
  object-fit: contain;
}
.evidence-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}
.ocr-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.ocr-chip {
  background: var(--surface-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
}
.ocr-chip-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.ocr-chip-val {
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}
.collapsible-raw {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.collapsible-raw summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.collapsible-raw summary:hover {
  color: var(--brand);
}


/* Cards & Grid */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.card-header h2, .card-header p {
  margin: 0;
}
.card-header p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.card-header a {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 24px;
  margin-bottom: 24px;
}
.grid > .card {
  margin-bottom: 0;
}

.grid-split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
@media (max-width: 1024px) {
  .grid-split {
    grid-template-columns: 1fr;
  }
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 26px;
}
.stat-card {
  padding: 20px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--bg);
  border-radius: 10px;
  color: var(--brand);
  margin-bottom: 16px;
}
.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 550;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}
.stat-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.good {
  background: var(--success-light);
  color: var(--success-text);
  border-color: rgba(16, 185, 129, 0.25);
}
.badge.bad {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.25);
}
.badge.warn {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: rgba(245, 158, 11, 0.25);
}
.badge-dot:before {
  content: "";
  height: 6px;
  width: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 14px 12px;
  vertical-align: middle;
  font-size: 12.5px;
  line-height: 1.5;
}
th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
td small {
  font-size: 11px;
  color: var(--text-muted);
}
tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--surface-hover);
}

/* Camera Live Grid & Tile */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 20px;
}
.camera-grid[data-columns="1"] {
  grid-template-columns: 1fr !important;
}
.camera-grid[data-columns="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
.camera-grid[data-columns="auto"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)) !important;
}
@media (max-width: 640px) {
  .camera-grid[data-columns="2"] {
    grid-template-columns: 1fr !important;
  }
}
.camera-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-card);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.camera-preview {
  aspect-ratio: 16/9;
  background: #090d16;
  position: relative;
  display: grid;
  place-items: center;
  color: #94a3b8;
  overflow: hidden;
}
.camera-preview video, .camera-preview img, .camera-preview [data-camera-frame] {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  position: relative;
  z-index: 1;
}
.camera-preview .preview-placeholder {
  position: absolute;
  display: grid;
  place-items: center;
  gap: 10px;
  font-size: 12px;
  color: #64748b;
  pointer-events: none;
  z-index: 0;
}
.camera-preview .preview-placeholder[hidden],
.camera-preview video[hidden],
.camera-preview img[hidden],
[hidden] {
  display: none !important;
}
.camera-preview .badge {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
  pointer-events: none;
}
.camera-fullscreen {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 15px;
  cursor: pointer;
  z-index: 2;
  display: grid;
  place-items: center;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}
.camera-fullscreen:hover {
  opacity: 1;
}
.camera-track-summary {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.camera-info {
  padding: 16px;
}
.camera-info a {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14.5px;
}
.camera-info p {
  font-size: 12px;
  margin: 4px 0 12px;
  color: var(--text-muted);
}
.camera-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Monitor Toolbar */
.monitor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.monitor-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}
.legend-person {
  color: #10b981;
  font-weight: 600;
}
.legend-object {
  color: #3b82f6;
  font-weight: 600;
}
.monitor-layout {
  display: inline-flex;
  gap: 6px;
}
.monitor-layout button {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 7px;
}
.monitor-layout button[aria-pressed=true] {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Video & Canvas Viewports */
.video-viewport-box {
  width: 100%;
  max-height: 600px;
  aspect-ratio: 16/9;
  background: #090d16;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.video-viewport-box video, .video-viewport-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.canvas-editor-box {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.canvas-editor-box img {
  max-width: 100%;
  display: block;
}
.canvas-editor-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

/* Monospace Code / OCR Viewer */
.code-block-viewer {
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 10px 0;
}

/* Empty State & Notices */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  color: var(--text-muted);
  opacity: 0.6;
  margin-bottom: 14px;
}
.empty-state h3 {
  color: var(--text-primary);
  margin-bottom: 6px;
  font-size: 15px;
}
.empty-state p {
  font-size: 12.5px;
  margin-bottom: 0;
  color: var(--text-muted);
}

.notice {
  border: 1px solid var(--brand-border);
  padding: 14px 18px;
  background: var(--brand-light);
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 22px;
  line-height: 1.6;
}
.notice.error {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Auth / Login Page */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 24px;
  background: var(--bg);
}
.login-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 1000px;
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}
.login-form-panel {
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-form-panel .brand {
  margin-bottom: 40px;
}
.login-form-panel h1 {
  font-size: 26px;
}
.login-form-panel > p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 20px;
}
.login-form-panel form > button {
  width: 100%;
  margin-top: 20px;
}
.login-art {
  background: #090d16;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  position: relative;
  background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}
.login-art .brand-mark {
  width: 56px;
  height: 56px;
  margin-bottom: 28px;
}
.login-art h2 {
  font-size: 30px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: #f8fafc;
}
.login-art p {
  color: #94a3b8;
  font-size: 13.5px;
}
.login-art .login-foot {
  margin-top: 36px;
  color: #64748b;
  font-size: 11px;
}
.password-field {
  position: relative;
}
.password-field input {
  padding-right: 96px;
}
.password-field button {
  position: absolute;
  right: 6px;
  top: 6px;
  font-size: 11px;
  padding: 6px 10px;
  background: transparent;
  color: var(--text-muted);
  border: none;
}
.password-field button:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Footer */
.page-footer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: auto;
  padding: 24px 32px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.page-footer span {
  margin: 0 8px;
  color: var(--border);
}

/* Pagination System */
.pagination-wrap {
  margin-top: 24px;
}
.cctv-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface, #1e293b);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
}
.pagination-summary {
  font-size: 13px;
  color: var(--text-muted, #94a3b8);
}
.pagination-summary strong {
  color: var(--text-primary, #f8fafc);
  font-weight: 600;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pagination-numbers {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-primary, #f8fafc);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: 7px;
  transition: all 0.15s ease;
  user-select: none;
}
.pagination-btn:hover:not(.disabled):not(.active) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-primary, #ffffff);
}
.pagination-btn.active {
  background: #2563eb;
  color: #ffffff !important;
  border-color: #3b82f6;
  font-weight: 600;
}
.pagination-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  font-size: 13px;
  color: var(--text-muted, #94a3b8);
}
@media (max-width: 640px) {
  .cctv-pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .pagination-controls {
    justify-content: center;
  }
}

/* Utility Helpers */
.w-full { width: 100% !important; }
.w-third { width: 35% !important; }
.max-w-full { max-width: 100% !important; }
.flex-1 { flex: 1 !important; }
.flex-2 { flex: 2 !important; }
.flex-none { flex: 0 0 auto !important; }
.min-w-140 { min-width: 140px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-6 { margin-top: 24px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-4 { margin-bottom: 16px !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }
.text-xs { font-size: 11px !important; }
.text-sm { font-size: 12.5px !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.font-medium { font-weight: 500 !important; }
.font-semibold { font-weight: 600 !important; }
.font-bold { font-weight: 700 !important; }
.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-end { justify-content: flex-end !important; }
.overflow-hidden { overflow: hidden !important; }

/* Responsive Adjustments */
@media (max-width: 980px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .app-shell {
    margin-left: 0;
  }
  #sidebar-toggle {
    display: inline-flex !important;
  }
  .nav-open .sidebar {
    transform: translateX(0);
  }
  .topbar {
    height: 68px;
    padding: 0 20px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .login-layout {
    grid-template-columns: 1fr;
    max-width: 480px;
  }
  .login-art {
    display: none;
  }
  .login-form-panel {
    padding: 40px 30px;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 20px 16px;
  }
  .topbar {
    padding: 0 16px;
  }
  .header-context, .user-name {
    display: none;
  }
  .page-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .form-row > div, .row > div {
    min-width: 100%;
  }
}
