* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #10151c;
  color: #e6e9ee;
}

header {
  padding: 1rem 1.5rem 0.5rem;
}

h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }

.subtitle {
  margin: 0;
  color: #9aa7b5;
  font-size: 0.9rem;
  max-width: 70ch;
}

main {
  padding: 1rem 1.5rem 1.5rem;
}

#map-section { position: relative; }

#map {
  height: 72vh;
  border-radius: 10px;
  background: #0b0f14;
}

.status {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #9aa7b5;
}

.status.error { color: #ff8a80; }

.noaa-history-btn {
  margin-top: 0.55rem;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 0.28rem 0.5rem;
  background: #1e293b;
  color: #e2e8f0;
  cursor: pointer;
}

.noaa-history-btn:disabled { cursor: progress; opacity: 0.7; }

.noaa-history { margin-top: 0.45rem; max-width: 270px; }
.noaa-history-title { font-weight: 600; margin-bottom: 0.1rem; }
.noaa-history-chart { display: block; width: 100%; height: auto; }
.noaa-history-chart line { stroke: #64748b; stroke-width: 1; }
.noaa-history-chart polyline { fill: none; stroke: #fb923c; stroke-width: 2; }

#chart-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: #cdd6e0;
}

.note {
  font-size: 0.8rem;
  color: #8a96a5;
}

/* Pulsante per aprire il pannello delle serie storiche */
.toggle-btn {
  margin: 0.9rem 0;
  padding: 0.55rem 1rem;
  border: 1px solid #344154;
  border-radius: 8px;
  background: #1b2431;
  color: #cdd6e0;
  font-size: 0.9rem;
  cursor: pointer;
}

.toggle-btn:hover { background: #232f41; }

/* Pannello laterale a scomparsa per il grafico */
#chart-section {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(520px, 94vw);
  margin: 0;
  padding: 1rem;
  background: #171e28;
  border-radius: 0;
  transform: translateX(105%);
  transition: transform 0.25s ease;
  z-index: 1500; /* sopra i controlli Leaflet */
  overflow-y: auto;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
}

#chart-section.open { transform: translateX(0); }

.close-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: #9aa7b5;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.close-btn:hover { color: #fff; }

/* Legenda mappa */
.legend {
  background: rgba(16, 21, 28, 0.9);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.legend .bar {
  height: 10px;
  width: 160px;
  border-radius: 5px;
  background: linear-gradient(to right, #2c7fb0, #fee08b, #d7301f);
  margin-bottom: 0.15rem;
}

.legend-ticks {
  display: flex;
  justify-content: space-between;
  width: 160px;
  font-size: 0.68rem;
  color: #8a96a5;
  margin-bottom: 0.3rem;
}

.legend-src {
  color: #8a96a5;
  font-size: 0.72rem;
}

/* Selettore layer in tema scuro */
.leaflet-control-layers {
  background: rgba(16, 21, 28, 0.92);
  color: #cdd6e0;
  border: 1px solid #344154;
  border-radius: 8px;
  font-size: 0.82rem;
}

/* Popup dei marker: valori con didascalia */
.popup-row {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid #e2e2e2;
}

.popup-row:last-child { border-bottom: none; }

.popup-row .lbl {
  color: #555;
  font-size: 0.78rem;
  line-height: 1.25;
}

.popup-row .val {
  font-weight: 700;
  white-space: nowrap;
  align-self: center;
}

