:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #152238;
  --muted: #5b6b84;
  --brand: #2563eb;
  --border: #dbe4f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1160px, 94vw);
  margin: 0 auto;
}

.site-header {
  background: linear-gradient(135deg, #1f4db7, #2291d2);
  color: #fff;
  padding: 24px 0;
  margin-bottom: 20px;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
}

.site-header p {
  margin: 0;
  opacity: 0.92;
}

.top-nav {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.top-nav a {
  color: #fff;
  text-decoration: none;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  font-weight: 500;
}

.top-nav a.active,
.top-nav a:hover {
  background: rgba(255, 255, 255, 0.15);
}

.grid-two {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(21, 34, 56, 0.05);
  overflow: hidden;
}

.panel h2,
.panel h1 {
  margin-top: 0;
}

.river-list,
.station-list {
  display: grid;
  gap: 10px;
}

.river-item {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
}

.river-item:hover,
.river-item.selected {
  border-color: var(--brand);
  color: var(--brand);
  background: #f0f6ff;
}

.station-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.station-card:hover {
  border-color: var(--brand);
}

.station-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.station-card p {
  margin: 0;
  color: var(--muted);
}

.level-badge {
  text-align: right;
  min-width: 110px;
}

.level-badge strong {
  display: block;
  color: var(--brand);
}

.level-change {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.level-change.up {
  color: #0f9f5c;
}

.level-change.down {
  color: #d14343;
}

.level-change.same {
  color: var(--muted);
}

.level-badge span {
  color: var(--muted);
  font-size: 0.85rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: min(52vh, 420px);
  min-height: 260px;
  background: #f2f3f5;
  border: 1px solid #d9dde3;
  border-radius: 10px;
  padding: 10px;
}

.chart-controls {
  margin: 18px 0 14px;
  padding: 14px 16px;
  border: 1px solid #d4d8de;
  border-radius: 10px;
  background: #f1f2f4;
}

.chart-range-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: #505866;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.chart-year-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: #505866;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.year-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.scale-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.scale-btn {
  border: 1px solid #c4cad3;
  background: #ffffff;
  color: #4d5562;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.84rem;
  cursor: pointer;
}

.scale-btn.active {
  background: #6f8bc8;
  border-color: #5f79b2;
  color: #fff;
}

.year-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #cfd4dc;
  border-radius: 999px;
  background: #fff;
  color: #4b5564;
  font-size: 0.88rem;
}

.year-option input {
  margin: 0;
}

.chart-range-values {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: #556985;
  font-size: 0.88rem;
  font-weight: 500;
}

.double-range {
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
}

.double-range-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  border-radius: 999px;
  background: #cfd4dc;
}


.double-range-fill {
  position: absolute;
  height: 4px;
  background-color: #2563eb;
  opacity: 0.3;
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
}


.double-range input[type="range"] {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.double-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #eef3fa);
  border: 2px solid #5b79ad;
  box-shadow: 0 2px 7px rgba(37, 61, 98, 0.26);
  pointer-events: auto;
  cursor: pointer;
}

.double-range input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #eef3fa);
  border: 2px solid #5b79ad;
  box-shadow: 0 2px 7px rgba(37, 61, 98, 0.26);
  pointer-events: auto;
  cursor: pointer;
}

.current-level-box {
  margin: 14px 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fbff, #eef5ff);
}

.current-level-value {
  color: var(--brand);
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  font-weight: 700;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}

#levelChart {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}

#map {
  width: 100%;
  height: 72vh;
  min-height: 420px;
  border-radius: 12px;
}

#windowFill {
  position: absolute;
  height: 4px;
  background-color: rgba(37, 99, 235, 0.15);
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
}

#rangeFill {
  position: absolute;
  height: 6px;
  background-color: #2563eb;
  border-radius: 3px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
  transition: left 0.05s, width 0.05s;
}

.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 10px;
}

.station-meta,
.muted {
  color: var(--muted);
}

.error {
  color: #c02626;
}

.station-label {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(21, 34, 56, 0.08);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 8px;
}

.station-label::before {
  display: none;
}

@media (max-width: 900px) {
  .grid-two {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .has-selected-river .stations-panel {
    order: -1;
  }

  .station-card {
    flex-direction: column;
  }

  .level-badge {
    text-align: left;
  }

  #levelChart {
    height: 100% !important;
  }

  .chart-wrap {
    height: min(48vh, 320px);
    min-height: 220px;
  }

  .chart-range-values {
    flex-direction: column;
    gap: 6px;
  }

  #map {
    height: 68vh;
    min-height: 320px;
  }
}
