/* ─── DESIGN TOKENS ──────────────────────────────────── */
:root {
  --deep:      #03111a;
  --dark:      #061c28;
  --surface:   #092130;
  --card:      #0d2a3b;
  --raised:    #122f42;
  --border:    #1a4459;
  --border-hi: #266080;

  --text:      #e0f2f7;
  --text-2:    #82bdd0;
  --text-3:    #416e80;
  --text-muted:#244455;

  --safe:  #00c9a7;
  --warn:  #f5a623;
  --crit:  #e63946;
  --info:  #38bdf8;

  --safe-dim: rgba(0,201,167,.12);
  --warn-dim: rgba(245,166,35,.12);
  --crit-dim: rgba(230,57,70,.12);
  --info-dim: rgba(56,189,248,.1);

  --g-safe: 0 0 18px rgba(0,201,167,.28);
  --g-warn: 0 0 18px rgba(245,166,35,.28);
  --g-crit: 0 0 18px rgba(230,57,70,.32);

  --mono: 'DM Mono', 'Courier New', monospace;
  --sans: 'Sora', system-ui, sans-serif;

  --r:  .875rem;
  --rm: .625rem;
  --rs: .4rem;
}

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

html { scroll-behavior: smooth; }

/* ─── BASE ───────────────────────────────────────────── */
body {
  font-family: var(--sans);
  background-color: var(--deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Topographic contour background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cpath d='M0 260 C65 240 110 275 180 258 C250 241 295 278 365 260 C435 242 478 272 520 260' fill='none' stroke='rgba(0%2C200%2C160%2C0.05)' stroke-width='1.5'/%3E%3Cpath d='M0 180 C70 163 115 196 188 178 C261 160 304 196 374 178 C444 160 487 190 520 180' fill='none' stroke='rgba(0%2C200%2C160%2C0.038)' stroke-width='1'/%3E%3Cpath d='M0 340 C68 324 112 357 183 340 C254 323 298 358 368 340 C438 322 481 353 520 340' fill='none' stroke='rgba(0%2C200%2C160%2C0.038)' stroke-width='1'/%3E%3Cpath d='M0 100 C78 86 125 115 200 100 C275 85 318 116 395 100 C470 84 497 112 520 100' fill='none' stroke='rgba(0%2C200%2C160%2C0.025)' stroke-width='0.8'/%3E%3Cpath d='M0 420 C76 406 122 434 198 420 C274 406 318 435 394 420 C470 405 496 432 520 420' fill='none' stroke='rgba(0%2C200%2C160%2C0.025)' stroke-width='0.8'/%3E%3Cpath d='M0 52 C82 40 130 62 205 52 C280 42 325 65 402 52 C479 39 500 60 520 52' fill='none' stroke='rgba(0%2C200%2C160%2C0.016)' stroke-width='0.6'/%3E%3C/svg%3E");
  background-size: 520px 520px;
}

/* ─── LAYOUT ─────────────────────────────────────────── */
.container {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  margin-bottom: 1.75rem;
}

/* ─── HEADER ─────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(3,17,26,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  color: white;
}

.header .container {
  display: flex;
  align-items: center;
  height: 60px;
  gap: 1.25rem;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-shrink: 0;
}

.logo-container {
  display: flex;
  align-items: center;
}

.logo-image {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.logo-brand-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 .625rem;
}

.system-title {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.page-title {
  flex: 1;
  text-align: center;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.last-updated {
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--text-3);
  letter-spacing: .04em;
  background: none;
  display: inline;
  padding: 0;
  border-radius: 0;
}

/* Language Toggle */
.language-toggle {
  display: flex;
  align-items: center;
}

.language-btn {
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .3rem .7rem;
  border-radius: var(--rs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}

.language-btn:hover {
  border-color: var(--info);
  color: var(--info);
}

/* Dam status indicator — moved to strip, hide in header */
.dam-status-indicator {
  display: none;
}

/* ─── STATUS STRIP ───────────────────────────────────── */
.status-strip {
  background: var(--dark);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.strip-inner {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  height: 38px;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}

.strip-inner::-webkit-scrollbar { display: none; }

.si {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .75rem;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.s { background: var(--safe); box-shadow: 0 0 6px var(--safe); }
.dot.w { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.dot.c { background: var(--crit); box-shadow: 0 0 8px var(--crit); animation: pd 1.5s infinite; }
.dot.i { background: var(--info); }

.si-lbl { color: var(--text-3); }
.si-val { font-family: var(--mono); color: var(--text); font-weight: 500; }

.strip-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── PAGE INTRO ─────────────────────────────────────── */
.page-intro {
  padding: 2.5rem 0 2rem;
  text-align: center;
}

.intro-eyebrow {
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--info);
  margin-bottom: .75rem;
}

.intro-title {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: .75rem;
}

.intro-title em {
  font-style: normal;
  color: var(--info);
}

.intro-sub {
  font-size: .88rem;
  color: var(--text-2);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ─── SECTION HEADERS ────────────────────────────────── */
.sh {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.sh h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.sh-tag {
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: .15em .45em;
}

.sh-desc {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-3);
}

/* ─── CARD BASE ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

/* ─── MAIN CONTENT AREA ──────────────────────────────── */
.main {
  padding: 2rem 0;
}

/* ─── FLOOD PREDICTION ───────────────────────────────── */
.flood-prediction-section {
  margin-bottom: 1.75rem;
}

.flow-hero {
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.75rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}

.flow-eyebrow {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
  margin-bottom: 1.5rem;
}

.flow-layout {
  display: grid;
  grid-template-columns: 1fr 140px 1fr;
  align-items: center;
  gap: 1rem;
}

/* Gauge station card */
.gauge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  padding: 1.25rem;
}

.gauge-card.up   { border-top: 2px solid var(--info); }
.gauge-card.down { border-top: 2px solid var(--warn); }

.gc-id {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .14em;
  color: var(--text-3);
  margin-bottom: .2rem;
}

.gc-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.1rem;
}

.gc-body {
  display: flex;
  align-items: flex-end;
  gap: .875rem;
}

.gc-bar-wrap { flex-shrink: 0; }

.gc-bar-track {
  width: 12px;
  height: 72px;
  background: var(--raised);
  border-radius: 6px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.gc-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 6px 6px 0 0;
  transition: height 1.8s cubic-bezier(.34,1.3,.64,1);
}

.gc-bar-fill.s { background: linear-gradient(0deg, #007a63, var(--safe)); }
.gc-bar-fill.w { background: linear-gradient(0deg, #b37300, var(--warn)); }
.gc-bar-fill.c { background: linear-gradient(0deg, #8c1520, var(--crit)); }

.gc-bar-tick {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--crit);
  opacity: .7;
}

.gc-reading { flex: 1; }

/* The main reading — JS sets textContent of this element */
.current-level,
.gc-val {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--safe);
}

.gc-val.s { color: var(--safe); text-shadow: var(--g-safe); }
.gc-val.w { color: var(--warn); text-shadow: var(--g-warn); }
.gc-val.c { color: var(--crit); text-shadow: var(--g-crit); }

/* Override color per station */
.gauge-card.up   .current-level { color: var(--info); }
.gauge-card.down .current-level { color: var(--warn); }

.gc-meta {
  margin-top: .7rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.gc-meta-row {
  font-size: .72rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text-3);
}

.gc-meta-row b {
  font-family: var(--mono);
  color: var(--text-2);
  font-weight: 500;
}

/* Pill badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .28em .65em;
  border-radius: 999px;
}

.pill.s { background: var(--safe-dim); color: var(--safe); border: 1px solid rgba(0,201,167,.25); }
.pill.w { background: var(--warn-dim); color: var(--warn); border: 1px solid rgba(245,166,35,.25); }
.pill.c { background: var(--crit-dim); color: var(--crit); border: 1px solid rgba(230,57,70,.25); animation: pt 1.5s infinite; }
.pill.i { background: var(--info-dim); color: var(--info); border: 1px solid rgba(56,189,248,.2); }

.pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* River flow center */
.flow-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.river-svg {
  width: 100%;
  overflow: visible;
  display: block;
}

@keyframes riverFlow {
  from { stroke-dashoffset: 48; }
  to   { stroke-dashoffset: 0; }
}

.river-animated {
  animation: riverFlow 1.8s linear infinite;
}

.flow-badge {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--rm);
  padding: .5rem .625rem;
  text-align: center;
}

.fb-val {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--info);
  display: block;
  line-height: 1;
}

.fb-lbl {
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ─── PREDICTION CARDS ───────────────────────────────── */
.prediction-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.prediction-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  padding: 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: .875rem;
  transition: border-color .2s, transform .2s;
}

.prediction-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
}

.prediction-card.high-risk {
  border-color: var(--crit);
  background: linear-gradient(135deg, var(--surface), rgba(230,57,70,.08));
}

.prediction-card.warning {
  border-color: var(--warn);
  background: linear-gradient(135deg, var(--surface), rgba(245,166,35,.08));
}

.prediction-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--rs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.prediction-icon svg {
  width: 18px;
  height: 18px;
}

.prediction-icon.icon-warn { background: var(--warn-dim); color: var(--warn); }
.prediction-icon.icon-info { background: var(--info-dim); color: var(--info); }
.prediction-icon.icon-safe { background: var(--safe-dim); color: var(--safe); }

.prediction-content { flex: 1; }

.prediction-content h4 {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: .35rem;
}

.risk-level, .warning-time, .trend-direction {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: .3rem;
  color: var(--text);
}

.risk-details, .warning-details, .trend-details {
  font-size: .75rem;
  color: var(--text-3);
  line-height: 1.55;
}

/* JS-set risk colours */
.risk-level.low,   .risk-normal  { color: var(--safe); }
.risk-level.moderate, .risk-moderate { color: var(--warn); }
.risk-level.high,  .risk-high    { color: var(--crit); }
.risk-critical { color: var(--crit); animation: pt 2s infinite; }

.trend-rising  { color: var(--crit); }
.trend-falling { color: var(--safe); }
.trend-stable  { color: var(--text-3); }

.warning-time.active { color: var(--warn); }
.trend-direction.rising  { color: var(--crit); }
.trend-direction.falling { color: var(--safe); }

/* ─── STATUS DOT COLOURS (used in station cards) ─────── */
.alert-green { color: var(--safe); }
.alert-yellow { color: var(--warn); }
.alert-red { color: var(--crit); }
.alert-blue { color: var(--info); }
.alert-gray { color: var(--text-muted); }

/* ─── CHART ──────────────────────────────────────────── */
.historical-section {
  margin-bottom: 1.75rem;
}

.historical-section > .sh,
.historical-section > h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  position: relative;
  height: auto;
  margin-bottom: 0;
}

#waterLevelChart {
  width: 100% !important;
  height: 240px !important;
}

.chart-scrollbar {
  margin-top: 1rem;
  padding: .375rem 0;
}

.scrollbar-track {
  width: 100%;
  height: 10px;
  background: var(--raised);
  border-radius: 5px;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
}

.scrollbar-thumb {
  height: 10px;
  background: var(--info);
  border-radius: 5px;
  position: absolute;
  top: 0;
  right: 0;
  width: 66.67%;
  cursor: grab;
  opacity: .7;
  transition: opacity .2s;
}

.scrollbar-thumb:hover { opacity: 1; }
.scrollbar-thumb:active { cursor: grabbing; }

.trend-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.trend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem;
  background: var(--surface);
  border-radius: var(--rm);
  border: 1px solid var(--border);
}

.trend-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.trend-value {
  font-family: var(--mono);
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
}

/* ─── MAE NGAT DAM ───────────────────────────────────── */
.mae-ngat-section {
  margin-bottom: 1.75rem;
}

.mae-ngat-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

/* JS builds dam visualization inside #maeNgatVisual */
.dam-visual {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.5rem;
  margin-top: 1rem;
}

.dam-visual h4 {
  color: var(--info);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .06em;
}

.dam-storage-container { margin-bottom: 1.5rem; }

.dam-storage-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .5rem;
  font-size: .82rem;
  color: var(--text-2);
}

.dam-storage-bar {
  height: 16px;
  background: var(--raised);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.dam-storage-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--safe) 0%, var(--warn) 65%, var(--crit) 90%);
  position: relative;
  transition: width .8s ease;
}

.dam-storage-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.12) 50%, transparent);
  animation: shimmer 2.8s ease infinite;
}

.dam-flow-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dam-flow-item {
  text-align: center;
  padding: .875rem;
  background: var(--surface);
  border-radius: var(--rm);
  border: 1px solid var(--border);
}

.dam-flow-icon {
  font-size: 1.25rem;
  margin-bottom: .4rem;
  display: block;
}

.dam-flow-value {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .2rem;
  display: block;
}

.dam-flow-label {
  font-size: .72rem;
  color: var(--text-3);
}

.inflow-icon  { color: var(--info); }
.outflow-icon { color: var(--safe); }

/* Data Sources dam item */
.dam-summary { margin: 1rem 0; }

.dam-item {
  background: var(--raised);
  padding: .75rem;
  border-radius: var(--rm);
  margin-bottom: .5rem;
  color: var(--text);
  border: 1px solid var(--border);
}

.dam-item strong { color: var(--info); display: block; margin-bottom: .2rem; }
.dam-item small  { color: var(--text-3); font-size: .75rem; }

/* ─── RAINFALL FORECAST ──────────────────────────────── */
.rainfall-forecast-section {
  margin-bottom: 1.75rem;
}

.rainfall-forecast-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.forecast-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.forecast-location-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  padding: 1.1rem;
}

.forecast-location-card h3 {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .875rem;
}

.forecast-periods {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

/* JS builds these inside forecast containers */
.forecast-period {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .45rem .7rem;
  background: var(--surface);
  border-radius: var(--rs);
  border: 1px solid var(--border);
}

.forecast-period-label {
  font-size: .72rem;
  color: var(--text-3);
}

.forecast-rain-amount {
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text);
}

.rain-indicator { font-size: 1rem; }
.rain-light  { color: var(--safe); }
.rain-moderate { color: var(--warn); }
.rain-heavy  { color: #f59e0b; }
.rain-extreme { color: var(--crit); }

.forecast-loading {
  text-align: center;
  color: var(--text-3);
  padding: 1.5rem;
  font-size: .8rem;
  font-style: italic;
}

.forecast-summary { margin-top: 1rem; }

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--rm);
  padding: 1.1rem 1.25rem;
}

.summary-card h4 {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--warn);
  margin-bottom: .5rem;
}

/* JS sets risk assessment content */
.risk-assessment {
  padding: .875rem;
  background: var(--raised);
  border-radius: var(--rs);
  border: 1px solid var(--border);
}

.risk-indicator {
  font-size: .85rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: .5rem;
  line-height: 1.55;
}

.risk-low     { border-color: var(--safe); background: linear-gradient(90deg, var(--safe-dim), transparent); }
.risk-high    { border-color: var(--warn); background: linear-gradient(90deg, var(--warn-dim), transparent); }
.risk-extreme { border-color: var(--crit); background: linear-gradient(90deg, var(--crit-dim), transparent); }

/* ─── LIVE CAMERA FEEDS ──────────────────────────────── */
.live-feed-section {
  margin-bottom: 1.75rem;
}

.live-feed-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.cameras-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.camera-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.camera-container h3 {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.camera-feed-wrap {
  aspect-ratio: 16/9;
  background: var(--surface);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: none;
  border-radius: 0;
}

.camera-info {
  padding: .625rem 1.1rem;
  border-top: 1px solid var(--border);
}

.camera-info p {
  font-size: .7rem;
  color: var(--text-3);
  margin-bottom: .15rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--crit);
  background: var(--crit-dim);
  border: 1px solid rgba(230,57,70,.25);
  border-radius: 2px;
  padding: .25em .55em;
  float: right;
  margin-top: .15rem;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--crit);
  animation: pd 1.5s infinite;
}

/* ─── MAP SECTION ────────────────────────────────────── */
.map-section {
  margin-bottom: 1.75rem;
}

.map-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .875rem;
  flex-wrap: wrap;
}

.map-btn {
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .35rem .8rem;
  border-radius: var(--rs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all .15s;
}

.map-btn:hover  { border-color: var(--border-hi); color: var(--text-2); }
.map-btn.active { background: var(--info-dim); border-color: var(--info); color: var(--info); }

.map-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  min-height: 380px;
}

.map {
  width: 100%;
  height: 380px;
  position: relative;
  z-index: 1;
}

.map-placeholder {
  text-align: center;
  color: var(--text-3);
  padding: 2rem;
  font-size: .85rem;
}

/* ─── STATIONS OVERVIEW ──────────────────────────────── */
.stations-overview {
  margin-bottom: 1.75rem;
}

.stations-overview h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.stations-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .875rem;
}

.station-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--rm);
  padding: 1.1rem;
  transition: border-color .2s, transform .2s;
  cursor: default;
}

.station-card:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
}

.station-card.active {
  border-color: var(--warn);
  background: var(--dark);
}

.station-card h3 {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-3);
  margin-bottom: .2rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.station-location {
  font-size: .7rem;
  color: var(--text-3);
  margin-bottom: .875rem;
}

.station-level {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text);
  margin-bottom: .3rem;
}

.station-level a {
  color: inherit;
  text-decoration: none;
}

.station-status {
  font-size: .7rem;
  color: var(--text-3);
}

/* ─── DATA SOURCES ───────────────────────────────────── */
.data-sources {
  margin-bottom: 1.75rem;
}

.data-sources h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.source-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--rm);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
}

.source-item h3 {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
}

.source-item p {
  font-size: .72rem;
  color: var(--text-3);
  line-height: 1.55;
  flex: 1;
  margin-bottom: .875rem;
}

.source-link {
  font-family: var(--mono);
  font-size: .67rem;
  letter-spacing: .06em;
  color: var(--info);
  text-decoration: none;
  transition: color .15s;
}

.source-link:hover { color: #7dd3fc; }
.source-link:focus { outline: 2px solid var(--info); outline-offset: 2px; }
.source-link.disabled { color: var(--text-muted); cursor: not-allowed; }

/* ─── ALERTS SECTION ─────────────────────────────────── */
.alerts-section {
  background: rgba(230,57,70,.1);
  border: 2px solid var(--crit);
  border-radius: var(--r);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

.alerts-section h2 {
  color: var(--crit);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: .875rem;
}

.alert {
  padding: .875rem 1rem;
  border-radius: var(--rm);
  border-left: 4px solid;
  color: var(--text);
}

.alert-critical {
  background: rgba(230,57,70,.15);
  border-left-color: var(--crit);
}

.alert-high {
  background: rgba(245,166,35,.15);
  border-left-color: var(--warn);
}

.alert-message {
  font-weight: 600;
  margin-bottom: .2rem;
  color: var(--text);
  font-size: .88rem;
}

.alert-time {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--text-3);
}

/* ─── FOOTER ─────────────────────────────────────────── */
.footer {
  background: var(--dark);
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  position: relative;
  z-index: 1;
}

.footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-logo { display: flex; align-items: center; gap: .625rem; }
.footer-logo-image { height: 22px; object-fit: contain; }

.footer .footer-text,
.footer p {
  font-size: .72rem;
  color: var(--text-3);
  line-height: 1.7;
  text-align: right;
  margin: 0;
}

.footer a { color: var(--text-2); text-decoration: none; }

/* ─── ANIMATIONS ─────────────────────────────────────── */
@keyframes pd {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.5; transform:scale(.8); }
}

@keyframes pt {
  0%,100% { opacity:1; }
  50%      { opacity:.7; }
}

@keyframes shimmer {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Loading state */
.loading { opacity: .6; pointer-events: none; }

/* ─── ERROR STATE ────────────────────────────────────── */
.error-message {
  background: var(--crit-dim);
  color: var(--crit);
  padding: .875rem;
  border-radius: var(--rm);
  margin-bottom: 1rem;
  border: 1px solid rgba(230,57,70,.3);
  font-size: .85rem;
}

/* ─── LEAFLET OVERRIDES ──────────────────────────────── */
.leaflet-container {
  background: var(--surface) !important;
  font-family: var(--sans) !important;
}

.leaflet-tile-pane {
  filter: brightness(.62) contrast(1.1) saturate(.55) hue-rotate(8deg);
}

.leaflet-control-zoom a {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-2) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--raised) !important;
  color: var(--text) !important;
}

.leaflet-control-attribution {
  background: rgba(3,17,26,.85) !important;
  color: var(--text-muted) !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a { color: var(--info) !important; }

.leaflet-popup-content-wrapper {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--rm) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,.55) !important;
  color: var(--text) !important;
  font-family: var(--sans) !important;
}

.leaflet-popup-tip { background: var(--card) !important; }
.leaflet-popup-close-button { color: var(--text-3) !important; }

.leaflet-control-container .leaflet-control {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--rm) !important;
}

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .stations-grid  { grid-template-columns: repeat(3, 1fr); }
  .sources-grid   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .container { padding: 0 1rem; }

  .flow-layout {
    grid-template-columns: 1fr;
  }

  .flow-center {
    flex-direction: row;
    justify-content: center;
  }

  .prediction-cards { grid-template-columns: 1fr; }

  .cameras-grid { grid-template-columns: 1fr; }

  .forecast-cards-grid { grid-template-columns: 1fr; }

  .trend-info { grid-template-columns: 1fr; }

  .stations-grid { grid-template-columns: repeat(2, 1fr); }

  .sources-grid { grid-template-columns: 1fr; }

  .dam-flow-container { grid-template-columns: 1fr; }

  .page-title { display: none; }

  .header .container { justify-content: space-between; }
}

@media (max-width: 480px) {
  .stations-grid { grid-template-columns: 1fr; }
  .sources-grid  { grid-template-columns: 1fr; }
  .map-btn { font-size: .7rem; padding: .3rem .6rem; }
}

/* ─── ACCESSIBILITY ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

.map-btn:focus,
.source-link:focus,
.language-btn:focus {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}
