/* =========================================
   MN Highways Live — Design System
   Terminal (dark green/olive) + Loon (MNUFC navy/blue)
   ========================================= */

/* ---- Terminal theme (default) ---- */
:root, [data-theme="terminal"] {
  --logo-svg-filter: brightness(0) saturate(100%) invert(63%) sepia(30%) saturate(550%) hue-rotate(65deg) brightness(108%);
  --bg-0: #070c06;
  --bg-1: #0d1509;
  --bg-2: #141f10;
  --bg-3: #1c2b17;
  --bg-4: #243520;

  --green-0: #1a2d14;
  --green-1: #2a4a1e;
  --green-2: #3d6830;
  --green-3: #5a8f46;
  --green-4: #7ab85e;
  --green-5: #a2d484;

  --olive-1: #3a4a1c;
  --olive-2: #5a6830;
  --olive-3: #8a9a50;

  --text-0: #e0f0d0;
  --text-1: #b0cc98;
  --text-2: #7a9a65;
  --text-3: #4a6a38;

  --amber: #d4a843;
  --amber-glow: rgba(212,168,67,0.35);
  --red: #c04040;
  --red-glow: rgba(192,64,64,0.3);

  --border: rgba(90,143,70,0.25);
  --border-bright: rgba(90,143,70,0.55);
  --glow-green: 0 0 20px rgba(90,143,70,0.4);
  --glow-bright: 0 0 30px rgba(90,143,70,0.7);
  --shadow: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-card: 0 4px 16px rgba(0,0,0,0.5);

  --radius: 6px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --nav-height: 56px;
  --transition: 200ms ease;
}

/* ---- Loon theme — MNUFC navy/steel blue ---- */
[data-theme="loon"] {
  --logo-svg-filter: brightness(0) saturate(100%) invert(45%) sepia(60%) saturate(500%) hue-rotate(190deg) brightness(120%);
  --bg-0: #060b17;
  --bg-1: #0a1222;
  --bg-2: #101a30;
  --bg-3: #17233e;
  --bg-4: #1e2e52;

  --green-0: #0f1e3c;
  --green-1: #1a3060;
  --green-2: #284e90;
  --green-3: #3d6db8;
  --green-4: #6098d8;
  --green-5: #90b8ee;

  --text-0: #d8e8f8;
  --text-1: #a8c0e0;
  --text-2: #6880a8;
  --text-3: #38506c;

  --border: rgba(60,109,184,0.25);
  --border-bright: rgba(60,109,184,0.55);
  --glow-green: 0 0 20px rgba(60,109,184,0.4);
  --glow-bright: 0 0 30px rgba(60,109,184,0.7);
}

/* ---- SVG map district fills (themed via CSS vars) ---- */
:root, [data-theme="terminal"] {
  --map-d1:    #1f3a18; --map-d1-h:    #3a6a2a;
  --map-d2:    #263f1c; --map-d2-h:    #40702c;
  --map-d3:    #2a441e; --map-d3-h:    #447830;
  --map-d4:    #304e24; --map-d4-h:    #4e8238;
  --map-d6:    #2c4820; --map-d6-h:    #487a32;
  --map-d7:    #283e1a; --map-d7-h:    #426c28;
  --map-d8:    #1e3416; --map-d8-h:    #385e24;
  --map-metro: #2a5c14; --map-metro-h: #4a9c24;
  --map-stroke: rgba(122,184,94,0.4);
  --map-stroke-bright: rgba(162,212,132,0.7);
  --map-border: rgba(162,212,132,0.55);
  --map-facet: rgba(122,184,94,0.15);
  --map-dot: #d4a843;
  --map-label: rgba(224,240,208,0.9);
  --map-sublabel: rgba(176,204,152,0.65);
  --map-count: rgba(212,168,67,0.9);
}

[data-theme="loon"] {
  --map-d1:    #152444; --map-d1-h:    #2a4a88;
  --map-d2:    #10203c; --map-d2-h:    #244080;
  --map-d3:    #132040; --map-d3-h:    #264490;
  --map-d4:    #162646; --map-d4-h:    #2a4a8c;
  --map-d6:    #112040; --map-d6-h:    #223e82;
  --map-d7:    #101e3a; --map-d7-h:    #203c7a;
  --map-d8:    #0e1c38; --map-d8-h:    #1e3870;
  --map-metro: #1a4a8a; --map-metro-h: #2e70cc;
  --map-stroke: rgba(60,109,184,0.45);
  --map-stroke-bright: rgba(96,152,216,0.7);
  --map-border: rgba(96,152,216,0.6);
  --map-facet: rgba(60,109,184,0.18);
  --map-dot: #d4a843;
  --map-label: rgba(216,232,248,0.9);
  --map-sublabel: rgba(168,192,224,0.65);
  --map-count: rgba(212,168,67,0.9);
}

/* Leaflet tile filter per theme */
[data-theme="loon"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(200deg) saturate(0.45) brightness(0.58) contrast(1.05);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--green-4); text-decoration: none; }
a:hover { color: var(--green-5); }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--green-1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-2); }

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(7,12,6,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 0;
  z-index: 1000;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-0);
  text-transform: uppercase;
  margin-right: 32px;
  text-decoration: none;
  transition: color var(--transition);
}
.nav-logo:hover { color: var(--green-4); }
.nav-logo-emoji { font-size: 22px; line-height: 1; }


.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-0);
  background: var(--bg-3);
}

.nav-link.active {
  color: var(--green-4);
}

.nav-clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  margin-left: auto;
}

.nav-weather {
  font-size: 13px;
  color: var(--text-1);
  margin-left: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-logo-svg {
  width: 20px;
  height: 26px;
  flex-shrink: 0;
  filter: var(--logo-svg-filter);
  transition: filter var(--transition);
}

/* Legacy: inline SVG path styling */
.nav-logo-svg path {
  fill: var(--green-0);
  stroke: var(--green-4);
  stroke-width: 5;
  stroke-linejoin: round;
  transition: fill var(--transition), stroke var(--transition);
}

[data-theme="loon"] .nav-logo-svg {
  filter: var(--logo-svg-filter);
}

[data-theme="loon"] .nav-logo-svg path {
  fill: var(--green-0);
  stroke: var(--green-4);
}

/* Nav links with border outline */
.nav-link {
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.nav-link:hover {
  color: var(--text-0);
  background: var(--bg-3);
  border-color: var(--border-bright);
}
.nav-link.active {
  color: var(--green-4);
  background: var(--bg-2);
  border-color: var(--green-2);
}

.theme-toggle {
  margin-left: 12px;
  padding: 5px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-bright);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  outline: none;
  appearance: auto;
}
.theme-toggle:hover, .theme-toggle:focus {
  background: var(--bg-3);
  color: var(--text-0);
  border-color: var(--green-4);
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--amber);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse-amber 2s ease infinite;
}

@keyframes pulse-amber {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--amber-glow); }
  50% { opacity: 0.7; box-shadow: 0 0 0 5px transparent; }
}

/* ============================================================
   LAYOUT WRAPPERS
   ============================================================ */
.page {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   HOME PAGE — LOW-POLY MAP
   ============================================================ */
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px 20px;
  min-height: calc(100vh - var(--nav-height));
  position: relative;
  overflow: hidden;
}

/* Atmospheric background grid */
.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(90,143,70,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90,143,70,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.home-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(42,74,30,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.hero-title h1 {
  font-size: clamp(24px, 4vw, 42px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-0);
  line-height: 1.1;
}

.hero-title h1 span {
  color: var(--green-4);
}

.hero-subtitle {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Map container */
.map-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 728px;
}

.map-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 40px rgba(42,74,30,0.5));
}

/* District polygons */
.district-poly {
  cursor: pointer;
  transition: filter 150ms ease, opacity 150ms ease;
}

.district-poly:hover {
  filter: brightness(1.6) drop-shadow(0 0 12px rgba(122,184,94,0.6));
}

.district-label {
  pointer-events: none;
  user-select: none;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  fill: rgba(224,240,208,0.85);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-anchor: middle;
  dominant-baseline: middle;
}

.district-sub {
  font-size: 7px;
  fill: rgba(176,204,152,0.65);
  font-weight: 400;
  letter-spacing: 0.04em;
}

.camera-dot {
  fill: var(--amber);
  animation: pulse-dot 3s ease infinite;
  pointer-events: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.9; r: 3; }
  50% { opacity: 0.5; r: 4; }
}

.map-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-2);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Map tooltip */
.map-tooltip {
  position: absolute;
  background: rgba(20,31,16,0.95);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 8px 14px;
  pointer-events: none;
  font-size: 12px;
  color: var(--text-0);
  white-space: nowrap;
  transform: translate(-50%, -110%);
  box-shadow: var(--shadow-card);
  display: none;
}

.map-tooltip .tt-name { font-weight: 700; }
.map-tooltip .tt-count { color: var(--green-4); font-size: 11px; margin-top: 2px; }

/* ============================================================
   DISTRICT / REGION PAGE
   ============================================================ */
.region-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}

.region-breadcrumb {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.region-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-0);
  text-transform: uppercase;
}

.region-meta {
  display: flex;
  gap: 24px;
  margin-top: 10px;
}

.region-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.region-stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--green-4);
}

.region-stat-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Region layout: map left, camera grid right */
.region-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - var(--nav-height) - 120px);
}

.region-map-wrap {
  position: relative;
  border-right: 1px solid var(--border);
}

#region-map {
  width: 100%;
  height: 100%;
}

/* Leaflet overrides */
.leaflet-container {
  background: var(--bg-1) !important;
  font-family: var(--font) !important;
}

.leaflet-tile-pane {
  filter: invert(1) hue-rotate(160deg) saturate(0.38) brightness(0.62) contrast(1.05);
}

.camera-marker-icon {
  background: var(--amber);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 10px !important;
  height: 10px !important;
  box-shadow: 0 0 8px var(--amber-glow);
}

/* Camera sidebar */
.region-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-1);
}

.sidebar-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-search {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--text-0);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.sidebar-search:focus { border-color: var(--green-3); }
.sidebar-search::placeholder { color: var(--text-3); }

.camera-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.camera-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  background: var(--bg-2);
}

.camera-item:hover {
  background: var(--bg-3);
  border-color: var(--border);
}

.camera-item.selected {
  background: var(--green-0);
  border-color: var(--green-2);
}

.camera-thumb {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bg-3);
  flex-shrink: 0;
}

.camera-info { flex: 1; min-width: 0; }

.camera-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camera-road {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 2px;
}

/* ============================================================
   CAMERA MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4,8,4,0.88);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), var(--glow-green);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.96) translateY(8px);
  transition: transform 200ms ease;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-0);
}

.modal-meta {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 3px;
}

.modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.modal-body {
  padding: 0;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.modal-camera-img {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  display: block;
}

.modal-camera-placeholder {
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  padding: 48px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
}

.refresh-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}

.refresh-badge.live { color: var(--green-4); }

.btn {
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid;
  transition: all var(--transition);
  letter-spacing: 0.04em;
}

.btn-primary {
  background: var(--green-2);
  border-color: var(--green-3);
  color: var(--text-0);
}

.btn-primary:hover {
  background: var(--green-3);
  box-shadow: var(--glow-green);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--bg-3);
  border-color: var(--border-bright);
  color: var(--text-0);
}

/* ============================================================
   SITUATION MONITOR
   ============================================================ */
.situation-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: calc(100vh - var(--nav-height));
  overflow: hidden;
}

.situation-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.situation-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-1);
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.select-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text-0);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.select-input:focus { border-color: var(--green-3); }

.camera-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
  align-content: start;
}

.grid-cell {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.grid-cell:hover {
  border-color: var(--green-3);
}

.grid-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.grid-cell-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 4px 8px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  font-size: 10px;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.grid-cell-live {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(212,168,67,0.9);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  pointer-events: none;
}

.grid-cell-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 11px;
}

.grid-cell-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 10px;
  padding: 8px;
  text-align: center;
}

.grid-cell-error .err-icon { font-size: 20px; opacity: 0.4; }

/* ADSB panel */
.adsb-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.adsb-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.adsb-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-1);
}

.adsb-subtitle {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}

.adsb-frame {
  flex: 1;
  border: none;
  background: #111;
}

/* ============================================================
   LOADING & ERROR STATES
   ============================================================ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  gap: 16px;
  color: var(--text-2);
}

.loader {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--green-3);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-bar {
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  display: flex;
  gap: 16px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tag-district {
  background: var(--green-0);
  color: var(--green-4);
  border: 1px solid var(--green-1);
}

.tag-live {
  background: rgba(212,168,67,0.15);
  color: var(--amber);
  border: 1px solid rgba(212,168,67,0.3);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}

.empty-state h3 { font-size: 15px; color: var(--text-2); margin-bottom: 8px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .region-layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .region-map-wrap { border-right: none; border-bottom: 1px solid var(--border); }
  .situation-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 320px; }
  .camera-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .camera-grid { grid-template-columns: 1fr 1fr; }
  .nav-logo span { display: none; }
  .hero-title h1 { font-size: 20px; }
}

/* ============================================================
   NORTH STAR THEME — Minnesota light theme
   Minnesota state colors: deep blue #003865 + gold
   ============================================================ */
[data-theme="northstar"] {
  --bg-0: #f2f5f9;
  --bg-1: #ffffff;
  --bg-2: #e8eef6;
  --bg-3: #d8e2f0;
  --bg-4: #c8d4e8;

  --green-0: #dce8f8;
  --green-1: #b4cef0;
  --green-2: #6098d8;
  --green-3: #1a56a6;
  --green-4: #003865;
  --green-5: #00244a;

  --text-0: #0d1b2e;
  --text-1: #1a3050;
  --text-2: #3a5878;
  --text-3: #7090b0;

  --amber: #9a6200;
  --amber-glow: rgba(154,98,0,0.25);
  --red: #b82020;
  --red-glow: rgba(184,32,32,0.2);

  --border: rgba(26,86,166,0.18);
  --border-bright: rgba(26,86,166,0.45);
  --glow-green: 0 0 20px rgba(26,86,166,0.2);
  --glow-bright: 0 0 30px rgba(26,86,166,0.4);
  --shadow: 0 8px 32px rgba(0,40,100,0.12);
  --shadow-card: 0 4px 16px rgba(0,40,100,0.08);
}

[data-theme="northstar"] .nav {
  background: rgba(242,245,249,0.96);
  border-bottom-color: rgba(26,86,166,0.2);
}

[data-theme="northstar"] .nav-logo { color: var(--text-0); }
[data-theme="northstar"] .nav-logo:hover { color: var(--green-4); }

[data-theme="northstar"] .nav-link {
  color: var(--text-2);
  border-color: rgba(26,86,166,0.18);
}
[data-theme="northstar"] .nav-link:hover,
[data-theme="northstar"] .nav-link.active {
  color: var(--green-4);
  background: var(--green-0);
  border-color: rgba(26,86,166,0.35);
}

[data-theme="northstar"] .theme-toggle {
  background: var(--bg-1);
  color: var(--text-2);
  border-color: rgba(26,86,166,0.3);
}

[data-theme="northstar"] .nav-clock,
[data-theme="northstar"] .nav-weather { color: var(--text-2); }

/* North Star map district fills */
[data-theme="northstar"] {
  --map-d1:    #ccd8ee; --map-d1-h:    #aabcde;
  --map-d2:    #c8d4ea; --map-d2-h:    #a8badc;
  --map-d3:    #d0daf0; --map-d3-h:    #b0c4e2;
  --map-d4:    #cad6ec; --map-d4-h:    #aabcde;
  --map-d6:    #ccdbf0; --map-d6-h:    #acc2e2;
  --map-d7:    #c8d4ec; --map-d7-h:    #a8bcde;
  --map-d8:    #c4d0e8; --map-d8-h:    #a4b8da;
  --map-metro: #7aaee8; --map-metro-h: #4e8ed4;
  --map-stroke: rgba(26,86,166,0.35);
  --map-stroke-bright: rgba(26,86,166,0.65);
  --map-border: rgba(26,86,166,0.5);
  --map-facet: rgba(26,86,166,0.1);
  --map-dot: #9a6200;
  --map-label: rgba(13,27,46,0.9);
  --map-sublabel: rgba(58,88,120,0.75);
  --map-count: rgba(154,98,0,0.9);
}

/* Leaflet tile pane — North Star uses light tiles, no invert filter */
[data-theme="northstar"] .leaflet-tile-pane { filter: none; }

/* Mobile theme icon button wrapper (injected by theme.js on small screens) */
.theme-btn-wrap {
  display: none;
  position: relative;
  flex-shrink: 0;
}
@media (max-width: 820px) {
  .theme-btn-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 36px;
    height: 32px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
  }
  .theme-btn-wrap::before {
    content: '🎨';
    font-size: 16px;
    pointer-events: none;
    position: absolute;
  }
  .theme-btn-wrap .theme-toggle {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
    border: none;
  }
}

/* Mobile notice banner */
.mobile-notice {
  display: none;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-2);
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mobile-notice strong { color: var(--text-1); }
.mobile-notice a { color: var(--amber); text-decoration: none; }

/* ============================================================
   MOBILE NAV — hamburger menu
   ============================================================ */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--radius);
  padding: 5px 11px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.nav-hamburger:hover { background: var(--bg-3); color: var(--text-0); }

@media (max-width: 820px) {
  .nav {
    padding: 0 16px;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .nav-hamburger { display: block; order: -1; margin-left: 0; }
  .nav-clock { display: none; }
  .nav-weather { display: none; }
  .nav-logo { margin-right: 0; }

  /* Collapse links into a full-width dropdown */
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    flex-direction: column;
    background: var(--bg-1);
    border-bottom: 2px solid var(--border-bright);
    padding: 8px 12px 12px;
    gap: 4px;
    z-index: 998;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  }
  .nav-links.nav-open { display: flex; }
  .nav-link { font-size: 13px; padding: 8px 14px; }

  /* Theme select — hidden inside icon wrapper on mobile */
  .theme-toggle { font-size: 11px; padding: 4px 6px; }

  /* Situation Monitor — hidden on mobile */
  .nav-link[href="situation.html"] { display: none; }

  /* Mobile notice banner (situation.html) */
  .mobile-notice { display: flex; }
}

/* ============================================================
   MOBILE LAYOUTS
   ============================================================ */
@media (max-width: 820px) {
  /* Warnings */
  .warnings-layout { height: auto; min-height: calc(100vh - var(--nav-height)); }
  .events-body { max-height: 70vh; }

  /* Situation Monitor */
  .situation-layout { grid-template-columns: 1fr; grid-template-rows: 50vh 1fr; }
  .camera-grid { grid-template-columns: repeat(2, 1fr); }
  .situation-main { border-right: none; border-bottom: 1px solid var(--border); }

  /* Index hero */
  .hero-cta { gap: 8px; }
  .hero-cta .btn { font-size: 12px; padding: 6px 12px; }
  .home-hero { padding: 16px 16px 12px; }

  /* Signs — sidebar hidden, full-width billboard */
  .signs-main { padding: 12px 12px; }

  /* Webcams — 2-col grid, scrollable */
  .webcam-layout { height: auto !important; overflow-y: auto !important; min-height: calc(100vh - var(--nav-height)); }
  .webcam-grid { grid-template-columns: repeat(2, 1fr) !important; overflow: visible !important; height: auto !important; }

  /* Matrix — 2-col on mobile */
  .matrix-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Road Intel — scrollable summary, fixed-height map */
  .viz-layout { flex-direction: column; height: auto !important; overflow: visible !important; }
  .viz-sidebar { width: 100% !important; height: auto !important; max-height: none !important; border-right: none; border-bottom: 1px solid var(--border); overflow-y: auto; }
  .viz-main { min-height: 55vh; flex-shrink: 0; }
}

@media (max-width: 480px) {
  .camera-grid { grid-template-columns: 1fr 1fr; }
  .hero-title h1 { font-size: 20px; letter-spacing: 0.06em; }
  .map-container { max-width: 100% !important; }
  .webcam-grid { grid-template-columns: 1fr 1fr !important; }
  .matrix-grid { grid-template-columns: 1fr 1fr !important; }
}
