/* ================================================================
   ARTGIS FIRE — Mission Control Dashboard
   Design: Satellite ops center + Bloomberg data density + JPL DSN Now
   ================================================================ */

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Background spectrum */
  --bg-deepest: #07070c;
  --bg-deep: #0a0a0f;
  --bg-dark: #0e0e16;
  --bg-panel: rgba(12, 12, 20, 0.92);
  --bg-card: rgba(18, 18, 30, 0.88);
  --bg-hover: rgba(30, 30, 50, 0.7);
  --bg-input: rgba(15, 15, 28, 0.95);

  /* Accent colors */
  --fire-orange: #ff6b35;
  --fire-red: #ff3333;
  --fire-amber: #f0ad4e;
  --fire-dim-yellow: #a89040;
  --cool-blue: #4ea8de;
  --success-green: #2dce89;
  --info-cyan: #17c3d6;
  --muted: #4a4a6a;
  --text-primary: #e0e0ec;
  --text-secondary: #8888a8;
  --text-dim: #55557a;
  --border: rgba(80, 80, 120, 0.25);
  --border-active: rgba(120, 120, 180, 0.4);
  --glow-orange: rgba(255, 107, 53, 0.4);
  --glow-red: rgba(255, 51, 51, 0.3);
  --glow-blue: rgba(78, 168, 222, 0.3);
  --glow-green: rgba(45, 206, 137, 0.3);

  /* Fonts */
  --font-mono: 'JetBrains Mono', 'Source Code Pro', 'Fira Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Layout */
  --top-bar-h: 44px;
  --bottom-bar-h: 110px;
  --left-panel-w: 280px;
  --right-panel-w: 300px;

  /* Effects */
  --panel-blur: blur(16px);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

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

/* Mobile-only elements hidden by default */
.mobile-only { display: none; }

/* ================================================================
   TOP BAR
   ================================================================ */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(10, 10, 18, 0.96) 0%, rgba(10, 10, 18, 0.88) 100%);
  backdrop-filter: var(--panel-blur);
  border-bottom: 1px solid var(--border);
}

.top-bar-left { display: flex; align-items: center; gap: 8px; }
.top-bar-center { display: flex; align-items: center; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }

.system-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.logo-icon {
  font-size: 16px;
  color: var(--fire-orange);
  text-shadow: 0 0 8px var(--glow-orange);
}
.logo-text {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text-primary);
}
.logo-divider {
  color: var(--text-dim);
  margin: 0 2px;
}
.logo-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* Status indicators */
.status-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
}
.status-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-green {
  background: var(--success-green);
  box-shadow: 0 0 6px var(--glow-green);
  animation: pulse-glow 2.5s ease-in-out infinite;
}
.status-blue {
  background: var(--cool-blue);
  box-shadow: 0 0 6px var(--glow-blue);
}
.status-orange {
  background: var(--fire-orange);
  box-shadow: 0 0 6px var(--glow-orange);
  animation: pulse-glow 1.5s ease-in-out infinite;
}
.status-red {
  background: var(--fire-red);
  box-shadow: 0 0 8px var(--glow-red);
  animation: pulse-glow 1.0s ease-in-out infinite;
}
.status-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.status-value {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Data badges */
.data-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.badge-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.badge-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

/* ================================================================
   MAIN LAYOUT
   ================================================================ */
#main-content {
  position: fixed;
  top: var(--top-bar-h);
  left: 0;
  right: 0;
  bottom: var(--bottom-bar-h);
  display: flex;
}

/* ================================================================
   PANELS (shared)
   ================================================================ */
.panel {
  width: var(--left-panel-w);
  height: 100%;
  background: var(--bg-panel);
  backdrop-filter: var(--panel-blur);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: width var(--transition-normal), opacity var(--transition-normal);
  overflow: hidden;
}
.panel.collapsed { width: 0; opacity: 0; pointer-events: none; }

#right-panel {
  width: var(--right-panel-w);
  border-right: none;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
}
.panel-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 3px;
  transition: all var(--transition-fast);
}
.panel-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 2px; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--text-dim);
  gap: 8px;
}
.empty-icon { font-size: 24px; }
.empty-text { font-size: 11px; letter-spacing: 0.5px; }

/* ================================================================
   FIRE EVENT CARDS
   ================================================================ */
.fire-event-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}
.fire-event-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}
.fire-event-card.selected {
  border-color: var(--fire-orange);
  box-shadow: 0 0 8px var(--glow-orange), inset 0 0 12px rgba(255, 107, 53, 0.05);
}

.event-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.event-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.event-state {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 2px;
  text-transform: uppercase;
}
.state-candidate { color: var(--cool-blue); border: 1px solid var(--cool-blue); }
.state-active { color: var(--fire-orange); border: 1px solid var(--fire-orange); box-shadow: 0 0 6px var(--glow-orange); animation: pulse-glow 1.5s ease-in-out infinite; }
.state-growing { color: var(--fire-red); border: 1px solid var(--fire-red); box-shadow: 0 0 6px var(--glow-red); animation: pulse-glow 1.0s ease-in-out infinite; }
.state-stable { color: var(--fire-amber); border: 1px solid var(--fire-amber); }
.state-contained { color: var(--success-green); border: 1px solid var(--success-green); }

.event-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.event-meta {
  display: flex;
  flex-direction: column;
}
.event-meta-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.event-meta-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

/* ================================================================
   MAP
   ================================================================ */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#map {
  width: 100%;
  height: 100%;
}

/* Override MapLibre controls */
.maplibregl-ctrl-group {
  background: var(--bg-panel) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}
.maplibregl-ctrl-group button {
  background-color: transparent !important;
  border-color: var(--border) !important;
}
.maplibregl-ctrl-group button:hover {
  background-color: var(--bg-hover) !important;
}
.maplibregl-ctrl-group button + button {
  border-top-color: var(--border) !important;
}
.maplibregl-ctrl-group .maplibregl-ctrl-icon {
  filter: invert(0.8);
}
.maplibregl-popup-content {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  font-family: var(--font-sans) !important;
  font-size: 12px !important;
  padding: 8px 12px !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
  backdrop-filter: var(--panel-blur) !important;
}
.maplibregl-popup-tip {
  border-top-color: var(--bg-panel) !important;
}
.maplibregl-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 16px !important;
}

/* Map layer controls */
#map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
}
.map-overlay {
  background: var(--bg-panel);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 3px 0;
  user-select: none;
}
.layer-toggle input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: var(--bg-input);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.layer-toggle input[type="checkbox"]:checked {
  background: var(--fire-orange);
  border-color: var(--fire-orange);
}
.layer-toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid var(--bg-deep);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Layer legend swatches — visually match map layers */
.layer-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}
.swatch-pixels {
  background: #ff6b35;
  box-shadow: 0 0 6px rgba(255, 107, 53, 0.6), inset 0 0 3px rgba(255, 200, 100, 0.4);
}
.swatch-perimeters {
  background: transparent;
  border: 2px dashed #ffaa55;
  width: 12px;
  height: 12px;
}
.swatch-burn {
  background: #2a0808;
  border: 1px solid #551111;
}
.swatch-satellite {
  background: linear-gradient(135deg, #2a5a2a, #4a8a4a);
  border: 1px solid #3a6a3a;
}
.swatch-goes {
  background: linear-gradient(135deg, #2a1a0a, #8a5a2a);
  border: 1px solid #6a4a2a;
}

/* Unavailable layer toggle */
.layer-toggle.layer-unavailable {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.layer-toggle.layer-unavailable .toggle-label::after {
  content: ' (N/A)';
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* Divider between fire layers and basemap layers */
.layer-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Pixel tooltip */
.map-tooltip {
  position: absolute;
  z-index: 200;
  background: var(--bg-panel);
  backdrop-filter: var(--panel-blur);
  border: 1px solid var(--fire-orange);
  border-radius: 4px;
  padding: 0;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px var(--glow-orange);
  pointer-events: none;
}
.tooltip-header {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--fire-orange);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.tooltip-body { padding: 6px 10px; }
.tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}
.tooltip-key {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.tooltip-val {
  font-size: 12px;
  color: var(--text-primary);
}

/* ================================================================
   RIGHT PANEL — Detail sections
   ================================================================ */
.detail-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.detail-section:last-child { border-bottom: none; }

.section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.detail-state-badge {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-align: center;
  padding: 8px 16px;
  border-radius: 3px;
  margin-bottom: 10px;
  color: var(--fire-orange);
  border: 1px solid var(--fire-orange);
  box-shadow: 0 0 12px var(--glow-orange);
}

.detail-meta {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}
.meta-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.meta-value {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Gauge */
.gauge-container {
  display: flex;
  justify-content: center;
}
.gauge-svg { width: 200px; height: 120px; }
.gauge-value {
  font-size: 24px;
  fill: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 600;
}
.gauge-unit {
  font-size: 10px;
  fill: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

/* Sparkline */
.sparkline-container { margin-bottom: 6px; }
.sparkline-svg {
  width: 100%;
  height: 60px;
  overflow: visible;
}
.sparkline-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

/* Metrics grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.metric-label {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.metric-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.metric-unit {
  font-size: 9px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Source badges */
.source-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.source-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 2px;
  border: 1px solid var(--muted);
  color: var(--text-dim);
}
.source-badge.active {
  color: var(--cool-blue);
  border-color: var(--cool-blue);
  box-shadow: 0 0 6px var(--glow-blue);
}

/* ================================================================
   BOTTOM BAR — Timeline
   ================================================================ */
#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-bar-h);
  z-index: 1000;
  background: linear-gradient(0deg, rgba(8, 8, 14, 0.98) 0%, rgba(10, 10, 18, 0.94) 100%);
  backdrop-filter: var(--panel-blur);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  gap: 6px;
}

/* Timeline controls row */
.timeline-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 3px;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}
.tl-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
}
.tl-play {
  background: var(--fire-orange);
  border-color: var(--fire-orange);
  color: var(--bg-deep);
  font-weight: 600;
  padding: 4px 14px;
}
.tl-play:hover {
  background: #ff8555;
  border-color: #ff8555;
  color: var(--bg-deep);
}
.tl-play.playing {
  background: var(--fire-red);
  border-color: var(--fire-red);
}
.tl-action {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 4px 12px;
  margin-left: 8px;
  color: var(--fire-orange);
  border-color: var(--fire-orange);
}
.tl-action:hover {
  background: rgba(255, 107, 53, 0.15);
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.speed-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.speed-control select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 3px;
  cursor: pointer;
}

/* Timeline track */
.timeline-track-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.timeline-time-label {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 40px;
}
.timeline-track {
  flex: 1;
  height: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 107, 53, 0.3) 0%, rgba(255, 51, 51, 0.4) 100%);
  border-radius: 3px 0 0 3px;
  transition: width 100ms linear;
  pointer-events: none;
}
.timeline-playhead {
  position: absolute;
  top: -2px;
  width: 3px;
  height: 28px;
  background: var(--fire-orange);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--glow-orange);
  transition: left 100ms linear;
  pointer-events: none;
  z-index: 10;
}
.timeline-tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(80, 80, 120, 0.2);
  pointer-events: none;
}
.timeline-tick.has-fire {
  background: rgba(255, 107, 53, 0.5);
}

/* Timeline info row */
.timeline-info {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tl-info-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.tl-info-value {
  font-size: 12px;
  color: var(--text-primary);
}
.tl-info-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 4px;
}

/* ================================================================
   CONFIDENCE INDICATORS
   ================================================================ */
.conf-high {
  color: var(--fire-orange);
  text-shadow: 0 0 4px var(--glow-orange);
}
.conf-medium {
  color: var(--fire-amber);
}
.conf-low {
  color: var(--fire-dim-yellow);
}

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes fire-pulse {
  0%, 100% { box-shadow: 0 0 4px var(--glow-orange); }
  50% { box-shadow: 0 0 12px var(--glow-orange); }
}

/* ================================================================
   RESPONSIVE (graceful degradation)
   ================================================================ */
@media (max-width: 1100px) {
  :root {
    --left-panel-w: 240px;
    --right-panel-w: 260px;
  }
}

/* ================================================================
   MOBILE (max-width: 768px)
   Full-screen map with overlay panels, bottom-sheet case studies,
   slide-in right panel, condensed bars.
   ================================================================ */
@media (max-width: 768px) {
  :root {
    --top-bar-h: 36px;
    --bottom-bar-h: 70px;
    --left-panel-w: 100%;
    --right-panel-w: 280px;
  }

  /* ---- Mobile toggle button (hamburger) ---- */
  .mobile-only {
    display: block;
  }
  #mobile-menu-btn {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1100;
    width: 44px;
    height: var(--top-bar-h);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }
  #mobile-menu-btn:focus-visible {
    outline: 2px solid var(--fire-orange);
    outline-offset: -2px;
  }

  /* ---- TOP BAR condensed ---- */
  #top-bar {
    height: var(--top-bar-h);
    padding: 0 8px 0 44px; /* room for hamburger */
  }
  .top-bar-center {
    display: none;
  }
  .top-bar-left .logo-divider,
  .top-bar-left .logo-subtitle {
    display: none;
  }
  .logo-text { font-size: 13px; letter-spacing: 1.5px; }
  .top-bar-right {
    gap: 6px;
  }
  .top-bar-right .data-badge {
    display: none;
  }
  .mode-toggle { margin-right: 0; }
  .mode-btn {
    padding: 4px 8px;
    font-size: 9px;
    min-height: 28px;
  }

  /* ---- MAIN CONTENT: map fills all space ---- */
  #main-content {
    display: block;
    position: fixed;
    top: var(--top-bar-h);
    left: 0;
    right: 0;
    bottom: var(--bottom-bar-h);
  }
  #map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
  }

  /* ---- LEFT PANEL: bottom-sheet overlay ---- */
  #left-panel {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: var(--bottom-bar-h);
    width: 100%;
    height: 60vh;
    max-height: calc(100vh - var(--top-bar-h) - var(--bottom-bar-h));
    z-index: 600;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    background: var(--bg-panel);
    backdrop-filter: var(--panel-blur);
    transform: translateY(100%);
    transition: transform 300ms ease;
    flex-shrink: unset;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  #left-panel.panel-open {
    transform: translateY(0);
  }
  /* collapsed class should also hide */
  #left-panel.collapsed {
    transform: translateY(100%);
    opacity: 1;
    pointer-events: auto;
  }
  .panel-header {
    padding: 8px 14px;
  }
  /* Drag handle hint at top of bottom sheet */
  #left-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--muted);
    border-radius: 2px;
    margin: 6px auto 0;
    flex-shrink: 0;
  }

  /* ---- Mobile bottom-sheet tab (always visible) ---- */
  #mobile-cs-tab {
    position: fixed;
    bottom: var(--bottom-bar-h);
    left: 8px;
    z-index: 550;
    background: var(--bg-panel);
    backdrop-filter: var(--panel-blur);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    padding: 6px 14px;
    cursor: pointer;
    min-width: 44px;
    min-height: 32px;
    -webkit-tap-highlight-color: transparent;
  }
  #mobile-cs-tab:focus-visible {
    outline: 2px solid var(--fire-orange);
    outline-offset: -2px;
  }

  /* ---- RIGHT PANEL: slide-in from right ---- */
  #right-panel {
    position: fixed;
    top: var(--top-bar-h);
    right: 0;
    bottom: var(--bottom-bar-h);
    width: var(--right-panel-w);
    max-width: 85vw;
    height: auto;
    z-index: 700;
    background: var(--bg-panel);
    backdrop-filter: var(--panel-blur);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 300ms ease;
    overflow-y: auto;
  }
  /* When displayed via JS (style.display != none), slide in */
  #right-panel[style*="display: flex"],
  #right-panel[style*="display:flex"],
  #right-panel[style*="display: block"],
  #right-panel[style*="display:block"],
  #right-panel.panel-open {
    transform: translateX(0);
  }

  /* ---- BOTTOM BAR condensed: 2 rows ---- */
  #bottom-bar {
    height: var(--bottom-bar-h);
    padding: 6px 10px;
    gap: 4px;
  }
  /* Row 1: play controls + speed + jump to fire */
  .timeline-controls {
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Row 2: timeline track */
  .timeline-track-wrapper {
    gap: 4px;
  }
  .timeline-time-label {
    font-size: 9px;
    min-width: 30px;
  }
  /* Hide info row on mobile (data is in right panel) */
  .timeline-info {
    display: none;
  }

  /* Touch-friendly tap targets */
  .tl-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 4px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .tl-play {
    padding: 4px 12px;
  }
  .tl-action {
    font-size: 9px;
    padding: 4px 8px;
    margin-left: 4px;
    min-width: auto;
  }
  .speed-control {
    margin-left: 4px;
  }
  .speed-control select {
    min-height: 36px;
    padding: 4px 6px;
  }

  /* ---- LAYER CONTROLS: top-left under top bar ---- */
  #map-controls {
    top: 8px;
    right: auto;
    left: 8px;
  }
  .map-overlay {
    padding: 6px 10px;
  }
  .layer-toggle {
    padding: 4px 0;
    font-size: 12px;
    min-height: 36px;
    align-items: center;
  }
  .layer-toggle input[type="checkbox"] {
    width: 22px;
    height: 22px;
    border-radius: 3px;
  }
  .layer-toggle input[type="checkbox"]:checked::after {
    top: 3px;
    left: 7px;
    width: 6px;
    height: 11px;
    border-width: 0 2.5px 2.5px 0;
  }
  .layer-swatch {
    width: 18px;
    height: 18px;
  }
  .swatch-perimeters {
    width: 16px;
    height: 16px;
  }

  /* ---- Panel toggle buttons touch-friendly ---- */
  .panel-toggle {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }

  /* ---- Backdrop overlay when panels are open ---- */
  .mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 550;
  }
  .mobile-backdrop.active {
    display: block;
  }

  /* ---- Fire event cards: touch-friendly ---- */
  .fire-event-card {
    padding: 12px 14px;
    min-height: 44px;
  }
  .cs-card {
    padding: 10px 12px;
    min-height: 44px;
  }

  /* ---- Metric cards inside right panel ---- */
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .metric-value {
    font-size: 16px;
  }
  .gauge-svg {
    width: 180px;
    height: 108px;
  }
}

/* ================================================================
   SCROLLBAR GLOBAL
   ================================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ================================================================
   MODE TOGGLE (DEMO / LIVE)
   ================================================================ */
/* ================================================================
   CASE STUDY SIDEBAR BROWSER
   ================================================================ */
.case-study-browser {
  margin-bottom: 0;
}

.cs-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cs-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.cs-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.cs-card.cs-active {
  border-color: var(--fire-orange);
  box-shadow: 0 0 8px var(--glow-orange), inset 0 0 12px rgba(255, 107, 53, 0.05);
}

.cs-card.cs-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--fire-orange);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 6px var(--glow-orange);
}

.cs-card-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-card-meta {
  margin-bottom: 4px;
}

.cs-card-location {
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.cs-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cs-stat {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: rgba(30, 30, 50, 0.6);
  border: 1px solid rgba(80, 80, 120, 0.15);
  border-radius: 2px;
  padding: 1px 6px;
}

.cs-card.cs-active .cs-stat {
  color: var(--text-secondary);
  border-color: rgba(255, 107, 53, 0.2);
  background: rgba(255, 107, 53, 0.06);
}

/* Panel divider between case studies and fire events */
.panel-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Section sub-header */
.panel-section-header {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-right: 8px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.mode-btn.mode-active {
  color: var(--text-primary);
  background: rgba(78, 168, 222, 0.2);
  border-color: var(--cool-blue);
}

/* ================================================================
   LIVE INDICATOR (pulsing green dot)
   ================================================================ */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-green);
}

.live-dot.live-pulse {
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--glow-green); }
  50% { opacity: 0.4; box-shadow: 0 0 8px var(--glow-green); }
}

/* ================================================================
   PREFERS REDUCED MOTION
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
