/* =========================================================================
   Lanier Navigator — styles (ported 1:1 from Streamlit app.py)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800;900&family=Barlow:wght@400;500;600;700&display=swap');

:root[data-theme="dark"] {
  --bg: #0e1117;
  --card-bg: #1e2130;
  --text: #fafafa;
  --sub-text: #a0aab5;
  --border: #333847;
  --reason-bg: rgba(0, 0, 0, 0.1);
  --stat-bg: rgba(255, 255, 255, 0.05);
  --dash-bg: rgba(20, 24, 38, 0.97);
  --chart-bg: rgba(255, 255, 255, 0.04);
}
:root[data-theme="light"] {
  --bg: #f0f2f6;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --sub-text: #6c757d;
  --border: #d1d8e0;
  --reason-bg: rgba(0, 0, 0, 0.05);
  --stat-bg: rgba(0, 0, 0, 0.04);
  --dash-bg: rgba(255, 255, 255, 0.97);
  --chart-bg: rgba(0, 0, 0, 0.04);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  max-width: 100vw;
  overflow-x: hidden;
}
body {
  background: var(--bg);
  font-family: 'Barlow', sans-serif;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

.container { max-width: 780px; margin: 0 auto; padding: 24px 16px; }

/* ---------- Header ---------- */
.main-title {
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: clamp(2.4rem, 10vw, 4.2rem);
  white-space: nowrap;
  margin: -10px 0 0 0;
  letter-spacing: -0.5px;
  text-align: center;
}
.live-clock {
  color: var(--sub-text);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 2px 0 10px;
  text-align: center;
}
.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 18px;
}
.toggle {
  background: var(--card-bg);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; user-select: none;
  font-weight: 700;
  font-size: 0.9rem;
}
.toggle input { accent-color: #3498db; }

/* ---------- Section header ---------- */
.section-header {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text);
  margin: 20px 0 10px 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ---------- Safety alerts banner ---------- */
.alert-expander {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  border-radius: 14px;
  color: white;
  margin: 5px 0 16px;
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.35);
}
.alert-summary {
  padding: 14px 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
}
.alert-summary::-webkit-details-marker { display: none; }
.alert-content {
  padding: 0 16px 14px;
  font-weight: 500;
  font-size: 0.92rem;
  line-height: 1.5;
}
.alert-content > div { margin-bottom: 8px; }

/* ---------- Metric cards ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  text-align: center;
  display: flex; flex-direction: column; justify-content: center;
}
.card-label {
  color: var(--sub-text);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 6px;
}
.card-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.1;
  color: var(--text);
}
.card-sub {
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 5px;
  color: var(--sub-text);
  line-height: 1.45;
}
.card-tiny {
  font-size: 0.6rem;
  opacity: 0.4;
  display: inline-block;
  margin-top: 3px;
}

/* ---------- Info pills ---------- */
.pill-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 8px 0 24px;
}
.info-pill {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  min-height: 64px;
}

/* ---------- Animations for pills ---------- */
@keyframes uv-pulse-anim {
  0%   { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(241, 196, 15, 0); }
  100% { box-shadow: 0 0 0 0 rgba(241, 196, 15, 0); }
}
.uv-pulse {
  animation: uv-pulse-anim 2s infinite;
  border-color: #f1c40f !important;
  color: #f1c40f !important;
}
@keyframes rain-drip {
  0%   { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(116, 185, 255, 0.4); }
  50%  { transform: translateY(2px);  box-shadow: 0 0 0 rgba(116, 185, 255, 0); }
  100% { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(116, 185, 255, 0.4); }
}
.rain-anim {
  animation: rain-drip 1.5s infinite ease-in-out;
  border-color: #74b9ff !important;
  color: #74b9ff !important;
}
@keyframes fog-fade {
  0%   { opacity: 0.5; filter: blur(1px); }
  50%  { opacity: 1;   filter: blur(0); }
  100% { opacity: 0.5; filter: blur(1px); }
}
.fog-anim {
  animation: fog-fade 3s infinite ease-in-out;
  border-color: #b2bec3 !important;
  color: #b2bec3 !important;
}

/* ---------- Score card ---------- */
.score-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.score-header-row { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; }
.score-num {
  font-size: 2.8rem; font-weight: 900;
  font-family: 'Barlow Condensed', sans-serif;
  line-height: 1;
}
.score-slash { font-size: 1rem; color: var(--sub-text); }
.score-label { font-size: 1rem; font-weight: 700; margin-left: 8px; }
.score-bar-bg {
  background: var(--border);
  border-radius: 10px;
  height: 10px;
  margin: 12px 0 10px;
  overflow: hidden;
}
.score-bar-fill {
  height: 10px;
  border-radius: 10px;
  transition: width 1s ease;
}
.score-factors {
  font-size: 0.75rem;
  color: var(--sub-text);
  margin-bottom: 10px;
}
.reason-pill {
  display: inline-block;
  background: var(--reason-bg);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  margin: 2px;
  font-weight: 700;
  border: 1px solid rgba(128, 128, 128, 0.25);
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.3px;
}

/* ---------- 24h chart ---------- */
.chart-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 10px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.chart-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.chart-title {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-family: 'Barlow Condensed', sans-serif;
  color: var(--sub-text);
}
.chart-stat-row {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 12px 10px;
  background: var(--chart-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.chart-stat-row > span { color: var(--sub-text); }

/* ---------- Wind card ---------- */
.wind-container {
  background: linear-gradient(135deg, #1a2a3a, #2c4a6e, #3498db);
  border-radius: 18px;
  padding: 18px;
  color: white;
  box-shadow: 0 8px 24px rgba(52, 152, 219, 0.25);
  margin-bottom: 20px;
}
.wind-merged {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
  width: 100%;
}
.wind-stats-box {
  background: rgba(0, 0, 0, 0.22);
  padding: 14px 22px;
  border-radius: 14px;
  min-width: 50%;
  text-align: center;
}
.wind-col { text-align: center; }

@keyframes wind-pulse {
  0%   { transform: translateY(0); opacity: 0.8; }
  50%  { transform: translateY(-8px); opacity: 1; filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8)); }
  100% { transform: translateY(0); opacity: 0.8; }
}
.animated-wind {
  display: inline-block;
  animation: wind-pulse 2s infinite ease-in-out;
}
@keyframes wind-shake-anim {
  0%   { transform: translateY(0) rotate(0); }
  25%  { transform: translateY(-3px) rotate(15deg); }
  50%  { transform: translateY(-6px) rotate(0); }
  75%  { transform: translateY(-3px) rotate(-15deg); }
  100% { transform: translateY(0) rotate(0); }
}
.wind-shake {
  display: inline-block;
  animation: wind-shake-anim 0.4s infinite ease-in-out;
  filter: drop-shadow(0 0 10px rgba(255, 118, 117, 0.9));
}

/* ---------- Wave simulator ---------- */
.sim-wave-box {
  position: relative;
  background: linear-gradient(to bottom, transparent 0%, rgba(52, 152, 219, 0.1) 100%);
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 12px;
  width: 100%;
  border-bottom: 3px solid #3498db;
}
.sim-wave-back {
  position: absolute; bottom: 0; left: 0;
  width: 200%; height: 55px;
  background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1200 60" xmlns="http://www.w3.org/2000/svg"><path d="M0,30 C150,60 350,0 600,30 C850,60 1050,0 1200,30 L1200,60 L0,60 Z" fill="%232980b9" opacity="0.5"/></svg>') repeat-x;
  background-size: 50% 100%;
  transform-origin: bottom;
  animation: wave-move var(--wave-speed-back, 3s) linear infinite reverse;
}
.sim-wave-front {
  position: absolute; bottom: 0; left: 0;
  width: 200%; height: 45px;
  background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1200 60" xmlns="http://www.w3.org/2000/svg"><path d="M0,30 C150,0 350,60 600,30 C850,0 1050,60 1200,30 L1200,60 L0,60 Z" fill="%233498db" opacity="0.8"/></svg>') repeat-x;
  background-size: 50% 100%;
  transform-origin: bottom;
  animation: wave-move var(--wave-speed-front, 2.5s) linear infinite;
}
@keyframes wave-move {
  0%   { transform: translateX(0) scaleY(var(--wave-scale, 1)); }
  100% { transform: translateX(-50%) scaleY(var(--wave-scale, 1)); }
}

/* ---------- Two-column row for camera + wave ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.two-col > .card { text-align: left; }
.yt-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
  margin-top: 8px;
}
.yt-embed iframe {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ---------- Utility expanders (checklist, fuel, bridge) ---------- */
.utility {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}
.utility > summary {
  padding: 14px 18px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  letter-spacing: 0.3px;
}
.utility > summary::-webkit-details-marker { display: none; }
.utility > summary::after {
  content: '▼';
  float: right;
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform 0.2s;
}
.utility[open] > summary::after { transform: rotate(180deg); }
.utility-body { padding: 10px 18px 18px; }
.checklist label {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.checklist input { accent-color: #3498db; transform: scale(1.2); }
.utility-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  margin: 6px 0;
}
.utility-input-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sub-text);
  margin-top: 8px;
  display: block;
}
.utility-success { background: rgba(46, 204, 113, 0.15); border: 1px solid #2ecc71; color: var(--text); padding: 10px 14px; border-radius: 8px; margin-top: 10px; font-weight: 600; }
.utility-warning { background: rgba(241, 196, 15, 0.15); border: 1px solid #f39c12; color: var(--text); padding: 10px 14px; border-radius: 8px; margin-top: 10px; font-weight: 600; }
.utility-error   { background: rgba(231, 76, 60, 0.15);  border: 1px solid #e74c3c; color: var(--text); padding: 10px 14px; border-radius: 8px; margin-top: 10px; font-weight: 600; }

/* ---------- MAP (full GPS nav component) ---------- */
#map-container {
  position: relative;
  height: 600px;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  margin-bottom: 20px;
}
#map { height: 100%; width: 100%; z-index: 1; }

/* GPS navigation fullscreen mode — works in regular Safari + standalone PWA */
.nav-hidden { display: none !important; }

body.nav-locked {
  overflow: hidden !important;
  width: 100vw !important;
  touch-action: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Regular Safari mode: lock body to current scroll position */
body.nav-locked:not(.nav-locked-pwa) {
  position: fixed !important;
}

/* iOS Standalone PWA mode: skip the position:fixed trick (causes phantom black overlay).
   The PWA has no scrollable browser chrome anyway, so we don't need it. */
body.nav-locked.nav-locked-pwa {
  position: relative !important;
  height: 100vh !important;
  height: 100dvh !important;
}

body.nav-locked .container {
  padding: 0 !important;
  max-width: 100vw !important;
  margin: 0 !important;
}

#map-container.nav-fullscreen {
  height: 100vh !important;
  height: 100dvh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  /* Use safe-area insets so map doesn't go under iPhone notch / home bar */
  padding-top: env(safe-area-inset-top, 0) !important;
  padding-bottom: env(safe-area-inset-bottom, 0) !important;
  box-sizing: border-box !important;
}

#nav-dashboard {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  z-index: 1001;
  background: var(--dash-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  padding: 14px 16px 18px;
  border-top: 3px solid #3498db;
  box-sizing: border-box;
  border-radius: 20px 20px 0 0;
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.3);
}
#nav-dashboard.active { transform: translateY(0); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  margin-top: 6px;
  gap: 6px;
}
.stat-box {
  background: var(--stat-bg);
  border-radius: 10px;
  padding: 8px 4px;
}
.stat-val {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.2;
  font-family: 'Barlow Condensed', sans-serif;
}
.stat-lbl {
  font-size: 0.65rem;
  opacity: 0.75;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-unit { font-size: 0.58rem; opacity: 0.5; }

#search-container {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 1000;
  width: 60%;
  max-width: 300px;
}
#poi-search {
  width: 100%;
  padding: 11px 15px;
  border-radius: 24px;
  border: 2px solid #3498db;
  background: var(--card-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  outline: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
#search-results {
  display: none;
  background: var(--card-bg);
  margin-top: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
}
.search-item {
  padding: 11px 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: rgba(52, 152, 219, 0.15); }

#filter-panel {
  position: absolute;
  bottom: 14px; right: 14px;
  z-index: 1000;
  background: var(--dash-bg);
  backdrop-filter: blur(6px);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  gap: 10px;
  align-items: center;
}
.filter-cb { margin-right: 4px; transform: scale(1.15); cursor: pointer; accent-color: #3498db; }
.filter-row { display: flex; align-items: center; cursor: pointer; white-space: nowrap; }

.map-marker {
  width: 34px; height: 34px;
  background: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  font-size: 18px;
  border: 2.5px solid white;
  transition: transform 0.2s;
}
.map-marker:hover { transform: scale(1.15); }
.marker-dining { border-color: #e74c3c; background: #fff5f5; }
.marker-fuel   { border-color: #f39c12; background: #fffbf0; }
.marker-marina { border-color: #3498db; background: #eaf4fd; }
.marker-launch { border-color: #27ae60; background: #edfaf1; }

/* Hazard report markers */
.hazard-marker {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  font-size: 18px;
  cursor: pointer;
  animation: hazard-pulse 2s ease-in-out infinite;
}
@keyframes hazard-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 0 rgba(231,76,60,0.5); }
  50%      { box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 0 0 8px rgba(231,76,60,0); }
}
.hazard-marker:hover { transform: scale(1.1); }

.poi-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text) !important;
  font-weight: 800 !important;
  font-size: 0.88rem !important;
  text-shadow:
    2px 2px 0 var(--bg),
   -2px -2px 0 var(--bg),
    2px -2px 0 var(--bg),
   -2px 2px 0 var(--bg) !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.3s !important;
}
#map.show-labels .poi-label { opacity: 1 !important; }

.start-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  margin-top: 10px;
  width: 100%;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.5px;
}
.start-btn:active { background: #2980b9; }
.stop-btn {
  background: #e74c3c;
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.8rem;
}
.nav-arrow-marker {
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s linear;
  transform-origin: center;
}

#recenter-btn {
  display: none;
  position: absolute;
  bottom: 60px; right: 14px;
  z-index: 1000;
  background: var(--card-bg);
  color: #3498db;
  border: 2px solid #3498db;
  width: 44px; height: 44px;
  border-radius: 50%;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  align-items: center; justify-content: center;
  transition: all 0.2s;
}
#recenter-btn:active { background: #3498db; color: white; }

/* ---------- Skeleton loading (shimmer) ---------- */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--border) 0%,
    rgba(128, 128, 128, 0.18) 50%,
    var(--border) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
  display: inline-block;
}
.skeleton-value { height: 2rem; width: 70%; margin: 6px auto; }
.skeleton-sub   { height: 0.7rem; width: 50%; margin: 4px auto; opacity: 0.6; }
.skeleton-pill  { height: 42px; width: 100%; border-radius: 16px; }
.chart-wrapper.loading {
  min-height: 220px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sub-text); font-size: 0.9rem;
}

/* ---------- Clickable cards and pills ---------- */
.card[data-metric],
.info-pill[data-metric],
.score-card[data-metric] {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.card[data-metric]:hover,
.info-pill[data-metric]:hover,
.score-card[data-metric]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 152, 219, 0.22);
}
.card[data-metric]::after,
.info-pill[data-metric]::after,
.score-card[data-metric]::after {
  content: '📈';
  position: absolute;
  top: 6px; right: 8px;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.card[data-metric]:hover::after,
.info-pill[data-metric]:hover::after,
.score-card[data-metric]:hover::after { opacity: 0.6; }

/* Stale data indicator */
.stale-badge {
  display: inline-block;
  font-size: 0.6rem;
  background: #f39c12;
  color: #000;
  padding: 2px 6px;
  border-radius: 8px;
  margin-left: 6px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ---------- Metric detail modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}
.modal-backdrop.open .modal-content { transform: scale(1); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
  gap: 12px;
}
.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  margin: 0;
}
.modal-close {
  background: none; border: none;
  color: var(--sub-text);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-current {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.8rem;
  font-weight: 900;
  text-align: center;
  margin: 8px 0 2px;
}
.modal-sub {
  text-align: center;
  font-size: 0.85rem;
  color: var(--sub-text);
  margin-bottom: 16px;
}
.modal-range-tabs {
  display: flex; justify-content: center; gap: 6px;
  margin: 12px 0 16px; flex-wrap: wrap;
}
.modal-range-tab {
  background: var(--card-bg); border: 1px solid var(--border);
  color: var(--text); padding: 6px 14px; border-radius: 16px;
  cursor: pointer; font-weight: 700; font-size: 0.8rem;
  font-family: 'Barlow Condensed', sans-serif;
}
.modal-range-tab.active { background: #3498db; color: white; border-color: #3498db; }
.modal-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-size: 0.85rem;
  margin-top: 14px;
}
.modal-stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.modal-stat-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sub-text);
}
.modal-stat-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.3rem;
  font-weight: 900;
  margin-top: 2px;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .main-title { font-size: clamp(2.2rem, 10vw, 2.8rem) !important; margin-bottom: 6px; }
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cards-grid .card:nth-child(3) { grid-column: span 2; }
  .card-value { font-size: 1.65rem !important; }
  .card { padding: 14px 12px; border-radius: 13px; }
  .card-sub { font-size: 0.7rem; }
  .pill-container { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .info-pill { font-size: 0.8rem; min-height: 56px; padding: 6px; }
  .toggle { width: 100%; }
  .wind-merged { flex-direction: column; text-align: center; }
  .wind-stats-box { width: 100%; padding: 12px; min-width: unset; }
  .wind-container { padding: 14px; border-radius: 14px; }
  .chart-wrapper { padding: 14px 10px 8px; }
  .section-header { font-size: 1.1rem; }
  .score-card { padding: 14px; }
  .two-col { grid-template-columns: 1fr; }
  #search-container { width: 90%; max-width: none; left: 5%; }
  #filter-panel { bottom: 10px; right: 5%; gap: 6px; padding: 6px 10px; font-size: 0.75rem; }
  #map-container { height: 500px; }
}
