/* =====================================================================
   Lao River & Reservoir — Glass-morphism Dark Dashboard
   Phase 1: Shared shell (command bar, ticker, view switcher, tab pills)
   ===================================================================== */

:root {
  /* --- Dark glass palette --- */
  --bg-deep:        #060d1c;
  --bg-base:        #0a1628;
  --bg-panel:       #0f1c33;
  --bg-elevated:    #14233f;

  --glass-bg:       rgba(15, 28, 51, 0.55);
  --glass-bg-strong:rgba(15, 28, 51, 0.78);
  --glass-border:   rgba(255, 255, 255, 0.08);
  --glass-border-2: rgba(255, 255, 255, 0.14);
  --glass-inner:    rgba(255, 255, 255, 0.06);

  --text-hi:        #f1f5fb;
  --text:           #d6dde9;
  --text-mid:       #93a1b8;
  --text-dim:       #6b7a93;

  --accent:         #3b82f6;
  --accent-soft:    #60a5fa;
  --accent-glow:    rgba(59, 130, 246, 0.45);
  --good:           #34d399;
  --good-glow:      rgba(52, 211, 153, 0.45);
  --warn:           #fbbf24;
  --danger:         #ef4444;

  --radius-lg:      20px;
  --radius-md:      14px;
  --radius-sm:      10px;
  --radius-pill:    999px;

  --blur:           blur(24px) saturate(1.4);
  --shadow-glass:   0 10px 40px rgba(0, 0, 0, 0.45),
                    inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --font-sans:      'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono:      'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.flow-page {
  /* Gradient veil — top glow + bottom depth */
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(59,130,246,0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(16,185,129,0.10), transparent 60%),
    linear-gradient(180deg, #060d1c 0%, #0a1628 50%, #060d1c 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { color: #93c5fd; }

/* =====================================================================
   COMMAND BAR — Floating glass pill at top
   ===================================================================== */

.cmd-bar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glass);
  min-height: 56px;
}

.cmd-logos {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cmd-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  padding: 4px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.cmd-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
  flex: 1 1 auto;
}
.cmd-title .t1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-hi);
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-title .t2 {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* View switcher pill (Map / RoleMap) */
.view-switcher {
  display: inline-flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  flex-shrink: 0;
}
.view-switcher button {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.3px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.18s ease;
}
.view-switcher button.on {
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.view-switcher button:hover:not(.on) { color: var(--text-hi); }

/* LIVE clock */
.live-clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(52,211,153,0.10);
  border: 1px solid rgba(52,211,153,0.30);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--good);
  flex-shrink: 0;
}
.live-clock .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good-glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.85); }
}
.live-clock .label { letter-spacing: 1.4px; }
.live-clock .time { color: var(--text-hi); }

/* OneMekong back link in command bar */
.cmd-back {
  font-size: 11px;
  color: var(--text-mid);
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  transition: all 0.18s ease;
  flex-shrink: 0;
}
.cmd-back:hover {
  color: var(--text-hi);
  border-color: var(--glass-border-2);
  background: rgba(255,255,255,0.04);
}

/* =====================================================================
   EVENT TICKER — Stock-ticker style streaming bar
   ===================================================================== */

.ticker {
  position: fixed;
  top: 84px;
  left: 16px;
  right: 16px;
  z-index: 999;
  height: 34px;
  background: rgba(10, 22, 40, 0.65);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  display: flex;
  align-items: center;
}
.ticker-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  background: linear-gradient(90deg, rgba(59,130,246,0.20), rgba(59,130,246,0));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--accent-soft);
  flex-shrink: 0;
  border-right: 1px solid var(--glass-border);
}
/* Viewport clips the scrolling track so translated items NEVER bleed under
   the fixed left label. Without this, translateX moves items into the
   label's area because the pill's overflow:hidden clips only at the outer
   edge, not at the label/track boundary. */
.ticker-viewport {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  position: relative;
}
/* Soft fade-in on the left edge so items don't pop into view abruptly. */
.ticker-viewport::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 24px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(10,22,40,0.95), rgba(10,22,40,0));
  z-index: 2;
}
.ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: ticker-scroll 90s linear infinite;
  will-change: transform;
}
.ticker-track:hover { animation-play-state: paused; }
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 32px;
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
}
.ticker-item .tk-name { color: var(--text-mid); }
.ticker-item .tk-val  { color: var(--text-hi); }
.ticker-item .tk-up   { color: var(--good); }
.ticker-item .tk-down { color: var(--danger); }
.ticker-item .tk-warn { color: var(--warn); }
.ticker-item .tk-danger { color: #fca5a5; }
.ticker-item .tk-tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-right: 4px;
}
.ticker-item .tk-tag.dam      { background: rgba(59,130,246,0.18);  color: #93c5fd; }
.ticker-item .tk-tag.mrc      { background: rgba(45,212,191,0.18);  color: #5eead4; }
.ticker-item .tk-tag.storm    { background: rgba(168,85,247,0.18);  color: #d8b4fe; }
.ticker-item .tk-tag.rain     { background: rgba(56,189,248,0.18);  color: #7dd3fc; }
.ticker-item .tk-tag.flood    { background: rgba(239,68,68,0.18);   color: #fca5a5; }
.ticker-item .tk-tag.cascade,
.ticker-item .tk-tag.hydropower { background: rgba(250,204,21,0.18);  color: #fde68a; }
.ticker-item .tk-tag.flash    { background: rgba(249,115,22,0.18);  color: #fdba74; }
@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* =====================================================================
   PAGE SHELL — shift content below command bar + ticker
   ===================================================================== */

.flow-shell {
  padding-top: 138px;   /* 16 + 56 + 12 (gap) + 34 + 20 (gap) */
  padding-bottom: 120px;/* room for floating tab pills */
  min-height: 100vh;
}

/* Hide legacy topbar — we replaced it with the command bar */
.topbar { display: none !important; }

/* =====================================================================
   FLOATING TAB PILLS (bottom center) — Map | RoleMap
   ===================================================================== */

.tab-pills {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glass);
}
.tab-pills button {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.4px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s ease;
}
.tab-pills button.on {
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.tab-pills button:hover:not(.on) { color: var(--text-hi); }
.tab-pills .pill-icon { width: 14px; height: 14px; }

/* =====================================================================
   VIEW CONTAINERS — Map view + RoleMap view (mutually visible)
   ===================================================================== */

.view { display: none; }
.view.active { display: block; }

/* =====================================================================
   ROLEMAP — Live Operations Cinema (Frame 1)
   ===================================================================== */

.rolemap-shell {
  max-width: 1200px;
  margin: 24px auto 100px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Header ---------- */
.rm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 24px 28px 22px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}
.rm-h-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rm-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: 1.6px;
  color: var(--accent-soft); text-transform: uppercase;
}
.rm-title {
  margin: 0;
  font-size: 26px; font-weight: 700; letter-spacing: -0.4px;
  color: var(--text-hi);
}
.rm-sub {
  margin: 0;
  color: var(--text-mid); font-size: 13px;
}
.rm-h-right { flex: 0 0 auto; }
.rm-state {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(52,211,153,0.10);
  border: 1px solid rgba(52,211,153,0.30);
  color: var(--good);
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px;
  transition: background .25s ease, border-color .25s ease, color .25s ease;
}
.rm-state .rm-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
}
.rm-state.is-watch    { background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.40); color: #fbbf24; }
.rm-state.is-pre      { background: rgba(251,146,60,0.14); border-color: rgba(251,146,60,0.45); color: #fb923c; }
.rm-state.is-critical { background: rgba(239,68,68,0.18);  border-color: rgba(239,68,68,0.55);  color: #ef4444; }
.rm-state.is-critical .rm-dot { animation: rmStatePulse 1.6s ease-in-out infinite; }
@keyframes rmStatePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.55); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* ---------- Alert slot ---------- */
.rm-alert-slot { display: flex; flex-direction: column; gap: 14px; }
.rm-alert-slot:empty { display: none; }

.rm-alert {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 22px 26px;
  background: linear-gradient(135deg, rgba(60,12,18,0.92), rgba(40,8,14,0.88));
  border: 1.5px solid rgba(239,68,68,0.85);
  border-radius: var(--radius-lg);
  box-shadow:
    0 18px 50px rgba(239,68,68,0.18),
    0 4px 16px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.05);
  animation: rmAlertSlide .55s cubic-bezier(.2,.9,.25,1.1);
  overflow: hidden;
}
@keyframes rmAlertSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.rm-alert::before {
  /* Background glow */
  content: "";
  position: absolute; inset: -40px;
  background: radial-gradient(circle at 30% 50%, rgba(239,68,68,0.25), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
.rm-alert > * { position: relative; z-index: 1; }

.rm-alert-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fca5a5, #ef4444 60%, #991b1b);
  display: grid; place-items: center;
  box-shadow: 0 0 0 4px rgba(239,68,68,0.20), 0 0 24px rgba(239,68,68,0.55);
  animation: rmIconPulse 1.4s ease-in-out infinite;
}
@keyframes rmIconPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(239,68,68,0.20), 0 0 24px rgba(239,68,68,0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(239,68,68,0.05), 0 0 36px rgba(239,68,68,0.75); }
}
.rm-alert-icon svg { width: 24px; height: 24px; color: #fff; }

.rm-alert-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rm-alert-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: 2px;
  color: #fecaca;
}
.rm-alert-tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: #ef4444;
  box-shadow: 0 0 8px rgba(239,68,68,0.9);
}
.rm-alert-name {
  margin: 0;
  font-size: 22px; font-weight: 700; letter-spacing: -0.3px;
  color: #fff;
}
.rm-alert-meta {
  display: flex; flex-wrap: wrap; gap: 18px 24px;
  font-size: 12px;
  color: #fecaca;
}
.rm-alert-meta .rm-mk { color: rgba(254,202,202,0.65); margin-right: 6px; font-weight: 500; }
.rm-alert-meta .rm-mv { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.rm-alert-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 180px; }
.rm-alert-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.rm-alert-btn:hover { background: rgba(255,255,255,0.18); }
.rm-alert-btn.primary {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  border-color: rgba(239,68,68,0.8);
  box-shadow: 0 6px 18px rgba(239,68,68,0.35);
}
.rm-alert-btn.primary:hover { transform: translateY(-1px); }
.rm-alert-btn.disabled {
  opacity: 0.55; cursor: not-allowed;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
}
.rm-alert-btn .rm-soon {
  font-size: 9px; font-weight: 800; letter-spacing: 1.4px;
  color: rgba(255,255,255,0.7);
  padding: 2px 6px;
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
}

/* ---------- Empty state (no critical dams) ---------- */
.rm-allclear {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px;
  background: linear-gradient(135deg, rgba(52,211,153,0.10), rgba(52,211,153,0.04));
  border: 1px solid rgba(52,211,153,0.30);
  border-radius: var(--radius-lg);
}
.rm-allclear .rm-ac-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6ee7b7, #34d399 70%);
  display: grid; place-items: center;
  box-shadow: 0 0 0 3px rgba(52,211,153,0.15);
}
.rm-allclear .rm-ac-icon svg { width: 20px; height: 20px; color: #052e22; }
.rm-allclear .rm-ac-text strong { color: var(--text-hi); font-size: 14px; }
.rm-allclear .rm-ac-text p { margin: 2px 0 0; color: var(--text-mid); font-size: 12px; }

/* ---------- Cascade strip ---------- */
.rm-cascade {
  padding: 20px 22px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}
.rm-cascade-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 14px;
}
.rm-cascade-head h3 {
  margin: 0; font-size: 15px; font-weight: 700; color: var(--text-hi);
  letter-spacing: -0.1px;
}
.rm-cascade-meta { font-size: 11px; color: var(--text-mid); font-family: var(--font-mono); }

.rm-tier-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.rm-tier-cell {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
}
.rm-tier-cell .rm-tc-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase;
}
.rm-tier-cell .rm-tc-count {
  font-size: 22px; font-weight: 700; color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.rm-tier-cell.tier-critical   { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.40); }
.rm-tier-cell.tier-critical   .rm-tc-label { color: #ef4444; }
.rm-tier-cell.tier-prerelease { background: rgba(251,146,60,0.10); border-color: rgba(251,146,60,0.35); }
.rm-tier-cell.tier-prerelease .rm-tc-label { color: #fb923c; }
.rm-tier-cell.tier-watch      { background: rgba(251,191,36,0.10); border-color: rgba(251,191,36,0.35); }
.rm-tier-cell.tier-watch      .rm-tc-label { color: #fbbf24; }
.rm-tier-cell.tier-normal     { background: rgba(45,212,191,0.08); border-color: rgba(45,212,191,0.28); }
.rm-tier-cell.tier-normal     .rm-tc-label { color: #2dd4bf; }

.rm-cascade-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.rm-cascade-list:empty::before {
  content: "Computing pre-release model…";
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-mid);
  font-size: 12px;
  padding: 24px 0;
}
.rm-dam-chip {
  position: relative;
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px 10px 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
  overflow: hidden;
}
.rm-dam-chip:hover { background: rgba(255,255,255,0.07); transform: translateY(-1px); }
.rm-dam-chip .rm-bar { align-self: stretch; background: var(--tier-color, #2dd4bf); }
.rm-dam-chip .rm-dam-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rm-dam-chip .rm-dam-name {
  font-size: 12px; font-weight: 600; color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rm-dam-chip .rm-dam-sub {
  font-size: 10px; color: var(--text-mid);
  font-family: var(--font-mono);
}
.rm-dam-chip .rm-dam-ratio {
  font-size: 11px; font-weight: 700;
  color: var(--tier-color, #2dd4bf);
  font-family: var(--font-mono);
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}
.rm-dam-chip.tier-critical { border-color: rgba(239,68,68,0.55); background: rgba(239,68,68,0.10); }
.rm-dam-chip.tier-critical .rm-dam-ratio { color: #fca5a5; background: rgba(239,68,68,0.20); }
.rm-dam-chip.tier-critical::after {
  /* subtle pulse halo on critical chips */
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.5);
  animation: rmChipPulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes rmChipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
.rm-dam-chip.tier-prerelease { border-color: rgba(251,146,60,0.45); }
.rm-dam-chip.tier-watch      { border-color: rgba(251,191,36,0.40); }

/* ---------- Next-frame teaser ---------- */
.rm-next {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--glass-border-2);
  border-radius: var(--radius-md);
}
.rm-next-text { font-size: 13px; color: var(--text-mid); }
.rm-next-text strong { color: var(--text-hi); margin-right: 6px; }
.rm-next-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 1.6px;
  color: var(--accent-soft);
  background: rgba(59,130,246,0.10);
  border: 1px solid rgba(59,130,246,0.30);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .rm-alert, .rm-alert-icon, .rm-state.is-critical .rm-dot, .rm-dam-chip.tier-critical::after {
    animation: none !important;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .rm-header { flex-direction: column; align-items: flex-start; }
  .rm-alert { grid-template-columns: auto 1fr; }
  .rm-alert-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .rm-alert-actions .rm-alert-btn { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .rm-tier-strip { grid-template-columns: repeat(2, 1fr); }
  .rm-cascade-list { grid-template-columns: 1fr 1fr; }
}

/* =====================================================================
   LEGACY DASHBOARD — Phase 2/3 will rewrite. For Phase 1, keep
   the old layout working but darkened so it looks coherent.
   ===================================================================== */

/* The [hidden] override is required because `.summary-bar { display: grid }`
   below would otherwise win against the browser's default [hidden] rule. */
.summary-bar[hidden] { display: none !important; }
.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 0 16px 16px;
  padding: 14px 18px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}
.sb-cell { display: flex; flex-direction: column; gap: 2px; }
.sb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-mid);
}
.sb-cell strong {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.sb-sub { font-size: 11px; color: var(--text-dim); }
.sb-sub a { color: var(--accent-soft); }

/* Compact icon-only toggle, pinned to the right edge. */
.summary-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin: 0 16px 8px;
}
.summary-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-mid);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.summary-toggle:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
  color: var(--text-hi);
}
.summary-toggle .st-chev { font-size: 9px; opacity: 0.7; transition: transform 160ms ease; }
.summary-toggle[aria-expanded="true"] .st-chev { transform: rotate(180deg); }

/* Risk-tinted KPI cells: tone via data-tone attribute. */
.sb-cell-risk { position: relative; padding-left: 10px; }
.sb-cell-risk::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px; border-radius: 2px;
  background: rgba(140,160,200,0.35);
  transition: background 200ms ease;
}
.sb-cell-risk[data-tone="ok"]::before      { background: #22c55e; }
.sb-cell-risk[data-tone="watch"]::before   { background: #fbbf24; }
.sb-cell-risk[data-tone="alarm"]::before   { background: #f97316; }
.sb-cell-risk[data-tone="danger"]::before  { background: #ef4444; }
.sb-cell-risk[data-tone="ok"] strong       { color: #6ee7a0; }
.sb-cell-risk[data-tone="watch"] strong    { color: #fcd34d; }
.sb-cell-risk[data-tone="alarm"] strong    { color: #fb923c; }
.sb-cell-risk[data-tone="danger"] strong   { color: #fca5a5; }

.flow-main {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 16px;
  padding: 0 16px;
  min-height: calc(100vh - 320px);
}

.flow-side, .flow-right {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

.flow-center {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.side-head h3 { margin: 0; font-size: 13px; font-weight: 700; color: var(--text-hi); letter-spacing: 0.2px; text-transform: uppercase; }

.side-filters { display: inline-flex; gap: 4px; }
.chip {
  appearance: none;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-mid);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text-hi); border-color: var(--glass-border-2); }
.chip-on, .chip.chip-on {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.45);
  color: var(--accent-soft);
}

.side-search {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-hi);
  font-family: var(--font-sans);
}
.side-search::placeholder { color: var(--text-dim); }
.side-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.dam-list { display: flex; flex-direction: column; gap: 6px; }
.dam-row {
  padding: 9px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.dam-row:hover { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.30); }
.dam-row.active { background: rgba(59,130,246,0.18); border-color: rgba(59,130,246,0.50); }
.dam-row .dr-name { font-size: 13px; font-weight: 600; color: var(--text-hi); }
.dam-row .dr-sub  { font-size: 11px; color: var(--text-mid); font-family: var(--font-mono); }

.map-wrap {
  position: relative;
  height: 640px;
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-glass);
}
#map { width: 100%; height: 100%; }

/* Map tools (top-right of map): search + basemap switcher */
.map-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.map-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 10px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glass);
  width: 260px;
  min-width: 220px;
}
.map-search .ms-icon { color: var(--text-mid); flex-shrink: 0; width: 16px; height: 16px; display: block; }
.map-search input {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-hi);
  font-family: var(--font-sans);
  font-size: 13px;
  width: 100%;
  outline: none;
}
.map-search input::placeholder { color: var(--text-dim); }
.map-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow: auto;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glass);
  padding: 4px;
}
.msr-group {
  padding: 6px 10px 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--text-dim);
}
.msr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
}
.msr-row:hover { background: rgba(59,130,246,0.14); }
.msr-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.msr-name { font-size: 13px; color: var(--text-hi); font-weight: 600; }
.msr-sub  { font-size: 11px; color: var(--text-mid); font-family: var(--font-mono); }
.msr-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--text-dim); }

.basemap-pill {
  display: inline-flex;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-pill);
  padding: 3px;
  box-shadow: var(--shadow-glass);
}
.basemap-pill button {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-mid);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.4px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}
.basemap-pill button.on {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  box-shadow: 0 3px 12px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.basemap-pill button:hover:not(.on) { color: var(--text-hi); }

/* =====================================================================
   MAP MARKERS — original PNG icons (dams + MRC stations)
   ===================================================================== */
/* Wrapper holds icon + side label; anchored at lng/lat from the left,
   so the icon sits exactly on the river and label extends to the right. */
.map-marker-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  pointer-events: auto;
}

/* Dam icons (PNG, no CSS background) */
.map-marker {
  position: relative;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 0;
  flex-shrink: 0;
  transition: transform 0.15s;
  box-sizing: border-box;
  display: block;
}
.map-marker-wrap:hover .map-marker { transform: scale(1.15); }

/* Dark pill label with status-tinted glow border */
.map-marker-label {
  font-size: 10px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding: 2px 6px;
  background: rgba(10, 16, 21, 0.82);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  pointer-events: none;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.map-marker-wrap:hover .map-marker-label { background: rgba(10, 16, 21, 0.95); }

/* Status-tinted glow ring around each dam label */
.map-marker-wrap.mms-low           .map-marker-label { border-color: rgba(56,189,248,0.55);  box-shadow: 0 0 6px rgba(56,189,248,0.35); }
.map-marker-wrap.mms-rising        .map-marker-label { border-color: rgba(34,211,238,0.55);  box-shadow: 0 0 6px rgba(34,211,238,0.35); }
.map-marker-wrap.mms-normal        .map-marker-label { border-color: rgba(52,211,153,0.55);  box-shadow: 0 0 6px rgba(52,211,153,0.35); }
.map-marker-wrap.mms-watch         .map-marker-label { border-color: rgba(251,191,36,0.6);   box-shadow: 0 0 6px rgba(251,191,36,0.4);  }
.map-marker-wrap.mms-high          .map-marker-label { border-color: rgba(249,115,22,0.65);  box-shadow: 0 0 7px rgba(249,115,22,0.45); }
.map-marker-wrap.mms-critical_high .map-marker-label { border-color: rgba(239,68,68,0.7);    box-shadow: 0 0 8px rgba(239,68,68,0.5);   }
.map-marker-wrap.mms-no_data       .map-marker-label { border-color: rgba(255,255,255,0.45); box-shadow: 0 0 5px rgba(255,255,255,0.25); }

/* Heat-ramp dot colors — icon PNG carries the visual */
.mm-storage-low,
.mm-storage-rising,
.mm-storage-normal,
.mm-storage-watch,
.mm-storage-high,
.mm-storage-critical_high,
.mm-storage-no_data { background: none; }

/* Operator-alert small indicator on the dot's top-right */
.map-marker-alert {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(10,16,21,0.95);
}
.mma-dot-evacuate { background: #b91c1c; box-shadow: 0 0 5px rgba(185,28,28,0.9); animation: mma-pulse 1.4s ease-in-out infinite; }
.mma-dot-warning  { background: #f59e0b; box-shadow: 0 0 4px rgba(245,158,11,0.7); }
.mma-dot-watch    { background: #fbbf24; }
@keyframes mma-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185,28,28,0.65); }
  50%      { box-shadow: 0 0 0 4px rgba(185,28,28,0); }
}

/* Active dam: brighter accent ring + label */
.map-marker-wrap.mm-active .map-marker {
  box-shadow: 0 0 0 3px rgba(59,130,246,0.55), 0 0 14px rgba(59,130,246,0.8);
  border-radius: 50%;
}
.map-marker-wrap.mm-active .map-marker-label {
  background: rgba(59,130,246,0.22);
  color: #fff;
  font-weight: 700;
  border-color: rgba(59,130,246,0.75);
  box-shadow: 0 0 8px rgba(59,130,246,0.55);
}

/* MRC station markers */
.mrc-marker { width: 24px; height: 24px; }
.map-marker-wrap.mrc-wrap:hover .mrc-marker { transform: scale(1.2); }
.map-marker-wrap.mrc-normal .mrc-label { border-color: rgba(47,138,62,0.55);  box-shadow: 0 0 6px rgba(47,138,62,0.4); }
.map-marker-wrap.mrc-alarm  .mrc-label { border-color: rgba(232,169,58,0.6);  box-shadow: 0 0 6px rgba(232,169,58,0.4); }
.map-marker-wrap.mrc-flood  .mrc-label { border-color: rgba(196,48,43,0.7);   box-shadow: 0 0 8px rgba(196,48,43,0.5); }
.map-marker-wrap.mrc-na     .mrc-label { border-color: rgba(107,110,116,0.5); box-shadow: 0 0 5px rgba(107,110,116,0.3); }
.map-marker-wrap.mrc-china  .mrc-label { border-color: rgba(31,78,168,0.6);   box-shadow: 0 0 6px rgba(31,78,168,0.4); }

/* MRC pill colors (used by station detail panel) */
.mrc-pill-normal { background:#2f8a3e; color:#fff; }
.mrc-pill-alarm  { background:#e8a93a; color:#3a2a00; }
.mrc-pill-flood  { background:#c4302b; color:#fff; }
.mrc-pill-na     { background:#6b6e74; color:#fff; }
.mrc-pill-china  { background:#1f4ea8; color:#fff; }

/* MapLibre controls styled for dark theme */
.maplibregl-ctrl-group {
  background: var(--glass-bg-strong) !important;
  -webkit-backdrop-filter: var(--blur) !important;
  backdrop-filter: var(--blur) !important;
  border: 1px solid var(--glass-border-2) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-glass) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button {
  background: transparent !important;
  border: none !important;
  width: 32px !important;
  height: 32px !important;
}
.maplibregl-ctrl-group button:hover { background: rgba(255,255,255,0.08) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--glass-border) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(0.9) brightness(1.3);
}

.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  max-width: 280px;
  font-size: 11px;
  color: var(--text);
}
.lg-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lg-header strong { font-size: 11px; color: var(--text-hi); letter-spacing: 0.6px; text-transform: uppercase; }
.lg-header-actions { display: inline-flex; gap: 6px; }
.lg-toggle, .lg-reset {
  appearance: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-mid);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.lg-toggle:hover, .lg-reset:hover { color: var(--text-hi); }
.lg-body { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.lg-body strong { font-size: 10px; color: var(--text-mid); letter-spacing: 0.4px; }
.lg-filter {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  cursor: pointer;
  text-align: left;
}
.lg-filter[aria-pressed="false"] { opacity: 0.35; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-storage-low      { background: #ef4444; }
.lg-storage-rising   { background: #f59e0b; }
.lg-storage-normal   { background: #34d399; }
.lg-storage-watch    { background: #fbbf24; }
.lg-storage-high     { background: #f97316; }
.lg-storage-critical { background: #dc2626; }
.lg-storage-none     { background: #6b7a93; }
.lg-mrc-normal { background: #34d399; }
.lg-mrc-alarm  { background: #fbbf24; }
.lg-mrc-flood  { background: #ef4444; }
.lg-mrc-na     { background: #6b7a93; }
.lg-mrc-china  { background: #a78bfa; }
.lg-line { display: inline-block; width: 18px; height: 3px; border-radius: 2px; }
.lg-mekong    { background: #3b82f6; }
.lg-tributary { background: #60a5fa; opacity: 0.6; }

/* Storm forecast legend swatches */
.lg-glyph {
  display: inline-block; width: 18px; height: 14px; line-height: 14px;
  font-size: 14px; text-align: center; vertical-align: middle;
  filter: drop-shadow(0 0 2px rgba(220,38,38,0.5));
}
.lg-storm-track {
  background: repeating-linear-gradient(
    to right,
    #f97316 0px, #f97316 5px,
    transparent 5px, transparent 8px
  );
  background-color: transparent;
}
.lg-ring {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #f97316; background: transparent;
  vertical-align: middle;
}
.lg-swatch {
  display: inline-block; width: 18px; height: 10px; border-radius: 2px;
  background: rgba(138,117,96,0.45);
  border: 1px dashed rgba(255,255,255,0.4);
}

/* Dam header + KPIs */
.dam-header, .station-detail {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dam-header { flex-direction: row; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.dh-left h2, .sd-left h2 { margin: 4px 0 2px; font-size: 20px; color: var(--text-hi); font-weight: 700; letter-spacing: -0.2px; }
.dh-eyebrow, .sd-eyebrow { font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-mid); font-weight: 700; }
.dh-sub, .sd-sub { font-size: 12px; color: var(--text-mid); }

.dh-right { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 110px;
}
.kpi-l { font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-mid); }
.kpi strong { font-size: 16px; color: var(--text-hi); font-variant-numeric: tabular-nums; font-weight: 700; }
.kpi.small strong { font-size: 14px; }

.sd-top { display: flex; justify-content: space-between; align-items: flex-start; }
.sd-status-pill {
  display: inline-block; margin-left: 6px;
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(52,211,153,0.15); color: var(--good);
  border: 1px solid rgba(52,211,153,0.30);
}
.sd-close {
  appearance: none; background: transparent; border: none;
  color: var(--text-mid); font-size: 24px; cursor: pointer; line-height: 1;
}
.sd-close:hover { color: var(--text-hi); }
.sd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sd-rain { padding-top: 4px; }
.sd-rain-label { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-mid); margin-bottom: 6px; }
.sd-rain-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.sd-chart-wrap { height: 200px; margin-top: 6px; }
.sd-footer { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-dim); }

/* Charts grid */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 14px 16px;
}
.chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.chart-head h4 { margin: 0; font-size: 12px; color: var(--text-hi); letter-spacing: 0.4px; text-transform: uppercase; font-weight: 700; }
.chart-meta { font-size: 11px; color: var(--text-mid); font-family: var(--font-mono); }
.chart-body { height: 180px; }

/* Right rail panels */
.panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}
.panel h3 { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-hi); }
.panel-lede { margin: 0 0 12px; font-size: 11px; color: var(--text-mid); line-height: 1.55; }
.panel-foot { margin: 10px 0 0; font-size: 11px; color: var(--text-dim); }

.slider-row { margin-bottom: 12px; }
.slider-row label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-mid); margin-bottom: 4px; }
.slider-row label span { color: var(--text-hi); font-family: var(--font-mono); font-weight: 600; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.scenario-result { margin: 10px 0; }
.sr-row { display: flex; justify-content: space-between; font-size: 11px; padding: 4px 0; color: var(--text-mid); border-bottom: 1px solid var(--glass-border); }
.sr-row:last-child { border-bottom: none; }
.sr-row strong { color: var(--text-hi); font-family: var(--font-mono); }
.sr-flag strong { color: var(--good); }

.fresh-grid { display: flex; flex-direction: column; gap: 6px; }

.btn {
  appearance: none; cursor: pointer;
  font-family: var(--font-sans); font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-hi);
  padding: 8px 14px; font-size: 12px;
  transition: all 0.15s ease;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: var(--glass-border-2); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  border-color: rgba(59,130,246,0.50);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 11px; }

/* Submission section */
.submit-section { padding: 24px 16px; }
.submit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row label { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-mid); }
.form-row input, .form-row select, .form-row textarea {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--glass-border);
  color: var(--text-hi);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 13px;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.form-msg { font-size: 11px; color: var(--text-mid); }

.upload-zone {
  border: 2px dashed var(--glass-border-2);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  background: rgba(255,255,255,0.02);
  transition: all 0.18s ease;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: rgba(59,130,246,0.06); }
.upload-cue strong { display: block; color: var(--text-hi); font-size: 14px; margin-bottom: 4px; }
.upload-cue span  { color: var(--text-mid); font-size: 12px; }
.link-btn { background: none; border: none; color: var(--accent-soft); cursor: pointer; font: inherit; padding: 0; }
.upload-preview h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-hi); letter-spacing: 0.4px; text-transform: uppercase; }
.preview-table-wrap { max-height: 220px; overflow: auto; border: 1px solid var(--glass-border); border-radius: var(--radius-sm); }
#previewTable { width: 100%; font-size: 11px; border-collapse: collapse; }
#previewTable th, #previewTable td { padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--glass-border); color: var(--text); }
#previewTable th { background: rgba(255,255,255,0.04); color: var(--text-hi); font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase; }

/* Footer */
.foot {
  margin-top: 32px;
  padding: 18px 16px;
  border-top: 1px solid var(--glass-border);
  background: rgba(6,13,28,0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.foot-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--text-mid); }
.foot-inner strong { color: var(--text-hi); }
.foot-links { display: inline-flex; gap: 16px; }
.foot-links a { color: var(--text-mid); }
.foot-links a:hover { color: var(--text-hi); }
.foot-meta { color: var(--text-dim); font-family: var(--font-mono); }

/* MapLibre overrides for dark theme */
.maplibregl-popup-content {
  background: var(--glass-bg-strong) !important;
  color: var(--text-hi) !important;
  border: 1px solid var(--glass-border-2);
  border-radius: var(--radius-md);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-attrib { background: rgba(0,0,0,0.4) !important; color: var(--text-dim) !important; }
.maplibregl-ctrl-attrib a { color: var(--text-mid) !important; }

/* =====================================================================
   PDC hazard popup (Phase 3.6.1) — styled detail card with severity
   header, impact guidance, timeline, and metadata.
   ===================================================================== */
.pdc-popup-wrap .maplibregl-popup-content {
  padding: 0 !important;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08) !important;
  background: rgba(15,20,30,0.96) !important;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.4);
}
.pdc-popup-wrap .maplibregl-popup-close-button {
  color: #fff;
  opacity: 0.9;
  font-size: 20px;
  padding: 4px 10px;
  top: 4px;
  right: 4px;
  z-index: 5;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.pdc-popup { font-family: inherit; min-width: 280px; max-width: 340px; color: var(--text-hi); }
.pdc-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.pdc-header-icon { width: 32px; height: 32px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); flex-shrink: 0; }
.pdc-header-text { flex: 1; min-width: 0; line-height: 1.2; }
.pdc-sev   { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.95; }
.pdc-type  { font-size: 16px; font-weight: 600; margin-top: 2px; text-transform: capitalize; }
.pdc-body  { padding: 12px 14px 14px; }
.pdc-title {
  font-size: 14px; font-weight: 600; line-height: 1.35;
  margin-bottom: 10px;
  color: var(--text-hi);
}
.pdc-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.06); }
.pdc-impact  { margin-top: 0; padding: 10px 12px; background: rgba(255,255,255,0.04); border-radius: 6px; border-left: 3px solid rgba(255,255,255,0.15); }
.pdc-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 6px;
}
.pdc-impact-text { font-size: 12.5px; line-height: 1.5; color: var(--text-mid); }
.pdc-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; padding: 3px 0;
  gap: 8px;
}
.pdc-row-label { color: var(--text-dim); flex-shrink: 0; }
.pdc-row-val   { color: var(--text-hi); text-align: right; font-variant-numeric: tabular-nums; }
.pdc-row-rel   { display: block; color: var(--text-dim); font-size: 11px; margin-top: 1px; }
.pdc-meta      { font-family: var(--font-mono, monospace); }
.pdc-meta-row  {
  display: flex; justify-content: space-between;
  font-size: 11px; padding: 2px 0; color: var(--text-mid);
}
.pdc-meta-row span:first-child { color: var(--text-dim); }
.pdc-cta {
  display: block;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.35);
  border-radius: 6px;
  color: #93c5fd !important;
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.pdc-cta:hover { background: rgba(59,130,246,0.25); border-color: rgba(59,130,246,0.6); }
.pdc-source { margin-top: 10px; font-size: 10px; color: var(--text-dim); text-align: center; opacity: 0.7; }

/* =====================================================================
   RESPONSIVE — Phase 6 will refine. Basic fallback now.
   ===================================================================== */

@media (max-width: 1100px) {
  .flow-main { grid-template-columns: 1fr; }
  .flow-side, .flow-right { max-height: none; }
  .charts-grid { grid-template-columns: 1fr; }
  .submit-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .cmd-bar { padding: 8px 12px; gap: 10px; }
  .cmd-logo { width: 32px; height: 32px; }
  .cmd-title .t1 { font-size: 12px; }
  .cmd-title .t2 { display: none; }
  .cmd-back { display: none; }
  .ticker { left: 8px; right: 8px; }
  .summary-bar { grid-template-columns: repeat(2, 1fr); margin: 0 8px 12px; }
  .summary-toggle-row { margin: 0 8px 6px; }
  .summary-toggle { padding: 5px 8px; }
  .flow-main { padding: 0 8px; gap: 10px; }
  /* Taller default map on mobile so it doesn't feel cramped */
  .map-wrap { height: 540px; }

  /* Stack search above basemap pill so neither gets clipped at viewport edge */
  .map-tools {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    top: 8px; right: 8px;
    /* Reserve room for the hazard row at top-center */
    max-width: calc(100% - 100px);
  }
  .map-search { width: auto; min-width: 0; max-width: 200px; }
  .map-search input { font-size: 12px; }
  .basemap-pill { padding: 2px; }
  .basemap-pill button { padding: 5px 9px; font-size: 10px; }

  /* Compact legend toggle stays clickable; collapsed body by default */
  .map-legend { bottom: 8px; left: 8px; max-width: calc(100% - 16px); padding: 6px 10px; }
  .map-legend .lg-body { max-height: 40vh; overflow-y: auto; }
}

/* ===== Fullscreen mode: keep ALL map controls visible on mobile =====
   When user taps the fullscreen button, MapLibre puts .map-wrap into the
   browser's fullscreen layer and adds .maplibregl-pseudo-fullscreen /
   :fullscreen. We re-pin the hazard row, basemap pills, legend, etc. so
   the user keeps full filtering/layer control without exiting fullscreen. */
.map-wrap:fullscreen,
.map-wrap.maplibregl-pseudo-fullscreen {
  height: 100vh !important;
  width: 100vw !important;
  border-radius: 0;
  border: none;
  /* Prevent iOS Safari's swipe-down-to-dismiss gesture from accidentally
     exiting fullscreen. User must tap the explicit Exit button instead. */
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
.map-wrap:fullscreen #map,
.map-wrap.maplibregl-pseudo-fullscreen #map {
  height: 100% !important;
  width: 100% !important;
}
/* In fullscreen the hazard row should be safely below the iOS status bar /
   notch. env(safe-area-inset-top) handles iPhone notch; falls back to 12px. */
.map-wrap:fullscreen .hazard-row,
.map-wrap.maplibregl-pseudo-fullscreen .hazard-row {
  top: max(12px, env(safe-area-inset-top, 12px));
}
.map-wrap:fullscreen .map-tools,
.map-wrap.maplibregl-pseudo-fullscreen .map-tools {
  top: max(12px, env(safe-area-inset-top, 12px));
  right: 12px;
}
.map-wrap:fullscreen .map-legend,
.map-wrap.maplibregl-pseudo-fullscreen .map-legend {
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  left: max(12px, env(safe-area-inset-left, 12px));
  z-index: 3;
}
/* On phones, the hazard row's icon-only buttons + top-right tools may collide.
   Drop tools to second row below hazard row so both stay tappable. */
@media (max-width: 720px) {
  .map-wrap:fullscreen .map-tools,
  .map-wrap.maplibregl-pseudo-fullscreen .map-tools {
    /* hazard row is ~46px tall on mobile; sit beneath it */
    top: calc(max(8px, env(safe-area-inset-top, 8px)) + 52px);
    right: 8px;
  }
  .map-wrap:fullscreen .layer-panel,
  .map-wrap.maplibregl-pseudo-fullscreen .layer-panel {
    top: calc(max(8px, env(safe-area-inset-top, 8px)) + 52px);
  }
  /* Bottom controls: time scrubber + legend need to stack on tiny screens */
  .map-wrap:fullscreen .time-scrubber,
  .map-wrap.maplibregl-pseudo-fullscreen .time-scrubber {
    bottom: max(8px, env(safe-area-inset-bottom, 8px));
  }
}

/* Exit fullscreen button — hidden by default, shown only when the map-wrap
   is in (pseudo-)fullscreen. Pinned to the TOP-RIGHT corner above other tools
   so it's the most obvious tap target on mobile. */
.exit-fullscreen-btn {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 50;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(15, 22, 36, 0.92);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 120ms ease, transform 120ms ease;
}
.exit-fullscreen-btn:hover { background: rgba(30, 42, 64, 0.95); }
.exit-fullscreen-btn:active { transform: scale(0.97); }
.exit-fullscreen-btn svg { display: block; }

.map-wrap:fullscreen .exit-fullscreen-btn,
.map-wrap.maplibregl-pseudo-fullscreen .exit-fullscreen-btn {
  display: inline-flex;
  /* `top` + `right` are managed dynamically by layoutFullscreenTools() in flow.js
     so the button never collides with the hazard row, search, or basemap pill. */
}

/* Compact pill style at narrow widths */
@media (max-width: 720px) {
  .map-wrap:fullscreen .exit-fullscreen-btn,
  .map-wrap.maplibregl-pseudo-fullscreen .exit-fullscreen-btn {
    padding: 9px 13px;
    font-size: 13px;
  }
}

/* ============================================================
   FLASH FLOOD FORECAST — Right-rail panel (Phase 6)
   ============================================================ */
.ffgs-panel { display:flex; flex-direction:column; gap:10px; }
.ffgs-head { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.ffgs-head h3 { margin:0; }
.ffgs-refresh {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: #cfd6e4;
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items:center; justify-content:center;
  transition: all 120ms ease;
}
.ffgs-refresh:hover { background: rgba(255,255,255,0.10); color:#fff; }
.ffgs-refresh:disabled { opacity:0.4; cursor:wait; }

.ffgs-meta {
  display:flex; align-items:center; justify-content:space-between;
  font-size: 11px;
  color: #97a2b6;
}
.ffgs-source {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border-radius: 4px;
  border: 1px solid rgba(59,130,246,0.25);
  letter-spacing: 0.3px;
}
.ffgs-stamp { font-variant-numeric: tabular-nums; }

.ffgs-toggle {
  display:flex; align-items:center; gap:8px;
  font-size:12px; color:#cfd6e4;
  cursor:pointer;
  padding: 6px 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
}
.ffgs-toggle input { accent-color: #3b82f6; }

.ffgs-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #7a8499;
  margin-top: 2px;
}

.ffgs-horizon-row {
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.ffgs-horizon-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #97a2b6;
  font-size: 12px;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 100ms ease;
  font-weight: 500;
}
.ffgs-horizon-btn:hover { color: #cfd6e4; border-color: rgba(255,255,255,0.18); }
.ffgs-horizon-btn.on {
  background: linear-gradient(180deg, rgba(59,130,246,0.30), rgba(59,130,246,0.15));
  border-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

.ffgs-summary { display:flex; gap:6px; flex-wrap:wrap; }
.ffgs-pill {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.ffgs-pill-mod  { background: rgba(245,158, 11,0.18); color:#fbbf24; border:1px solid rgba(245,158,11,0.35); }
.ffgs-pill-high { background: rgba(239, 68, 68,0.18); color:#fca5a5; border:1px solid rgba(239,68,68,0.40); }
.ffgs-pill-ext  { background: rgba(217, 70,239,0.18); color:#e9a5fb; border:1px solid rgba(217,70,239,0.40); }

.ffgs-country-row { display:flex; gap:3px; flex-wrap:wrap; }
.ffgs-country-tab {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  color: #97a2b6;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 100ms ease;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ffgs-country-tab:hover { color: #cfd6e4; }
.ffgs-country-tab.on {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.50);
  color: #93c5fd;
}

.ffgs-table-wrap {
  max-height: 280px;
  overflow-y: auto;
  border-radius: 6px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.05);
}
.ffgs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.ffgs-table thead {
  position: sticky; top: 0;
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(8px);
  z-index: 1;
}
.ffgs-table th {
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #7a8499;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ffgs-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #cfd6e4;
  vertical-align: top;
}
.ffgs-table tr:hover td { background: rgba(255,255,255,0.025); }
.ffgs-row { cursor: pointer; transition: background 120ms ease; }
.ffgs-row:hover td { background: rgba(102, 187, 255, 0.07); }
.ffgs-row:focus { outline: none; }
.ffgs-row:focus td { background: rgba(102, 187, 255, 0.12); box-shadow: inset 2px 0 0 #66bbff; }
.ffgs-sub { font-size: 10px; color: #7a8499; }
.ffgs-empty { text-align:center; color:#7a8499; padding: 18px 8px; font-style: italic; }

.ffgs-lv {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: inline-block;
}
.ffgs-lv-moderate { background: rgba(245,158,11,0.20); color:#fbbf24; }
.ffgs-lv-high     { background: rgba(239, 68,68,0.22); color:#fca5a5; }
.ffgs-lv-extreme  { background: rgba(217, 70,239,0.22); color:#e9a5fb; }

.ffgs-legend {
  display:flex; gap:10px; flex-wrap:wrap;
  font-size: 10px; color:#97a2b6;
  padding-top: 4px;
}
.ffgs-legend span { display:inline-flex; align-items:center; gap:5px; }
.ffgs-sw { display:inline-block; width:10px; height:10px; border-radius:2px; }
.ffgs-sw-mod  { background: rgba(245,180, 60,0.65); }
.ffgs-sw-high { background: rgba(239, 68, 68,0.75); }
.ffgs-sw-ext  { background: rgba(217, 70,239,0.80); }

/* Map popup (district click) */
.ffgs-popup .maplibregl-popup-content {
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #cfd6e4;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  padding: 12px;
  font-size: 12px;
}
.ffgs-popup .maplibregl-popup-close-button { color:#97a2b6; font-size:18px; padding:2px 8px; }
.ffgs-popup .maplibregl-popup-tip { display:none; }
.ffgs-pop-head { margin-bottom: 8px; }
.ffgs-pop-head strong { display:block; font-size: 13px; color:#fff; }
.ffgs-pop-head span { font-size: 10px; color:#7a8499; }
.ffgs-pop-tbl { width:100%; border-collapse:collapse; font-size:11px; }
.ffgs-pop-tbl th { text-align:left; font-size:9px; color:#7a8499; padding:4px 6px; text-transform:uppercase; }
.ffgs-pop-tbl td { padding:4px 6px; border-top: 1px solid rgba(255,255,255,0.05); }
.ffgs-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:6px; vertical-align: middle; }

/* ============================================================
   Phase 3: Master filters, layer panel, time scrubber, export
   ============================================================ */

/* Utility */
.hidden { display: none !important; }

/* Master filter panel (right rail, top) */
.mf-panel { padding: 14px 16px 12px; }
.mf-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.mf-head h3 { margin: 0; }
.mf-clear {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.78);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.mf-clear:hover {
  background: rgba(255,255,255,0.09);
  color: #fff;
  border-color: rgba(255,255,255,0.22);
}
.mf-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label count" "select select";
  column-gap: 8px;
  row-gap: 4px;
  margin-top: 10px;
}
.mf-label {
  grid-area: label;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  align-self: center;
}
.mf-row .mf-select { grid-area: select; }
.mf-row .mf-count { grid-area: count; align-self: center; margin-left: 0; text-align: right; white-space: nowrap; }
.mf-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(8,14,22,0.65);
  color: #e9eef6;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 6px 26px 6px 10px;
  font-size: 12px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a8b3c0' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  transition: border-color 120ms, background-color 120ms;
}
.mf-select:hover { border-color: rgba(255,255,255,0.25); }
.mf-select:focus {
  outline: none;
  border-color: #58a6ff;
  background-color: rgba(8,14,22,0.85);
}
.mf-select option { background: #0c1320; color: #e9eef6; }
.mf-stats {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  display: flex; flex-wrap: wrap; gap: 4px 12px;
}
.mf-stats .mfs-num { color: #e9eef6; font-weight: 600; }
.mf-stats .mfs-on { color: #6fd49b; }

/* Inline live count chip next to each filter label */
.mf-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.01em;
}
.mf-count.is-filtered { color: #6fd49b; }
.mf-count.is-zero { color: #f59f7a; }

/* Layer panel (floating glass card on map, top-left corner) */
.layer-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  background: rgba(12,18,28,0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.36);
  overflow: hidden;
  transition: width 180ms ease;
}
.layer-panel-toggle {
  display: flex; align-items: center; gap: 7px;
  background: transparent;
  color: #e9eef6;
  border: 0;
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.layer-panel-toggle:hover { background: rgba(255,255,255,0.04); }
.layer-panel-body {
  display: none;
  padding: 4px 10px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.layer-panel[data-open="true"] .layer-panel-body { display: block; }
.layer-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 4px;
  font-size: 12px;
  color: rgba(255,255,255,0.82);
  cursor: pointer;
  border-radius: 5px;
  transition: background 100ms;
}
.layer-row:hover { background: rgba(255,255,255,0.04); }
.layer-row input[type="checkbox"] {
  accent-color: #58a6ff;
  width: 13px; height: 13px;
  cursor: pointer;
}

/* Time scrubber (bottom-center of map) */
.time-scrubber {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex; align-items: center; gap: 8px;
  background: rgba(12,18,28,0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 7px 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.36);
}
.ts-label {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-right: 2px;
}
.ts-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(8,14,22,0.70);
  color: #e9eef6;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 5px 22px 5px 8px;
  font-size: 12px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a8b3c0' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  cursor: pointer;
  transition: border-color 120ms;
}
.ts-select:hover { border-color: rgba(255,255,255,0.25); }
.ts-select:focus { outline: none; border-color: #58a6ff; }
.ts-select option { background: #0c1320; color: #e9eef6; }
.ts-hour { min-width: 64px; }
.ts-live {
  background: rgba(111,212,155,0.16);
  color: #6fd49b;
  border: 1px solid rgba(111,212,155,0.34);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms;
}
.ts-live:hover { background: rgba(111,212,155,0.26); }

/* Export menu (sits below the basemap pill at top-right of map) */
.export-wrap {
  position: absolute;
  top: 60px;
  right: 14px;
  z-index: 4;
}
.export-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(12,18,28,0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: #e9eef6;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.30);
  transition: border-color 120ms, background 120ms;
}
.export-btn:hover {
  border-color: rgba(255,255,255,0.24);
  background: rgba(20,28,42,0.92);
}
.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: rgba(12,18,28,0.94);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  display: flex; flex-direction: column;
}
.export-menu button {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.86);
  text-align: left;
  padding: 8px 11px;
  font-size: 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}
.export-menu button:hover {
  background: rgba(88,166,255,0.16);
  color: #fff;
}

/* Province boundary fallback styling (used if MapLibre layer fails) */
.province-toast {
  position: absolute;
  bottom: 60px;
  left: 14px;
  z-index: 5;
  background: rgba(12,18,28,0.92);
  color: #ffb86b;
  border: 1px solid rgba(255,184,107,0.30);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
}

/* Make sure the map-wrap is a positioned container for absolute children */
.map-wrap { position: relative; }

/* Mobile compaction */
@media (max-width: 720px) {
  .layer-panel { top: 8px; left: 8px; }
  .export-wrap { top: 8px; right: 8px; }
  .time-scrubber { bottom: 8px; padding: 6px 8px; gap: 6px; }
  .ts-label { display: none; }
}

/* =============================================================================
 * Phase 3.6 — Hazard buttons + banner
 * ===========================================================================*/

.hazard-row {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 8px;
  background: rgba(12, 18, 28, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hazard-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: transparent;
  color: #e4ecf6;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 160ms ease;
  white-space: nowrap;
}
.hazard-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}
.hazard-btn .hz-icon {
  font-size: 14px;
  line-height: 1;
}

/* Active state: each button gets its own color */
.hazard-btn[data-hazard="storm"].active {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  border-color: #c4b5fd;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.25), 0 4px 12px rgba(168, 85, 247, 0.35);
}
.hazard-btn[data-hazard="landslide"].active {
  background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
  border-color: #fbbf24;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.25), 0 4px 12px rgba(180, 83, 9, 0.35);
}
.hazard-btn[data-hazard="pdc-flood"].active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  border-color: #fca5a5;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25), 0 4px 12px rgba(220, 38, 38, 0.35);
}
.hazard-btn[data-hazard="ffgs"].active {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: #93c5fd;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25), 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* Hazard banner: appears under the hazard row when a mode is active */
.hazard-banner {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(12, 18, 28, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  padding: 8px 14px;
  color: #e4ecf6;
  font-size: 12px;
  max-width: 80%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}
.hazard-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hazard-banner strong {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #ffb86b;
}
.hazard-banner span {
  font-size: 11px;
  opacity: 0.85;
  line-height: 1.4;
}

@media (max-width: 720px) {
  .hazard-row { top: 8px; gap: 4px; padding: 4px; }
  .hazard-btn { padding: 6px 8px; font-size: 11px; }
  .hazard-btn .hz-label { display: none; }  /* icons-only on mobile */
  .hazard-banner { top: 50px; max-width: 92%; padding: 6px 10px; }
}

/* ============================================================
   PDC Hazard Brief — inline popup expansion
   When the user taps "Open hazard brief", the existing MapLibre
   popup expands in place to show the full brief content.
   ============================================================ */

/* Expanded popup variant: wider, taller, scrollable inside, dark theme.
   z-index lifted above all dashboard chrome (cmd-bar, tab-pills, time-scrubber,
   ticker all sit at 999/1000) so the expanded brief is always tappable. */
.maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded {
  z-index: 2000;
}
.maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .maplibregl-popup-content {
  max-width: 480px;
  width: 480px;
  max-height: min(78vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  background: var(--bg-panel, #0f172a);
  color: var(--text-hi, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.55);
}
.maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .pdc-brief {
  display: flex;
  flex-direction: column;
}
/* Maplibre close button stays on top inside the expanded popup */
.maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .maplibregl-popup-close-button {
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 1;
  z-index: 5;
  color: #fff;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 50%;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .maplibregl-popup-close-button:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Collapse (“Show less”) action row */
.pdc-brief-actions {
  padding: 10px 16px 16px;
  border-top: 1px solid rgba(148,163,184,0.12);
  background: rgba(15, 23, 42, 0.4);
  position: sticky;
  bottom: 0;
  z-index: 2;
}
.pdc-brief-collapse {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.pdc-brief-collapse:hover { background: rgba(30, 41, 59, 0.85); border-color: rgba(148,163,184,0.4); }
.pdc-brief-collapse:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }

/* Tip arrow matches dark theme */
.maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .maplibregl-popup-tip {
  border-top-color: var(--bg-panel, #0f172a) !important;
  border-bottom-color: var(--bg-panel, #0f172a) !important;
}

.pdc-brief-header {
  padding: 18px 56px 18px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fff;
}
.pdc-brief-header-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.pdc-brief-header-text { flex: 1; min-width: 0; line-height: 1.25; }
.pdc-brief-sev {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.95;
}
.pdc-brief-name {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
  word-break: break-word;
}
.pdc-brief-meta-inline {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pdc-brief-loading {
  padding: 40px 18px;
  text-align: center;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.pdc-brief-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(148,163,184,0.25);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: pdc-spin 0.8s linear infinite;
}
@keyframes pdc-spin { to { transform: rotate(360deg); } }

.pdc-brief-error {
  padding: 24px 18px;
  color: #fca5a5;
}
.pdc-brief-error-detail {
  margin-top: 6px;
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
}

.pdc-brief-section {
  padding: 14px 18px;
  border-top: 1px solid rgba(148,163,184,0.12);
}
.pdc-brief-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pdc-brief-section-sub {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: #64748b;
  font-size: 11px;
}

.pdc-brief-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.pdc-brief-stat {
  background: rgba(148,163,184,0.08);
  border-radius: 8px;
  padding: 10px 12px;
}
.pdc-brief-stat-val {
  font-size: 18px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.2;
}
.pdc-brief-stat-label {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pdc-brief-agegroup {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  font-size: 12px;
  color: #cbd5e1;
}
.pdc-brief-agegroup strong { color: #e2e8f0; margin-right: 4px; }

.pdc-brief-disclaimer {
  font-size: 10px;
  color: #64748b;
  font-style: italic;
  margin-top: 10px;
}

.pdc-brief-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.pdc-brief-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(148,163,184,0.08);
  color: #cbd5e1;
}
.pdc-brief-table td:last-child { text-align: right; font-weight: 600; color: #e2e8f0; }

.pdc-brief-desc {
  font-size: 13px;
  line-height: 1.55;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}

.pdc-brief-map {
  width: 100%;
  border-radius: 8px;
  display: block;
  background: rgba(148,163,184,0.08);
  border: 1px solid rgba(148,163,184,0.12);
}
.pdc-brief-map-fallback {
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
  padding: 16px;
  text-align: center;
  background: rgba(148,163,184,0.08);
  border-radius: 8px;
}

.pdc-brief-timeline { display: flex; flex-direction: column; gap: 8px; }
.pdc-brief-tl-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 6px 8px;
  align-items: center;
  font-size: 11px;
  color: #94a3b8;
}
.pdc-brief-tl-row.latest .pdc-brief-tl-time { color: #e2e8f0; font-weight: 600; }
.pdc-brief-tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  justify-self: center;
}
.pdc-brief-tl-row.latest .pdc-brief-tl-dot { background: #60a5fa; box-shadow: 0 0 0 3px rgba(96,165,250,0.18); }
.pdc-brief-tl-rel { color: #64748b; font-size: 10px; }
.pdc-brief-tl-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #60a5fa;
  background: rgba(96,165,250,0.12);
  padding: 2px 6px;
  border-radius: 10px;
  grid-column: 2 / 4;
  justify-self: start;
}

.pdc-brief-near-group { margin-top: 8px; }
.pdc-brief-near-group:first-child { margin-top: 0; }
.pdc-brief-near-label {
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 4px;
}
.pdc-brief-near-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148,163,184,0.06);
  font-size: 12px;
}
.pdc-brief-near-row:last-child { border-bottom: none; }
.pdc-brief-near-name { color: #e2e8f0; font-weight: 500; }
.pdc-brief-near-meta {
  grid-column: 1 / 2;
  font-size: 10px;
  color: #64748b;
}
.pdc-brief-near-dist {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  align-self: center;
  font-size: 11px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.pdc-brief-source-row { display: flex; gap: 10px; align-items: center; }
.pdc-brief-source-logo {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(148,163,184,0.08);
  object-fit: contain;
}
.pdc-brief-source-name {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}
.pdc-brief-source-url {
  font-size: 11px;
  color: #60a5fa;
  text-decoration: none;
}
.pdc-brief-source-url:hover { text-decoration: underline; }

.pdc-brief-footer {
  padding: 12px 18px 20px;
  font-size: 11px;
  color: #64748b;
  text-align: center;
  border-top: 1px solid rgba(148,163,184,0.12);
}
.pdc-brief-footer a { color: #94a3b8; }

/* Mobile: expanded popup becomes a near-fullscreen card. We DON'T override
   maplibre's transform (that would break its anchor math on map pan/zoom)
   — instead, we just constrain the inner content box to fit the viewport
   and add tip styling so it reads as a card. The popup wrapper still tracks
   the geographic point as the user pans. */
@media (max-width: 720px) {
  .maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .maplibregl-popup-content {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: 80vh;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.65);
  }
  .pdc-brief-header { padding: 16px 56px 16px 16px; }
  .pdc-brief-section { padding: 12px 16px; }
  .pdc-brief-stats { grid-template-columns: repeat(2, 1fr); }
  /* Bigger touch targets on mobile */
  .pdc-brief-collapse { min-height: 48px; font-size: 14px; }
  /* Larger maplibre close button on mobile */
  .maplibregl-popup.pdc-popup-wrap.pdc-popup-expanded .maplibregl-popup-close-button {
    width: 48px;
    height: 48px;
    font-size: 30px;
  }
}

/* Ensure the popup CTA button is mobile-friendly (44px tap height) */
.pdc-popup .pdc-cta {
  display: block;
  width: 100%;
  min-height: 44px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  border: 1px solid rgba(59,130,246,0.5);
  background: rgba(59,130,246,0.15);
  color: #93c5fd;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0 4px;
  transition: background 160ms ease, border-color 160ms ease;
}
.pdc-popup .pdc-cta:hover {
  background: rgba(59,130,246,0.25);
  border-color: rgba(59,130,246,0.65);
}

/* ============================================================================
   MRC station popup — compact card + inline-expanded chart
   Mirrors PDC popup pattern: dark theme, lifted z-index for mobile chrome,
   480px wide expanded state. Both states live inside the same maplibre popup.
   ============================================================================ */

/* Container (compact + expanded common base) */
.maplibregl-popup.mrc-pop-wrap {
  z-index: 1100;
}
.maplibregl-popup.mrc-pop-wrap .maplibregl-popup-content {
  padding: 0;
  background: var(--bg-panel, #0f172a);
  color: var(--text-hi, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.55);
  border: 1px solid rgba(148,163,184,0.15);
}
.maplibregl-popup.mrc-pop-wrap .maplibregl-popup-close-button {
  width: 32px; height: 32px;
  font-size: 22px; line-height: 1;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 50%;
  top: 6px; right: 6px;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.maplibregl-popup.mrc-pop-wrap .maplibregl-popup-close-button:hover {
  color: #fff; background: rgba(30, 41, 59, 0.85);
}
.maplibregl-popup.mrc-pop-wrap .maplibregl-popup-tip {
  border-top-color: var(--bg-panel, #0f172a) !important;
  border-bottom-color: var(--bg-panel, #0f172a) !important;
}

/* Inner wrapper */
.mrc-pop {
  font-family: inherit;
  color: var(--text-hi, #e2e8f0);
  min-width: 260px;
  padding: 14px 16px 12px;
  line-height: 1.4;
}

/* Header (title + status pill) */
.mrc-pop-header {
  display: flex; gap: 10px;
  align-items: flex-start;
  padding-right: 28px; /* room for close button */
  margin-bottom: 10px;
}
.mrc-pop-title-wrap { flex: 1; min-width: 0; }
.mrc-pop-title {
  font-size: 15px; font-weight: 700; color: #fff;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.mrc-pop-sub {
  font-size: 11px; color: #94a3b8;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* Status pill */
.mrc-pop-status {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  padding: 4px 8px; border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  align-self: flex-start;
}
.mrc-pop-status-normal  { background: rgba(34,197,94,0.15);  color: #4ade80; border-color: rgba(34,197,94,0.35); }
.mrc-pop-status-alarm   { background: rgba(245,158,11,0.18); color: #fbbf24; border-color: rgba(245,158,11,0.4); }
.mrc-pop-status-flood   { background: rgba(239,68,68,0.2);   color: #f87171; border-color: rgba(239,68,68,0.45); }
.mrc-pop-status-na      { background: rgba(148,163,184,0.15);color: #94a3b8; border-color: rgba(148,163,184,0.3); }
.mrc-pop-status-china   { background: rgba(59,130,246,0.18); color: #93c5fd; border-color: rgba(59,130,246,0.4); }

/* Latest reading block */
.mrc-pop-latest {
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 8px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: baseline;
}
.mrc-pop-latest-val {
  font-size: 24px; font-weight: 700; color: #fff;
  grid-row: span 2;
  line-height: 1.1;
}
.mrc-pop-latest-lbl {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: #94a3b8;
}
.mrc-pop-latest-time {
  font-size: 11px; color: #cbd5e1;
  grid-column: 2;
}
.mrc-pop-headroom-ok    { font-size: 11px; color: #4ade80; grid-column: 1 / -1; margin-top: 4px; }
.mrc-pop-headroom-watch { font-size: 11px; color: #fbbf24; grid-column: 1 / -1; margin-top: 4px; }
.mrc-pop-headroom-warn  { font-size: 11px; color: #f87171; grid-column: 1 / -1; margin-top: 4px; font-weight: 600; }

/* Threshold rows (alarm / flood / low-lying) */
.mrc-pop-thresholds {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.mrc-pop-th {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.4);
}
.mrc-pop-th-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.mrc-pop-th-alarm .mrc-pop-th-dot { background: #f59e0b; }
.mrc-pop-th-flood .mrc-pop-th-dot { background: #ef4444; }
.mrc-pop-th-low   .mrc-pop-th-dot { background: #a3a3a3; }
.mrc-pop-th-lbl { flex: 1; color: #cbd5e1; }
.mrc-pop-th-val { font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }

/* Sparkline (compact view) */
.mrc-pop-sparkline-wrap {
  height: 56px;
  margin-bottom: 10px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 6px;
  padding: 4px 6px;
  position: relative;
}
.mrc-pop-sparkline-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.mrc-pop-sparkline-empty {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 0 8px;
}

/* Action buttons */
.mrc-pop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.mrc-pop-cta {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease;
}
.mrc-pop-cta-primary {
  border: 1px solid rgba(59,130,246,0.5);
  background: rgba(59,130,246,0.18);
  color: #93c5fd;
}
.mrc-pop-cta-primary:hover {
  background: rgba(59,130,246,0.3);
  border-color: rgba(59,130,246,0.7);
}
.mrc-pop-cta-secondary {
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
}
.mrc-pop-cta-secondary:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(148,163,184,0.4);
}
.mrc-pop-cta-collapse {
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
}
.mrc-pop-cta-collapse:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(148,163,184,0.4);
}
.mrc-pop-cta:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Source link */
.mrc-pop-source {
  font-size: 10px;
  color: #64748b;
  text-align: center;
  padding-top: 4px;
  border-top: 1px solid rgba(148,163,184,0.1);
  margin-top: 4px;
}
.mrc-pop-source a {
  color: #94a3b8;
  text-decoration: none;
  word-break: break-all;
}
.mrc-pop-source a:hover { color: #cbd5e1; text-decoration: underline; }

/* ============================================================================
   Expanded state — wide popup with full Chart.js hydrograph
   ============================================================================ */
.maplibregl-popup.mrc-pop-wrap.mrc-pop-expanded {
  z-index: 2000; /* above dashboard chrome on mobile */
}
.maplibregl-popup.mrc-pop-wrap.mrc-pop-expanded .maplibregl-popup-content {
  width: 480px;
  max-width: 480px;
  max-height: min(78vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.maplibregl-popup.mrc-pop-wrap.mrc-pop-expanded .maplibregl-popup-close-button {
  width: 40px; height: 40px;
  font-size: 26px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  top: 8px; right: 8px;
}

.mrc-pop-expanded-body { padding: 16px 18px 14px; }

/* Stats grid (latest / alarm / flood / low-lying) */
.mrc-pop-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 4px 0 12px;
}
.mrc-pop-stat {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  min-width: 0;
}
.mrc-pop-stat-val {
  font-size: 15px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.mrc-pop-stat-lbl {
  font-size: 10px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-top: 2px;
}

/* Range tabs (24h / 1w / 2w / 30d) */
.mrc-pop-rng {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.5);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.mrc-rng-btn {
  flex: 1;
  min-height: 32px;
  padding: 6px 4px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.mrc-rng-btn:hover {
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
}
.mrc-rng-btn.mrc-rng-on {
  background: rgba(59,130,246,0.25);
  color: #fff;
  border-color: rgba(59,130,246,0.5);
}
.mrc-rng-btn:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Chart canvas wrapper */
.mrc-pop-chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
}
.mrc-pop-chart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.mrc-pop-chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #94a3b8;
  pointer-events: none;
}

/* Legend (water / rain / alarm / flood / low-lying) */
.mrc-pop-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
  color: #cbd5e1;
  margin-bottom: 10px;
  padding: 0 2px;
}
.mrc-leg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.mrc-leg-line {
  width: 14px; height: 2px;
  background: #1e3a8a;
  border-radius: 1px;
}
.mrc-leg-water .mrc-leg-line { background: #1e3a8a; }
.mrc-leg-bar {
  width: 10px; height: 8px;
  background: #38bdf8;
  border-radius: 1px;
}
.mrc-leg-dash {
  width: 14px; height: 0;
  border-top: 2px dashed currentColor;
}
.mrc-leg-alarm { color: #f59e0b; }
.mrc-leg-flood { color: #ef4444; }
.mrc-leg-low   { color: #a3a3a3; }

/* Rainfall summary row */
.mrc-pop-rainfall-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 10px;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 6px;
}
.mrc-rf-cell {
  flex: 1 1 auto;
  white-space: nowrap;
}
.mrc-rf-cell b { color: #38bdf8; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================================
   Mobile responsive — full-width expanded popup
   ============================================================================ */
@media (max-width: 600px) {
  .maplibregl-popup.mrc-pop-wrap.mrc-pop-expanded .maplibregl-popup-content {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: 80vh;
  }
  .maplibregl-popup.mrc-pop-wrap.mrc-pop-expanded .maplibregl-popup-close-button {
    width: 44px; height: 44px;
    font-size: 28px;
  }
  .mrc-pop-chart-wrap { height: 240px; }
  .mrc-pop-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mrc-rng-btn { min-height: 44px; font-size: 12px; }
  .mrc-pop-cta { min-height: 44px; font-size: 13px; }
}

/* ============================================================================
   Hydropower dam popup — compact card + inline-expanded operations chart
   Mirrors the MRC popup pattern: dark theme, lifted z-index for mobile chrome,
   480px wide expanded state. Both states live inside the same maplibre popup.
   ============================================================================ */

/* Container (compact + expanded common base) */
.maplibregl-popup.hp-pop-wrap {
  z-index: 1100;
}
.maplibregl-popup.hp-pop-wrap .maplibregl-popup-content {
  padding: 0;
  background: var(--bg-panel, #0f172a);
  color: var(--text-hi, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.55);
  border: 1px solid rgba(148,163,184,0.15);
}
.maplibregl-popup.hp-pop-wrap .maplibregl-popup-close-button {
  width: 32px; height: 32px;
  font-size: 22px; line-height: 1;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 50%;
  top: 6px; right: 6px;
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.maplibregl-popup.hp-pop-wrap .maplibregl-popup-close-button:hover {
  color: #fff; background: rgba(30, 41, 59, 0.85);
}
.maplibregl-popup.hp-pop-wrap .maplibregl-popup-tip {
  border-top-color: var(--bg-panel, #0f172a) !important;
  border-bottom-color: var(--bg-panel, #0f172a) !important;
}

/* Inner wrapper */
.hp-pop {
  font-family: inherit;
  color: var(--text-hi, #e2e8f0);
  min-width: 280px;
  padding: 14px 16px 12px;
  line-height: 1.4;
}

/* Header (title + status pill) */
.hp-pop-header {
  display: flex; gap: 10px;
  align-items: flex-start;
  padding-right: 28px;
  margin-bottom: 10px;
}
.hp-pop-title-wrap { flex: 1; min-width: 0; }
.hp-pop-title {
  font-size: 15px; font-weight: 700; color: #fff;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.hp-pop-sub {
  font-size: 11px; color: #94a3b8;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* Status pill — maps to computeStorage status names */
.hp-pop-status {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  padding: 4px 8px; border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  align-self: flex-start;
}
.hp-pop-status-normal        { background: rgba(52,211,153,0.15);  color: #4ade80; border-color: rgba(52,211,153,0.35); }
.hp-pop-status-rising        { background: rgba(245,158,11,0.18);  color: #fbbf24; border-color: rgba(245,158,11,0.4); }
.hp-pop-status-watch         { background: rgba(251,191,36,0.18);  color: #fbbf24; border-color: rgba(251,191,36,0.4); }
.hp-pop-status-high          { background: rgba(249,115,22,0.22);  color: #fb923c; border-color: rgba(249,115,22,0.45); }
.hp-pop-status-critical_high { background: rgba(220,38,38,0.25);   color: #f87171; border-color: rgba(220,38,38,0.5); }
.hp-pop-status-low           { background: rgba(239,68,68,0.2);    color: #f87171; border-color: rgba(239,68,68,0.45); }
.hp-pop-status-no_data       { background: rgba(148,163,184,0.15); color: #94a3b8; border-color: rgba(148,163,184,0.3); }

/* Operator alert banner */
.hp-pop-alert {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.hp-pop-alert-evacuate { background: rgba(220,38,38,0.22); color: #fca5a5; border-color: rgba(220,38,38,0.55); }
.hp-pop-alert-warning  { background: rgba(245,158,11,0.20); color: #fbbf24; border-color: rgba(245,158,11,0.5); }
.hp-pop-alert-watch    { background: rgba(251,191,36,0.18); color: #fde68a; border-color: rgba(251,191,36,0.45); }

/* Latest reading block */
.hp-pop-latest {
  padding: 10px 12px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 8px;
  margin-bottom: 10px;
}
.hp-pop-latest-val {
  font-size: 26px; font-weight: 700; color: #fff;
  line-height: 1.1;
}
.hp-pop-latest-unit {
  font-size: 13px; color: #94a3b8;
  margin-left: 4px;
  font-weight: 500;
}
.hp-pop-latest-lbl {
  font-size: 11px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-top: 4px;
}
.hp-pop-latest-time {
  font-size: 11px; color: #cbd5e1;
  margin-top: 4px;
}
.hp-pop-fill {
  font-size: 12px; color: #93c5fd;
  margin-top: 6px;
  font-weight: 600;
}

/* Metrics grid (2x2 of generation / release / inflow / storage) */
.hp-pop-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.hp-pop-metric {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148,163,184,0.10);
  border-radius: 6px;
  padding: 6px 8px;
}
.hp-pop-metric-val {
  font-size: 15px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.hp-pop-metric-unit {
  font-size: 11px; color: #94a3b8;
  margin-left: 3px;
  font-weight: 500;
}
.hp-pop-metric-lbl {
  font-size: 10px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.3px;
  margin-top: 2px;
}

/* Reservoir vertical profile mini */
.hp-pop-profile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 6px;
  margin-bottom: 10px;
  min-height: 72px;
}
.hp-pop-profile-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  min-width: 48px;
}
.hp-pop-profile-label {
  font-size: 10px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.hp-pop-profile-val {
  font-size: 11px; color: #cbd5e1;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.hp-pop-profile-bar {
  position: relative;
  height: 60px;
  background: linear-gradient(to top, rgba(96,165,250,0.05), rgba(239,68,68,0.05));
  border-left: 1px solid rgba(148,163,184,0.2);
  border-right: 1px solid rgba(148,163,184,0.2);
  border-radius: 4px;
  overflow: visible;
}
.hp-pop-profile-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(59,130,246,0.5), rgba(96,165,250,0.3));
  border-radius: 0 0 3px 3px;
  transition: height 200ms ease;
}
.hp-pop-profile-current {
  position: absolute;
  left: -3px; right: -3px;
  height: 2px;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251,191,36,0.6);
  transform: translateY(1px);
}
.hp-pop-profile-current-lbl {
  position: absolute;
  right: calc(100% + 6px);
  font-size: 10px;
  color: #fbbf24;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translateY(50%);
  pointer-events: none;
}
.hp-pop-profile-na {
  font-size: 11px; color: #64748b;
  text-align: center;
  padding: 10px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 6px;
  margin-bottom: 10px;
}

/* Sparkline (compact view, 30d generation or level) */
.hp-pop-sparkline-wrap {
  height: 56px;
  margin-bottom: 10px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 6px;
  padding: 4px 6px;
  position: relative;
}
.hp-pop-sparkline-canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.hp-pop-sparkline-lbl {
  position: absolute;
  top: 4px; left: 8px;
  font-size: 9px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  pointer-events: none;
}
.hp-pop-sparkline-empty {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 0 8px;
}

/* Action buttons */
.hp-pop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.hp-pop-cta {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease;
}
.hp-pop-cta-primary {
  border: 1px solid rgba(59,130,246,0.5);
  background: rgba(59,130,246,0.18);
  color: #93c5fd;
}
.hp-pop-cta-primary:hover {
  background: rgba(59,130,246,0.3);
  border-color: rgba(59,130,246,0.7);
}
.hp-pop-cta-secondary {
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
}
.hp-pop-cta-secondary:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(148,163,184,0.4);
}
.hp-pop-cta-collapse {
  border: 1px solid rgba(148,163,184,0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #cbd5e1;
}
.hp-pop-cta-collapse:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(148,163,184,0.4);
}
.hp-pop-cta:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Source line */
.hp-pop-source {
  font-size: 10px;
  color: #64748b;
  text-align: center;
  padding-top: 4px;
  border-top: 1px solid rgba(148,163,184,0.1);
  margin-top: 4px;
}

/* ============================================================================
   Expanded state — wide popup with full Chart.js operations chart
   ============================================================================ */
.maplibregl-popup.hp-pop-wrap.hp-pop-expanded {
  z-index: 2000;
}
.maplibregl-popup.hp-pop-wrap.hp-pop-expanded .maplibregl-popup-content {
  width: 480px;
  max-width: 480px;
  max-height: min(78vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.maplibregl-popup.hp-pop-wrap.hp-pop-expanded .maplibregl-popup-close-button {
  width: 40px; height: 40px;
  font-size: 26px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  top: 8px; right: 8px;
}

.hp-pop-expanded-body { padding: 16px 18px 14px; }

/* Stats grid (3 cols × 2 rows) */
.hp-pop-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0 12px;
}
.hp-pop-stat {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  min-width: 0;
}
.hp-pop-stat-val {
  font-size: 15px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.hp-pop-stat-lbl {
  font-size: 10px; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-top: 2px;
}

/* Range tabs (30d / 90d / 1y / all) */
.hp-pop-rng {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.5);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 10px;
}
.hp-rng-btn {
  flex: 1;
  min-height: 32px;
  padding: 6px 4px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.hp-rng-btn:hover { background: rgba(30, 41, 59, 0.7); color: #cbd5e1; }
.hp-rng-btn.hp-rng-on {
  background: rgba(59,130,246,0.25);
  color: #fff;
  border-color: rgba(59,130,246,0.5);
}
.hp-rng-btn:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

/* Chart canvas wrapper */
.hp-pop-chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
}
.hp-pop-chart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.hp-pop-chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #94a3b8;
  pointer-events: none;
}

/* Legend */
.hp-pop-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
  color: #cbd5e1;
  margin-bottom: 10px;
  padding: 0 2px;
}
.hp-leg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.hp-leg-line {
  width: 14px; height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.hp-leg-dash {
  width: 14px; height: 0;
  border-top: 2px dashed currentColor;
}
.hp-leg-level   { color: #60a5fa; }
.hp-leg-gen     { color: #fbbf24; }
.hp-leg-release { color: #34d399; }
.hp-leg-fsl     { color: #ef4444; }
.hp-leg-mol     { color: #94a3b8; }

/* Dam spec summary row (capacity / FSL / MOL / crest / height / storage) */
.hp-pop-spec {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 6px;
}
.hp-spec-cell {
  flex: 1 1 auto;
  white-space: nowrap;
  min-width: 0;
}
.hp-spec-cell b {
  color: #cbd5e1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   Mobile responsive — full-width expanded popup, 44px touch targets
   ============================================================================ */
@media (max-width: 600px) {
  .hp-pop { min-width: 0; }
  /* Bump compact-state close button to WCAG-compliant touch target on mobile. */
  .maplibregl-popup.hp-pop-wrap .maplibregl-popup-close-button {
    width: 44px; height: 44px; font-size: 26px;
  }
  .maplibregl-popup.hp-pop-wrap.hp-pop-expanded .maplibregl-popup-content {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    max-height: 80vh;
  }
  .maplibregl-popup.hp-pop-wrap.hp-pop-expanded .maplibregl-popup-close-button {
    width: 44px; height: 44px;
    font-size: 28px;
  }
  .hp-pop-chart-wrap { height: 240px; }
  .hp-pop-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hp-pop-metrics    { grid-template-columns: 1fr 1fr; }
  .hp-rng-btn { min-height: 44px; font-size: 12px; }
  .hp-pop-cta { min-height: 44px; font-size: 13px; }
}

/* ===================================================================
   Storm Navigator
   When 2+ named tropical cyclones are active, this list-panel appears
   below the hazard banner so the user can jump between each storm.
   =================================================================== */
.storm-nav {
  position: absolute;
  top: 110px;
  right: 12px;
  z-index: 7;  /* sit above .hazard-row (z-index 6) so its dropdown never gets clipped */
  width: 260px;
  max-height: calc(100% - 140px);
  background: rgba(12, 18, 28, 0.94);
  border: 1px solid rgba(220, 38, 38, 0.45);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: #e4ecf6;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 220ms ease, transform 220ms ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.storm-nav.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.storm-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(220, 38, 38, 0.12);
}
.storm-nav .sn-head-title {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffb86b;
  font-weight: 600;
}
.storm-nav .sn-collapse,
.storm-nav .sn-fit-all {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #e4ecf6;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 4px;
}
.storm-nav .sn-collapse {
  font-size: 16px;
}
.storm-nav .sn-collapse:hover,
.storm-nav .sn-fit-all:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}
.storm-nav-list {
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.storm-nav.collapsed .storm-nav-list {
  display: none;
}
.storm-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  color: #e4ecf6;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.storm-nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}
.storm-nav-item.active {
  background: rgba(220, 38, 38, 0.18);
  border-color: rgba(220, 38, 38, 0.55);
}
.storm-nav-item .sn-icon {
  font-size: 16px;
  line-height: 1.1;
  flex: 0 0 auto;
}
.storm-nav-item .sn-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}
.storm-nav-item .sn-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.storm-nav-item .sn-name {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  letter-spacing: 0.01em;
}
.storm-nav-item .sn-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.2;
}
.storm-nav-item .sn-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: rgba(228, 236, 246, 0.7);
  line-height: 1.3;
}
.storm-nav-item .sn-wind {
  color: #ffd699;
}
.storm-nav-item .sn-heading {
  color: rgba(228, 236, 246, 0.6);
}
.storm-nav-item .sn-adv {
  color: rgba(228, 236, 246, 0.55);
}

/* ===== ECMWF MODEL / INVEST provenance badges (storm navigator) ===== */
.storm-nav-item .sn-prov {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  line-height: 1.4;
}
.storm-nav-item .sn-prov.ops {
  background: #dc2626;
  color: #ffe4e6;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.45);
}
.storm-nav-item .sn-prov.model {
  background: #f97316;
  color: #1a1208;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.4);
}
.storm-nav-item .sn-prov.invest {
  background: #fbbf24;
  color: #1a1208;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4);
}
.storm-nav-item.sn-item-model {
  border-left: 3px solid #f97316;
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.08) 0%, transparent 60%);
}
.storm-nav-item.sn-item-invest {
  border-left: 3px solid #fbbf24;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.05) 0%, transparent 60%);
  opacity: 0.92;
}

/* ===== Storm region groups (navigator) ===== */
.sn-group {
  border-bottom: 1px solid rgba(228, 236, 246, 0.06);
}
.sn-group:last-child { border-bottom: none; }
.sn-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  background: rgba(228, 236, 246, 0.02);
  transition: background 0.15s ease;
}
.sn-group-header:hover {
  background: rgba(96, 165, 250, 0.08);
}
.sn-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: rgba(228, 236, 246, 0.65);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 3px;
}
.sn-chevron:hover {
  background: rgba(228, 236, 246, 0.08);
  color: #e4ecf6;
}
.sn-group-label {
  flex: 1 1 auto;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(228, 236, 246, 0.82);
  text-transform: uppercase;
}
.sn-group-count {
  flex: 0 0 auto;
  background: rgba(228, 236, 246, 0.08);
  color: rgba(228, 236, 246, 0.75);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9px;
  min-width: 20px;
  text-align: center;
}
.sn-tier-dots {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}
.sn-tier-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.sn-tier-dot.ops    { background: #dc2626; box-shadow: 0 0 4px rgba(220, 38, 38, 0.6); }
.sn-tier-dot.model  { background: #f97316; box-shadow: 0 0 4px rgba(249, 115, 22, 0.5); }
.sn-tier-dot.invest { background: #fbbf24; box-shadow: 0 0 4px rgba(251, 191, 36, 0.5); }

.sn-group-body {
  display: none;
}
.sn-group.open .sn-group-body {
  display: block;
}
.sn-group.open .sn-group-header {
  background: rgba(96, 165, 250, 0.05);
}

/* ===== Storm popup header badges (operational / model / invest) ===== */
.storm-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
  line-height: 1.4;
}
.storm-badge.ops {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.5);
}
.storm-badge.model {
  background: #f97316;
  color: #1a1208;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.5);
}
.storm-badge.invest {
  background: #fbbf24;
  color: #1a1208;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.5);
}

/* Mid-desktop: nudge panel up so it doesn't collide with the hazard banner */
@media (max-width: 1100px) {
  .storm-nav { top: 100px; }
}

/* Mobile: anchor list to bottom-center, full-width, generous height so storms
   are visible under the region header without scrolling. */
@media (max-width: 640px) {
  .storm-nav {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: 60vh;
  }
  .storm-nav-item {
    padding: 10px 10px;
    min-height: 44px;
  }
  .storm-nav .sn-collapse {
    width: 32px;
    height: 32px;
  }
}

/* ===== Storm navigator tier-visibility chips + info popover ===== */
.storm-nav .sn-info {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.05);
  color: #e4ecf6;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: auto;
  margin-right: 2px;
}
.storm-nav .sn-info:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

.storm-nav .sn-tier-row {
  display: flex;
  gap: 6px;
  padding: 6px 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
}
.storm-nav.collapsed .sn-tier-row { display: none; }

.storm-nav .sn-tier-chip {
  flex: 1;
  min-width: 0;
  padding: 5px 4px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.15;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(228, 236, 246, 0.45);
  transition: all 140ms ease;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
}
.storm-nav .sn-tier-chip.sn-tier-ops.on    { background: rgba(220, 38, 38, 0.20); border-color: rgba(220, 38, 38, 0.55); color: #fca5a5; }
.storm-nav .sn-tier-chip.sn-tier-model.on  { background: rgba(251, 146, 60, 0.18); border-color: rgba(251, 146, 60, 0.55); color: #fdba74; }
.storm-nav .sn-tier-chip.sn-tier-invest.on { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.50); color: #fcd34d; }
.storm-nav .sn-tier-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e4ecf6;
}
.storm-nav .sn-tier-chip.on:hover {
  filter: brightness(1.15);
}

.storm-nav .sn-info-popover {
  position: absolute;
  top: 74px;
  left: 8px;
  right: 8px;
  background: rgba(8, 14, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  padding: 8px 10px 10px;
  z-index: 50;
  color: #e4ecf6;
  font-size: 11px;
  line-height: 1.45;
  backdrop-filter: blur(10px);
}
.storm-nav .sn-info-popover[hidden] { display: none; }
.storm-nav .sn-info-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffb86b;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}
.storm-nav .sn-info-close {
  width: 22px; height: 22px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #e4ecf6;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.storm-nav .sn-info-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}
.storm-nav .sn-info-row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  align-items: flex-start;
}
.storm-nav .sn-info-row + .sn-info-row {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.storm-nav .sn-info-row b {
  font-weight: 700;
  letter-spacing: 0.04em;
}
.storm-nav .sn-info-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.storm-nav .sn-info-dot.ops    { background: #dc2626; }
.storm-nav .sn-info-dot.model  { background: #fb923c; }
.storm-nav .sn-info-dot.invest { background: #f59e0b; }

/* Storm nav is already position:absolute (line 3206), so it's already a positioning context. */

/* ============================================================================
   Flash-flood cascade analytics panel
   ============================================================================ */
.ffc-panel { display: flex; flex-direction: column; gap: 10px; }
.ffc-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.ffc-head h3 { margin: 0; }
.ffc-meta-stamp {
  font-size: 11px; color: var(--muted, #9aa3af); letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.ffc-controls {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-top: 2px; margin-bottom: 4px;
}
.ffc-run-btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 6px 14px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: 1px solid rgba(59, 130, 246, 0.6);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 1px 6px rgba(37, 99, 235, 0.35);
  transition: transform 80ms ease, background 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.ffc-run-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 10px rgba(37, 99, 235, 0.5);
}
.ffc-run-btn:active:not(:disabled) { transform: translateY(1px); }
.ffc-run-btn:disabled {
  opacity: 0.65; cursor: progress;
  background: linear-gradient(180deg, #475569 0%, #334155 100%);
  border-color: rgba(148, 163, 184, 0.3);
  box-shadow: none;
}
.ffc-run-status {
  font-size: 11px; color: #9aa3af; font-variant-numeric: tabular-nums;
}
.ffc-summary {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px;
}
.ffc-pill {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(148, 163, 184, 0.15); color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.ffc-pill-trib { background: rgba(59, 130, 246, 0.16); color: #93c5fd; border-color: rgba(59, 130, 246, 0.35); }
.ffc-pill-dams { background: rgba(168, 85, 247, 0.16); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.35); }
.ffc-pill-dist { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.ffc-pill-main { background: rgba(14, 165, 233, 0.16); color: #7dd3fc; border-color: rgba(14, 165, 233, 0.35); }
.ffc-pill-quiet { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

.ffc-body {
  display: flex; flex-direction: column; gap: 10px;
}
.ffc-empty {
  font-size: 12px; color: var(--muted, #9aa3af); padding: 10px 4px;
  border: 1px dashed rgba(148, 163, 184, 0.25); border-radius: 8px;
  text-align: center;
}

.ffc-card {
  border-radius: 10px;
  padding: 10px 11px 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-left-width: 3px;
}
.ffc-card-moderate { border-left-color: #fbbf24; }
.ffc-card-high     { border-left-color: #f97316; }
.ffc-card-extreme  { border-left-color: #dc2626; box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.18) inset; }

.ffc-card-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 6px 8px; margin-bottom: 8px;
}
.ffc-card-title {
  display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 100%;
  flex-wrap: wrap;
}
.ffc-trib {
  font-weight: 700; font-size: 13.5px; color: #e5e7eb;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.ffc-card-meta { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.ffc-count {
  font-size: 11px; color: #9aa3af; font-variant-numeric: tabular-nums;
}
.ffc-lv {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: #0b0e14;
}
.ffc-lv-sm { font-size: 9.5px; padding: 0 5px; }
.ffc-lv-moderate { background: #fbbf24; }
.ffc-lv-high     { background: #f97316; color: #fff; }
.ffc-lv-extreme  { background: #dc2626; color: #fff; }
.ffc-lv-low      { background: #475569; color: #cbd5e1; }

.ffc-dams {
  list-style: none; padding: 0; margin: 0 0 8px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.ffc-dam {
  display: grid;
  grid-template-columns: 18px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 3px;
  padding: 6px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(148, 163, 184, 0.10);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.ffc-dam:hover { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); }
.ffc-dam:active { transform: scale(0.998); }
.ffc-dam-idx {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  font-variant-numeric: tabular-nums; text-align: center;
  background: rgba(148, 163, 184, 0.12); border-radius: 4px; padding: 2px 0;
  grid-row: 1 / span 2; align-self: center;
}
.ffc-dam-main {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
  grid-column: 2; grid-row: 1;
}
.ffc-dam-name {
  font-size: 12.5px; font-weight: 600; color: #e5e7eb;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.25;
}
.ffc-dam-sub {
  font-size: 10.5px; color: #94a3b8; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ffc-dam-tags {
  display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap;
  grid-column: 2; grid-row: 2; margin-top: 1px;
}
.ffc-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(0, 0, 0, 0.18);
  color: var(--c, #cbd5e1);
  border: 1px solid color-mix(in srgb, var(--c, #cbd5e1) 40%, transparent);
}

/* 'drains into' badge for dams linked via FFC.upstreamDams adjacency table */
.ffc-link-badge {
  display: inline-flex; align-items: center;
  margin-left: 6px; padding: 0 5px;
  height: 14px; border-radius: 3px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #67e8f9;
  background: rgba(34, 211, 238, 0.10);
  border: 1px solid rgba(34, 211, 238, 0.35);
  vertical-align: middle;
}
.ffc-dam-upstream {
  border-left: 2px solid rgba(34, 211, 238, 0.45);
}

.ffc-card-foot {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  padding-top: 7px;
  border-top: 1px dashed rgba(148, 163, 184, 0.15);
  font-size: 10.5px;
}
.ffc-foot-label { color: #9aa3af; }
.ffc-foot-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ffc-chip {
  display: inline-flex; align-items: center;
  padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
  background: rgba(148, 163, 184, 0.12); color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.22);
}
.ffc-chip-moderate { background: rgba(251, 191, 36, 0.14); color: #fcd34d; border-color: rgba(251, 191, 36, 0.4); }
.ffc-chip-high     { background: rgba(249, 115, 22, 0.16); color: #fdba74; border-color: rgba(249, 115, 22, 0.45); }
.ffc-chip-extreme  { background: rgba(220, 38, 38, 0.18); color: #fca5a5; border-color: rgba(220, 38, 38, 0.5); }
.ffc-chip-more     { background: rgba(148, 163, 184, 0.08); color: #94a3b8; }

/* =========================================================================
   Rainfall forecast layer controls (radios + legend)
   ========================================================================= */
.layer-row-rain {
  /* visual separator above the rainfall section */
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.rain-controls {
  margin: 4px 0 2px 22px;   /* indent under the checkbox row */
  padding: 6px 8px 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.78);
}
.rain-controls[hidden] { display: none; }

.rain-window-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.rain-radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 5px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  color: rgba(255,255,255,0.7);
  transition: background 120ms, color 120ms, border-color 120ms;
}
.rain-radio input[type="radio"] {
  display: none;
}
.rain-radio:hover {
  background: rgba(88,166,255,0.10);
  color: rgba(255,255,255,0.92);
}
.rain-radio:has(input:checked) {
  background: linear-gradient(180deg, rgba(88,166,255,0.22), rgba(88,166,255,0.13));
  border-color: rgba(88,166,255,0.55);
  color: #fff;
  box-shadow: 0 1px 3px rgba(88,166,255,0.18) inset;
}

.rain-legend {
  margin-top: 4px;
}
.rain-legend-bar {
  height: 7px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    rgba(46,134,222,0.45) 0%,
    rgba(38,201,201,0.65) 25%,
    rgba(245,201,67,0.80) 50%,
    rgba(241,136,38,0.90) 75%,
    rgba(214,55,52,0.95) 100%
  );
}
.rain-legend-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 10px;
  color: rgba(255,255,255,0.62);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.rain-legend-unit {
  margin-top: 1px;
  font-size: 9.5px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: right;
}
.rain-meta {
  margin-top: 6px;
  font-size: 9.5px;
  color: rgba(255,255,255,0.42);
  letter-spacing: 0.02em;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  line-height: 1.3;
}

/* Rainfall forecast — animation playback */
.rain-playback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(20, 32, 56, 0.6);
  border: 1px solid rgba(80, 130, 200, 0.25);
  border-radius: 8px;
}
.rain-play {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(60, 145, 230, 0.18);
  border: 1px solid rgba(120, 180, 240, 0.5);
  color: #cfe5ff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.rain-play:hover { background: rgba(60, 145, 230, 0.32); }
.rain-play:active { transform: scale(0.94); }
.rain-play.playing { background: rgba(245, 140, 40, 0.25); border-color: rgba(245, 180, 90, 0.7); color: #ffdca8; }
.rain-slider {
  flex: 1 1 auto;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(90deg, rgba(60,145,230,0.6), rgba(245,210,70,0.6), rgba(225,55,55,0.6));
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
.rain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(60, 145, 230, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.rain-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(60, 145, 230, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.rain-time {
  flex: 0 0 auto;
  min-width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #cfe5ff;
  letter-spacing: 0.02em;
}

/* ===== Pre-release decision panel (HYDRO) ===== */
.hydro-panel-wrap {
  position: absolute;
  top: 56px;               /* stack directly under the Layers panel (collapsed = ~38px tall) */
  left: 14px;
  z-index: 5;              /* above layer panel so panel-body doesn't intercept clicks */
  background: rgba(12,18,28,0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.36);
  overflow: hidden;
  width: auto;
  max-width: 360px;
}
.hydro-panel-toggle {
  display: flex; align-items: center; gap: 7px;
  background: transparent;
  color: #e9eef6;
  border: 0;
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.hydro-panel-toggle:hover { background: rgba(255,255,255,0.04); }
.hydro-panel-wrap.open .hydro-panel-toggle::after { content: ' ▾'; opacity: 0.6; }
.hydro-panel {
  display: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 8px 10px 10px;
  width: 340px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.hydro-panel-wrap.open .hydro-panel { display: block; }
.hp-empty {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  padding: 14px 4px;
  text-align: center;
  line-height: 1.5;
}
.hp-empty small { display: block; margin-top: 4px; opacity: 0.7; }
.hp-summary {
  display: flex; flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.hp-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.92);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}
.hp-pill.hp-tier-critical    { background: rgba(239,68,68,0.22);  border-color: rgba(239,68,68,0.55); }
.hp-pill.hp-tier-prerelease  { background: rgba(251,146,60,0.22); border-color: rgba(251,146,60,0.55); }
.hp-pill.hp-tier-watch       { background: rgba(251,191,36,0.22); border-color: rgba(251,191,36,0.55); }
.hp-pill.hp-tier-normal      { background: rgba(45,212,191,0.20); border-color: rgba(45,212,191,0.50); }
.hp-rows { display: flex; flex-direction: column; gap: 5px; }
.hp-row {
  padding: 7px 8px;
  border-radius: 7px;
  background: rgba(255,255,255,0.025);
  border-left: 3px solid rgba(255,255,255,0.20);
  cursor: pointer;
  transition: background 120ms;
}
.hp-row:hover { background: rgba(255,255,255,0.06); }
.hp-row.hp-tier-critical    { border-left-color: #ef4444; }
.hp-row.hp-tier-prerelease  { border-left-color: #fb923c; }
.hp-row.hp-tier-watch       { border-left-color: #fbbf24; }
.hp-row.hp-tier-normal      { border-left-color: #2dd4bf; }
.hp-row-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.hp-tier-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  color: #0c121c;
  text-transform: uppercase;
}
.hp-name {
  flex: 1;
  font-size: 12px;
  color: rgba(255,255,255,0.94);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hp-ratio {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.78);
}
.hp-row.hp-tier-critical .hp-ratio,
.hp-row.hp-tier-prerelease .hp-ratio { color: #fb923c; }
.hp-row-detail {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px 8px;
  margin-top: 3px;
}
.hp-met {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255,255,255,0.65);
}
.hp-met label { opacity: 0.7; }
.hp-met value { color: rgba(255,255,255,0.9); font-variant-numeric: tabular-nums; }
.hp-met.hp-release {
  grid-column: 1 / -1;
  color: #fb923c;
  font-weight: 600;
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px dashed rgba(251,146,60,0.30);
}
.hp-met.hp-release label { color: #fb923c; opacity: 1; }
.hp-met.hp-release value { color: #fb923c; }

/* ===== Active storage row inside the pre-release card ===== */
/* Colors match the map storage legend exactly:
   Low <15% / Filling 15-40% / Normal 40-70% / Watch 70-85% / High 85-95% / Critical >=95%. */
.hp-met.hp-storage {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  padding-bottom: 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.10);
}
.hp-met.hp-storage value { font-weight: 600; }
.hp-storage-label {
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 8px;
  border: 1px solid currentColor;
  background: rgba(255,255,255,0.04);
}
.hp-met.hp-storage-critical_high value { color: #ef4444; }
.hp-met.hp-storage-high          value { color: #f97316; }
.hp-met.hp-storage-watch         value { color: #facc15; }
.hp-met.hp-storage-normal        value { color: #22c55e; }
.hp-met.hp-storage-rising        value { color: #eab308; }
.hp-met.hp-storage-low           value { color: #ef4444; }
.hp-met.hp-storage-no_data       value { color: rgba(255,255,255,0.45); }
.hp-met.hp-storage-no_data .hp-storage-label { border-color: rgba(255,255,255,0.25); }

.hp-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 10px;
  color: rgba(255,255,255,0.50);
  line-height: 1.5;
}

/* Mobile: stack the hydro panel below the layer panel */
@media (max-width: 760px) {
  .hydro-panel-wrap { top: 60px; left: 8px; max-width: calc(100vw - 16px); }
  .hydro-panel { width: calc(100vw - 30px); max-height: 60vh; }
}

/* ===== Pre-release sidebar (replaces the dam list) ===== */
.flow-side-prerelease .dam-list,
.hp-sidebar {
  /* Use the existing sidebar scroll chrome; no extra positioning needed. */
  gap: 6px;
}
.hp-sidebar .hp-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  padding: 0;
}
.hp-sidebar .hp-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hp-sidebar .hp-row {
  padding: 9px 10px;
  border-radius: 8px;
}
.hp-sidebar .hp-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.hp-sidebar .hp-name {
  font-size: 13px;
}
.hp-sidebar .hp-ratio {
  font-size: 12px;
}
.hp-sidebar .hp-row-detail {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 10px;
}
.hp-sidebar .hp-met {
  font-size: 11px;
}
.hp-sidebar .hp-foot {
  margin-top: 10px;
  padding-top: 10px;
  font-size: 10px;
}

/* The old floating Pre-release button is gone — hide any cached DOM. */
.hydro-panel-wrap { display: none !important; }

/* ===== Pre-release "How it works" info popover ===== */
.flow-side-prerelease .side-head {
  flex-wrap: wrap;
  row-gap: 8px;
}
.flow-side-prerelease .side-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.flow-side-prerelease .side-head #hpWindowTabs {
  margin-left: auto;
}
.hp-info-btn {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.30);
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  font-family: ui-serif, Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.hp-info-btn:hover,
.hp-info-btn[aria-expanded="true"] {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.55);
  color: #93c5fd;
}

.flow-side-prerelease { position: relative; }
.hp-info-popover {
  position: absolute;
  top: 60px;
  left: 12px;
  right: 12px;
  z-index: 60;
  background: rgba(8, 14, 26, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  padding: 10px 12px 12px;
  color: #e4ecf6;
  font-size: 12px;
  line-height: 1.55;
  backdrop-filter: blur(12px);
  max-height: calc(100% - 80px);
  overflow-y: auto;
}
.hp-info-popover[hidden] { display: none; }
.hp-info-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #93c5fd;
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  margin-bottom: 10px;
}
.hp-info-close {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #e4ecf6;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.hp-info-close:hover { background: rgba(255,255,255,0.10); }
.hp-info-body p { margin: 0 0 8px; }
.hp-info-body code {
  background: rgba(96, 165, 250, 0.10);
  border: 1px solid rgba(96, 165, 250, 0.20);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: #bfdbfe;
}
.hp-info-steps {
  margin: 6px 0 10px;
  padding-left: 18px;
}
.hp-info-steps li { margin-bottom: 6px; }
.hp-info-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0 10px;
}
.hp-info-tiers .hp-pill {
  font-size: 10.5px;
  padding: 3px 8px;
}
.hp-info-note {
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 8px;
  margin-top: 4px !important;
}

/* ===== Per-dam collapsible forecast chart ===== */
.hp-row { padding: 0 !important; }  /* reset previous padding since toggle is the new clickable surface */
.hp-row-toggle {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  border-radius: 10px;
  transition: background 0.15s;
}
.hp-row-toggle:hover { background: rgba(255,255,255,0.03); }
.hp-row-toggle:focus { outline: none; }
.hp-row-toggle:focus-visible { outline: 2px solid rgba(96,165,250,0.55); outline-offset: -2px; }

.hp-row .hp-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.hp-row .hp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-row .hp-chev {
  display: inline-flex;
  width: 16px; height: 16px;
  align-items: center;
  justify-content: center;
  color: rgba(148,163,184,0.85);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.22s ease-out;
  margin-left: 4px;
  flex-shrink: 0;
}
.hp-row.hp-open .hp-chev { transform: rotate(90deg); color: #93c5fd; }

/* Chart panel slide-down */
.hp-row-chart {
  overflow: hidden;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(10, 18, 32, 0.55);
  padding: 0;
}
.hp-row.hp-open .hp-row-chart {
  padding: 10px 12px 12px;
  animation: hpSlideDown 220ms ease-out;
}
@keyframes hpSlideDown {
  from { opacity: 0; transform: translateY(-4px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0);    max-height: 320px; }
}

.hp-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}
.hp-chart-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.hp-chart-eyebrow {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #93c5fd;
  font-weight: 700;
}
.hp-chart-sub {
  font-size: 10.5px;
  color: rgba(148,163,184,0.85);
}
.hp-chart-tabs { display: inline-flex; gap: 3px; flex-shrink: 0; }
.hp-chart-tab {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(203,213,225,0.85);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 9px;
  cursor: pointer;
  line-height: 1;
}
.hp-chart-tab.on {
  background: rgba(96,165,250,0.18);
  border-color: rgba(96,165,250,0.55);
  color: #93c5fd;
}
.hp-chart-tab:hover:not(.on) { background: rgba(255,255,255,0.05); }

.hp-chart-canvas {
  display: block;
  width: 100% !important;
  height: 160px;
  border-radius: 6px;
  background: rgba(0,0,0,0.18);
}

.hp-chart-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 10.5px;
  color: rgba(148,163,184,0.95);
}
.hp-chart-foot b { color: #e4ecf6; font-weight: 700; }
.hp-chart-foot .hp-foot-warn { color: #fca5a5; }
.hp-chart-foot .hp-foot-warn b { color: #fca5a5; }
.hp-chart-foot .hp-foot-ok   { color: #5eead4; }
.hp-chart-foot .hp-foot-rel  { color: #fdba74; }
.hp-chart-foot .hp-foot-rel b { color: #fdba74; }

.hp-chart-loading, .hp-chart-empty {
  font-size: 11px;
  color: rgba(148,163,184,0.85);
  padding: 18px 4px;
  text-align: center;
}

/* Visual lift when row is open */
.hp-row.hp-open {
  background: rgba(255,255,255,0.025);
  box-shadow: 0 0 0 1px rgba(96,165,250,0.20) inset;
}

/* Inline legend strip under the chart canvas */
.hp-chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 6px;
  padding: 5px 4px 0;
  font-size: 9.5px;
  color: rgba(148,163,184,0.95);
}
.hp-leg-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hp-leg-label { line-height: 1; white-space: nowrap; }
.hp-leg-label.hp-leg-warn { color: #fca5a5; font-weight: 600; }
.hp-leg-bar {
  display: inline-block;
  width: 6px;
  height: 10px;
  border-radius: 1px;
}
.hp-leg-r1 { background: rgba(96,165,250,0.85); }
.hp-leg-r2 { background: rgba(59,130,246,0.90); }
.hp-leg-r3 { background: rgba(251,146,60,0.92); }
.hp-leg-r4 { background: rgba(239,68,68,0.95); }
.hp-leg-line {
  display: inline-block;
  width: 14px;
  height: 2.4px;
  border-radius: 1px;
}
.hp-leg-dash {
  display: inline-block;
  width: 14px;
  height: 1px;
  background-image: linear-gradient(to right, rgba(251,146,60,0.95) 50%, transparent 50%);
  background-size: 5px 1px;
  background-repeat: repeat-x;
  position: relative;
}
.hp-leg-tri {
  display: inline-block;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid rgba(239,68,68,1);
}

/* RoleMap Frame 1 — JS-render supplements */
.rm-alert-prov { color: var(--text-mid); font-weight: 500; font-size: 13px; margin-left: 6px; }
.rm-alert-more {
  margin: 8px 4px 0; padding: 10px 14px;
  background: rgba(239,68,68,0.08); border: 1px dashed rgba(239,68,68,0.35);
  border-radius: 10px; color: #fca5a5; font-size: 13px; text-align: center;
}
.rm-loading {
  padding: 24px; text-align: center; color: var(--text-mid); font-size: 13px;
  background: rgba(255,255,255,0.02); border: 1px dashed rgba(255,255,255,0.10); border-radius: 12px;
}
.rm-alert-icon svg { width: 26px; height: 26px; color: #fff; }
.rm-alert-btn svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; }

/* ============================================================
 * Live Operations Cinema · Frames 2 & 3
 * ============================================================ */

.rm-frame2, .rm-frame3 {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.rm-f2-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
}
.rm-f2-divider::before,
.rm-f2-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.10), transparent);
}
.rm-f2-divider span {
  font-size: 11px; letter-spacing: 0.18em; font-weight: 700;
  color: #94a3b8;
  padding: 4px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
}

/* ----- Frame 2 layout ----- */
.rm-f2-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
}
.rm-f2-side { display: flex; flex-direction: column; gap: 12px; }
.rm-card {
  background: linear-gradient(180deg, rgba(15,23,42,0.55), rgba(15,23,42,0.30));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px 16px;
}
.rm-card-eyebrow {
  font-size: 10px; letter-spacing: 0.16em; font-weight: 700;
  color: #94a3b8; margin-bottom: 8px;
}
.rm-source-card {
  border-color: rgba(239,68,68,0.4);
  background: linear-gradient(180deg, rgba(239,68,68,0.08), rgba(15,23,42,0.30));
}
.rm-source-name {
  font-size: 17px; font-weight: 800; color: #fff; margin-bottom: 4px;
}
.rm-source-tier {
  font-size: 12px; color: #cbd5e1; margin-bottom: 10px;
}
.rm-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
}
.rm-tag.tag-critical { background: #ef4444; color: #fff; }
.rm-source-meta { display: flex; flex-direction: column; gap: 6px; }
.rm-source-row, .rm-engine-row {
  display: flex; justify-content: space-between; font-size: 12px; color: #cbd5e1;
}
.rm-source-row strong, .rm-engine-row strong { color: #fff; font-weight: 700; }
.rm-engine-name { font-size: 15px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.rm-engine-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.rm-conf { color: #fbbf24 !important; }
.rm-engine-note {
  font-size: 11px; color: #94a3b8; font-style: italic;
  padding-top: 6px; border-top: 1px dashed rgba(255,255,255,0.10);
}
.rm-prop-title { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.rm-prop-track {
  position: relative; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.10);
  margin: 8px 6px 18px;
}
.rm-prop-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #3b82f6, #fb923c 50%, #a855f7);
  opacity: 0.75;
}
.rm-prop-labels {
  display: flex; justify-content: space-between; padding: 0 0px;
  margin-top: -14px;
}
.rm-prop-dot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rm-prop-dot i {
  display: block; width: 10px; height: 10px; border-radius: 50%;
  background: #3b82f6; border: 2px solid #0f172a;
}
.rm-prop-dot.t6 i { background: #fb923c; }
.rm-prop-dot.t12 i { background: #f97316; }
.rm-prop-dot.t24 i { background: #a855f7; }
.rm-prop-dot.tp i { background: #a855f7; }
.rm-prop-dot label { font-size: 10px; color: #94a3b8; }

/* River canvas */
.rm-f2-canvas {
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, rgba(15,23,42,0.45), rgba(15,23,42,0.20));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px;
  min-height: 540px;
}
.rm-f2-header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border: 1px solid rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.06);
  border-radius: 10px;
}
.rm-f2-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.5);
  animation: rmStatePulse 1.8s ease-out infinite;
}
.rm-f2-text strong { display: block; font-size: 12px; letter-spacing: 0.08em; color: #fff; font-weight: 800; }
.rm-f2-text span { display: block; font-size: 12px; color: #cbd5e1; margin-top: 2px; }
.rm-river-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 460px;
}
.rm-river-svg { width: 100%; height: auto; max-height: 540px; }

/* SVG element animations */
.rm-pulse-halo {
  transform-origin: center;
  animation: rmDamHaloPulse 1.6s ease-out infinite;
}
@keyframes rmDamHaloPulse {
  0%   { r: 18; opacity: 0.6; }
  100% { r: 38; opacity: 0;   }
}
.rm-wave-anim.go {
  animation: rmWaveSweep 3.6s cubic-bezier(0.65,0.05,0.35,1) forwards;
}
@keyframes rmWaveSweep {
  from { stroke-dashoffset: var(--rm-wave-len, 1000); opacity: 1; }
  to   { stroke-dashoffset: 0; opacity: 0.85; }
}

/* ----- Frame 3 layout ----- */
.rm-f3-grid {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 14px;
}
.rm-f3-side { display: flex; flex-direction: column; gap: 12px; }
.rm-path-title { font-size: 16px; font-weight: 800; color: #fff; margin-bottom: 12px; }
.rm-path-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.rm-path-row {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center;
}
.rm-path-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #94a3b8; box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.rm-path-row.tone-red .rm-path-dot    { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }
.rm-path-row.tone-orange .rm-path-dot { background: #fb923c; }
.rm-path-row.tone-yellow .rm-path-dot { background: #fbbf24; }
.rm-path-text strong { display: block; font-size: 13px; color: #fff; font-weight: 700; }
.rm-path-text em { display: block; font-size: 11px; color: #94a3b8; font-style: normal; margin-top: 2px; }
.rm-path-time {
  font-size: 11px; font-weight: 700; color: #fb923c;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(251,146,60,0.10);
}
.rm-path-row.tone-red .rm-path-time { color: #fca5a5; background: rgba(239,68,68,0.10); }
.rm-path-row.tone-yellow .rm-path-time { color: #fbbf24; background: rgba(251,191,36,0.10); }
.rm-nwmc-card { border-color: rgba(251,191,36,0.30); }
.rm-nwmc-title { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.rm-nwmc-sub { font-size: 11px; color: #94a3b8; margin-bottom: 10px; }
.rm-nwmc-btn {
  width: 100%; padding: 10px 12px;
  background: #fbbf24; color: #0f172a;
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 800; letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.rm-nwmc-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.rm-nwmc-btn.is-done { background: #22c55e; color: #fff; }

/* Center: fan-out cards */
.rm-f3-center {
  display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, rgba(15,23,42,0.45), rgba(15,23,42,0.20));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
}
.rm-f3-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(255,255,255,0.10);
}
.rm-f3-text strong { display: block; font-size: 12px; letter-spacing: 0.10em; color: #fff; font-weight: 800; }
.rm-f3-text span { display: block; font-size: 11px; color: #94a3b8; margin-top: 2px; }
.rm-f3-pill {
  font-size: 10px; font-weight: 800; letter-spacing: 0.10em;
  color: #22c55e;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.30);
}
.rm-fan-list { display: flex; flex-direction: column; gap: 10px; }
.rm-fan-card {
  display: grid;
  grid-template-columns: 56px 1fr 200px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: rgba(15,23,42,0.55);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.rm-fan-card:hover { transform: translateY(-1px); }
.rm-fan-card.is-selected { border-color: #fbbf24; box-shadow: 0 0 0 2px rgba(251,191,36,0.18); }
.rm-fan-card.tone-red    { border-color: rgba(239,68,68,0.50); }
.rm-fan-card.tone-orange { border-color: rgba(251,146,60,0.45); }
.rm-fan-card.tone-yellow { border-color: rgba(251,191,36,0.45); }
.rm-fan-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
  background: #475569;
}
.rm-fan-card.tone-red .rm-fan-avatar    { background: #ef4444; }
.rm-fan-card.tone-orange .rm-fan-avatar { background: #fb923c; }
.rm-fan-card.tone-yellow .rm-fan-avatar { background: #fbbf24; color: #0f172a; }
.rm-fan-name { font-size: 14px; font-weight: 800; color: #fff; }
.rm-fan-role { font-size: 12px; color: #cbd5e1; margin-top: 1px; }
.rm-fan-org { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.rm-fan-phone { font-size: 12px; color: #38bdf8; margin-top: 4px; font-weight: 600; }
.rm-fan-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.rm-fan-alarm {
  font-size: 11px; font-weight: 700;
  color: #fca5a5;
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.30);
  padding: 3px 10px; border-radius: 999px;
}
.rm-fan-card.tone-orange .rm-fan-alarm { color: #fdba74; background: rgba(251,146,60,0.10); border-color: rgba(251,146,60,0.30); }
.rm-fan-card.tone-yellow .rm-fan-alarm { color: #fde68a; background: rgba(251,191,36,0.10); border-color: rgba(251,191,36,0.30); }
.rm-fan-action {
  padding: 8px 12px;
  font-size: 12px; font-weight: 700;
  border: none; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: filter 0.12s ease;
}
.rm-fan-action .w {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,0.20); font-size: 10px; font-weight: 800;
}
.rm-fan-action.send { background: #22c55e; color: #fff; }
.rm-fan-action.send:hover { filter: brightness(1.08); }
.rm-fan-action.sent { background: rgba(34,197,94,0.18); color: #86efac; border: 1px solid rgba(34,197,94,0.40); }
.rm-fan-action.sent em { font-style: normal; color: #4ade80; margin-left: 2px; }
.rm-fan-action.sent .t { color: #cbd5e1; font-weight: 600; margin-left: 4px; }

/* Right: drafted message panel */
.rm-f3-msg {
  display: flex; flex-direction: column; gap: 12px;
}
.rm-msg-head { display: flex; flex-direction: column; gap: 4px; padding-bottom: 4px; }
.rm-msg-head strong { font-size: 15px; color: #fff; font-weight: 800; }
.rm-msg-en, .rm-msg-lo {
  background: linear-gradient(180deg, rgba(56,189,248,0.06), rgba(15,23,42,0.30));
  border: 1px solid rgba(56,189,248,0.25);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12px; line-height: 1.55; color: #e2e8f0;
  white-space: pre-wrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.rm-msg-lo-wrap { display: flex; flex-direction: column; gap: 6px; }
.rm-msg-lo-head { font-size: 10px; letter-spacing: 0.16em; font-weight: 700; color: #94a3b8; }
.rm-msg-lo {
  border-color: rgba(168,85,247,0.30);
  background: linear-gradient(180deg, rgba(168,85,247,0.06), rgba(15,23,42,0.30));
}
.rm-fb-preview {
  background: linear-gradient(180deg, rgba(15,23,42,0.65), rgba(15,23,42,0.30));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 12px 14px;
  position: relative;
}
.rm-fb-banner {
  margin: 6px 0 12px;
  padding: 8px 12px;
  background: linear-gradient(90deg, #ef4444, #dc2626);
  color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
  border-radius: 8px;
  text-align: center;
}
.rm-fb-rows { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.rm-fb-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.rm-fb-row dt { font-size: 11px; color: #94a3b8; }
.rm-fb-row dd { font-size: 12px; color: #fff; font-weight: 600; margin: 0; }
.rm-fb-stamp {
  position: absolute; right: 12px; bottom: 10px;
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff; color: #0f172a;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}

.rm-f3-footer {
  margin-top: 14px; padding-top: 8px; text-align: right;
  font-size: 10px; letter-spacing: 0.10em; color: #64748b;
}

.rm-allnormal-note {
  margin-top: 22px;
  padding: 14px 18px;
  background: rgba(34,197,94,0.06);
  border: 1px dashed rgba(34,197,94,0.30);
  border-radius: 12px;
  color: #86efac;
  font-size: 12px;
  text-align: center;
}

/* Alert card buttons: ghost style for the two scroll-to-frame buttons */
.rm-alert-btn.ghost {
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  border: 1px solid rgba(255,255,255,0.14);
}
.rm-alert-btn.ghost:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}

/* Mobile */
@media (max-width: 1100px) {
  .rm-f2-grid { grid-template-columns: 1fr; }
  .rm-f3-grid { grid-template-columns: 1fr; }
  .rm-fan-card { grid-template-columns: 48px 1fr; }
  .rm-fan-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  .rm-pulse-halo, .rm-f2-dot { animation: none; }
  .rm-wave-anim.go { animation: none; stroke-dashoffset: 0; opacity: 0.7; }
}

/* ===== Live Ops Cinema: Replay + Send-All buttons ===== */
.rm-f2-header { justify-content: flex-start; }
.rm-f2-text { flex: 1; min-width: 0; }
.rm-replay-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto;
  padding: 6px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  color: #fca5a5;
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.rm-replay-btn svg { width: 12px; height: 12px; display: block; }
.rm-replay-btn:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.55);
  color: #fecaca;
}
.rm-replay-btn:active { transform: translateY(1px); }
.rm-replay-btn.is-flash {
  background: rgba(239,68,68,0.30);
  border-color: rgba(239,68,68,0.70);
}

.rm-f3-actions {
  display: flex; align-items: center; gap: 10px;
}
.rm-sendall-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  color: #fff;
  background: #22c55e;
  border: none; border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34,197,94,0.25);
  transition: filter 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.rm-sendall-btn .w {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,0.20);
  font-size: 10px; font-weight: 800; color: #fff;
}
.rm-sendall-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.rm-sendall-btn:active { transform: translateY(0); }
.rm-sendall-btn.is-done {
  background: rgba(34,197,94,0.18);
  color: #86efac;
  border: 1px solid rgba(34,197,94,0.40);
  box-shadow: none;
  cursor: default;
}
.rm-sendall-btn.is-done .w {
  background: rgba(34,197,94,0.30);
  color: #86efac;
}

@media (max-width: 720px) {
  .rm-f2-header { flex-wrap: wrap; }
  .rm-replay-btn { margin-left: 0; }
  .rm-f3-actions { flex-wrap: wrap; }
  .rm-sendall-btn { padding: 6px 12px; font-size: 11px; }
}

/* ========================================================
 * Data Health sidebar card (Phase 1 reliability layer)
 * ====================================================== */
.data-health-panel {
  margin-top: 12px;
}
.data-health-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.data-health-panel > summary::-webkit-details-marker { display: none; }
.data-health-panel > summary::after {
  content: '▸';
  color: #94a3b8;
  font-size: 11px;
  transition: transform 0.18s ease;
  margin-left: 6px;
}
.data-health-panel[open] > summary::after { transform: rotate(90deg); }
.dh-head h3 {
  margin: 0;
  font-size: 13px;
  color: #e5e7eb;
}
.dh-count {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.30);
}
.dh-count.dh-good {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.40);
}
.dh-count.dh-bad {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.40);
}
.dh-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.dh-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  background: rgba(148, 163, 184, 0.05);
  transition: background 0.12s ease;
}
.dh-row:hover { background: rgba(148, 163, 184, 0.10); }
.dh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dh-dot.dh-ok      { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.45); }
.dh-dot.dh-stale   { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.45); }
.dh-dot.dh-err     { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.50); }
.dh-dot.dh-loading { background: #60a5fa; animation: dhPulse 1.2s infinite; }
.dh-dot.dh-idle    { background: #475569; }
@keyframes dhPulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1.0;  }
}
.dh-label {
  color: #e5e7eb;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dh-age {
  color: #94a3b8;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.dh-trail {
  font-size: 10px;
  letter-spacing: 0.03em;
}
.dh-timing      { color: #64748b; font-variant-numeric: tabular-nums; }
.dh-err-msg     { color: #fca5a5; font-weight: 600; }
.dh-stale-msg   { color: #fbbf24; font-weight: 700; letter-spacing: 0.08em; }
.dh-loading-msg { color: #93c5fd; }

/* ============================================================
   Storm HTML Overlay — Windy-style hurricane glyphs + leader-line labels
   ============================================================ */
.storm-html-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}
.storm-html-overlay svg.storm-leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.storm-center-glyph {
  position: absolute;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.55));
}
.storm-center-glyph svg {
  width: 100%;
  height: 100%;
  animation: stormSwirl 14s linear infinite;
}
@keyframes stormSwirl {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.storm-keystep-label {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid #f97316;
  border-radius: 4px;
  padding: 4px 8px;
  color: #ffe7c2;
  font-size: 11px;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  line-height: 1.25;
  transform: translateY(-50%);
}
.storm-keystep-label .kl-date {
  font-weight: 700;
  color: #ffe7c2;
  letter-spacing: 0.02em;
}
.storm-keystep-label .kl-stats {
  font-size: 10px;
  opacity: 0.85;
  color: #fed7aa;
  margin-top: 1px;
}

/* ============================================================
   Storm Navigator — Detail mode (Gap #6)
   ============================================================ */
.storm-nav.detail-mode {
  /* Slightly wider to accommodate forecast positions list */
}
.storm-nav.detail-mode .sd-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
  background: rgba(15,23,42,0.55);
}
.sd-back {
  background: rgba(148,163,184,0.12);
  border: 1px solid rgba(148,163,184,0.25);
  border-radius: 4px;
  color: #cbd5e1;
  font-size: 16px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s ease;
}
.sd-back:hover { background: rgba(148,163,184,0.22); color: #fff; }
.sd-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.sd-name {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: 0.02em;
}
.sd-body {
  padding: 10px 12px 12px;
  max-height: 60vh;
  overflow-y: auto;
}
.sd-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-bottom: 12px;
}
.sd-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 8px;
  background: rgba(148,163,184,0.06);
  border-radius: 4px;
}
.sd-meta-k {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  font-weight: 600;
}
.sd-meta-v {
  font-size: 12px;
  color: #e5e7eb;
  font-variant-numeric: tabular-nums;
}
.sd-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  font-weight: 700;
  margin: 6px 0 4px;
}
.sd-positions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sd-row {
  display: grid;
  grid-template-columns: 12px 52px 1fr 56px 64px;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(148,163,184,0.05);
  border: 1px solid rgba(148,163,184,0.08);
  border-radius: 4px;
  font-size: 11px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  color: #e5e7eb;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.sd-row:hover {
  background: rgba(249,115,22,0.10);
  border-color: rgba(249,115,22,0.35);
}
.sd-row.active {
  background: rgba(249,115,22,0.20);
  border-color: #f97316;
}
.sd-row.sd-obs { border-left: 3px solid #22c55e; }
.sd-row.sd-fcst { border-left: 3px solid #94a3b8; }
.sd-keystep-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 4px rgba(249,115,22,0.6);
  display: inline-block;
}
.sd-keystep-dot.empty {
  background: transparent;
  box-shadow: none;
}
.sd-fh {
  font-weight: 700;
  color: #ffe7c2;
  font-size: 10.5px;
}
.sd-vt {
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-wind { color: #fed7aa; font-weight: 600; text-align: right; }
.sd-pres { color: #94a3b8; text-align: right; }
.sd-empty {
  padding: 16px 8px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
}
