:root {
  --bg: #0a0e1a;
  --panel: #0f1420;
  --card: #151b2e;
  --muted: #94a3b8;
  --text: #f1f5f9;
  --accent: #ef4444;
  --accent-2: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --critical: #ef4444;
  --info: #3b82f6;
  --surface: rgba(255, 255, 255, 0.03);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
  background: linear-gradient(135deg, #0a0e1a 0%, #0f1420 100%);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  padding: 16px;
  max-width: 1920px;
  margin: 0 auto;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 28px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  margin-bottom: 16px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.logo {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  border: 2px solid rgba(59, 130, 246, 0.3);
  overflow: hidden;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}

h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.subhead {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meta-block {
  background: var(--card);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  min-width: 140px;
}

.label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
  font-weight: 600;
}

.value {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.value.accent {
  color: var(--success);
}

.pill {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.pill.mild {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}

.pill.outline {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.pill.critical {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.pill.warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.stage {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tab-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 16px 0;
  background: var(--panel);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tab {
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
}

.tab:hover {
  color: var(--text);
  background: var(--surface);
}

.tab.active {
  border-color: var(--border-strong);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.panel.hidden {
  display: none;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 8px 0;
}

.form-row label {
  font-size: 12px;
  color: var(--muted);
}

.form-row input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.hidden {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: min(420px, 90vw);
  box-shadow: 0 16px 50px rgba(0,0,0,0.45);
}

.login-card h3 {
  margin: 0 0 4px;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.status-dot {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, rgba(58, 217, 165, 0.22), rgba(58, 217, 165, 0.08));
  border: 1px solid rgba(58, 217, 165, 0.5);
  color: #a9fce1;
}

.status-dot.pulsing {
  position: relative;
}

.status-dot.pulsing::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  background: rgba(58, 217, 165, 0.14);
  animation: pulse 1.8s ease-out infinite;
  z-index: -1;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.4); opacity: 0; }
}

.live-frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--border-strong);
  min-height: 480px;
}

.live-frame img, .live-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.alert-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  padding: 20px;
}

.alert-overlay .flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(239, 68, 68, 0.12), transparent 50%);
  animation: breathe 2s ease-in-out infinite;
  mix-blend-mode: overlay;
}

@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.alert-overlay .banner {
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  max-width: 480px;
  color: #fff;
  backdrop-filter: blur(8px);
}

.alert-overlay h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
}

.alert-overlay p {
  margin: 4px 0 0;
  font-size: 14px;
}

.alert-overlay .eyebrow {
  color: rgba(255, 255, 255, 0.9);
  margin: 0 0 4px;
}

.stats {
  position: absolute;
  inset: auto 16px 16px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  z-index: 3;
}

.stats > div {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  backdrop-filter: blur(12px);
}

.stats .label {
  font-size: 10px;
  margin-bottom: 6px;
}

.stats .value {
  font-size: 28px;
  font-weight: 700;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tags, .filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.muted {
  color: var(--muted);
  margin: 8px 0;
  font-size: 14px;
}

.muted.small {
  font-size: 12px;
  margin-top: 4px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 20px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #dc2626;
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn.danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.5);
}

.btn.outline {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn.outline:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.events {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 8px;
}

.events::-webkit-scrollbar {
  width: 6px;
}

.events::-webkit-scrollbar-track {
  background: var(--surface);
  border-radius: 3px;
}

.events::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.event {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: center;
  transition: all 0.15s ease;
}

.event:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.event img {
  width: 100px;
  height: 75px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #000;
}

.event h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.event p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.event .badge {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  min-width: 100px;
  font-size: 13px;
  font-weight: 600;
}

.badge.critical {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.badge.warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fcd34d;
}

.badge.info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.gallery .thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  aspect-ratio: 4/3;
  background: #000;
}

.thumb:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  border-color: var(--border-strong);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .stamp {
  position: absolute;
  inset: auto 8px 8px 8px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  backdrop-filter: blur(8px);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  z-index: 500;
  padding: 20px;
}

.lightbox.hidden {
  display: none;
}

.lightbox img {
  max-width: 95vw;
  max-height: 85vh;
  border-radius: 8px;
  border: 2px solid var(--border-strong);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.roi-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  z-index: 900;
  transition: opacity 0.2s ease;
}

.roi-modal.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.roi-card {
  width: min(960px, 96vw);
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.roi-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.roi-stage {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  display: inline-block;
  overflow: hidden;
  width: auto;
  max-width: 100%;
  min-height: 240px;
  max-height: 65vh;
  margin: 0 auto;
}

.roi-stage img,
.roi-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 60vh;
}

.roi-stage img {
  width: auto;
  height: auto;
  border-radius: 10px;
}

.roi-stage canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  cursor: crosshair;
}

.roi-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 26, 0.85);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.roi-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.roi-row {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.roi-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Audio Prompt Modal */
.audio-prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  transition: opacity 0.3s ease;
}

.audio-prompt-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.audio-prompt-card {
  width: min(480px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.audio-prompt-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.audio-prompt-card .eyebrow {
  margin-bottom: 8px;
}

.audio-prompt-card h3 {
  margin-bottom: 16px;
  color: var(--text-high);
}

.audio-prompt-text {
  color: var(--text-med);
  line-height: 1.6;
  margin-bottom: 24px;
}

.audio-prompt-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.audio-prompt-actions .pill {
  min-width: 140px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.form-row label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  transition: all 0.15s ease;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--border-strong);
  background: var(--card);
}

select[multiple] {
  min-height: 120px;
}

select[multiple] option {
  padding: 4px 6px;
}

.camera-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.camera-chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.camera-chip:hover:not(.disabled) {
  border-color: var(--border-strong);
  background: rgba(59, 130, 246, 0.2);
}

.camera-chip.selected {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  border-color: rgba(16, 185, 129, 0.95);
  color: #02150f;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.45);
}

.camera-chip.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.table th {
  background: var(--panel);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.table tbody tr {
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--surface);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table input {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 32px;
  width: min(440px, 90vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.login-card h3 {
  margin: 0 0 20px;
  font-size: 20px;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.status-dot {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.status-dot.pulsing {
  position: relative;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
  }
}

/* Current alert panel specific */
.panel.current {
  border-left: 3px solid var(--accent);
}

.panel.current .panel-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

/* List panel specific */
.panel.list {
  grid-row: 2;
  grid-column: 2;
}

/* List view panel specific */
.panel.list-view {
  grid-row: 1;
  grid-column: 2;
}

/* Gallery panel specific */
.panel.gallery {
  grid-row: 2;
  grid-column: 1;
}

/* Responsive improvements */
@media (max-width: 768px) {
  .page {
    padding: 12px;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-meta {
    width: 100%;
  }

  .event {
    grid-template-columns: 80px 1fr;
  }

  .event .badge {
    grid-column: 2;
    justify-self: start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .panel.list {
    grid-row: auto;
    grid-column: auto;
  }

  .panel.list-view {
    grid-row: auto;
    grid-column: auto;
  }

  .panel.gallery {
    grid-row: auto;
    grid-column: auto;
  }
}

/* ===========================================
   GRID/LIST VIEW STYLES
   =========================================== */

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--panel);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.view-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.view-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.view-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Camera Views */
.camera-views {
  position: relative;
}

/* Global Acknowledge Bar */
.global-ack-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Camera Grid - Default 2 columns for optimal viewing */
.camera-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}

.camera-grid.cameras-1 {
  grid-template-columns: 1fr;
  max-width: 700px;
  margin: 0 auto;
}

.camera-grid.cameras-2,
.camera-grid.cameras-3,
.camera-grid.cameras-4,
.camera-grid.cameras-5,
.camera-grid.cameras-6 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 900px) {
  .camera-grid,
  .camera-grid.cameras-2,
  .camera-grid.cameras-3,
  .camera-grid.cameras-4,
  .camera-grid.cameras-5,
  .camera-grid.cameras-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .camera-grid,
  .camera-grid.cameras-1,
  .camera-grid.cameras-2,
  .camera-grid.cameras-3,
  .camera-grid.cameras-4,
  .camera-grid.cameras-5,
  .camera-grid.cameras-6 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* Grid Cell */
.grid-cell {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.grid-cell:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.grid-cell.has-alert {
  border-color: var(--accent);
  animation: alertPulse 2s ease-in-out infinite;
}

.grid-cell.in-cooldown {
  border-color: var(--warning);
  opacity: 0.85;
}

@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.1); }
}

.grid-cell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.grid-cell-header .camera-name {
  font-size: 14px;
  font-weight: 600;
}

.grid-cell-header .alert-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
}

.grid-cell.has-alert .alert-indicator {
  background: var(--accent);
  animation: indicatorBlink 1s ease-in-out infinite;
}

.grid-cell.in-cooldown .alert-indicator {
  background: var(--warning);
}

@keyframes indicatorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.grid-cell-feed {
  position: relative;
  /* Fixed aspect ratio container for any resolution video */
  aspect-ratio: 16/9;
  background: #000;
  overflow: hidden;
  /* Minimum height to ensure visibility */
  min-height: 180px;
}

.grid-cell-feed .camera-feed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* contain: shows full video with letterboxing if needed */
  /* cover: fills container, may crop edges */
  object-fit: contain;
  background: #000;
}

.grid-cell-feed .camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.grid-cell-feed .alert-badge {
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
}

.grid-cell-feed .cooldown-badge {
  padding: 6px 12px;
  background: rgba(245, 158, 11, 0.95);
  color: #000;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}

.grid-cell-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

.grid-cell-footer .camera-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--success);
}

.grid-cell.has-alert .grid-cell-footer .camera-status {
  color: var(--accent);
}

.grid-cell.in-cooldown .grid-cell-footer .camera-status {
  color: var(--warning);
}

.grid-cell-footer .camera-last-detection {
  font-size: 11px;
}

.grid-cell-footer .btn-ack-camera {
  padding: 6px 12px;
  font-size: 11px;
}

.grid-cell-footer .btn-ack-camera:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ack-camera.ack-cooldown {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fff;
}

/* Camera List */
.camera-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-row {
  display: grid;
  /* Larger thumbnail for event proof visibility */
  grid-template-columns: 260px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.15s ease;
}

.list-row:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.02);
}

.list-row.has-alert {
  border-left: 4px solid var(--accent);
  animation: listAlertPulse 2s ease-in-out infinite;
}

.list-row.in-cooldown {
  border-left: 4px solid var(--warning);
  opacity: 0.9;
}

@keyframes listAlertPulse {
  0%, 100% { background: var(--panel); }
  50% { background: rgba(239, 68, 68, 0.05); }
}

.list-row-thumb {
  position: relative;
  /* Fixed width with 16:9 aspect ratio */
  width: 260px;
  height: 146px;
  min-width: 260px;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.list-row-thumb .camera-feed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.list-row-thumb .alert-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid rgba(0, 0, 0, 0.5);
}


.list-row.has-alert .list-row-thumb .alert-indicator {
  background: var(--accent);
  animation: indicatorBlink 1s ease-in-out infinite;
}

.list-row.in-cooldown .list-row-thumb .alert-indicator {
  background: var(--warning);
}

.list-row-info {
  min-width: 0;
}

.list-row-info .camera-name {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
}

.list-row-info .camera-status {
  font-size: 13px;
  margin: 0 0 2px;
  color: var(--muted);
}

.list-row.has-alert .list-row-info .camera-status {
  color: var(--accent);
  font-weight: 500;
}

.list-row-info .camera-meta {
  font-size: 11px;
  margin: 0;
}

.list-row-status {
  text-align: center;
}

.status-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.normal {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.status-badge.alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.status-badge.cooldown {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.list-row-actions {
  text-align: right;
  justify-self: end;
  align-self: end;
}

.list-row-actions .btn-ack-camera {
  padding: 8px 14px;
  font-size: 12px;
}

.list-row-actions .btn-ack-camera:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state p {
  margin: 8px 0;
}

.empty-state p:first-child {
  font-size: 16px;
  font-weight: 500;
}

/* Responsive List */
@media (max-width: 900px) {
  .list-row {
    grid-template-columns: 200px 1fr auto;
    gap: 12px;
  }
  .list-row-thumb {
    width: 200px;
    height: 113px;
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .list-row {
    grid-template-columns: 160px 1fr;
    gap: 10px;
    padding: 10px 12px;
  }
  .list-row-thumb {
    width: 160px;
    height: 90px;
    min-width: 160px;
  }
  .list-row-status,
  .list-row-actions {
    grid-column: 2;
  }
  .list-row-status {
    text-align: left;
    margin-top: 6px;
  }
}

@media (max-width: 480px) {
  .list-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .list-row-thumb {
    width: 100%;
    height: auto;
    min-width: unset;
    aspect-ratio: 16/9;
    /* Firefox fallback */
    min-height: 120px;
  }
  .list-row-info,
  .list-row-status,
  .list-row-actions {
    grid-column: 1;
  }
}

/* =============================================
   FIREFOX COMPATIBILITY
   ============================================= */

/* Firefox aspect-ratio fallback using padding-top hack */
@supports not (aspect-ratio: 16/9) {
  .grid-cell-feed {
    aspect-ratio: unset;
    padding-top: 56.25%; /* 9/16 = 0.5625 */
    height: 0;
    position: relative;
  }
  .grid-cell-feed .camera-feed {
    position: absolute;
    top: 0;
    left: 0;
  }
  .list-row-thumb {
    aspect-ratio: unset;
  }
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 1;
  transform: translateY(0);
}

.toast-notification.hidden {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

.toast-notification p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
