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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: 390px;
  flex-shrink: 0;
  background: #1a1d26;
  border-right: 1px solid #2d3148;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid #2d3148;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo { width: 32px; height: 32px; object-fit: contain; }
.brand-block { display: flex; flex-direction: column; }
.brand { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.02em; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 0.65rem; color: #64748b; letter-spacing: 0.04em; }

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel {
  padding: 14px 16px;
  border-bottom: 1px solid #2d3148;
}
.panel h3 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8892a4;
  margin-bottom: 10px;
}

/* Collapsible panels */
.panel-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-toggle::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid #8892a4;
  border-bottom: 1.5px solid #8892a4;
  transform: rotate(45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.panel-toggle[aria-expanded="false"]::after {
  transform: rotate(-45deg);
}
.panel-toggle[aria-expanded="false"] {
  margin-bottom: 0;
}
.panel-body {
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  max-height: 800px;
  opacity: 1;
}
.panel-body.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Data layer toggles */
.data-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.82rem;
  color: #cbd5e1;
}
.data-toggle input { flex-shrink: 0; accent-color: #22d3ee; }
.data-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.35;
  transition: opacity 0.15s;
}
.data-toggle input:checked ~ .data-dot { opacity: 1; }
.data-name { font-weight: 500; }

.forecast-hint {
  font-size: 0.68rem;
  color: #4b5563;
  font-style: italic;
  margin-top: 8px;
  line-height: 1.4;
}

/* ── Info tips ─────────────────────────────────────────────────────────────── */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #334155;
  color: #94a3b8;
  font-size: 0.55rem;
  font-style: italic;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}
.info-tip:hover { background: #475569; color: #e2e8f0; }

.info-tooltip {
  position: fixed;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  width: 210px;
  white-space: normal;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ── Form elements ────────────────────────────────────────────────────────── */
.pin-btn {
  width: 100%;
  padding: 7px 10px;
  background: #1e293b;
  border: 1px solid #2d3148;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.pin-btn:hover, .pin-btn.active {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #93c5fd;
}

.coords-display {
  font-size: 0.75rem;
  color: #60a5fa;
  font-family: monospace;
  margin: 5px 0 0;
}

.form-group { margin-top: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: #8892a4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.field-input {
  width: 100%;
  background: #0f1117;
  border: 1px solid #2d3148;
  border-radius: 5px;
  color: #e2e8f0;
  font-size: 0.82rem;
  padding: 5px 8px;
}
.field-input:focus { outline: none; border-color: #2563eb; }

.run-btn {
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  background: #2563eb;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.run-btn:hover:not(:disabled) { background: #1d4ed8; }
.run-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Summary panel ────────────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}
.summary-stat {
  background: #0f1117;
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}
.summary-stat .stat-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.summary-stat .stat-label {
  font-size: 0.65rem;
  color: #8892a4;
  text-transform: uppercase;
  margin-top: 3px;
  letter-spacing: 0.05em;
}
.stat-high { color: #b91c1c !important; }
.stat-mod  { color: #fb923c !important; }

.show-results-btn {
  margin-top: 10px;
  width: 100%;
  padding: 7px;
  background: #1e293b;
  border: 1px solid #2d3148;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}
.show-results-btn:hover { background: #273548; }

/* ── Legend ────────────────────────────────────────────────────────────────── */
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: #94a3b8;
}
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-high { background: #991b1b; }
.dot-mod  { background: #f97316; }
.dot-pos  { background: #eab308; }
.dot-none { background: #475569; }
.dot-fire { background: #ef4444; border: 2px solid #dc2626; }
.dot-pa   { background: #22c55e; border: 1px solid #0f1117; }

/* ── Smoke Forecast ───────────────────────────────────────────────────────── */
.forecast-category {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  margin: 6px 0;
}
.forecast-description {
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin: 6px 0 0;
}
.forecast-popout {
  position: absolute;
  top: 50%; left: calc(390px + 50%);
  transform: translate(-50%, -50%);
  width: min(800px, calc(100vw - 420px));
  max-height: 80vh;
  background: #1a1d26;
  border: 1px solid #2d3148;
  border-radius: 10px;
  z-index: 25;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
}
.forecast-popout.hidden { display: none; }
.forecast-popout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #2d3148;
}
.forecast-popout-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #e2e8f0;
}
.forecast-popout-body {
  padding: 16px;
  overflow-y: auto;
}
.forecast-popout-body canvas {
  width: 100% !important;
  height: 300px !important;
}
@media (max-width: 900px) {
  .forecast-popout {
    left: 50%;
    width: 90vw;
  }
}

/* ── Base map switcher ────────────────────────────────────────────────────── */
.basemap-switcher {
  display: flex;
  gap: 6px;
}
.basemap-btn {
  flex: 1;
  padding: 6px 0;
  background: #0f1117;
  border: 1px solid #2d3148;
  border-radius: 6px;
  color: #8892a4;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.basemap-btn:hover { background: #1e293b; color: #cbd5e1; }
.basemap-btn.active {
  background: #1e293b;
  border-color: #3b82f6;
  color: #e2e8f0;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.sidebar-footer { padding: 14px 16px; margin-top: auto; }
.muted { font-size: 0.75rem; color: #4b5563; line-height: 1.5; }

/* ── Map ──────────────────────────────────────────────────────────────────── */
#map { flex: 1; }

/* Pin-drop cursor */
.pin-drop-mode,
.pin-drop-mode .mapboxgl-canvas {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='36' viewBox='0 0 24 36'%3E%3Cpath d='M12 0C5.4 0 0 5.4 0 12c0 9 12 24 12 24s12-15 12-24C24 5.4 18.6 0 12 0z' fill='%232563eb'/%3E%3Ccircle cx='12' cy='12' r='5' fill='white'/%3E%3C/svg%3E")
    12 34,
    crosshair !important;
}

/* ── Results drawer ───────────────────────────────────────────────────────── */
.results-drawer {
  position: absolute;
  bottom: 0;
  left: 390px;
  right: 0;
  max-height: 44vh;
  background: #1a1d26;
  border-top: 2px solid #2d3148;
  z-index: 20;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.results-drawer.hidden { transform: translateY(100%); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #2d3148;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}
.drawer-header button {
  background: none; border: none;
  color: #64748b; cursor: pointer; font-size: 1rem;
}
.drawer-header button:hover { color: #e2e8f0; }

#drawer-content { overflow-y: auto; padding: 0 16px 12px; }

/* Results table */
.attr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 8px;
}
.attr-table th {
  color: #8892a4;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #2d3148;
  white-space: nowrap;
}
.attr-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #1e2233;
  color: #cbd5e1;
  vertical-align: middle;
}
.attr-table tr:hover td { background: #0f1117; }

/* Attribution badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-high { background: #7f1d1d; color: #fca5a5; }
.badge-mod  { background: #7c2d12; color: #fdba74; }
.badge-pos  { background: #713f12; color: #fde68a; }
.badge-none { background: #1e293b; color: #64748b; }

/* Export button */
.export-btn {
  flex: 1;
  text-align: center;
  padding: 7px 6px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
  background: #2563eb;
  color: #fff;
}
.export-btn:hover { opacity: 0.8; }

.exceedance-flag {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.65rem;
  color: #f87171;
  font-weight: 700;
}

/* ── Mapbox popup (fire hover) ────────────────────────────────────────────── */
.mapboxgl-popup.fire-popup .mapboxgl-popup-content {
  background: #1a1d26;
  border: 1px solid #2d3148;
  border-radius: 10px;
  color: #e2e8f0;
  padding: 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-width: 200px;
}
.mapboxgl-popup.fire-popup .mapboxgl-popup-close-button {
  color: #64748b;
  font-size: 1.1rem;
  right: 6px;
  top: 4px;
}
.mapboxgl-popup.fire-popup .mapboxgl-popup-close-button:hover { color: #e2e8f0; }
.mapboxgl-popup.fire-popup .mapboxgl-popup-tip {
  border-top-color: #1a1d26;
}
.fire-popup-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 10px;
  color: #f97316;
}
.fire-popup-icon {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 8px rgba(249,115,22,0.6);
  flex-shrink: 0;
}
.fire-popup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid #1e2233;
}
.fire-popup-row:last-child { border-bottom: none; }
.fire-popup-label { color: #64748b; }
.fire-popup-value { color: #cbd5e1; font-weight: 500; }

/* ── Time slider ──────────────────────────────────────────────────────────── */
.time-slider-bar {
  position: absolute;
  bottom: 0;
  left: 390px;
  right: 0;
  background: #1a1d26;
  border-top: 1px solid #2d3148;
  padding: 10px 20px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.25s ease;
}
.time-slider-bar.hidden { transform: translateY(100%); }
.time-slider-bar .slider-label {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
  font-family: monospace;
}
.time-slider-bar input[type="range"] {
  flex: 1;
  accent-color: #2563eb;
  height: 4px;
  cursor: pointer;
}
.time-slider-bar .slider-btn {
  background: #1e293b;
  border: 1px solid #2d3148;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 0.82rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.time-slider-bar .slider-btn:hover { background: #273548; color: #e2e8f0; }
.time-slider-bar .slider-btn.playing { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Adjust drawer when slider is shown */
.results-drawer.with-slider { bottom: 44px; }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-overlay.hidden { display: none; }

.loading-box {
  background: #1a1d26;
  border: 1px solid #2d3148;
  border-radius: 12px;
  padding: 32px 40px;
  text-align: center;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid #2d3148;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-msg { font-size: 0.9rem; font-weight: 600; color: #e2e8f0; }
.loading-sub { font-size: 0.75rem; color: #64748b; margin-top: 6px; line-height: 1.5; }

/* ── Error banner ─────────────────────────────────────────────────────────── */
#error-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #991b1b;
  color: #fef2f2;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.85rem;
  z-index: 100;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}
#error-banner.visible { transform: translateY(0); }

/* ── Mobile sidebar toggle ────────────────────────────────────────────────── */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 30;
  background: #1a1d26;
  border: 1px solid #2d3148;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 1.3rem;
  width: 40px; height: 40px;
  cursor: pointer;
  line-height: 1;
}

/* ── Auth overlay ─────────────────────────────────────────────────────────── */
#auth-overlay {
  position: fixed;
  inset: 0;
  background: #0f1117;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#auth-overlay.hidden { display: none; }
.auth-card {
  text-align: center;
  padding: 40px 36px;
  background: #1a1d26;
  border: 1px solid #2d3148;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  max-width: 360px;
  width: 90%;
}
.auth-logo { width: 56px; height: 56px; object-fit: contain; margin-bottom: 16px; }
.auth-card h1 { font-size: 1.8rem; font-weight: 700; color: #fff; margin-bottom: 4px; }
.auth-sub { font-size: 0.82rem; color: #64748b; margin-bottom: 28px; }
.auth-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  background: #fff;
  color: #1f2937;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.auth-google-btn:hover { box-shadow: 0 4px 16px rgba(255,255,255,0.15); }
.auth-hint { font-size: 0.72rem; color: #4b5563; margin-top: 16px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #sidebar-toggle { display: block; }
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 25;
  }
  #sidebar.open { transform: translateX(0); }
  .results-drawer { left: 0; }
}
