/* South Platte River Flow Tracker - Modern Responsive Design System */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Color Palette - Light Mode */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;

  /* Brand / River Theming */
  --river-blue: #0284c7;
  --river-blue-hover: #0369a1;
  --river-cyan: #06b6d4;
  --river-light: #e0f2fe;

  --badge-cdwr-bg: #e0f2fe;
  --badge-cdwr-text: #0369a1;
  --badge-cdwr-border: #bae6fd;

  --badge-usgs-bg: #ecfdf5;
  --badge-usgs-text: #047857;
  --badge-usgs-border: #a7f3d0;

  --trend-up: #ef4444;
  --trend-up-bg: #fef2f2;
  --trend-down: #0284c7;
  --trend-down-bg: #f0f9ff;
  --trend-steady: #64748b;
  --trend-steady-bg: #f8fafc;

  --chart-grid: #e2e8f0;
  --chart-axis: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-page: #0b1120;
  --bg-card: #151e32;
  --bg-card-hover: #1e293b;
  --bg-subtle: #1e293b;
  --bg-input: #1e293b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-color: #27354f;
  --border-subtle: #334155;

  --river-blue: #38bdf8;
  --river-blue-hover: #7dd3fc;
  --river-cyan: #22d3ee;
  --river-light: #0c4a6e;

  --badge-cdwr-bg: #082f49;
  --badge-cdwr-text: #7dd3fc;
  --badge-cdwr-border: #0369a1;

  --badge-usgs-bg: #064e3b;
  --badge-usgs-text: #6ee7b7;
  --badge-usgs-border: #047857;

  --trend-up: #f87171;
  --trend-up-bg: #450a0a;
  --trend-down: #38bdf8;
  --trend-down-bg: #082f49;
  --trend-steady: #94a3b8;
  --trend-steady-bg: #1e293b;

  --chart-grid: #27354f;
  --chart-axis: #64748b;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6);
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessible Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 1rem;
  background: var(--river-blue);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 1rem;
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ==================== HEADER ==================== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

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

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--river-blue), var(--river-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

.brand-icon svg {
  width: 26px;
  height: 26px;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.site-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

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

.last-updated-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 640px) {
  .last-updated-text {
    display: inline-block;
  }
}

.btn-icon, .btn-refresh {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-icon:hover, .btn-refresh:hover {
  background: var(--border-color);
}

.btn-icon {
  width: 40px;
  padding: 0;
  justify-content: center;
}

.btn-refresh svg, .btn-icon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.spin-icon {
  animation: spin 1s linear infinite;
}

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

/* ==================== WATERSHED SUMMARY BAR ==================== */
.summary-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
}

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

.summary-card {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--river-blue);
}

.summary-card.inflow::before { background: var(--river-cyan); }
.summary-card.outflow::before { background: #6366f1; }
.summary-card.stations::before { background: #10b981; }

.summary-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.summary-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.summary-unit {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.summary-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==================== TOOLBAR & FILTERS ==================== */
.toolbar-section {
  padding: 1.25rem 0 0.5rem;
}

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

.toolbar-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* View Switcher Tabs */
.view-switcher {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.15s ease;
}

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

.tab-btn.active {
  background: var(--river-blue);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tab-btn svg {
  width: 16px;
  height: 16px;
}

/* Search Box */
.search-form {
  position: relative;
  flex-grow: 1;
  max-width: 380px;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 2.25rem 0.55rem 2.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--river-blue);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.search-clear-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  padding: 4px;
  border-radius: 50%;
}

.search-clear-btn.visible {
  display: inline-flex;
}

/* Secondary Filter Bar (Chips & Agency) */
.toolbar-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.filter-chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--river-blue);
  color: var(--text-main);
}

.chip-btn.active {
  background: var(--river-light);
  border-color: var(--river-blue);
  color: var(--river-blue);
  font-weight: 700;
}

[data-theme="dark"] .chip-btn.active {
  background: #082f49;
  color: #38bdf8;
  border-color: #38bdf8;
}

.agency-filter {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.agency-pill {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.agency-pill.active {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--text-main);
}

/* ==================== VIEWS ==================== */
.view-container {
  padding: 1.25rem 0 3rem;
  flex-grow: 1;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* ==================== RIVER JOURNEY VIEW ==================== */
.journey-section {
  margin-bottom: 2.25rem;
}

.journey-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

.journey-section-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--river-light);
  color: var(--river-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

[data-theme="dark"] .journey-section-icon {
  background: #082f49;
  color: #38bdf8;
}

.journey-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.journey-section-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
}

/* Station Grid */
.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.15rem;
}

/* Station Card */
.station-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.station-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--river-blue);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-milestone-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.card-order-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--river-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-agency {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.badge-agency.cdwr {
  background: var(--badge-cdwr-bg);
  color: var(--badge-cdwr-text);
  border: 1px solid var(--badge-cdwr-border);
}

.badge-agency.usgs {
  background: var(--badge-usgs-bg);
  color: var(--badge-usgs-text);
  border: 1px solid var(--badge-usgs-border);
}

.card-stream {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Flow Display Row */
.card-flow-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-top: 1px dashed var(--border-color);
  border-bottom: 1px dashed var(--border-color);
}

.card-flow-val-wrap {
  display: flex;
  flex-direction: column;
}

.card-flow-val {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  font-family: var(--font-sans);
}

.card-flow-unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.card-stage-val {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.2rem;
}

/* Trend Badges */
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-full);
}

.trend-badge.rising {
  background: var(--trend-up-bg);
  color: var(--trend-up);
}

.trend-badge.falling {
  background: var(--trend-down-bg);
  color: var(--trend-down);
}

.trend-badge.steady {
  background: var(--trend-steady-bg);
  color: var(--trend-steady);
}

/* Sparkline area */
.card-chart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-sparkline-wrap {
  flex-grow: 1;
}

.sparkline-svg {
  display: block;
  width: 100%;
  height: 34px;
}

.sparkline-svg.empty line {
  stroke: var(--border-color);
}

.card-chart-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}

/* Card Footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-time {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-action-link {
  font-weight: 600;
  color: var(--river-blue);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

/* ==================== MAP VIEW ==================== */
.map-view-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
}

.map-toolbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend-dot.cdwr { background: #0284c7; }
.legend-dot.usgs { background: #059669; }

#map-container {
  width: 100%;
  height: 640px;
  min-height: 480px;
  background: var(--bg-subtle);
}

/* Custom Leaflet Map Pin */
.station-map-pin {
  background: transparent;
  border: none;
}

.pin-badge {
  background: var(--bg-card);
  border: 2px solid var(--river-blue);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: var(--text-main);
  transition: transform 0.15s ease;
}

.pin-badge:hover {
  transform: scale(1.1);
  z-index: 999;
}

.pin-badge.marker-cdwr {
  border-color: #0284c7;
}

.pin-badge.marker-usgs {
  border-color: #059669;
}

.pin-order {
  background: var(--river-blue);
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
}

.marker-usgs .pin-order {
  background: #059669;
}

.pin-flow {
  font-family: var(--font-sans);
}

.pin-cfs {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 1px;
}

/* Map Popup */
.custom-leaflet-popup .leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
}

.custom-leaflet-popup .leaflet-popup-tip {
  background: var(--bg-card);
}

.station-map-popup {
  padding: 0.25rem;
}

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

.popup-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
}

.popup-badge.marker-cdwr {
  background: var(--badge-cdwr-bg);
  color: var(--badge-cdwr-text);
}

.popup-badge.marker-usgs {
  background: var(--badge-usgs-bg);
  color: var(--badge-usgs-text);
}

.popup-order {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.popup-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.2rem;
  color: var(--text-main);
}

.popup-milestone {
  font-size: 0.72rem;
  color: var(--river-blue);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.popup-flow {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.popup-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.popup-stream {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
}

.btn-popup-details {
  width: 100%;
  background: var(--river-blue);
  color: white;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.btn-popup-details:hover {
  background: var(--river-blue-hover);
}

/* ==================== TABLE VIEW ==================== */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
}

.data-table th.sortable:hover {
  color: var(--text-main);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-subtle);
}

.table-flow-cell {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

.table-sparkline-cell {
  min-width: 110px;
}

/* ==================== MODAL DIALOG ==================== */
.modal-dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  max-width: 680px;
  width: 90vw;
  max-height: 90vh;
  padding: 0;
  outline: none;
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

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

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-close-modal {
  background: var(--bg-subtle);
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-close-modal:hover {
  color: var(--text-main);
  background: var(--border-color);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Chart Container & Tooltips */
.chart-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-range-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.range-btn {
  background: transparent;
  border: none;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.range-btn.active {
  background: var(--bg-card);
  color: var(--river-blue);
  box-shadow: var(--shadow-sm);
}

.chart-header-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.stat-pill {
  background: var(--bg-subtle);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-main);
}

.stat-pill .lbl {
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.svg-container {
  position: relative;
  width: 100%;
}

.hydrograph-svg {
  width: 100%;
  height: 240px;
  display: block;
}

.chart-axis-text {
  font-size: 10px;
  fill: var(--chart-axis);
  font-family: var(--font-sans);
}

.chart-axis-title {
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-muted);
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  z-index: 10;
  white-space: nowrap;
}

.tooltip-time {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.tooltip-value {
  color: var(--river-blue);
  font-weight: 800;
  font-size: 0.9rem;
}

.chart-empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

/* Modal Metadata Grid */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  background: var(--bg-subtle);
  padding: 0.85rem;
  border-radius: var(--radius-md);
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.meta-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.meta-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.station-desc-box {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  background: var(--bg-card);
  border-left: 3px solid var(--river-blue);
  padding: 0.5rem 0.85rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-external {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--river-blue);
  text-decoration: none;
}

.btn-external:hover {
  text-decoration: underline;
}

/* ==================== FOOTER ==================== */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.footer-links {
  display: flex;
  gap: 1.25rem;
}

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

.footer-links a:hover {
  color: var(--river-blue);
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 768px) {
  .site-title {
    font-size: 1.15rem;
  }
  
  .station-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-primary {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form {
    max-width: 100%;
  }

  .view-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
  }

  #map-container {
    height: 440px;
  }
}
