:root {
  color-scheme: light;
  --page:            #f9f9f7;
  --surface-1:        #fcfcfb;
  --text-primary:     #0b0b0b;
  --text-secondary:   #52514e;
  --text-muted:       #898781;
  --gridline:         #e1e0d9;
  --baseline:         #c3c2b7;
  --border:           rgba(11,11,11,0.10);

  --series-1:         #2a78d6; /* blue — lake storage */
  --series-1-wash:    rgba(42,120,214,0.10);
  --series-1-track:   #cde2fb; /* light step of blue ramp, meter track */
  --series-2:         #1baf7a; /* aqua — primary inflow (English Crossing) */
  --series-2-wash:    rgba(27,175,122,0.10);
  --series-8:         #eb6834; /* orange — secondary inflow gauges */
  --series-5:         #4a3aa7; /* violet — tertiary inflow gauges */
  --series-4:         #c9971c; /* yellow — Patterson Rd (kept distinct from lake-storage blue) */
  --series-4-wash:    rgba(201,151,28,0.12);

  --good:             #0ca30c;
  --warning:          #fab219;
  --serious:          #ec835a;
  --critical:         #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:            #0d0d0d;
    --surface-1:        #1a1a19;
    --text-primary:     #ffffff;
    --text-secondary:   #c3c2b7;
    --text-muted:       #898781;
    --gridline:         #2c2c2a;
    --baseline:         #383835;
    --border:           rgba(255,255,255,0.10);

    --series-1:         #3987e5;
    --series-1-wash:    rgba(57,135,229,0.14);
    --series-1-track:   #184f95;
    --series-2:         #199e70;
    --series-2-wash:    rgba(25,158,112,0.14);
    --series-8:         #d95926;
    --series-5:         #9085e9;
    --series-4:         #e0b23e;
    --series-4-wash:    rgba(224,178,62,0.16);

    --good:             #0ca30c;
    --warning:          #fab219;
    --serious:          #ec835a;
    --critical:         #d03b3b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:            #0d0d0d;
  --surface-1:        #1a1a19;
  --text-primary:     #ffffff;
  --text-secondary:   #c3c2b7;
  --text-muted:       #898781;
  --gridline:         #2c2c2a;
  --baseline:         #383835;
  --border:           rgba(255,255,255,0.10);

  --series-1:         #3987e5;
  --series-1-wash:    rgba(57,135,229,0.14);
  --series-1-track:   #184f95;
  --series-2:         #199e70;
  --series-2-wash:    rgba(25,158,112,0.14);
  --series-8:         #d95926;
  --series-5:         #9085e9;
  --series-4:         #e0b23e;
  --series-4-wash:    rgba(224,178,62,0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ---- topbar ---- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  font-size: 28px;
  line-height: 1;
}

.brand h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.live-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px 8px 12px;
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(12,163,12,0.5);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
.pulse.stale { background: var(--warning); animation: none; }
.pulse.error { background: var(--critical); animation: none; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(12,163,12,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(12,163,12,0); }
  100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); }
}

.live-status-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

#as-of-label {
  font-size: 13px;
  font-weight: 600;
}

.next-refresh {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- hero card ---- */

.hero-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}

.hero-primary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.hero-figure-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  align-self: center;
}

.hero-figure {
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.hero-unit {
  font-size: 14px;
  color: var(--text-muted);
}

.hero-delta {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gridline);
  color: var(--text-secondary);
}
.hero-delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.hero-delta.down { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }

.meter-block { margin-bottom: 16px; }

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.meter-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.meter-value {
  font-size: 20px;
  font-weight: 600;
}

.meter-track {
  height: 14px;
  border-radius: 999px;
  background: var(--series-1-track);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: var(--series-1);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.meter-foot {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-top: 8px;
  color: var(--text-primary);
}

.meter-foot .muted { color: var(--text-muted); }

.flood-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--gridline);
  flex-wrap: wrap;
}

.status-badge {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 6px;
}
.status-badge.good     { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.status-badge.warning  { background: color-mix(in srgb, var(--warning) 20%, transparent); color: #8a5a00; }
.status-badge.serious  { background: color-mix(in srgb, var(--serious) 18%, transparent); color: #9a3d1a; }
.status-badge.critical { background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical); }
:root[data-theme="dark"] .status-badge.warning,
@media (prefers-color-scheme: dark) { .status-badge.warning { color: var(--warning); } .status-badge.serious { color: var(--serious); } }

.flood-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---- kpi row ---- */

.section-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.flow-diagram {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.flow-node {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.flow-node.flow-lake { color: var(--text-primary); }

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

.flow-arrow {
  color: var(--text-muted);
  font-size: 13px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.gauge-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  overflow: hidden;
  position: relative;
}
.gauge-card.inactive { opacity: 0.55; }

.gauge-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.gauge-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.gauge-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.gauge-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.gauge-unit {
  font-size: 12px;
  color: var(--text-muted);
}

.gauge-sparkline { width: 100%; height: 36px; display: block; overflow: hidden; }
.gauge-sparkline svg { width: 100%; height: 100%; display: block; }

.gauge-axis {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- tooltip ---- */

.chart-tooltip {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  white-space: nowrap;
  transition: opacity 0.1s ease;
  z-index: 2;
}

.gauge-tooltip {
  font-size: 11px;
  padding: 4px 8px;
  line-height: 1.4;
}

/* ---- misc ---- */

.disclaimer {
  font-size: 13px;
  color: var(--critical);
  background: color-mix(in srgb, var(--critical) 10%, transparent);
  border-radius: 10px;
  padding: 10px 14px;
}

footer {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

footer a { color: var(--text-secondary); }

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

@media (max-width: 560px) {
  .hero-figure { font-size: 42px; }
  .topbar { flex-direction: column; align-items: stretch; }
}

/* ---- doc pages (privacy / contact) ---- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--text-primary); }

.doc-content h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.doc-updated {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 28px;
}

.doc-content h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 8px;
}

.doc-content p, .doc-content li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.doc-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.doc-content a { color: var(--series-1); }

.doc-content strong { color: var(--text-primary); }

.footer-nav {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.footer-nav a { color: var(--text-secondary); }
