:root {
  --bg-deep: #06090e;
  --bg-panel: #0c121d;
  --bg-panel-elevated: #121b2b;
  --bg-tile: #05070b;
  --border-subtle: #1e293b;
  --border-bright: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

/* App Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Top SOC Command Header */
.soc-header {
  height: 52px;
  min-height: 52px;
  background: linear-gradient(180deg, #101827 0%, #0b101b 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
  z-index: 30;
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.88); }
}

.brand-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: #fff;
}

.brand-sub {
  color: var(--accent-cyan);
  font-weight: 500;
}

.brand-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.stat-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.stat-pill:hover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.dot-green { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.dot-red { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
.dot-amber { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }

/* Controls & Buttons */
.ctrl-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.65);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.soc-select, .soc-input, .soc-textarea {
  background: #080d16;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
}

.soc-select:focus, .soc-input:focus, .soc-textarea:focus {
  border-color: var(--accent-cyan);
}

.soc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-panel-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.soc-btn:hover {
  border-color: var(--border-bright);
  background: #1e293b;
}

.soc-btn-primary {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.55);
  color: #67e8f9;
}

.soc-btn-primary:hover {
  background: rgba(6, 182, 212, 0.3);
  border-color: var(--accent-cyan);
}

.soc-btn-accent {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.soc-btn-accent:hover, .soc-btn-accent.active {
  background: rgba(16, 185, 129, 0.3);
  border-color: var(--accent-emerald);
}

.modal-footer .soc-btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.soc-btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
  border-color: var(--accent-red);
  color: #fecaca;
}

.soc-btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-panel-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.grid-selector {
  display: flex;
  background: #080d16;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  overflow: hidden;
}

.grid-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-right: 1px solid var(--border-subtle);
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.grid-btn:last-child {
  border-right: none;
}

.grid-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.grid-btn.active {
  background: var(--accent-cyan);
  color: #03151a;
}

/* Workspace & Sidebar */
.soc-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.soc-sidebar {
  width: 370px;
  min-width: 330px;
  max-width: 55vw;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  z-index: 20;
}

.soc-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none;
  overflow: hidden;
}

/* Split-Screen Map Dashboard Builder Mode */
.soc-sidebar.split-builder {
  width: 50vw;
  min-width: 480px;
}

.sidebar-tabs {
  display: flex;
  align-items: center;
  background: #080d16;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 6px;
  height: 38px;
  gap: 4px;
}

.sidebar-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  height: 100%;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-tab:hover {
  color: var(--text-main);
}

.sidebar-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.sidebar-expand-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-expand-btn.active, .sidebar-expand-btn:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: var(--accent-emerald);
}

.sidebar-mobile-close-btn {
  display: none;
  margin-left: auto;
  align-items: center;
  gap: 4px;
  background: rgba(6, 182, 212, 0.2);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.55);
  border-radius: 4px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

/* Filter Panel */
.filter-panel {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: rgba(8, 13, 22, 0.6);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: #060a11;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 6px 26px 6px 28px;
  font-size: 12px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-cyan);
}

.clear-search-btn {
  position: absolute;
  right: 6px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 15px;
  cursor: pointer;
}

.direction-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-tiny-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-right: 2px;
}

.dir-btn {
  background: #0a101d;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.dir-btn.active {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--accent-blue);
  color: #93c5fd;
}

.filter-count-label {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.corridor-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 58px;
  overflow-y: auto;
}

.corridor-pill {
  background: #0a101d;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.corridor-pill:hover {
  border-color: var(--border-bright);
  color: var(--text-main);
}

.corridor-pill.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #03151a;
}

/* Sidebar Tab Panels */
.sidebar-tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tab-panel.active {
  display: flex;
}

/* Camera Directory List */
.camera-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cam-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(18, 27, 43, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cam-card:hover {
  border-color: var(--border-bright);
  background: rgba(30, 41, 59, 0.75);
}

.cam-card.in-grid {
  border-color: rgba(16, 185, 129, 0.65);
  background: rgba(16, 185, 129, 0.1);
}

.cam-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.cam-card-badges {
  display: flex;
  align-items: center;
  gap: 5px;
}

.badge-slot {
  background: var(--accent-emerald);
  color: #022c22;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.badge-corridor {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #93c5fd;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 0 5px;
  border-radius: 3px;
}

.badge-dir {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 4px;
  border-radius: 3px;
}

.badge-id {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

.cam-card-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cam-mini-btn {
  background: #090e17;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.cam-mini-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* Map Picker Panel */
.map-toolbar {
  padding: 6px 8px;
  background: #080d16;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.map-rapid-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.rapid-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}

.map-layer-toggles {
  display: flex;
  gap: 3px;
}

.layer-btn {
  background: #0d1524;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.layer-btn.active {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--accent-cyan);
  color: #67e8f9;
}

.map-style-select {
  background: #0d1524;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-family: var(--font-mono);
}

.map-picker-hint {
  font-size: 10.5px;
  color: var(--text-muted);
}

.leaflet-map-container {
  flex: 1;
  width: 100%;
  min-height: 240px;
  background: #06090e;
}

.leaflet-tile.osm-dark-tiles {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* Custom Leaflet Markers */
.kc-map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  transition: transform 0.12s ease;
}

.kc-map-pin-cam {
  width: 14px;
  height: 14px;
  background: #0ea5e9;
  border: 2px solid #e0f2fe;
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.8);
}

.kc-map-pin-cam.active-slot {
  width: 22px;
  height: 22px;
  background: #10b981;
  color: #022c22;
  border: 2px solid #ffffff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.95);
  z-index: 900 !important;
}

.kc-map-pin-inc {
  width: 16px;
  height: 16px;
  background: var(--accent-red);
  border: 2px solid #fee2e2;
  box-shadow: 0 0 10px var(--accent-red);
  animation: pulse-dot 1.4s infinite;
}

.kc-map-pin-inc.scheduled {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
}

.kc-map-pin-sign {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  background: #1c1917;
  border: 1.5px solid #f59e0b;
  color: #f59e0b;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kc-map-pin-sign.inactive {
  border-color: #475569;
  color: #64748b;
  opacity: 0.65;
}

/* Dark Leaflet Popups */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #0f172a !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-bright);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.75) !important;
}

.map-popup-card {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-popup-snap {
  width: 100%;
  height: 124px;
  object-fit: cover;
  background: #05070b;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Active Slot Tray inside Map Picker */
.builder-slot-tray {
  background: #080d16;
  border-top: 1px solid var(--border-subtle);
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 135px;
}

.builder-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.builder-tray-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.builder-tray-actions {
  display: flex;
  gap: 4px;
}

.tray-mini-btn {
  background: #121b2b;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.tray-mini-btn:hover {
  border-color: var(--accent-cyan);
}

.tray-mini-primary {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.tray-mini-danger:hover {
  border-color: var(--accent-red);
  color: #fca5a5;
}

.builder-slot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow-y: auto;
}

.slot-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #d1fae5;
  cursor: pointer;
}

.slot-chip-num {
  background: var(--accent-emerald);
  color: #022c22;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 2px;
}

.slot-chip-remove {
  color: #fca5a5;
  font-weight: 700;
  margin-left: 2px;
}

/* Video Wall Container & Grid Layouts */
.video-wall-container {
  flex: 1;
  background: var(--bg-deep);
  padding: 6px;
  overflow: hidden;
  display: flex;
}

.video-grid {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 6px;
}

.video-grid.grid-1x1 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.video-grid.grid-2x2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.video-grid.grid-3x3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}

.video-grid.grid-4x4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.video-grid.grid-auto {
  grid-template-columns: repeat(var(--auto-grid-cols, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--auto-rows, 2), minmax(0, 1fr));
}

/* Solo Mode Override */
.video-grid.solo-mode .video-tile:not(.solo-active) {
  display: none !important;
}

.video-grid.solo-mode {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}

.video-grid.solo-mode .video-tile.solo-active {
  grid-column: 1 / -1 !important;
}

/* Video Tile & HUD Overlay */
.video-tile {
  position: relative;
  background: var(--bg-tile);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-tile:hover {
  border-color: var(--border-bright);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #030508;
}

.tile-hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(4, 7, 13, 0.88) 0%, rgba(4, 7, 13, 0.45) 68%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
  z-index: 5;
}

.tile-hud-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.65);
  color: #6ee7b7;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.live-pill.connecting {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.65);
  color: #fcd34d;
}

.live-pill.error {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.7);
  color: #fca5a5;
}

.tile-street-title {
  font-weight: 600;
  font-size: 11.5px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-cam-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.8);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Bottom Tile Hover Controls */
.tile-hud-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(0deg, rgba(4, 7, 13, 0.92) 0%, rgba(4, 7, 13, 0.5) 70%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.16s ease;
  z-index: 6;
}

.video-tile:hover .tile-hud-actions {
  opacity: 1;
}

.tile-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tile-btn {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 4px;
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.tile-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: #0f172a;
}

.tile-btn-danger:hover {
  border-color: var(--accent-red);
  color: #fca5a5;
}

/* Empty Slot Picker Placeholder */
.empty-slot-tile {
  border: 1px dashed var(--border-bright);
  background: rgba(12, 18, 29, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.empty-slot-tile:hover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.07);
  color: #6ee7b7;
}

/* Bottom Incident & DMS Sign Ticker */
.soc-ticker {
  height: 32px;
  min-height: 32px;
  background: #080d16;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  overflow: hidden;
  z-index: 25;
}

.ticker-badge {
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #111a2e;
  color: #fcd34d;
  border: none;
  border-right: 1px solid var(--border-subtle);
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.ticker-badge:hover {
  background: #1e293b;
}

.ticker-track-wrap {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  cursor: pointer;
}

.ticker-track {
  display: inline-block;
  padding-left: 30px;
  animation: ticker-scroll 420s linear infinite;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-main);
}

.ticker-track:hover {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 36px;
}

.ticker-tag-inc {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
}

.ticker-tag-dms {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.5);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
}

.ticker-right {
  padding: 0 10px;
  border-left: 1px solid var(--border-subtle);
  height: 100%;
  display: flex;
  align-items: center;
}

.ticker-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-emerald);
}

/* Slide-Over Alerts & DMS Signs Drawer */
.alerts-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 32px;
  height: 54vh;
  background: rgba(10, 15, 26, 0.97);
  backdrop-filter: blur(12px);
  border-top: 2px solid var(--accent-cyan);
  box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  z-index: 45;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #070b13;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-tabs {
  display: flex;
  gap: 8px;
}

.drawer-tab {
  background: var(--bg-panel-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 5px 12px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}

.drawer-tab.active {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  color: #67e8f9;
}

.drawer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-search {
  background: #0d1524;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 5px 10px;
  width: 240px;
  font-size: 12px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.drawer-panel {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
}

.drawer-panel.active {
  display: grid;
}

/* Incident Cards & Realistic LED Matrix DMS Sign Cards */
.incident-card {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-red);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.incident-card.scheduled {
  border-left-color: var(--accent-amber);
}

.dms-card {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.led-board {
  background: #110f0a;
  border: 2px solid #292524;
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.75);
  letter-spacing: 0.06em;
  text-align: center;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.led-board.blank {
  color: #44403c;
  text-shadow: none;
}

/* Modals */
.soc-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.soc-modal {
  width: 480px;
  max-width: 94vw;
  max-height: 88vh;
  background: #0d1422;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.soc-modal-lg {
  width: 680px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #080d16;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-cam-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px;
  background: #070b12;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
}

.modal-footer {
  padding: 10px 16px;
  background: #080d16;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.share-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.share-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.share-camera-endpoints {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 210px;
  overflow-y: auto;
}

.ha-cam-row {
  background: #070b12;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 44px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
}

.toast {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid var(--accent-cyan);
  border-left: 4px solid var(--accent-cyan);
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
}

/* Kiosk Mode (?kiosk=1) Overrides for Home Assistant Embed */
.kiosk-exit-btn {
  display: none;
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 90;
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

body.kiosk-mode:hover .kiosk-exit-btn {
  opacity: 0.85;
}

body.kiosk-mode .soc-header,
body.kiosk-mode .soc-sidebar,
body.kiosk-mode .soc-ticker,
body.kiosk-mode .alerts-drawer {
  display: none !important;
}

body.kiosk-mode .kiosk-exit-btn {
  display: block;
}

body.kiosk-mode .video-wall-container {
  padding: 2px;
}

body.kiosk-mode .video-grid {
  gap: 2px;
}

.video-tile.hud-visible .tile-hud-actions {
  opacity: 1;
}

/* ==========================================================================
   Responsive Tablet & Mobile Layout
   ========================================================================== */
@media (max-width: 960px) {
  .soc-header {
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 6px;
  }

  .header-left {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
    gap: 6px;
  }

  .brand-sub,
  .brand-meta {
    display: none;
  }

  .stat-pills {
    margin-left: auto;
    gap: 4px;
  }

  .stat-pill {
    padding: 3px 6px;
    font-size: 10.5px;
  }

  .header-center {
    order: 3;
    flex: 1 1 auto;
    min-width: 0;
  }

  .preset-group {
    width: 100%;
    padding: 3px 6px;
    gap: 5px;
  }

  .preset-group .soc-select {
    flex: 1;
    min-width: 95px;
  }

  .header-right {
    order: 2;
    gap: 5px;
  }

  /* Full-Screen Slide-Over Picker Drawer on Mobile/Tablet */
  .soc-sidebar {
    position: absolute;
    inset: 0;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    z-index: 35;
    border-right: none;
  }

  .soc-sidebar.collapsed {
    display: none !important;
  }

  .sidebar-expand-btn {
    display: none !important;
  }

  .sidebar-mobile-close-btn {
    display: inline-flex;
  }

  /* Slide-Over Alerts & DMS Drawer on Mobile */
  .alerts-drawer {
    height: 76dvh;
  }

  .drawer-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
  }

  .drawer-controls {
    width: 100%;
  }

  .drawer-search {
    flex: 1;
    width: auto;
  }

  .drawer-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .pill-label,
  .ctrl-label,
  .soc-header .btn-text {
    display: none;
  }

  .header-center {
    flex: 1 1 100%;
  }

  .header-right {
    order: 4;
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .grid-selector {
    flex: 1;
    display: flex;
  }

  .grid-btn {
    flex: 1;
    text-align: center;
    padding: 5px 4px;
  }

  .ticker-right {
    display: none;
  }

  .ticker-badge {
    padding: 0 8px;
    font-size: 9.5px;
  }

  /* Scrollable Vertical / 2-Column Camera Feed on Phones */
  .video-wall-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
  }

  .video-grid {
    height: auto;
    min-height: 100%;
    align-content: start;
  }

  .video-grid.grid-1x1 {
    height: 100%;
  }

  .video-grid.grid-2x2,
  .video-grid.grid-3x3,
  .video-grid.grid-4x4 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: auto;
  }

  .video-grid.grid-auto {
    grid-template-rows: none;
    grid-auto-rows: auto;
  }

  .video-tile {
    aspect-ratio: 3 / 2;
    min-height: 190px;
  }

  .video-grid.grid-1x1 .video-tile,
  .video-grid.solo-mode .video-tile.solo-active {
    aspect-ratio: auto;
    height: 100%;
  }

  .video-grid.solo-mode {
    height: 100%;
  }

  /* Keep touch action bar accessible and compact */
  .tile-hud-actions {
    padding: 5px 6px;
  }

  .tile-btn {
    padding: 4px 6px;
    font-size: 10px;
  }

  .tile-btn.act-left,
  .tile-btn.act-right {
    display: none;
  }

  /* Prevent iOS Safari input auto-zoom */
  .soc-input,
  .soc-select,
  .soc-textarea,
  .search-box input,
  .drawer-search {
    font-size: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 38px;
  }
}


