/* ==========================================================================
   Design System & Root Variable Declarations
   ========================================================================== */
:root {
  --bg-app: #080b11;
  --bg-card: #0f141f;
  --bg-card-hover: #141b2a;
  --bg-input: #171f30;
  
  --border-color: rgba(255, 255, 255, 0.05);
  --border-color-glow: rgba(56, 189, 248, 0.2);
  
  /* Color Palette - HSL Custom Coordinates */
  --primary: hsl(217, 91%, 60%);
  --primary-glow: hsla(217, 91%, 60%, 0.15);
  
  --success: hsl(142, 76%, 45%);
  --success-glow: hsla(142, 76%, 45%, 0.15);
  
  --warning: hsl(38, 92%, 50%);
  --warning-glow: hsla(38, 92%, 50%, 0.15);
  
  --danger: hsl(354, 76%, 52%);
  --danger-glow: hsla(354, 76%, 52%, 0.15);

  --critical: hsl(290, 80%, 50%);
  --critical-glow: hsla(290, 80%, 50%, 0.15);
  
  --text-main: hsl(210, 40%, 98%);
  --text-muted: hsl(215, 20%, 65%);
  --text-dark: hsl(215, 15%, 55%);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   App Layout
   ========================================================================== */
.dashboard-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  gap: 1.5rem;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2.25rem;
  height: 2.25rem;
  filter: drop-shadow(0 0 8px hsla(217, 91%, 60%, 0.4));
}

.brand-text h1 {
  font-size: 1.35rem;
  color: var(--text-main);
  line-height: 1.1;
}

.sub-brand {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.system-time {
  text-align: right;
}

.meta-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-dark);
  letter-spacing: 0.05em;
}

.meta-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.led-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  transition: all var(--transition-normal);
}

.led-dot.warning-mode {
  background-color: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.led-dot.danger-mode {
  background-color: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}

/* Main Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.main-column, .sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ==========================================================================
   Component Cards
   ========================================================================== */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  border-color: var(--border-color-glow);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  font-size: 1rem;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

/* Legend items in map header */
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.75rem;
}

.legend-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}
.legend-dot.low { background-color: var(--success); }
.legend-dot.warning { background-color: var(--warning); }
.legend-dot.danger { background-color: var(--danger); }
.legend-dot.critical { background-color: var(--critical); }

/* ==========================================================================
   Basin Risk Map Area
   ========================================================================== */
.map-container {
  position: relative;
  min-height: 380px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.map-svg {
  width: 100%;
  height: 100%;
  max-height: 400px;
}

/* Map SVG styling */
.river-path {
  stroke: hsl(205, 80%, 40%);
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 8 4;
  animation: flowAnimation 30s linear infinite;
  transition: stroke var(--transition-normal), stroke-width var(--transition-normal);
}

.river-path.flow-high {
  stroke: hsl(205, 90%, 55%);
  stroke-dasharray: 6 3;
  animation: flowAnimation 15s linear infinite;
}

.river-path.flow-halted {
  stroke: hsl(210, 15%, 25%);
  animation: none;
}

.tributary-path {
  stroke: hsl(205, 60%, 30%);
  stroke-width: 2.5;
  stroke-linecap: round;
  fill: none;
}

.tributary-path.flow-halted {
  stroke: hsl(210, 15%, 20%);
}

.muni-node {
  cursor: pointer;
  transition: transform var(--transition-normal), filter var(--transition-normal);
}

.muni-node:hover {
  transform: scale(1.15);
  filter: brightness(1.2) drop-shadow(0 0 8px currentColor);
}

.muni-node-ring {
  stroke: #ffffff;
  stroke-width: 1.5;
  fill: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.muni-node:hover .muni-node-ring,
.muni-node.selected .muni-node-ring {
  opacity: 1;
}

.muni-text {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
  transition: fill var(--transition-fast);
}

.muni-node:hover .muni-text,
.muni-node.selected .muni-text {
  fill: var(--text-main);
  font-weight: 700;
}

/* Detail Drawer (Telemetry display below map) */
.detail-drawer {
  background-color: rgba(255, 255, 255, 0.01);
  border-top: 1px solid var(--border-color);
  padding: 1.25rem;
}

.drawer-instruction {
  font-size: 0.8rem;
  color: var(--text-dark);
  text-align: center;
  font-style: italic;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
}

.drawer-muni-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drawer-metric {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.drawer-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.drawer-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
}

/* ==========================================================================
   Alert Area
   ========================================================================== */
.alerts-panel {
  flex-grow: 1;
}

.alert-list {
  max-height: none;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-error {
  background-color: var(--danger-glow);
  color: var(--danger);
  border: 1px solid hsla(354, 76%, 52%, 0.3);
}

.empty-alerts {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 0;
  font-style: italic;
}

.alert-card {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.01);
  border-left: 4px solid var(--primary);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  transition: transform var(--transition-fast);
}

.alert-card:hover {
  transform: translateX(4px);
}

.alert-card.alert-critical {
  border-left-color: var(--critical);
  background-color: var(--critical-glow);
}

.alert-card.alert-danger {
  border-left-color: var(--danger);
  background-color: var(--danger-glow);
}

.alert-card.alert-warning {
  border-left-color: var(--warning);
  background-color: var(--warning-glow);
}

.alert-card.alert-low {
  border-left-color: var(--success);
  background-color: var(--success-glow);
}

.alert-icon-wrapper {
  color: inherit;
  flex-shrink: 0;
}

.alert-info {
  flex-grow: 1;
}

.alert-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.alert-muni {
  font-weight: 600;
  font-size: 0.9rem;
}

.alert-type {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.alert-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.alert-meta {
  margin-top: 0.5rem;
  display: flex;
  gap: 1rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-dark);
}

/* ==========================================================================
   Pipeline Status & Telemetry
   ========================================================================== */
.connector-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background-color: var(--success-glow);
  color: var(--success);
  border: 1px solid hsla(142, 76%, 45%, 0.2);
  transition: all var(--transition-normal);
}

.connector-badge.broken {
  background-color: var(--danger-glow);
  color: var(--danger);
  border-color: hsla(354, 76%, 52%, 0.2);
}

.status-metric-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.metric-card {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.metric-val {
  font-size: 1.15rem;
  font-family: var(--font-mono);
  font-weight: 600;
  transition: color var(--transition-normal);
}

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-info { color: var(--primary); }

.sync-progress-bar {
  height: 3px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  box-shadow: 0 0 8px var(--primary);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.progress-bar-fill.halted {
  background: var(--text-dark);
  box-shadow: none;
  width: 0% !important;
}

/* ==========================================================================
   Break Feed Control Panel
   ========================================================================== */
.control-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  /* Explicit text color: buttons without a variant otherwise fall back to
     the UA default (black), invisible on this dark theme. */
  color: var(--text-main);
  border: 1px solid transparent;
  background-color: transparent;
  transition: all var(--transition-normal);
}

.btn-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.btn-danger {
  color: var(--text-main);
  background-color: var(--danger-glow);
  border-color: hsla(354, 76%, 52%, 0.3);
}

.btn-danger:hover {
  background-color: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 0 15px hsla(354, 76%, 52%, 0.4);
}

.btn-success {
  color: var(--text-main);
  background-color: var(--success-glow);
  border-color: hsla(142, 76%, 45%, 0.3);
}

.btn-success:hover {
  background-color: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 15px hsla(142, 76%, 45%, 0.4);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Console Log Panel
   ========================================================================== */
.log-console {
  background-color: #05070a;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  height: 120px;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log-line {
  line-height: 1.3;
  color: var(--text-muted);
}

.log-line.system { color: var(--text-muted); }
.log-line.telemetry { color: var(--success); }
.log-line.error { color: var(--danger); }
.log-line.warn { color: var(--warning); }
.log-line.action { color: var(--primary); }

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dark);
  padding: 1.5rem 0 0.5rem 0;
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes flowAnimation {
  0% {
    stroke-dashoffset: 24;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.pulse-slow {
  animation: pulseGrad 4s ease infinite;
}

@keyframes pulseGrad {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.75;
  }
}

.api-offline-banner {
  background-color: var(--danger);
  color: var(--text-main);
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 9999;
}

.broadcast-box {
  margin-top: 1rem;
  background-color: #06080e;
  border: 1px solid rgba(244, 63, 94, 0.2);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.broadcast-box.empty {
  border-color: var(--border-color);
  background-color: rgba(255, 255, 255, 0.01);
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.broadcast-header {
  background-color: rgba(244, 63, 94, 0.1);
  border-bottom: 1px solid rgba(244, 63, 94, 0.2);
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.broadcast-tag {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--danger);
  letter-spacing: 0.05em;
}

.broadcast-status {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--danger);
  text-shadow: 0 0 4px var(--danger);
}

.broadcast-text {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.4;
  margin: 0;
  max-height: 180px;
  overflow-y: auto;
}

/* Plain-language public advisory (replaces the technical broadcast in
   Public Alert mode). */
.advisory-plain {
  padding: 1rem;
}

.advisory-line {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.5;
  margin: 0 0 0.6rem 0;
}

.advisory-line:last-child {
  margin-bottom: 0;
}

.advisory-source {
  font-size: 0.75rem;
  color: var(--text-muted);
}


/* Google Maps Loader and UI Additions */
.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(7, 9, 15, 0.85);
  z-index: 10;
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}
.map-loading-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.drawer-hazard-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.hazard-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid;
}
.hazard-pill.dominant {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.3);
}
.hazard-pill.secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border-color: var(--border-color);
}

/* ==========================================================================
   Redesign Classes & Tokenized Styles
   ========================================================================== */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.basin-selector-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

.basin-select {
  background: #0d131f;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.google-map {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.connectors-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.connector-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.01);
  transition: border-color var(--transition-normal);
}

.connector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.connector-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.connector-details-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 0.5rem;
  font-size: 0.7rem;
  margin-bottom: 0.75rem;
}

.connector-detail-label {
  color: var(--text-dark);
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
}

.connector-detail-value {
  font-weight: 500;
  font-family: var(--font-mono);
}

.connector-detail-value.freshness {
  font-weight: 600;
}

.connector-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-connector {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
  border-radius: 4px;
}

.notification-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-description-compact {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.btn-full-width {
  width: 100%;
}

.token-display-box {
  background: #05070a;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  word-break: break-all;
}

.token-label {
  color: var(--text-dark);
  display: block;
  font-size: 0.55rem;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.token-code {
  color: var(--warning);
}

.btn-token-copy {
  width: 100%;
  padding: 0.25rem;
  font-size: 0.65rem;
  margin-top: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
}

.badge-demo-optin {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--primary);
}

.badge-autonomous {
  background-color: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.badge-autonomous-mini {
  background-color: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  font-size: 0.55rem;
  padding: 0.05rem 0.25rem;
  margin-left: 0.25rem;
  border-radius: 3px;
}

.logs-container-max-150 {
  max-height: 150px;
  overflow-y: auto;
}

.logs-container-max-180 {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.muni-detail-header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.muni-hazard-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.civil-advisory-badge {
  font-weight: 800;
  font-size: 0.7rem;
  border: 1px solid var(--danger);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.alert-meta-row {
  margin-top: 0.6rem;
}

.heal-log-item {
  border-left: 2px solid var(--success);
  padding-left: 0.5rem;
  margin-bottom: 0.25rem;
}

.heal-log-time {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.heal-log-label {
  color: var(--success);
}

.heal-log-details {
  color: var(--text-dark);
}

.incident-log-item {
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.incident-log-item.reopened {
  background: rgba(255, 255, 255, 0.02);
}

.incident-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.incident-log-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.incident-log-status-badge {
  font-size: 0.65rem;
  color: var(--danger);
  font-weight: bold;
}

.btn-incident-reopen {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  font-size: 0.72rem;
  padding: 0.4rem 0.85rem;
  min-height: 44px;
  min-width: 64px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-incident-reopen:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.incident-log-details {
  font-size: 0.75rem;
  color: var(--text-dark);
  line-height: 1.2;
}

.badge-low {
  background-color: var(--success-glow);
  color: var(--success);
}

.badge-warning {
  background-color: var(--warning-glow);
  color: var(--warning);
}

.badge-danger {
  background-color: var(--danger-glow);
  color: var(--danger);
}

.badge-critical {
  background-color: var(--critical-glow);
  color: var(--critical);
}

.text-critical {
  color: var(--critical);
}

/* Hazard SVGs in layout */
.hazard-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

/* Severity SVGs in layout */
.severity-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  display: inline-block;
}

.card-footer-compact {
  padding: 0 1.25rem 1.25rem 1.25rem;
}

.btn-return-live {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.border-low {
  border-left: 2px solid var(--success);
}
.border-warning {
  border-left: 2px solid var(--warning);
}
.border-danger {
  border-left: 2px solid var(--danger);
}
.border-critical {
  border-left: 2px solid var(--critical);
}

/* Mode switching styling */
.mode-switch-wrapper {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.25rem;
  gap: 0.25rem;
  margin-left: 1rem;
}

.mode-switch-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-switch-btn:hover {
  color: var(--text-main);
}

.mode-switch-btn.active {
  background: var(--primary);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

.btn-diagnostics {
  background: rgba(56, 189, 248, 0.1);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.2);
}
.btn-diagnostics:hover {
  background: var(--primary);
  color: var(--text-main);
}

/* Visibility switches */
.dashboard-wrapper.mode-operations .ops-panels-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  grid-column: 1 / -1;
}

.dashboard-wrapper.mode-operations .public-panels-container,
.dashboard-wrapper.mode-operations .muni-select-dropdown {
  display: none !important;
}

.dashboard-wrapper.mode-public .public-panels-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  grid-column: 1 / -1;
}

/* Residents pick their municipality, not a watershed: the basin scope is an
   operator concept and stays in Operations mode only. */
.dashboard-wrapper.mode-public .basin-select-dropdown {
  display: none !important;
}

.dashboard-wrapper.mode-public .ops-panels-container,
.dashboard-wrapper.mode-public .system-time,
.dashboard-wrapper.mode-public .sync-indicator,
.dashboard-wrapper.mode-public .btn-diagnostics {
  display: none !important;
}

@media (max-width: 1024px) {
  .dashboard-wrapper.mode-public .public-panels-container {
    grid-template-columns: 1fr;
  }
}

/* Slide-out Panel CSS */
.diagnostics-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.diagnostics-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.diagnostics-slideout {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  transition: right var(--transition-normal);
  display: flex;
  flex-direction: column;
}
.diagnostics-slideout.open {
  right: 0;
}

/* Public Mode Specific Styles */
.public-hero-card {
  padding: 2.5rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.public-hero-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.public-hero-status {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.public-hero-desc {
  font-size: 1.1rem;
  color: var(--text-main);
  max-width: 500px;
  line-height: 1.5;
}
.public-hero-timestamp {
  font-size: 0.8rem;
  color: var(--text-dark);
  font-family: var(--font-mono);
}

.guidance-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.guidance-title {
  font-size: 1.1rem;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}
.guidance-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.guidance-item {
  display: flex;
  gap: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-muted);
}
.guidance-item-bullet {
  color: var(--primary);
  font-weight: bold;
}

.plain-warnings-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.plain-warning-card {
  padding: 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
}
.plain-warning-title {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}
.plain-warning-body {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.map-wrapper {
  flex: 1;
  position: relative;
  min-height: 380px;
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.map-panel-split {
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem;
}

.detail-rail {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 768px) {
  .map-panel-split {
    flex-direction: column;
  }
  .detail-rail {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-left: 0;
    padding-top: 1.5rem;
  }
}

@media (max-width: 1024px) {
  .basin-selector-wrapper {
    margin-left: 0;
  }
  .header-meta {
    margin-left: auto;
  }
}

@media (max-width: 768px) {
  .mode-switch-wrapper {
    margin-left: 0;
  }
  .header-meta {
    margin-left: 0;
    width: 100%;
  }
}

/* Tooltip system */
.tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tooltip-trigger {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0 -12px 0 0; /* adjust for layout centering, giving a nice touch area */
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  color: var(--text-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.tooltip-trigger:hover,
.tooltip-trigger:focus-visible {
  color: var(--primary);
}

.info-icon {
  width: 1rem;
  height: 1rem;
}

.tooltip-content {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color-glow);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: opacity var(--transition-fast) ease, transform var(--transition-fast) ease;
  text-align: left;
}

.tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--bg-input) transparent transparent transparent;
}

.tooltip-wrapper:hover .tooltip-content,
.tooltip-wrapper:focus-within .tooltip-content,
.tooltip-trigger:focus .tooltip-content {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-4px);
}

@media (prefers-reduced-motion: reduce) {
  .tooltip-content {
    transition: none !important;
  }
  .bullet-gauge-fill,
  .sub-score-fill {
    transition: none !important;
    animation: none !important;
  }
}

/* Detail cards */
.composite-risk-card,
.bullet-gauge-card,
.sub-scores-card {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.detail-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 1.5rem; /* helps align triggers cleanly */
}

.detail-section-header .drawer-label {
  margin-bottom: 0; /* override original margin */
}

/* Composite Risk display */
.risk-percentage-display {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.risk-percentage-num {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.risk-percentage-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Bullet gauge */
.bullet-gauge-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
}

.bullet-gauge-text-val {
  color: var(--text-muted);
}

.bullet-gauge-text-val strong {
  color: var(--text-main);
  font-weight: 700;
}

.bullet-gauge-pct {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.gauge-exceeded-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--danger);
  letter-spacing: 0.05em;
}

.bullet-gauge-track {
  position: relative;
  height: 10px;
  background-color: var(--bg-input);
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  overflow: visible; /* so target line can stand out nicely if needed */
}

.bullet-gauge-fill {
  height: 100%;
  border-radius: 9999px;
  background-color: var(--primary);
  width: 0%;
  transition: width var(--transition-normal);
}

.bullet-gauge-fill.exceeded {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.bullet-gauge-target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  background-color: var(--text-main);
  border-radius: 9999px;
  transform: translateX(-50%);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  z-index: 2;
}

/* Hazard sub-score bars */
.sub-score-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sub-score-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.sub-score-icon-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-weight: 500;
}

.sub-score-icon-label .hazard-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.sub-score-val {
  font-weight: 700;
  color: var(--text-main);
}

.sub-score-track {
  height: 6px;
  background-color: var(--bg-input);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.sub-score-fill {
  height: 100%;
  border-radius: 9999px;
  width: 0%;
  transition: width var(--transition-normal);
}

.flood-fill {
  background-color: var(--primary);
}

.landslide-fill {
  background-color: var(--warning);
}

.seismic-fill {
  background-color: var(--critical);
}

.drawer-divider {
  grid-column: 1 / -1;
  height: 1px;
  background-color: var(--border-color);
  margin: 0.5rem 0;
}

/* ==========================================================================
   Step 4: Accessibility — Focus Rings, Interactive States, Target Sizes
   ========================================================================== */

/* Global focus-visible ring */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Ensure base interactive elements meet 44px minimum */
.btn,
.mode-switch-btn,
.slideout-close-btn {
  min-height: 44px;
}

.mode-switch-btn {
  min-width: 44px;
}

.btn-sm {
  min-height: 44px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* basin-select and inline select: 44px height */
.basin-select {
  min-height: 44px;
  padding-top: 0;
  padding-bottom: 0;
}

/* Active tactile feedback */
.btn:active,
.mode-switch-btn:active {
  transform: scale(0.97);
  filter: brightness(0.9);
}

/* Disabled state */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* basin-select focus ring */
.basin-select:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
}

/* Slideout close button */
.slideout-close-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}
.slideout-close-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.06); }
.slideout-close-btn:active { background: rgba(255,255,255,0.12); }

/* Slideout structural styles */
.slideout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.slideout-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Keep slideout cards at natural height; the panel scrolls instead of
   compressing cards (which clipped their content, e.g. the demo buttons). */
.slideout-body > .card {
  flex-shrink: 0;
}

/* ==========================================================================
   Step 4: Selector Labels
   ========================================================================== */
.selector-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.selector-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dark);
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

/* ==========================================================================
   Step 4: Skeleton Loaders
   ========================================================================== */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

span.skeleton-block {
  display: inline-block;
}

.skeleton-block {
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.map-skeleton {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 90%;
  max-width: 400px;
}

.skeleton-map-bg {
  width: 100%;
  height: 200px;
  border-radius: 8px;
}

.skeleton-row {
  display: flex;
  gap: 0.5rem;
}

.skeleton-pill {
  height: 28px;
  width: 80px;
  border-radius: 9999px;
}

.skeleton-connector-card {
  padding: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.skeleton-title  { height: 14px; width: 55%; }
.skeleton-text   { height: 11px; width: 80%; }
.skeleton-text-short { width: 45%; }

/* ==========================================================================
   Step 4: Comprehensive prefers-reduced-motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:       0.01ms !important;
    animation-iteration-count: 1     !important;
    transition-duration:      0.01ms !important;
    scroll-behavior:          auto   !important;
  }
  .skeleton-block {
    animation: none;
    background: rgba(255,255,255,0.06);
  }
  .river-path { animation: none; stroke-dashoffset: 0; }
  .pulse-slow  { animation: none; }
  .diagnostics-slideout,
  .diagnostics-overlay { transition: none; }
  .bullet-gauge-fill,
  .sub-score-fill { transition: none; }
  .tooltip-content { transition: none; }
}

/* ==========================================================================
   Step 4: Mobile-First Responsive Breakpoints
   ========================================================================== */

/* ≤ 480px — phones (375 target) */
@media (max-width: 480px) {
  .dashboard-wrapper {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .app-header {
    gap: 0.75rem 0.75rem;
    padding-bottom: 0.75rem;
  }

  .brand-text h1 { font-size: 1.1rem; }
  .sub-brand { display: none; }
  .logo-icon { width: 1.75rem; height: 1.75rem; }

  .mode-switch-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
  }

  /* Selectors stack full-width */
  .basin-selector-wrapper {
    flex-direction: column;
    gap: 0.75rem;
    margin-left: 0;
    width: 100%;
  }

  .selector-group { width: 100%; }
  .basin-select   { width: 100%; }

  /* Public mode: single column always */
  .dashboard-wrapper.mode-public .public-panels-container {
    grid-template-columns: 1fr !important;
  }

  .public-hero-status { font-size: 2.25rem; }
  .public-hero-desc   { font-size: 0.95rem; }
  .public-hero-card   { padding: 1.5rem 1rem; }
  .guidance-card      { padding: 1rem; }

  /* Map & rail */
  .map-panel-split {
    flex-direction: column;
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .detail-rail {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-left: 0;
    padding-top: 1rem;
  }

  .map-wrapper { min-height: 0; }
  .google-map { height: 260px; }

  /* Full-width diagnostics panel */
  .diagnostics-slideout {
    width: 100%;
    right: -100%;
  }

  .btn-full-width { padding: 0.9rem 1rem; }
}

/* 481 – 768px — small tablets */
@media (min-width: 481px) and (max-width: 768px) {
  .dashboard-wrapper { padding: 1rem; }
  .basin-selector-wrapper { margin-left: 0; }
  .dashboard-wrapper.mode-public .public-panels-container {
    grid-template-columns: 1fr;
  }
}

/* ≥ 1440px — wide desktops */
@media (min-width: 1440px) {
  .dashboard-wrapper {
    padding: 2rem 3rem;
  }
  .app-header {
    gap: 1rem 2rem;
  }
}




/* ==========================================================================
   Public Alert additions: structured 5-element alert card,
   "This is your area" map, historical context + uphill directive
   ========================================================================== */
.public-alert-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.alert-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.25rem;
  margin: 0;
}

.alert-field { margin: 0; }
.alert-field-wide { grid-column: 1 / -1; }

.alert-field-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.alert-field-value {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text-main);
}

.alert-context-line {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.45;
}

.alert-uphill-line {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.alert-uphill-line[hidden] { display: none; }

.public-map-card {
  grid-column: 1 / -1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.public-map-wrapper {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.public-map { width: 100%; height: 100%; }

.public-map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.public-map-loading.hidden { display: none; }

/* ==========================================================================
   Nearest hospital / safe point + walking route
   ========================================================================== */
.safe-route-card {
  grid-column: 1 / -1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.safe-route-disclaimer {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.btn-safe-route {
  align-self: flex-start;
  min-height: 44px;
  min-width: 44px;
  padding: 0.75rem 1.25rem;
  color: var(--text-main);
  background-color: var(--primary-glow);
  border-color: hsla(217, 91%, 60%, 0.35);
}

.btn-safe-route:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 15px hsla(217, 91%, 60%, 0.4);
}

.btn-safe-route:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-safe-route[aria-busy="true"] { opacity: 0.7; cursor: progress; }
.btn-safe-route:disabled { cursor: not-allowed; }

.safe-route-result { display: flex; flex-direction: column; gap: 0.75rem; }

.safe-route-status {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-main);
}

.safe-route-detail[hidden] { display: none; }

.safe-route-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.safe-route-dest {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.safe-route-meta {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.safe-route-directions { margin: 0; }

.safe-route-steps {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 260px;
  overflow-y: auto;
}

.safe-route-step {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-main);
}

@media (max-width: 600px) {
  .alert-field-grid { grid-template-columns: 1fr; }
  .public-map-wrapper { height: 280px; }
  .btn-safe-route { align-self: stretch; }
}

/* ==========================================================================
   Live Seismic Activity panel + Demo Controls (additive)
   ========================================================================== */
.badge-live-usgs {
  background-color: rgba(56, 189, 248, 0.1);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-simulated {
  background-color: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.seismic-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 320px;
  overflow-y: auto;
}

.seismic-event-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.01);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.seismic-event-row.simulated {
  background-color: rgba(245, 158, 11, 0.04);
}

.seismic-mag {
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 3.4rem;
  text-align: center;
}

.seismic-event-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.seismic-event-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.seismic-source-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #38bdf8;
}

.seismic-event-place {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seismic-event-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.demo-controls-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.demo-controls-status {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1em;
}

/* ==========================================================================
   Live Risk Timeline panel (additive)
   ========================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.risk-timeline-meta {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.risk-timeline-muni {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.risk-timeline-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.risk-timeline-chart {
  position: relative;
  height: 150px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* River & rainfall trend panel reuses the timeline chart frame. */
.telemetry-trend-chart {
  position: relative;
  height: 170px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.telemetry-trend-chart:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.telemetry-trend-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.trend-provenance {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.trend-legend {
  position: absolute;
  top: 6px;
  left: 8px;
  display: flex;
  gap: 0.8rem;
  font-size: 0.62rem;
  color: var(--text-muted);
}

.trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.trend-swatch {
  width: 10px;
  height: 3px;
  border-radius: 1px;
  display: inline-block;
}

.trend-kpi-notes {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.telemetry-trend-chart .trend-kpi-notes {
  position: absolute;
  left: 10px;
  bottom: 18px;
}

.trend-time-axis {
  position: absolute;
  bottom: 4px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  color: var(--text-dark);
  pointer-events: none;
}

.trend-swatch-river { background: #38bdf8; }
.trend-swatch-rain { background: var(--primary); opacity: 0.55; height: 8px; width: 6px; }
.trend-swatch-discharge { background: #34d399; }
.trend-swatch-soil { background: #a78bfa; }
.trend-swatch-threshold { background: #ef4444; }

/* C3: data-table fallbacks for the charts. */
.chart-table-toggle {
  min-height: 32px;
}

.chart-table-wrap {
  margin-top: 0.6rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  max-height: 240px;
  overflow-y: auto;
}

/* The flex rule above would otherwise override the hidden attribute. */
.chart-table-wrap[hidden] {
  display: none;
}

.chart-table {
  border-collapse: collapse;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.chart-table caption {
  text-align: left;
  font-size: 0.65rem;
  color: var(--text-dark);
  padding-bottom: 0.3rem;
}

.chart-table th,
.chart-table td {
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.9rem;
  text-align: left;
  min-width: 110px;
}

.chart-table td.tabular-nums,
.chart-table th.num {
  text-align: right;
}

.chart-table th {
  color: var(--text-main);
  font-weight: 600;
}

.chart-table-note {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.risk-timeline-chart:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.risk-timeline-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.risk-timeline-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.risk-timeline-band-labels {
  position: absolute;
  top: 0;
  right: 6px;
  height: 100%;
  pointer-events: none;
}

.risk-timeline-band-labels .band-label {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.risk-timeline-band-labels .band-label.critical { top: 20%; color: #a855f7; }
.risk-timeline-band-labels .band-label.danger   { top: 40%; color: #ef4444; }
.risk-timeline-band-labels .band-label.warning  { top: 60%; color: #f59e0b; }

@media (prefers-reduced-motion: no-preference) {
  .risk-timeline-line-animated {
    animation: risk-line-fade 0.45s ease-out;
  }
}

@keyframes risk-line-fade {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

/* ==========================================================================
   Map overlay states + tooltip edge handling (additive)
   ========================================================================== */
.map-overlay-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

/* Arrow follows the JS-computed horizontal offset; falls back to centered. */
.tooltip-content::after {
  left: var(--tooltip-arrow-x, 50%);
}

/* Flipped tooltip (shown below the trigger): arrow sits on top, pointing up. */
.tooltip-content.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-color: transparent transparent var(--bg-input) transparent;
}

@media (prefers-reduced-motion: reduce) {
  .map-loading-spinner {
    animation: none !important;
  }
}

/* ==========================================================================
   Live Seismic Events feed (clickable rows + active regions + seismic focus)
   ========================================================================== */
.seismic-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.seismic-regions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.seismic-regions[hidden] {
  display: none;
}

/* Context chips in the 30-day row are informational, not interactive. */
.seismic-region-chip.context {
  cursor: default;
  min-height: 0;
}

/* Scope strip: the page's live navigation. min-width 0 across this chain:
   the strip's intrinsic chip width must never widen the page (it was forcing
   a ~750px-wide body on phones). */
.ops-panels-container {
  min-width: 0;
}

.scope-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  min-width: 0;
  max-width: 100%;
  /* Themed scrollbar: the OS default bar broke the dark styling. */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.scope-strip::-webkit-scrollbar {
  height: 6px;
}

.scope-strip::-webkit-scrollbar-track {
  background: transparent;
}

.scope-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.scope-strip::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Public area cards reuse the scope-item look, slightly smaller. */
.public-area-section {
  grid-column: 1 / -1;
}

.public-area-caption {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0 0 0.4rem 0;
}

.public-area-item {
  min-height: 48px;
}

.scope-item {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  flex: 0 0 auto;
  min-height: 52px;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  border-left-width: 3px;
  background-color: var(--bg-card, rgba(255, 255, 255, 0.02));
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.scope-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.scope-item.active {
  background-color: rgba(79, 142, 247, 0.14);
  border-color: var(--primary);
}

.scope-item.active .scope-item-name {
  color: var(--primary);
}

.scope-item-name {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-main);
}

.scope-item-meta {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.scope-basin {
  border-left-width: 3px;
  border-left-color: var(--success);
}

/* Scope chips on basin-scoped panels (G2). */
.scope-chip {
  background-color: rgba(52, 211, 153, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 0.6rem;
}

/* Basin-only panels vanish while a seismic scope owns the page: information
   stays consequent with the selection (G2, hardened after user feedback). */
.card.scope-hidden {
  display: none;
}

/* Charts sit side by side on wide screens to shorten the page. */
.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .charts-row {
    grid-template-columns: 1fr 1fr;
  }
}

.seismic-regions:empty {
  display: none;
}

.seismic-region-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.3rem 0.6rem;
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  border-left-width: 3px;
  background-color: rgba(255, 255, 255, 0.02);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.seismic-region-chip:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.seismic-region-chip.active {
  background-color: rgba(79, 142, 247, 0.12);
  border-color: var(--primary);
}

.seismic-region-chip.active .seismic-region-name {
  color: var(--primary);
}

.seismic-regions-toggle {
  justify-content: center;
  border-left-width: 1px;
}

.seismic-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.5rem;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.seismic-filter-clear {
  min-height: 32px;
}

.seismic-region-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-main);
}

.seismic-region-meta {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* Feed rows are real buttons now: reset button chrome, keep the row look. */
button.seismic-event-row {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  transition: background-color 120ms ease;
}

button.seismic-event-row:hover {
  background-color: rgba(56, 189, 248, 0.06);
}

button.seismic-event-row.simulated:hover {
  background-color: rgba(245, 158, 11, 0.08);
}

button.seismic-event-row:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* Transient seismic-focus view in the detail rail */
/* The rail is narrow: the drawer's auto-fit multi-column grid fragments the
   focus content into cramped cells, so the focus uses one column. */
.drawer-grid.seismic-focus-rail {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.seismic-focus-rail .drawer-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.seismic-focus-rail .drawer-metric .drawer-val {
  text-align: right;
}

.seismic-focus-return {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.seismic-focus-return:hover {
  background-color: rgba(255, 255, 255, 0.09);
}

.badge-seismic-focus {
  background-color: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.seismic-focus-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.seismic-focus-close {
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.seismic-focus-close:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.seismic-focus-close:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.seismic-focus-place {
  margin: 0;
}

.seismic-focus-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.seismic-focus-mag {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.seismic-focus-mag-num {
  font-size: 1.8rem;
  font-weight: 700;
}

.seismic-focus-mag-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.seismic-focus-narration {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
}

.seismic-focus-narration p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-main);
}

.seismic-focus-note {
  margin: 0;
  font-size: 0.7rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Conditions at the epicenter (focus rail + public event view). */
.epicenter-conditions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
  text-align: left;
}

.condition-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-main);
}

.condition-source {
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  button.seismic-event-row {
    transition: none;
  }
}

/* Rain component bar + subtle drawer text (index rail) */
.sub-score-fill.rain-fill { background: linear-gradient(90deg, #38bdf8, #60a5fa); }
.drawer-subtle { color: var(--text-muted); font-size: 0.85em; }

/* Candidate watchlist panel (read-only ranked candidates) */
.watchlist-row {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}
.watchlist-row-main { display: flex; align-items: center; gap: 8px; }
.watchlist-name { font-weight: 600; }
.watchlist-country { color: var(--text-muted); font-size: 0.85em; }
.watchlist-badge {
  font-size: 0.65em; border: 1px solid var(--border-color-glow);
  color: var(--text-muted); padding: 1px 6px;
}
.watchlist-badge-warn { border-color: rgba(210, 153, 34, 0.6); color: #d29922; }
.watchlist-row-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--text-muted); font-size: 0.85em;
}
.watchlist-bar {
  display: inline-block; width: 72px; height: 7px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.06); overflow: hidden;
}
.watchlist-bar i { display: block; height: 100%; }
.watchlist-score { font-weight: 600; }
.watchlist-computed-at { color: var(--text-muted); font-size: 0.8em; }
.watchlist-footnote {
  color: var(--text-muted); font-size: 0.78em; margin: 0;
  padding: 8px 16px 12px; border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   NEW UNIFIED INDEX UI (next.html / Phase A) — shares tokens with the
   legacy page; legacy selectors above remain untouched until cutover.
   ========================================================================== */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.4rem; border-bottom: 1px solid var(--border-color);
}
.app-header h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.12em; }
.header-tagline { color: var(--text-muted); font-size: 0.8rem; margin-left: 0.6rem; }
.header-meta { display: flex; align-items: center; gap: 0.8rem; }
.app-footer {
  padding: 0.8rem 1.4rem; color: var(--text-muted); font-size: 0.75rem;
  border-top: 1px solid var(--border-color);
}
#index-view, #detail-view { padding: 1.1rem 1.4rem; }
.index-toolbar { margin-bottom: 0.9rem; }
.index-toolbar input[type="search"] {
  width: min(340px, 100%); padding: 0.5rem 0.8rem; border-radius: 6px;
  border: 1px solid var(--border-color); background: rgba(255,255,255,0.04);
  color: inherit;
}
.grid-section-title { font-size: 0.95rem; margin: 1.1rem 0 0.6rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}
.tile-grid {
  display: flex; flex-wrap: wrap; gap: 0.7rem;
}
.tile {
  display: flex; flex-direction: column; gap: 4px;
  width: 230px; padding: 0.7rem 0.85rem; text-align: left;
  background: rgba(255,255,255,0.03); color: inherit; cursor: pointer;
  border: 1px solid var(--border-color); border-left-width: 4px;
  border-radius: 8px; font: inherit;
}
.tile:hover, .tile:focus-visible { border-color: var(--border-color-glow); }
.tile-hidden { display: none; }
.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tile-name { font-weight: 600; }
.tile-hazard .hazard-icon { width: 18px; height: 18px; color: var(--text-muted); }
.tile-severity { font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.tile-model-tag { color: var(--text-muted); font-size: 0.65rem; letter-spacing: 0.06em; }
.tile-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.06); overflow: hidden; }
.tile-bar i { display: block; height: 100%; }
.tile-meta { color: var(--text-muted); font-size: 0.75rem; }
.tile-candidate { opacity: 0.92; background: rgba(255,255,255,0.015); border-style: dashed; border-left-style: solid; }
.tile-badge { font-size: 0.6rem; border: 1px solid var(--border-color-glow); color: var(--text-muted); padding: 1px 6px; }
#detail-view { display: flex; gap: 1rem; }
#side-rail { width: 220px; flex-shrink: 0; }
#detail-main { flex: 1; min-width: 0; }
.detail-kind { color: var(--text-muted); font-size: 0.8rem; }
.diag-section { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border-color); }
.diag-section h3 { margin: 0 0 0.5rem; font-size: 0.85rem; }
.diag-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.diag-status { color: var(--text-muted); font-size: 0.78rem; min-height: 1em; }
.diag-connector-row, .diag-history-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 4px 0; font-size: 0.82rem;
}
.api-offline-banner {
  background: var(--danger, #ef4444); color: #fff; text-align: center;
  padding: 0.4rem; font-size: 0.85rem;
}
.api-offline-banner.hidden { display: none; }
#detail-view[hidden] { display: none; }
/* Phase B: detail view panels */
.detail-map { height: 380px; border-radius: 8px; }
.detail-columns { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 0.9rem; }
.detail-columns > .card { flex: 1; min-width: 300px; }
#detail-main > .card { margin-top: 0.9rem; }
.alert-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; margin: 0.7rem 0; }
.alert-field dt { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
.alert-field dd { margin: 0; font-size: 0.9rem; }
.alert-field-wide { grid-column: 1 / -1; }
.alert-context { color: var(--text-muted); font-size: 0.8rem; }
.alert-meaning { margin-left: 0.6rem; }
.public-hero-status { font-size: 1.4rem; font-weight: 700; }
.rail-item {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  width: 100%; padding: 0.45rem 0.6rem; margin-bottom: 4px; text-align: left;
  background: rgba(255,255,255,0.03); color: inherit; cursor: pointer; font: inherit;
  border: 1px solid var(--border-color); border-left-width: 3px; border-radius: 6px;
}
.rail-item.active { border-color: var(--border-color-glow); background: rgba(255,255,255,0.07); }
.rail-candidate { opacity: 0.85; border-style: dashed; border-left-style: solid; }
.rail-meta { color: var(--text-muted); font-size: 0.75rem; }
#rail-list { display: flex; flex-direction: column; margin-top: 0.6rem; }
.components-headline { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.component-row { display: grid; grid-template-columns: 64px 1fr 44px; gap: 0.5rem; align-items: center; margin-bottom: 6px; }
.component-label { font-size: 0.8rem; }
.component-bar { height: 7px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.component-bar i { display: block; height: 100%; }
.component-hint { grid-column: 2 / -1; color: var(--text-muted); font-size: 0.72rem; margin-top: -2px; }
.component-raws { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.6rem; }
.candidate-honesty { color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border-color); padding-top: 0.6rem; margin-top: 0.8rem; }
.conditions-row { display: grid; grid-template-columns: 130px 1fr; gap: 0.2rem 0.8rem; padding: 4px 0; font-size: 0.85rem; }
.conditions-prov { grid-column: 2; color: var(--text-muted); font-size: 0.7rem; }
.history-svg { width: 100%; height: auto; display: block; }
.history-meta, .trend-label { color: var(--text-muted); font-size: 0.75rem; }
.history-meta { margin-top: 0.35rem; }
.trend-row { margin-bottom: 0.7rem; }
.trend-row:last-child { margin-bottom: 0; }
.trend-head { display: flex; justify-content: space-between; align-items: baseline; }
.trend-latest { font-size: 0.8rem; font-weight: 700; }
.trend-unit { color: var(--text-muted); font-weight: 400; font-size: 0.7rem; }
.trend-prov { color: var(--text-muted); font-size: 0.65rem; }
/* Chart frame: subtle y ticks (top/bottom) + x endpoints around the sparkline. */
.chart { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem; }
.chart-axis-title { color: var(--text-muted); font-size: 0.65rem; margin-bottom: 1px; }
.chart-yaxis { display: flex; flex-direction: column; justify-content: space-between;
  text-align: right; color: var(--text-muted); font-size: 0.6rem; padding: 1px 0; min-width: 1.7rem; }
.chart-main { min-width: 0; }
.chart-xaxis { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.6rem; margin-top: 1px; }
/* These history panels hug their content instead of stretching to match the
   taller sibling card (which left a large dead area under the timeline). */
#risk-timeline-panel, #trend-panel { align-self: flex-start; }
/* Phase C: seismic feed + route card */
.seismic-row {
  display: flex; gap: 0.7rem; align-items: center; width: 100%;
  padding: 0.45rem 0.6rem; margin-bottom: 4px; text-align: left;
  background: rgba(255,255,255,0.02); color: inherit; cursor: pointer; font: inherit;
  border: 1px solid var(--border-color); border-left-width: 3px; border-radius: 6px;
}
.seismic-row:hover { border-color: var(--border-color-glow); }
.seismic-mag { font-weight: 700; min-width: 52px; }
.seismic-info { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; }
.seismic-meta { color: var(--text-muted); font-size: 0.75rem; }
.seismic-filter-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.78rem; margin-bottom: 0.5rem; }
.seismic-focus-content { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-color); }
.focus-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.focus-head .btn { margin-left: auto; }
.focus-body { font-size: 0.85rem; margin: 0.4rem 0 0; }
.focus-note { color: var(--text-muted); font-size: 0.72rem; margin: 0.3rem 0 0; }
.route-steps { font-size: 0.82rem; padding-left: 1.2rem; }
.route-steps li { margin-bottom: 3px; }
/* The hidden attribute always wins, no matter what display a class sets. */
[hidden] { display: none !important; }
/* Skeleton tiles while the first data lands */
.tile-skeleton { height: 96px; border-left-color: var(--border-color); animation: skeleton-pulse 1.2s ease-in-out infinite; pointer-events: none; }
@keyframes skeleton-pulse { 0%,100% { opacity: 0.35; } 50% { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) { .tile-skeleton { animation: none; opacity: 0.5; } }
.broadcast-box { margin-top: 0.7rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border-color); border-radius: 6px; }
.broadcast-original summary { color: var(--text-muted); font-size: 0.75rem; cursor: pointer; }
.broadcast-original p { color: var(--text-muted); font-size: 0.8rem; }
/* Mobile + visibility round */
#place-subscribe-btn {
  display: inline-block; margin: 0.3rem 0 0.6rem;
  padding: 0.55rem 1.1rem; font-size: 0.95rem; font-weight: 600;
  background: #38bdf8; color: #07090f; border: none; border-radius: 8px;
}
#place-subscribe-btn:hover { background: #7dd3fc; }
#index-view > .card { margin-top: 1.2rem; }
.focus-close { margin-left: auto; font-size: 1rem; line-height: 1; padding: 2px 9px; }
.rail-toggle { display: none; }
@media (max-width: 760px) {
  #detail-view { flex-direction: column; }
  #side-rail { width: 100%; }
  .rail-toggle { display: inline-block; margin-bottom: 0.5rem; }
  #side-rail #rail-list, #side-rail #back-to-grid { display: none; }
  #side-rail.rail-open #rail-list, #side-rail.rail-open #back-to-grid { display: flex; }
  #side-rail.rail-open #rail-list { flex-direction: column; max-height: 45vh; overflow-y: auto; }
  .detail-columns { flex-direction: column; }
}
/* Plain-language + layout round */
.plain-warning-card {
  display: block; padding: 0.55rem 0.8rem; margin: 0 0 0.55rem;
  border: 1px solid var(--border-color); border-radius: 6px;
  background: rgba(255,255,255,0.02);
}
.plain-warning-card .plain-warning-title { display: block; font-weight: 600; margin-bottom: 2px; }
.plain-warning-card .plain-warning-body { display: block; font-size: 0.85rem; }
/* The map fills its row even when the alert card grows tall. */
.detail-columns > .card[aria-label="Map"] { display: flex; flex-direction: column; }
.detail-columns > .card[aria-label="Map"] .detail-map { flex: 1; min-height: 380px; height: auto; }
.footer-links { display: flex; gap: 1rem; margin-top: 0.4rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.78rem; }
.footer-links a:hover { color: inherit; text-decoration: underline; }
.app-footer { display: flex; flex-direction: column; }

/* Site pages as in-page modals (about/technology/privacy/terms/glossary). */
.page-modal { position: fixed; inset: 0; z-index: 1100; display: none; }
.page-modal.open { display: block; }
.page-modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.page-modal-panel {
  position: relative;
  max-width: 760px;
  margin: 4vh auto;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.page-modal-close {
  position: absolute;
  top: 0.55rem; right: 0.7rem;
  width: 2rem; height: 2rem;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 1.2rem; line-height: 1;
  cursor: pointer;
}
.page-modal-close:hover { color: inherit; }
.page-modal-body { padding: 1.6rem 1.8rem 2.2rem; line-height: 1.65; }
.page-modal-body h1 { font-size: 1.4rem; margin: 0 2rem 0 0; }
.page-modal-body h2 { font-size: 1.05rem; margin-top: 1.6rem; }
.page-modal-body a { color: #38bdf8; }
/* Scrollbar styled to match the dark theme (default chrome looked out of place). */
.page-modal-panel { scrollbar-width: thin; scrollbar-color: var(--border-color-glow) transparent; }
.page-modal-panel::-webkit-scrollbar { width: 10px; }
.page-modal-panel::-webkit-scrollbar-track { background: transparent; }
.page-modal-panel::-webkit-scrollbar-thumb {
  background: var(--border-color); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}
.page-modal-panel::-webkit-scrollbar-thumb:hover { background: var(--border-color-glow); }
/* Definition lists (glossary) read formatted inside the modal, not just on the
   standalone page where the inline <style> applies. */
.page-modal-body dl { margin: 0.6rem 0 0; }
.page-modal-body dt {
  font-weight: 700; color: var(--text-main); margin-top: 0.9rem;
  border-top: 1px solid var(--border-color); padding-top: 0.9rem;
}
.page-modal-body dt:first-of-type { border-top: none; padding-top: 0; }
.page-modal-body dd { margin: 0.25rem 0 0; color: var(--text-muted); }

/* Inline explanatory figures on the Technology page (work standalone + modal).
   Capped so they read as small diagrams instead of stretching the full column. */
.tech-fig { margin: 1.1rem 0 0.4rem; max-width: 440px; }
.tech-fig svg { width: 100%; height: auto; display: block; }
.tech-fig figcaption { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.4rem; line-height: 1.45; }

/* Worldwide seismic events: pack multiple cards per row instead of one-per-row. */
#world-events-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
}
#world-events-body .seismic-row { margin-bottom: 0; }

/* Alert-card controls: a de-emphasized footer below the alert content, so the
   warning text leads and the language/audio options sit quietly underneath.
   Padded to align with the card body (they used to hug the left border). */
.alert-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.015);
}
.alert-control-row { display: flex; align-items: center; gap: 0.55rem; }
.alert-control-label {
  color: var(--text-muted); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.07em; min-width: 2.6rem;
}
.seg-group { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.seg-group .seg-btn {
  border: none; border-radius: 0; min-height: 38px; padding: 0.35rem 0.85rem;
  background-color: rgba(255, 255, 255, 0.03); color: var(--text-muted); font-weight: 600;
}
.seg-group .seg-btn + .seg-btn { border-left: 1px solid var(--border-color); }
.seg-group .seg-btn:hover { background-color: rgba(255, 255, 255, 0.09); color: var(--text-main); }
.seg-group .seg-btn.seg-active {
  background-color: var(--primary-glow); color: var(--text-main);
  box-shadow: inset 0 -2px 0 var(--primary);
}
.seg-group .seg-btn[data-playing="true"] { color: var(--text-main); background-color: rgba(255, 255, 255, 0.09); }

/* Separate the per-place warning cards from the guidance text above them. */
#alert-advisories { margin-top: 0.9rem; }
@media (max-width: 760px) {
  .page-modal-panel { margin: 0; max-height: 100vh; border-radius: 0; min-height: 100vh; }
  .page-modal-body { padding: 1.3rem 1.2rem 2rem; }
}

/* Mobile: two tiles per row, tighter */
@media (max-width: 760px) {
  .tile { width: calc(50% - 0.45rem); padding: 0.55rem 0.6rem; }
  .tile-name { font-size: 0.9rem; }
  .tile-meta { font-size: 0.68rem; }
  .tile-severity { font-size: 0.78rem; flex-wrap: wrap; }
}
