/* Colorado Basin Network -- dark-mode design tokens per the dataviz skill's
   reference palette (references/palette.md), validated 2026-08-13.
   Status colors map to the same blue ramp the Sankey plots use, so a basin's
   dot on the map and its river's color on its own detail page tell the same
   visual story: gray (untouched) -> light blue (surveyed) -> darker blue
   (verified) -> green (deployed, live). */

:root {
  --page-plane:     #0a0a0f;
  --surface:        #15151d;
  --surface-raised: #1e1e28;
  --ink-primary:    #ffffff;
  --ink-secondary:  #c3c2b7;
  --ink-muted:      #898781;
  --border:         rgba(255, 255, 255, 0.10);
  --border-strong:  rgba(255, 255, 255, 0.18);

  --brand:          #3987e5;   /* categorical blue/400 -- data encoding, unchanged */
  --brand-soft:     #86b6ef;   /* blue/200 -- data encoding, unchanged */

  /* Decorative-only brand identity: alpenglow violet -> glacier cyan, a
     gradient pair distinct from any data-encoding color above so it never
     gets confused with something the map/charts mean. Used for chrome only
     (brand mark, accents, headings) -- never for a data mark. */
  --accent-violet:  #a78bfa;
  --accent-cyan:    #22d3ee;
  --brand-gradient: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));

  --status-deployed:      #0ca30c;  /* status good */
  --status-verified:      #3987e5;  /* blue/400 */
  --status-survey:        #86b6ef;  /* blue/200 */
  /* Validated 2026-08-13: original #5b5a56 measured 2.52:1 against the dark
     surface, below the 3:1 relief threshold -- lightened to clear it
     outright rather than relying solely on the paired text label. */
  --status-unavailable:   #6e6d68;

  --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-plane);
  color: var(--ink-primary);
  font-family: var(--font-body);
}

/* Soft twin-glow vignette behind the hero -- fixed so it doesn't shift on
   scroll, low-opacity so it reads as atmosphere, not decoration competing
   with content. Decorative only, no data meaning. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(680px 460px at 12% -8%, rgba(167, 139, 250, 0.16), transparent 60%),
    radial-gradient(620px 420px at 88% 6%, rgba(34, 211, 238, 0.12), transparent 60%);
  pointer-events: none;
}

/* Generic UI links use the decorative cyan accent, not the blue data-ramp
   (--brand/--brand-soft) -- keeps "this is a clickable link" visually
   distinct from "this dot means draft-verified" everywhere both appear. */
a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header / nav ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #111110, var(--page-plane));
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 650;
  font-size: 1.05rem;
  color: var(--ink-primary);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--accent-cyan); }

.brand-mark {
  /* Hydrohistorian mark (static/brand/mark.svg): the Continental Divide
     ridgeline over ledger rules -- replaces the old decorative gradient
     circle (2026-08-19 rebrand). */
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.site-nav { display: flex; gap: 1.5rem; font-size: 0.92rem; }
.site-nav a { color: var(--ink-secondary); transition: color 0.15s ease; white-space: nowrap; padding: 0.6rem 0; display: inline-block; }
.site-nav a:hover { color: var(--accent-cyan); }

/* ---------- footer ---------- */

.site-footer {
  padding: 1.5rem 1.75rem 3rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
  max-width: 900px;
}

/* ---------- landing / hero ---------- */

.hero {
  padding: 2.5rem 1.75rem 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.hero h1 .accent-word {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p.lede {
  color: var(--ink-secondary);
  max-width: 78ch;
  line-height: 1.55;
  margin: 0 0 1.5rem;
}

/* Informational detail grid under the lede -- replaces the old pitchy
   one-paragraph hero (user feedback 2026-08-18: "more developed, not
   like a sales pitch"). */
.hero-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 0 0 1.75rem;
}
.hd-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
}
.hd-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 650;
  color: var(--brand);
  margin-bottom: 0.4rem;
}
.hd-body {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}
.hd-body strong { color: var(--ink-primary); }

.stat-row {
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.stat .n { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--ink-muted); font-size: 0.85rem; }
.stat .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0.4rem; }

/* ---------- map ---------- */

.map-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.75rem 1rem;
  position: relative;
}

.map-scroll-hint {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(21, 21, 29, 0.92);
  color: var(--ink-primary);
  border: 1px solid var(--border-strong);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

#map {
  width: 100%;
  height: 620px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(167, 139, 250, 0.06);
}

/* Colorado's shape is wider than tall -- a 620px-tall map wastes a lot of
   a phone screen's height for the same content a shorter box shows fine. */
@media (max-width: 640px) {
  #map { height: 340px; }
}

.leaflet-container { background: var(--surface) !important; }

.city-label {
  color: var(--ink-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

/* Smooth the map polygons' hover state -- Leaflet sets fill-opacity/
   stroke-width via inline SVG attributes on mouseover/mouseout, which
   snaps instantly without this. */
.leaflet-interactive { transition: fill-opacity 0.15s ease, stroke-width 0.15s ease; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}
.map-legend .item { display: flex; align-items: center; gap: 0.4rem; }
.map-legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.basin-tooltip {
  font-family: var(--font-body);
  background: var(--surface-raised) !important;
  color: var(--ink-primary) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 8px !important;
  padding: 0.5rem 0.7rem !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}
.basin-tooltip .name { font-weight: 600; }
.basin-tooltip .meta { color: var(--ink-muted); font-size: 0.8rem; margin-top: 0.15rem; }

/* ---------- basin grid ---------- */

.grid-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 3rem;
}

.grid-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.search-input {
  flex: 1 1 260px;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.55rem 0.8rem;
  color: var(--ink-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
}
.search-input::placeholder { color: var(--ink-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip:hover { border-color: var(--border-strong); color: var(--ink-primary); }
.chip.is-active {
  border-color: rgba(167, 139, 250, 0.55);
  background: rgba(167, 139, 250, 0.10);
  color: var(--ink-primary);
}

.no-results {
  color: var(--ink-muted);
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.9rem;
}

.grid-wrap h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink-secondary);
  margin: 2rem 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}

.basin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.7rem;
}

.basin-card {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.basin-card:hover {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.12);
  transform: translateY(-1px);
  text-decoration: none;
}
.basin-card .name { font-weight: 600; color: var(--ink-primary); font-size: 0.92rem; }
.basin-card .meta { color: var(--ink-muted); font-size: 0.78rem; margin-top: 0.3rem; }
.basin-card .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  margin-top: 0.5rem;
}
.basin-card .badge .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- basin detail ---------- */

.detail-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.75rem 4rem;
}
.detail-wrap--wide { max-width: 1400px; }

.detail-header { margin-bottom: 1.5rem; }
.detail-header .back {
  font-size: 0.85rem;
  color: var(--ink-muted);
  transition: color 0.15s ease;
}
.detail-header .back:hover { color: var(--accent-cyan); }
.detail-header h1 { margin: 0.5rem 0 0.3rem; font-size: 1.8rem; letter-spacing: -0.01em; }
.detail-header .subtitle { color: var(--ink-secondary); font-size: 0.95rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  margin-top: 0.6rem;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; }

.review-report {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem 2rem;
  line-height: 1.6;
}
.review-report h1 { display: none; } /* title already shown in detail-header */
.review-report h2 {
  font-size: 1.05rem;
  margin-top: 2rem;
  color: var(--ink-primary);
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}
.review-report h3 { font-size: 0.95rem; color: var(--ink-secondary); }
.review-report table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.85rem;
}
.review-report th, .review-report td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.review-report th { color: var(--ink-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.review-report code {
  font-family: var(--font-mono);
  background: var(--surface-raised);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}
.review-report strong { color: var(--ink-primary); }
.review-report blockquote {
  border-left: 3px solid var(--accent-violet);
  margin: 1rem 0;
  padding: 0.4rem 0 0.4rem 1rem;
  color: var(--ink-secondary);
  background: rgba(167, 139, 250, 0.08);
  border-radius: 0 8px 8px 0;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
}

.no-report {
  color: var(--ink-muted);
  padding: 3rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 14px;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  font: inherit;
  color: var(--ink-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover { color: var(--ink-primary); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel.is-hidden { display: none; }

.historical-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.historical-controls label {
  color: var(--ink-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}
.historical-controls input[type="date"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-primary);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font: inherit;
  color-scheme: dark;
}
.historical-load-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--surface);
  background: var(--brand);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.historical-load-btn:hover { opacity: 0.85; }
.historical-load-btn:disabled { opacity: 0.5; cursor: default; }
.historical-status {
  color: var(--ink-muted);
  font-size: 0.85rem;
}
.historical-status--error { color: #ef4444; }
.historical-kinks { margin-top: 1.25rem; }
.historical-kinks ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.historical-kinks li { color: var(--ink-secondary); margin-bottom: 0.5rem; line-height: 1.5; }
.historical-kinks strong { color: var(--ink-primary); }

/* ---------- report content (parsed fragments, rendered inline -- see
   web/report_sections.py) -- dark-theme equivalents of report.html.j2's
   own light-theme banner/table/figure styles, same semantic color mapping
   (danger=red, warn=amber, ok=green, info=blue) the report itself uses. */
.report-top-banner { margin-bottom: 1.25rem; }
.report-card { color: var(--ink-secondary); } /* base for spans/divs the color-strip pass above leaves unstyled */
.report-card h3 {
  font-size: 1rem;
  color: var(--ink-primary);
  margin: 1.5rem 0 0.5rem;
}
.report-card p { color: var(--ink-secondary); }
.report-card small { color: var(--ink-muted); }
.report-card input[type="text"] {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--ink-primary);
  border-radius: 6px;
}
.report-card input[type="text"]::placeholder { color: var(--ink-muted); }
.report-card thead th { position: sticky; top: 0; }

.report-card .banner,
.report-card .headline,
.report-card .anomalies {
  padding: 0.9rem 1.1rem;
  margin: 0.75rem 0;
  border-radius: 8px;
  border-left: 4px solid var(--brand);
  background: rgba(57, 135, 229, 0.10);
  color: var(--ink-primary);
}
.report-card .banner-danger,
.report-card .anomalies.alert {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.10);
}
.report-card .banner-warn { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.10); }
.report-card .banner-ok { border-left-color: var(--status-deployed); background: rgba(12, 163, 12, 0.10); }
.report-card .banner-info { border-left-color: var(--brand); background: rgba(57, 135, 229, 0.10); }
.report-card .banner strong.tag { text-transform: uppercase; font-size: 0.78em; letter-spacing: 0.03em; }

.report-card table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.85rem;
}
.report-card th, .report-card td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--ink-secondary);
}
.report-card th {
  background: var(--surface-raised);
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.report-card tr.short-record td { color: #f59e0b; }

.report-card .figure {
  margin: 1.25rem 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-raised);
  padding: 0.5rem;
}
.report-card .stat-strip {
  color: var(--ink-muted);
  font-size: 0.88em;
  padding: 0.4rem 0 1rem;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 0.5rem;
}
.report-card details.anomaly-rest summary {
  cursor: pointer;
  color: var(--brand);
  font-size: 0.9em;
  font-weight: 600;
  padding: 0.3rem 0;
}

/* Leaflet's default container background is light gray (#ddd) -- on the
   dark theme any not-yet-loaded tile area flashes as a bright "error"
   patch. Match the site surface instead (basemap tiles paint over it). */
.leaflet-container { background: #0d1117; }
.leaflet-control-attribution { background: rgba(13,17,23,0.7) !important; color: #9aa4b2 !important; }
.leaflet-control-attribution a { color: #93c5fd !important; }

/* "Add to My Water" chips -- injected beside charts/popups site-wide */
.mywater-chip {
  display: inline-block; margin: 0.3rem 0 0.2rem 0.4rem; padding: 0.18rem 0.6rem;
  font-size: 0.75rem; border-radius: 999px; cursor: pointer;
  color: #93c5fd; background: rgba(96,165,250,0.10);
  border: 1px solid rgba(96,165,250,0.45);
}
.mywater-chip:hover { background: rgba(96,165,250,0.22); }
.mywater-chip.mywater-added { color: #2dd4bf; border-color: rgba(45,212,191,0.55); background: rgba(45,212,191,0.10); cursor: default; }
.mywater-chip.mywater-mini { margin: 0 0 0 0.3rem; padding: 0 0.35rem; font-size: 0.8rem; line-height: 1.2; vertical-align: baseline; }

/* Shared on-map legend (hydrohistorianMapLegend) -- all Leaflet maps */
.rw-map-legend {
  background: rgba(13, 17, 23, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: #c3c2b7;
  font-size: 0.74rem;
  line-height: 1.45;
  max-width: 240px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
}
.rw-leg-title { font-weight: 600; color: #e8e6df; margin-bottom: 0.25rem; font-size: 0.78rem; }
.rw-leg-row { display: flex; align-items: center; gap: 0.45rem; margin: 0.12rem 0; }
.rw-leg-note { color: #9aa4b2; font-style: italic; margin-top: 0.3rem; font-size: 0.7rem; }
.rw-sw { flex: 0 0 auto; display: inline-block; }
.rw-sw-square { width: 12px; height: 12px; border-radius: 3px; opacity: 0.85; }
.rw-sw-dot { width: 12px; height: 12px; border-radius: 50%; }
.rw-sw-line { width: 16px; height: 3px; border-radius: 2px; }
.rw-sw-ring { width: 11px; height: 11px; border-radius: 50%; border: 2px dashed; background: transparent; }
@media (max-width: 640px) { .rw-map-legend { font-size: 0.68rem; max-width: 190px; } }
/* Pin the legend tight into the map corner (Leaflet default margins float it) */
.leaflet-bottom.leaflet-left .rw-map-legend { margin: 0 0 6px 6px; }
.leaflet-bottom.leaflet-right .rw-map-legend { margin: 0 6px 6px 0; }

/* Visually hidden, still read aloud. Table captions and section labels use
   this so screen-reader users get context that sighted users infer from
   layout -- without adding visual clutter. */
.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;
}

/* Call-cascade scenario chips. Styled like the tab buttons but deliberately
   NOT .tab-btn -- that class carries a click handler that switches panels. */
.cascade-preset {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.cascade-preset:hover {
  border-color: rgba(96, 165, 250, 0.7);
  background: rgba(96, 165, 250, 0.08);
}
.cascade-preset.active {
  border-color: rgba(96, 165, 250, 0.9);
  background: rgba(96, 165, 250, 0.16);
}
.cascade-preset:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.9);
  outline-offset: 2px;
}

/* Plotly's modebar adds ~8 unlabeled icon buttons per chart -- 752 on the
   Clear Creek page alone (accessibility review 2026-08-26) -- for zoom and
   export tools this site does not rely on. Hidden site-wide. */
.modebar, .modebar-container { display: none !important; }

/* ------------------------------------------------------------------------
   Mobile layer (phone/tablet review 2026-08-26). Everything above this line
   was designed on a desktop; these rules make the same pages usable at
   390 px without a horizontal scroll, with 44 px tap targets where fingers
   land, and without maps that trap a thumb-swipe.
   ------------------------------------------------------------------------ */
.report-card #status-table { font-size: 0.85rem !important; }   /* generated with inline 12px */

@media (max-width: 640px) {
  html { font-size: 17px; }                    /* single lever: lifts every rem-sized text off the 12-13px floor */
  .site-header { padding: 0.75rem 1rem; gap: 0.75rem; }
  .site-nav { gap: 0.9rem; font-size: 0.88rem; }
  .brand { font-size: 0.98rem; }

  /* Tab bar: one swipeable row instead of a six-row wall of 13px buttons. */
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; scrollbar-width: thin;
    margin: 0 -1rem 1rem; padding: 0 1rem;
  }
  .tab-btn { flex: 0 0 auto; min-height: 44px; font-size: 0.9rem; padding: 0.7rem 0.8rem; scroll-snap-align: start; }

  .detail-wrap { padding: 1.25rem 1rem 3rem; }
  .report-card { padding: 1rem 0.9rem; }
  .stat-row { gap: 1rem; }

  /* Wide tables scroll inside their card, first column pinned so the row
     label stays readable while the numbers slide. */
  .report-card table, .trends-table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; }
  .report-card table th:first-child, .report-card table td:first-child,
  .trends-table th:first-child, .trends-table td:first-child {
    position: sticky; left: 0; background: var(--surface, #15151d); z-index: 1;
  }
  .report-card th, .report-card td, .trends-table th, .trends-table td { padding: 0.45rem 0.5rem; font-size: 0.85rem; }
  .trends-table th:nth-child(3), .trends-table td:nth-child(3),
  .trends-table th:nth-child(5), .trends-table td:nth-child(5) { display: none; }

  /* The flow schematic is unreadable squeezed to 284px; let it keep a
     legible width and scroll inside the card. */
  #tab-schematic .plotly-graph-div, #tab-schematic .js-plotly-plot, #historical-plot { min-width: 640px; }

  .rw-map-legend { max-width: 130px; font-size: 0.62rem; }
  .rw-map-legend .rw-leg-note { display: none; }
}

@media (hover: none) {
  .map-scroll-hint { display: none; }          /* Ctrl+scroll means nothing on touch */
  .mywater-chip.mywater-mini { padding: 0.3rem 0.6rem; font-size: 1rem; min-width: 32px; min-height: 32px; }
  input[type="range"] { height: 32px; }
  .historical-controls input[type="date"], .historical-load-btn, #evo-speed { min-height: 44px; }
  .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; }
}
