:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.90);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --blue: #3b82f6;
  --light-blue: #60a5fa;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.42);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
select {
  font: inherit;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  z-index: 1000;
}

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

.logo {
  font-size: 28px;
}

.brand h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.brand h1 span {
  color: var(--accent);
  font-weight: 300;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

#refresh-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

#refresh-btn:hover {
  transform: rotate(180deg);
}

#map {
  position: absolute;
  top: 60px;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

.sidebar {
  position: absolute;
  top: 80px;
  left: 20px;
  width: 330px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 900;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 600;
}

#count {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 12px;
}

.filters {
  padding: 14px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.filters label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filters select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: #172033 !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  padding: 9px 12px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  font-size: 13px;
}

.filters select:hover,
.filters select:focus {
  border-color: rgba(56, 189, 248, .6) !important;
}

.filters select option {
  background: #172033 !important;
  color: #e2e8f0 !important;
}

.filters select option:checked {
  background: #1e3a5f !important;
  color: #ffffff !important;
}

.sidebar-note {
  margin-top: 6px;
  color: #64748b;
  font-size: 10px;
  line-height: 1.45;
}

.legend {
  position: absolute;
  bottom: 28px;
  right: 20px;
  z-index: 900;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  font-size: 12px;
}

.legend h3 {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  color: var(--text-muted);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.dot.very-low { background: #2563eb; }
.dot.low { background: #60a5fa; }
.dot.normal { background: #22c55e; }
.dot.high { background: #f59e0b; }
.dot.very-high { background: #ef4444; }
.dot.unknown { background: #64748b; }

.error-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: min(560px, calc(100vw - 40px));
  background: rgba(30, 30, 30, 0.95);
  color: #fca5a5;
  padding: 16px 24px;
  border-radius: 8px;
  border: 1px solid #ef4444;
  z-index: 2000;
  display: none;
  font-size: 13px;
}

.leaflet-popup-content-wrapper {
  background: #0f172a;
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
}

.leaflet-popup-tip {
  background: #0f172a;
}

.leaflet-popup-content {
  margin: 12px;
  font-family: 'Inter', sans-serif;
}

.station-popup {
  width: 540px;
  max-width: calc(100vw - 80px);
}

.station-popup button {
  user-select: none;
}

.hydro-chart-container {
  user-select: none;
}

.chart-hover-line,
.chart-hover-point {
  pointer-events: none;
}

@media (max-width: 768px) {
  .topbar {
    height: 56px;
    padding: 0 12px;
  }

  .brand h1 {
    font-size: 17px;
  }

  #map {
    top: 56px;
  }

  .sidebar {
    top: auto;
    bottom: 10px;
    left: 10px;
    width: calc(100% - 20px);
  }

  .legend {
    right: 10px;
    bottom: 140px;
    padding: 10px 12px;
    font-size: 11px;
  }
}
