/* ==========================================================================
   EcoPulse design system
   Palette: deep teal + warm orange on a cool grey canvas.
   Type: Archivo (headings) / Public Sans (body).
   ========================================================================== */

:root {
  --ink: #17242c;
  --muted: #5c6b75;
  --bg: #f2f4f5;
  --card: #ffffff;
  --line: #dfe4e8;
  --brand: #0e5a6d;
  --brand-dark: #0a4353;
  --brand-soft: #e3eef1;
  --accent: #e8630a;
  --accent-dark: #c85207;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 36, 44, 0.06), 0 4px 12px rgba(23, 36, 44, 0.05);

  /* US EPA AQI category colours (semantic — used only for data) */
  --aqi-good: #3d8b48;
  --aqi-moderate: #b8860b;
  --aqi-usg: #d2691e;
  --aqi-unhealthy: #c0392b;
  --aqi-very-unhealthy: #8e44ad;
  --aqi-hazardous: #7b1e3b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Public Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3, .brand-name, .stat-value, .temp, .temp-lg, .aqi-value {
  font-family: "Archivo", system-ui, sans-serif;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { vertical-align: -0.15em; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }

/* --- Brand ------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid transparent;
  font: 600 14px "Public Sans", system-ui, sans-serif;
  cursor: pointer; text-decoration: none !important; transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #fff; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-disabled { opacity: 0.4; pointer-events: none; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding-top: 16px; }

/* --- Landing page ------------------------------------------------------- */
.site-nav { background: #fff; border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; gap: 32px; height: 64px; }
.nav-brand { text-decoration: none !important; }
.nav-links { display: flex; gap: 22px; margin-right: auto; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-actions { display: flex; gap: 10px; }

.hero { background: #fff; padding: 72px 0 64px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 48px; align-items: center; }
.eyebrow {
  margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--brand);
}
.hero h1 { font-size: 42px; letter-spacing: -0.025em; margin-bottom: 16px; }
.lede { font-size: 17px; color: var(--muted); max-width: 46ch; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.fine-print { margin-top: 14px; font-size: 13px; color: var(--muted); }
.trust-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--brand-dark);
}
.trust-badge svg { flex-shrink: 0; color: var(--brand); }

.preview-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; max-width: 340px; margin-left: auto;
}
.preview-head { font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.preview-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.preview-row span:first-child { font-weight: 500; }
.preview-foot { margin-top: 10px; font-size: 11px; color: var(--muted); text-align: right; }

.stats-band { background: var(--brand); color: #fff; }
.stats-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; padding: 26px 0; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-family: "Archivo", sans-serif; font-size: 26px; }
.stat span:last-child { font-size: 13px; opacity: 0.85; }

.section { padding: 64px 0; }
.section-alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-title { font-size: 28px; letter-spacing: -0.02em; }
.section-sub { color: var(--muted); max-width: 60ch; margin: 0 0 30px; }
.feature-grid, .steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.feature-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 9px; margin-bottom: 14px;
  background: var(--brand-soft); color: var(--brand);
}
.feature-card h3 { font-size: 17px; }
.feature-card p { color: var(--muted); margin: 0; font-size: 14px; }
.step { padding: 8px 4px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; margin-bottom: 12px;
  background: var(--brand); color: #fff; font: 700 14px "Archivo", sans-serif;
}
.step h3 { font-size: 16px; }
.step p { color: var(--muted); font-size: 14px; margin: 0; }
.data-note p { max-width: 70ch; color: var(--muted); }

.cta-band { background: var(--brand-dark); color: #fff; padding: 52px 0; }
.cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.cta-inner h2 { font-size: 24px; margin: 0; }

.site-footer { background: #fff; border-top: 1px solid var(--line); padding: 22px 0; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* --- Language switcher ---------------------------------------------------- */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.lang-btn {
  padding: 0 10px; height: 40px; display: inline-flex; align-items: center;
  font: 600 12px "Public Sans", system-ui, sans-serif; color: var(--muted);
  background: var(--card); text-decoration: none !important;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--line); }
.lang-btn:hover { background: var(--brand-soft); color: var(--ink); }
.lang-btn.active { background: var(--brand); color: #fff; }

/* --- Auth pages ---------------------------------------------------------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; position: relative; }
.auth-top { position: absolute; top: 16px; right: 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 34px;
}
.auth-card.center { text-align: center; }
.auth-brand { display: inline-block; margin-bottom: 22px; text-decoration: none !important; }
.auth-card h1 { font-size: 24px; }
.auth-sub { color: var(--muted); margin: 0 0 22px; }
.auth-card label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.auth-card label .hint { font-weight: 400; color: var(--muted); }
.auth-card input[type="text"], .auth-card input[type="email"], .auth-card input[type="password"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: 400 15px "Public Sans", sans-serif; background: #fbfcfc;
}
.auth-card input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; margin: 16px 0 !important; }
.auth-card .btn-block { margin-top: 8px; }
.auth-alt { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.error-code { font-size: 56px; margin: 6px 0; color: var(--brand); }

/* --- Flash / banners ------------------------------------------------------ */
.flash-stack { margin-bottom: 16px; }
.flash, .banner { padding: 11px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 8px; border: 1px solid; }
.flash-error, .banner-error { background: #fdf1f0; border-color: #eecac6; color: #9c2f23; }
.flash-message, .banner-info { background: #eef4f6; border-color: #cfdfe4; color: #0a4353; }

/* --- App shell ------------------------------------------------------------ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; display: flex; flex-direction: column;
  background: #fff; border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); text-decoration: none !important; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.side-label {
  margin: 18px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px; margin-bottom: 1px;
  color: var(--ink); font-weight: 500; font-size: 14px;
}
.side-link svg { color: var(--muted); flex-shrink: 0; }
.side-link:hover { background: var(--bg); text-decoration: none; }
.side-link.active { background: var(--brand-soft); color: var(--brand-dark); }
.side-link.active svg { color: var(--brand); }
.sidebar-foot { border-top: 1px solid var(--line); padding: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand); color: #fff; font: 700 15px "Archivo", sans-serif;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 32px 0;
}
.page-title { font-size: 24px; letter-spacing: -0.02em; margin: 0; }
.page-sub { color: var(--muted); margin: 3px 0 0; font-size: 14px; }
.content { padding: 22px 32px 40px; }

/* --- Cards / stats --------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 16px; }
.aqi-abbr { font-weight: 400; opacity: 0.7; }
.aqi-hint { margin: 0 0 12px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-row-2 { grid-template-columns: repeat(2, 1fr); }
/* Doubled selector so this reliably beats the existing ".stat-row { 1fr }"
   ≤960px override further down the file (equal source order would
   otherwise let that generic mobile rule win between 641-959px). */
.stat-row-4.stat-row-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 5px; align-items: flex-start;
}
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; margin-bottom: 4px;
  background: var(--brand-soft); color: var(--brand);
}
.stat-icon-alert-red { background: var(--aqi-unhealthy); color: #fff; }
.stat-icon-alert-orange { background: var(--aqi-usg); color: #fff; }
.stat-icon-alert-green { background: var(--aqi-good); color: #fff; }
/* .stat-row-4.stat-row-4 (doubled selector) beats the existing generic
   ".stat-row { 1fr }" mobile override further down regardless of source
   order, without having to reshuffle unrelated rules. */
@media (max-width: 640px) { .stat-row-4.stat-row-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px) { .stat-row-4.stat-row-4 { grid-template-columns: 1fr; } }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); }

/* Owner-only stat-card that doubles as a button (toggles the
   administrators roster). Resets the browser's default button chrome
   back to plain .stat-card looks, then adds an obvious hover/focus state
   so it still reads as clickable. */
.stat-card-btn {
  font: inherit; text-align: left; width: 100%; cursor: pointer;
}
.stat-card-btn:hover { border-color: var(--brand); }
.stat-card-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --- Health tip card ---------------------------------------------------------- */
.health-tip-card { display: flex; align-items: center; gap: 20px; padding: 18px 22px; margin-bottom: 18px; }
.health-tip-illustration { width: 88px; height: 88px; flex-shrink: 0; border-radius: 50%; }
.health-tip-body { flex: 1; min-width: 0; }
.health-tip-body .card-title { margin-bottom: 4px; }
.health-tip-body p { margin: 0 0 4px; }
.health-tip-body p:last-child { margin-bottom: 0; }

/* --- Region grid ------------------------------------------------------------ */
.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.region-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; color: var(--ink);
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.15s, transform 0.15s;
}
.region-card:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.region-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.region-card-head h3 { font-size: 16px; margin: 0; }
.region-card-body { display: flex; align-items: center; gap: 10px; }
.w-icon { color: var(--brand); display: inline-flex; }
.temp { font-size: 26px; font-weight: 700; }
.region-card-foot {
  display: flex; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--line); padding-top: 11px;
  font-size: 12.5px; color: var(--muted);
}

/* --- Rankings ------------------------------------------------------------ */
.ranking-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.ranking-tab {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.ranking-tab:hover { border-color: var(--brand); color: var(--ink); }
.ranking-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.ranking-panel { display: none; }
.ranking-panel.active { display: block; }
.rank-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.ranking-panel .rank-row:last-of-type { border-bottom: none; }
.rank-row:hover { background: var(--bg); }
.rank-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.rank-name { flex: 1; font-weight: 500; }
.rank-chevron { color: var(--muted); flex-shrink: 0; transition: transform 0.15s ease; }
.rank-row.expanded .rank-chevron { transform: rotate(90deg); }
.rank-districts { display: none; padding: 2px 4px 12px 38px; }
.rank-districts.open { display: block; }
.rank-row-sub {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  font-size: 13px; border-bottom: 1px dashed var(--line);
}
.rank-row-sub:last-child { border-bottom: none; }
.rank-row-sub .rank-num { width: 20px; height: 20px; font-size: 11px; background: transparent; color: var(--muted); }
.rank-row-sub .rank-name { font-weight: 400; }
.rank-row-stale { opacity: 0.6; }
.rank-row-stale .rank-name::after { content: " *"; color: var(--muted); }
.chip-neutral { background: var(--muted); }
/* Hottest-ranking chip: the plain grey chip-neutral read as flat/washed
   out against the app's near-black default background and didn't visually
   say "temperature" at all - a warm gradient off the existing brand
   accent orange reads as heat at a glance and keeps solid contrast on
   both the light landing theme and the dark in-app default. */
.chip-hot { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }

/* --- Skeleton loaders (generic - used while any client-fetched panel is
   still loading, e.g. the Rankings district expand) ------------------- */
.rank-skeleton { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.rank-skeleton-row { height: 28px; border-radius: 6px; }
.rank-skeleton-row,
.skeleton-block {
  background: linear-gradient(90deg, var(--bg) 25%, var(--line) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- News ------------------------------------------------------------------ */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.news-card {
  display: flex; flex-direction: column; color: var(--ink); text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.news-card:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.news-thumb {
  display: block; width: 100%; height: 150px;
  object-fit: cover; object-position: center; background: var(--bg);
}
.news-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.news-body h3 { font-size: 15px; line-height: 1.35; margin: 0; }
.news-body p { margin: 0; line-height: 1.5; }
.news-meta { margin-top: auto; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.news-attribution { margin-top: 16px; }

/* --- Wildfires / Hurricanes ------------------------------------------------- */
.storm-list { display: flex; flex-direction: column; gap: 10px; }
.storm-card {
  display: block; padding: 14px 18px; color: var(--ink); text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: border-color .15s;
}
.storm-card:hover { border-color: var(--brand); }
.storm-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.storm-card-head h3 { margin: 0; font-size: 15px; }
.storm-card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.storm-alert-green { background: var(--aqi-good); }
.storm-alert-orange { background: var(--aqi-usg); }
.storm-alert-red { background: var(--aqi-unhealthy); }

/* --- Map ------------------------------------------------------------------- */
.map-card { padding: 0; overflow: hidden; margin-bottom: 16px; }
#map-canvas, #wildfire-map-canvas, #hurricane-map-canvas { height: 520px; width: 100%; background: var(--bg); }
.map-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 12px 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px;
}
.map-legend-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.map-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.map-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map-dot-district { background: var(--muted); width: 8px; height: 8px; }

/* District navigation pins (clustered) - deliberately plain, not
   AQI-coloured (see the comment in views.map_view for why). */
.leaflet-div-icon.map-district-icon {
  background: transparent; border: none;
  display: flex; align-items: center; justify-content: center;
}
.map-district-dot {
  display: block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: transparent; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: var(--brand); color: #fff; opacity: 0.88; font-weight: 700;
}

/* AQI mood-face badge (map popups) - a coloured circle reusing the exact
   same .aqi-* background classes as the chips elsewhere, so the colour
   is always identical to the number sitting right next to it. */
.aqi-face {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; color: #fff; flex-shrink: 0;
}

/* Leaflet popup/tooltip content - scoped to our own className so this
   always wins over Leaflet's own default padding regardless of the
   two stylesheets' load order. */
.map-tooltip-rich, .map-popup-wrap .leaflet-popup-content-wrapper {
  padding: 0; border-radius: 10px; box-shadow: var(--shadow);
  background: var(--card); color: var(--ink);
}
.map-tooltip-rich::before { display: none; }
.map-popup-wrap .leaflet-popup-content { margin: 0; }
.map-popup-wrap .leaflet-popup-tip { background: var(--card); }
.map-popup-wrap .leaflet-popup-close-button {
  color: var(--muted); width: 28px; height: 28px; font-size: 20px;
  line-height: 28px; top: 2px; right: 2px;
}
.map-popup-wrap .leaflet-popup-close-button:hover { color: var(--ink); }
.map-popup {
  min-width: 210px; max-width: 78vw; padding: 14px 16px;
  font: 400 13px "Public Sans", system-ui, sans-serif; color: var(--ink);
}
.map-popup h4 { margin: 0 0 2px; font-size: 15px; }
.map-popup .muted { margin: 0 0 8px; }
.map-popup-aqi { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.map-popup-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
  font-size: 12.5px; color: var(--muted); margin-bottom: 10px;
}
.map-popup-link {
  display: inline-block; font-size: 13px; font-weight: 600; color: var(--brand);
  text-decoration: none; padding: 6px 0; min-height: 28px;
}
.map-popup-link:hover { text-decoration: underline; }

/* Touch-friendly zoom control: Leaflet's default 26px buttons are under
   the ~44px comfortable tap-target size. Bumped up only when Leaflet has
   detected a touch device (it adds this class itself). */
.leaflet-touch .leaflet-bar a { width: 38px; height: 38px; line-height: 38px; font-size: 18px; }
.leaflet-touch .leaflet-control-zoom { border-radius: 8px; overflow: hidden; }

/* --- AQI chips ---------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap;
}
.chip-lg { font-size: 14px; padding: 5px 13px; }
.aqi-good { background: var(--aqi-good); }
.aqi-moderate { background: var(--aqi-moderate); }
.aqi-usg { background: var(--aqi-usg); }
.aqi-unhealthy { background: var(--aqi-unhealthy); }
.aqi-very-unhealthy { background: var(--aqi-very-unhealthy); }
.aqi-hazardous { background: var(--aqi-hazardous); }
.aqi-good-text { color: var(--aqi-good); }
.aqi-moderate-text { color: var(--aqi-moderate); }
.aqi-usg-text { color: var(--aqi-usg); }
.aqi-unhealthy-text { color: var(--aqi-unhealthy); }
.aqi-very-unhealthy-text { color: var(--aqi-very-unhealthy); }
.aqi-hazardous-text { color: var(--aqi-hazardous); }

/* --- Region detail --------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; }
.current-main { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.w-icon-lg { color: var(--brand); display: inline-flex; }
.temp-lg { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; }
.current-label { font-weight: 600; margin: 0; }
.detail-list { display: flex; flex-wrap: wrap; gap: 14px 26px; margin: 0; border-top: 1px solid var(--line); padding-top: 15px; }
.detail-list div { display: flex; flex-direction: column; gap: 3px; }
.detail-list dt { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.detail-list dd { margin: 0; font-weight: 600; }
.aqi-main { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.aqi-value { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; }
.aqi-advice { margin: 0 0 8px; }
.aqi-card-body { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.aqi-card-text { flex: 1; min-width: 0; }
.aqi-illustration { width: 100px; height: 100px; flex-shrink: 0; }
.chart-wrap { position: relative; height: 300px; }

.day-list { display: flex; flex-direction: column; }
.day-block { border-bottom: 1px solid var(--line); }
.day-block:last-child { border-bottom: none; }
.day-cell {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 4px; background: none; border: none; font: inherit; color: inherit;
  text-align: left; cursor: pointer;
}
.day-cell:hover { background: var(--bg); }
.day-cell-static { cursor: default; }
.day-cell-static:hover { background: none; }
.day-cell svg { color: var(--brand); flex-shrink: 0; }
.day-name { width: 46px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; flex-shrink: 0; }
.day-aqi-chip { font-size: 11px; padding: 2px 8px; flex-shrink: 0; }
.day-temps { font-weight: 700; font-size: 14.5px; margin-left: auto; }
.day-temps small { color: var(--muted); font-weight: 500; }
.day-wind { display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0; }
.day-rain { width: 34px; text-align: right; flex-shrink: 0; }
.day-chevron { color: var(--muted); flex-shrink: 0; transition: transform 0.25s ease; }
.day-cell[aria-expanded="true"] .day-chevron { transform: rotate(90deg); }

.hour-strip { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.hour-strip.open { max-height: 220px; }
.hour-strip-inner { display: flex; gap: 16px; overflow-x: auto; padding: 4px 4px 16px; }
.hour-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 50px; flex-shrink: 0; font-size: 12px;
}
.hour-cell svg { color: var(--brand); }
.hour-time { color: var(--muted); }
.hour-temp { font-weight: 700; }
.hour-aqi-chip { font-size: 10.5px; padding: 1px 7px; }
.hour-wind { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 10.5px; }
.wind-arrow { color: var(--muted); flex-shrink: 0; transition: transform 0.3s ease; }

/* --- Weather icon animation --------------------------------------------
   Subtle, continuous motion on the condition icons themselves (sun,
   cloud, rain, snow, storm, fog) wherever they appear - region cards,
   the current-weather card, day/hour forecast cells. Scoped by exactly
   which sprite symbol is referenced, so it never touches unrelated UI
   icons (nav, admin, etc.) that happen to sit in the same SVG sprite. */
use[href="#i-sun"] { transform-origin: center; animation: icon-sun-spin 16s linear infinite; }
use[href="#i-cloud"], use[href="#i-sun-cloud"], use[href="#i-fog"] {
  transform-origin: center; animation: icon-cloud-drift 4.5s ease-in-out infinite;
}
use[href="#i-rain"], use[href="#i-drizzle"] {
  transform-origin: center; animation: icon-rain-fall 1.6s ease-in-out infinite;
}
use[href="#i-snow"] { transform-origin: center; animation: icon-snow-drift 3s ease-in-out infinite; }
use[href="#i-storm"] { transform-origin: center; animation: icon-storm-flash 2.2s ease-in-out infinite; }

@keyframes icon-sun-spin { to { transform: rotate(360deg); } }
@keyframes icon-cloud-drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(2px); }
}
@keyframes icon-rain-fall {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(1.5px); opacity: .7; }
}
@keyframes icon-snow-drift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(1.5px) rotate(10deg); }
}
@keyframes icon-storm-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
@media (prefers-reduced-motion: reduce) {
  use[href="#i-sun"], use[href="#i-cloud"], use[href="#i-sun-cloud"], use[href="#i-fog"],
  use[href="#i-rain"], use[href="#i-drizzle"], use[href="#i-snow"], use[href="#i-storm"] {
    animation: none;
  }
}

/* --- Tables ------------------------------------------------------------------------ */
/* Horizontal scroll wrapper so wide tables never break the page layout
   on narrow phones - the card scrolls internally instead. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); }
.table tbody tr:last-child td { border-bottom: none; }
.role-badge {
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  text-transform: capitalize; white-space: nowrap;
}
.role-admin { background: var(--brand-soft); color: var(--brand-dark); }
.role-user { background: #eef0f2; color: var(--muted); }

/* --- Responsive --------------------------------------------------------------------- */
@media (max-width: 960px) {
  .hero-grid, .detail-grid { grid-template-columns: 1fr; }
  .hero-preview { display: none; }
  .feature-grid, .steps-grid, .stat-row { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  #map-canvas, #wildfire-map-canvas, #hurricane-map-canvas { height: min(70vh, 480px); }
}

/* Small phones: tighten spacing and stack controls so nothing overlaps
   or forces horizontal scrolling. Purely layout/spacing - no colours,
   copy or functionality change. */
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .content { padding-left: 16px; padding-right: 16px; }

  /* Landing nav: logo stays on its own row, the controls (language,
     theme, sign in / create account) wrap to a right-aligned row below
     instead of squeezing onto one line with the brand mark. */
  .nav-inner { flex-wrap: wrap; row-gap: 10px; height: auto; padding: 12px 0; }
  .nav-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }

  .hero { padding: 40px 0 36px; }
  .hero h1 { font-size: 27px; }
  .lede { font-size: 15px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; }

  /* Even 2-column grid instead of flex space-between, which looks
     ragged once the 4 stats wrap onto two lines. */
  .stats-inner { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 12px; padding: 22px 0; }

  .section { padding: 44px 0; }
  .section-title { font-size: 23px; }
  .feature-card, .auth-card { padding: 20px; }

  .cta-inner { text-align: center; justify-content: center; }
  .cta-inner .btn { width: 100%; }

  .stat-card, .card { padding: 16px; }
  .page-title { font-size: 20px; }

  .ranking-tabs { gap: 6px; }
  .ranking-tab { padding: 7px 12px; font-size: 12.5px; }
  .rank-row { gap: 8px; }
  .rank-districts { padding-left: 30px; }

  .health-tip-card { flex-direction: column; text-align: center; gap: 10px; }
  .health-tip-illustration { width: 72px; height: 72px; }

  .aqi-card-body { flex-direction: column; text-align: center; }
  .aqi-illustration { width: 84px; height: 84px; }
}

/* --- Location picker (cascading searchable dropdowns) -------------------- */
.picker { display: flex; gap: 10px; width: 420px; max-width: 46vw; }
.picker .ts-wrapper { flex: 1; min-width: 0; }
.picker .ts-control {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font: 500 14px "Public Sans", system-ui, sans-serif;
  background: var(--card); color: var(--ink); box-shadow: none;
}
.picker .ts-control input { font: inherit; color: inherit; }
.picker .ts-wrapper.focus .ts-control { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.picker .ts-wrapper.disabled .ts-control { background: var(--bg); color: var(--muted); }
.ts-dropdown {
  border: 1px solid var(--line); border-radius: 8px;
  font: 400 14px "Public Sans", system-ui, sans-serif;
  box-shadow: var(--shadow);
  /* Appended straight to <body> (see picker.js) so it can never be
     clipped by a page's own content, but that also puts it in the same
     stacking context as the mobile sidebar (z-index 60) and its
     backdrop (55) - without its own z-index here it could render
     underneath them on phones. */
  z-index: 70;
}
.ts-dropdown .active { background: var(--brand-soft); color: var(--brand-dark); }
@media (max-width: 960px) { .picker { width: 100%; max-width: none; } }

/* --- v5 additions: location button, avatar photo, owner controls -------- */
.loc-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--brand); cursor: pointer; transition: background 0.15s;
}
.loc-btn:hover { background: var(--brand-soft); }
.loc-btn.loading { opacity: 0.5; pointer-events: none; }
.avatar-img { background-size: cover; background-position: center; color: transparent; }

.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.icon-btn-danger:hover { background: #fdf1f0; color: #c0392b; border-color: #eecac6; }

/* form controls inside plain cards (edit user page) */
.card form label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.card form input[type="text"], .card form input[type="email"], .card form select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: 400 15px "Public Sans", sans-serif; background: #fbfcfc;
}
.card form input:focus, .card form select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.form-row { display: flex; gap: 10px; margin-top: 18px; }
.auth-card input[type="date"], .auth-card input[type="file"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: 400 14px "Public Sans", sans-serif; background: #fbfcfc;
}

/* ==========================================================================
   v6: dark mode, mobile burger menu
   ========================================================================== */

/* --- Theme toggle button --------------------------------------------------- */
.theme-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); cursor: pointer; transition: background 0.15s;
}
.theme-btn:hover { background: var(--brand-soft); }
.theme-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-btn .icon-moon { display: none; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* --- Burger + mobile sidebar ----------------------------------------------- */
.burger {
  display: none; flex-shrink: 0;
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); cursor: pointer;
  align-items: center; justify-content: center;
}
.sidebar-backdrop { display: none; }

@media (max-width: 760px) {
  .burger { display: inline-flex; }
  .sidebar {
    display: flex; position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
    width: 270px; max-width: 82vw; height: 100vh;
    transform: translateX(-102%); transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.25);
  }
  .shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(15, 25, 31, 0.45);
    opacity: 0; pointer-events: none; transition: opacity 0.22s ease;
  }
  .shell.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  /* topbar-right holds the picker + language switch + theme button; it
     has no wrap of its own by default, so on narrow screens the
     full-width picker was squeezing against the other controls instead
     of moving to its own line. Wrapping the group and giving the picker
     a 100% flex-basis puts language/theme on a compact first row and
     the picker on a clean full-width row under it. */
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; row-gap: 10px; }
  .picker { flex: 1 1 100%; max-width: none; order: 3; }
}

/* --- Dark theme ------------------------------------------------------------- */
[data-theme="dark"] {
  --ink: #e6edf1;
  --muted: #93a4ae;
  --bg: #0e1519;
  --card: #162026;
  --line: #29363e;
  --brand: #3aa5c0;
  --brand-dark: #7fd0e4;
  --brand-soft: #11333f;
  --accent: #f0761f;
  --accent-dark: #ff8a33;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] .site-nav, [data-theme="dark"] .hero,
[data-theme="dark"] .section-alt, [data-theme="dark"] .site-footer,
[data-theme="dark"] .sidebar { background: var(--card); }
[data-theme="dark"] .btn-ghost:hover { background: var(--bg); }
[data-theme="dark"] .auth-card input, [data-theme="dark"] .card form input,
[data-theme="dark"] .card form select,
[data-theme="dark"] .auth-card input[type="date"], [data-theme="dark"] .auth-card input[type="file"] {
  background: #0f181d; color: var(--ink); border-color: var(--line);
}
[data-theme="dark"] .flash-message, [data-theme="dark"] .banner-info {
  background: #11333f; border-color: #1d4a58; color: #bfe3ee;
}
[data-theme="dark"] .flash-error, [data-theme="dark"] .banner-error {
  background: #3a1a17; border-color: #59322d; color: #f0b6ae;
}
[data-theme="dark"] .role-user { background: #223038; color: var(--muted); }
[data-theme="dark"] .icon-btn { background: var(--card); }
[data-theme="dark"] .icon-btn:hover { background: var(--bg); }
[data-theme="dark"] .icon-btn-danger:hover { background: #3a1a17; color: #f0b6ae; border-color: #59322d; }
[data-theme="dark"] .ts-dropdown { background: var(--card); color: var(--ink); }
[data-theme="dark"] .stats-band { background: var(--brand-soft); }
[data-theme="dark"] .cta-band { background: var(--brand-soft); }
[data-theme="dark"] .preview-card, [data-theme="dark"] .loc-btn, [data-theme="dark"] .picker .ts-control { background: var(--card); }

/* --- v6.1: native dark scrollbars + tidy sidebar scrollbar ---------------- */
:root { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

.sidebar-nav { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px;
  border: 2px solid var(--card); background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--muted); }

body { scrollbar-color: var(--line) var(--bg); }
body::-webkit-scrollbar { width: 12px; }
body::-webkit-scrollbar-track { background: var(--bg); }
body::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px;
  border: 3px solid var(--bg); background-clip: padding-box;
}

/* ==========================================================================
   v11: professional pass — refined dark palette, rankings bars & medals,
   curated news library, leadership roster, info notes, role colours
   ========================================================================== */

/* Slightly deeper, more neutral dark canvas: the previous values were a
   touch washed-out; deeper background + subtly lighter cards read as a
   more deliberate, premium dark UI while keeping the same hue family. */
[data-theme="dark"] {
  --bg: #0b1114;
  --card: #121b21;
  --line: #26333c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* Section headings between page blocks (News live vs library, etc.) */
.section-heading { margin: 26px 0 14px; }
.section-heading:first-child { margin-top: 0; }
.section-heading h2 { font-size: 18px; letter-spacing: -0.01em; margin: 0 0 3px; }
.section-heading p { margin: 0; }

/* --- Info note (the "why we track this" cards) --------------------------- */
.info-note { display: flex; gap: 16px; align-items: flex-start; }
.info-note-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand);
}
.info-note .card-title { margin-bottom: 6px; }
.info-note p { margin: 0; max-width: 90ch; }

/* --- Rankings: value bars + medals ---------------------------------------- */
.rank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rank-bar {
  display: block; height: 5px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
.rank-bar i {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  transition: width 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.rank-bar-sub { height: 4px; opacity: 0.85; }
.rank-row { align-items: center; }
.rank-num.rank-medal { color: #fff; }
.rank-medal-1 { background: linear-gradient(135deg, #e8b923, #c9920a); box-shadow: 0 1px 4px rgba(201, 146, 10, 0.45); }
.rank-medal-2 { background: linear-gradient(135deg, #b8c2cc, #8e9aa6); box-shadow: 0 1px 4px rgba(142, 154, 166, 0.45); }
.rank-medal-3 { background: linear-gradient(135deg, #cd8a4b, #a96430); box-shadow: 0 1px 4px rgba(169, 100, 48, 0.45); }
.ranking-tab { display: inline-flex; align-items: center; gap: 6px; }
.ranking-tab svg { flex-shrink: 0; }

/* --- News: curated story library ------------------------------------------ */
.news-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.news-filter {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.news-filter:hover { border-color: var(--brand); color: var(--ink); }
.news-filter.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.news-card-story .news-body { gap: 9px; }
.story-tags { display: flex; align-items: center; gap: 8px; }
.story-cat {
  display: inline-flex; align-items: center;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.story-year { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.story-read { color: var(--brand); font-weight: 700; }
.news-card-story:hover .story-read { text-decoration: underline; }

/* Category hues (backgrounds are translucent so the same rule works on
   both light and dark cards; text colours get a dark-mode lift below). */
.story-cat-air        { background: rgba(58, 165, 192, 0.16);  color: #23768e; }
.story-cat-climate    { background: rgba(232, 99, 10, 0.14);   color: #b5500a; }
.story-cat-water      { background: rgba(47, 111, 208, 0.14);  color: #2a5ba8; }
.story-cat-plastic    { background: rgba(194, 65, 126, 0.14);  color: #a33368; }
.story-cat-wildlife   { background: rgba(91, 158, 61, 0.16);   color: #45772f; }
.story-cat-forests    { background: rgba(46, 125, 91, 0.16);   color: #276a4d; }
.story-cat-disasters  { background: rgba(192, 57, 43, 0.14);   color: #a13023; }
.story-cat-energy     { background: rgba(184, 134, 11, 0.16);  color: #8f6809; }
.story-cat-policy     { background: rgba(125, 91, 190, 0.14);  color: #64459c; }
.story-cat-pollution  { background: rgba(92, 107, 117, 0.16);  color: #4d5b64; }
.story-cat-region     { background: rgba(14, 90, 109, 0.14);   color: #0e5a6d; }
[data-theme="dark"] .story-cat-air        { color: #6fc4dc; }
[data-theme="dark"] .story-cat-climate    { color: #f09b5c; }
[data-theme="dark"] .story-cat-water      { color: #7ba7e8; }
[data-theme="dark"] .story-cat-plastic    { color: #e08ab4; }
[data-theme="dark"] .story-cat-wildlife   { color: #9cc97f; }
[data-theme="dark"] .story-cat-forests    { color: #7bbf9e; }
[data-theme="dark"] .story-cat-disasters  { color: #e88a7d; }
[data-theme="dark"] .story-cat-energy     { color: #dcb45c; }
[data-theme="dark"] .story-cat-policy     { color: #b79ae0; }
[data-theme="dark"] .story-cat-pollution  { color: #a3b2bc; }
[data-theme="dark"] .story-cat-region     { color: #6fc4dc; }

/* --- Role badges: owner gold, queen violet -------------------------------- */
.role-owner { background: #f7ecd3; color: #8a6410; }
.role-queen { background: #efe6f8; color: #6b3fa0; }
[data-theme="dark"] .role-owner { background: #3a2f14; color: #e8c56a; }
[data-theme="dark"] .role-queen { background: #2d1f42; color: #c9a7f0; }

/* --- Owner-only leadership roster ------------------------------------------ */
.admin-roster { border-color: var(--brand); }
.admin-roster .card-title {
  display: flex; align-items: center; gap: 7px;
  color: var(--brand); margin-bottom: 2px;
}
.admin-roster-head { margin-bottom: 14px; }
.admin-roster-head p { margin: 0; }
@keyframes roster-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.roster-reveal { animation: roster-in 0.35s ease; }

/* --- Small refinements ------------------------------------------------------ */
/* Keyboard focus is clearly visible on interactive chips/rows everywhere. */
.ranking-tab:focus-visible, .news-filter:focus-visible, .rank-row:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
/* Leaflet attribution strip follows the theme instead of glowing white. */
[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(18, 27, 33, 0.85); color: var(--muted);
}
[data-theme="dark"] .leaflet-control-attribution a { color: var(--brand); }
[data-theme="dark"] .leaflet-bar a {
  background: var(--card); color: var(--ink); border-color: var(--line);
}
[data-theme="dark"] .leaflet-bar a:hover { background: var(--bg); }
[data-theme="dark"] .leaflet-bar a.leaflet-disabled {
  background: var(--card); color: var(--line);
}

/* ==========================================================================
   v12: Uzbekistan problem-solving sections — storm & dust alerts, fire
   danger, trees / Yashil Makon, audience role switcher
   ========================================================================== */

/* --- Audience role switcher (Public / Farmer / Expert) -------------------- */
.role-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.role-head .card-title { margin-bottom: 0; }
.role-switch {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden; flex-shrink: 0;
}
.role-btn {
  padding: 7px 14px; border: none; background: var(--card); color: var(--muted);
  font: 600 12.5px "Public Sans", system-ui, sans-serif; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.role-btn + .role-btn { border-left: 1px solid var(--line); }
.role-btn:hover { color: var(--ink); }
.role-btn.active { background: var(--brand); color: #fff; }
.role-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.advice-list { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.advice-list li { line-height: 1.5; }
.advice-list li::marker { color: var(--brand); }

/* --- Risk tier chips (storms + shared) ------------------------------------- */
.risk-red { background: var(--aqi-unhealthy); }
.risk-orange { background: var(--aqi-usg); }
.risk-yellow { background: var(--aqi-moderate); }
.risk-green { background: var(--aqi-good); }

.storm-level { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-weight: 500; }
.storm-table td { white-space: nowrap; }
.storm-table td:first-child a { font-weight: 600; }
.storm-signals { display: flex; gap: 6px; flex-wrap: wrap; }
.signal-tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  background: rgba(232, 99, 10, 0.15); color: var(--accent);
}
.signal-tag.signal-dust { background: rgba(184, 134, 11, 0.16); color: var(--aqi-moderate); }
[data-theme="dark"] .signal-tag { color: #f09b5c; }
[data-theme="dark"] .signal-tag.signal-dust { color: #dcb45c; }

/* --- Fire danger grid (wildfires page) ------------------------------------- */
.fire-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px; margin: 12px 0 14px;
}
.fire-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; text-decoration: none;
  transition: transform 0.15s ease-out, border-color 0.15s ease-out;
}
.fire-chip:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--brand); }
.fire-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fire-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fire-chip strong { font-family: "Archivo", sans-serif; }
/* Tier is carried by a translucent tint of the semantic colour (same
   device as the news category chips) plus the coloured index value -
   readable on both themes without decorative border stripes. */
.fire-red { background: rgba(192, 57, 43, 0.13); }
.fire-red strong { color: var(--aqi-unhealthy); }
.fire-orange { background: rgba(210, 105, 30, 0.13); }
.fire-orange strong { color: var(--aqi-usg); }
.fire-yellow { background: rgba(184, 134, 11, 0.13); }
.fire-yellow strong { color: var(--aqi-moderate); }
.fire-green { background: rgba(61, 139, 72, 0.13); }
.fire-green strong { color: var(--aqi-good); }
[data-theme="dark"] .fire-red strong { color: #e88a7d; }
[data-theme="dark"] .fire-orange strong { color: #f09b5c; }
[data-theme="dark"] .fire-yellow strong { color: #dcb45c; }
[data-theme="dark"] .fire-green strong { color: #9cc97f; }

/* --- Trees / Yashil Makon --------------------------------------------------- */
.community-counter { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.community-total {
  font: 700 40px "Archivo", sans-serif; letter-spacing: -0.03em;
  color: var(--brand);
}
.pledge-form label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.pledge-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pledge-row input[type="number"] {
  width: 110px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: 400 15px "Public Sans", sans-serif; background: var(--card); color: var(--ink);
}
.pledge-row select {
  flex: 1; min-width: 150px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font: 400 14px "Public Sans", sans-serif;
  background: var(--card); color: var(--ink);
}
.pledge-row input:focus, .pledge-row select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.pledge-form .muted.small { margin-top: 8px; }
.pledge-feed { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 8px; }
.pledge-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 0;
  border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.pledge-item:last-child { border-bottom: none; }
.pledge-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: rgba(61, 139, 72, 0.15); color: var(--aqi-good);
}
[data-theme="dark"] .pledge-icon { color: #9cc97f; }
.pledge-text { flex: 1; min-width: 0; }

.tree-calc { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.tree-calc input[type="number"] {
  width: 140px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: 600 17px "Archivo", sans-serif; background: var(--card); color: var(--ink);
}
.tree-calc input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.tree-calc-results { display: flex; gap: 24px; flex-wrap: wrap; }
.tree-calc-results strong {
  display: block; font: 700 26px "Archivo", sans-serif; letter-spacing: -0.02em;
  color: var(--brand);
}

/* --- v12 polish pass --------------------------------------------------------- */
/* Region context under a stat value (storms page): its own quiet line
   instead of wrapping raggedly inside the number. */
.stat-context {
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  margin-top: -2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

/* Card-shaped links get the same visible keyboard focus as buttons. */
.news-card:focus-visible, .region-card:focus-visible, .storm-card:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* Comfortable touch targets for the audience switcher on touch devices:
   the segmented control becomes a full-width row of >=44px buttons. */
@media (max-width: 760px) {
  .role-switch { display: flex; width: 100%; }
  .role-btn { flex: 1; min-height: 44px; padding: 10px 12px; font-size: 13px; text-align: center; }
}

/* Reduced motion: every v11/v12 animation gets an instant alternative. */
@media (prefers-reduced-motion: reduce) {
  .roster-reveal { animation: none; }
  .rank-bar i { transition: none; }
  .fire-chip, .news-card, .region-card, .rank-chevron, .day-chevron { transition: none; }
  .fire-chip:hover, .news-card:hover, .region-card:hover { transform: none; }
  .rank-skeleton-row, .skeleton-block { animation: none; }
}
