.view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.view-switch button {
  background: var(--panel);
  border: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 12px;
  cursor: pointer;
  border-right: 1px solid var(--line);
  transition: color var(--dur) ease, background var(--dur) ease;
}
.view-switch button:last-child { border-right: none; }
.view-switch button:hover { color: var(--fg); }
.view-switch button.active { background: var(--panel-2); color: var(--accent); }

.view { padding: 16px 24px 24px; }
.view.hidden { display: none; }

.time-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.time-control input[type="datetime-local"] {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
}
.time-control button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--dur) ease;
}
.time-control button:hover { background: var(--panel-2); }
.time-control button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.time-control .status { margin-left: auto; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr; }
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.tile .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.tile .value {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.tile .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.tile .sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Mapa -------------------------------------------------------------- */
#map {
  height: min(62vh, 620px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
}
@media (max-width: 760px) {
  #map { height: 48vh; }
}

.leaflet-container {
  background: var(--ink);
  font-family: var(--sans);
}
.leaflet-popup-content-wrapper {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.leaflet-popup-tip {
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.leaflet-popup-close-button {
  color: var(--muted) !important;
}
.leaflet-control-attribution {
  background: var(--panel) !important;
  color: var(--muted) !important;
  font-family: var(--mono);
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--fg) !important;
  border-color: var(--line) !important;
}
.leaflet-control-zoom a:hover { background: var(--panel-2) !important; }

/* Zawartość popupu stacji — budowana przez map.js metodami DOM
   (textContent), nigdy przez innerHTML z danymi źródła. */
.wx-popup-content { font-family: var(--sans); min-width: 160px; }
.wx-popup-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.wx-popup-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.wx-popup-empty {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.wx-popup-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 10px;
}
.wx-popup-label { color: var(--muted); }
.wx-popup-val { color: var(--fg); text-align: right; }
.wx-popup-btn {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--dur) ease;
}
.wx-popup-btn:hover { background: var(--ink); }
.wx-popup-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.legend {
  max-width: 360px;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.legend-bar {
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.legend-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}
.legend-nodata {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.legend-nodata .swatch-nodata {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px dashed var(--muted);
  background: transparent;
  flex: none;
}

/* Etykieta temperatury przy markerze — tooltip Leaflet, zawsze widoczny
   (permanent: true), nie tylko na hover. */
.leaflet-tooltip.wx-temp-label {
  background: rgba(11, 18, 26, 0.88);
  border: 1px solid var(--line);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  box-shadow: none;
}
.leaflet-tooltip.wx-temp-label::before { display: none; }

/* ---- Panel stacji (dokowany, nie L.popup — canvas potrzebuje realnego
   layoutu w chwili tworzenia, którego popup Leafleta nie daje) ---------- */
.station-panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.station-panel.hidden { display: none; }
.station-panel-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.station-panel-header .name { font-size: 15px; font-weight: 600; }
.station-panel-header .code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}
.station-panel-close {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.station-panel-close:hover { color: var(--fg); background: var(--panel-2); }

.station-panel .segmented { margin-bottom: 10px; }

.station-panel .plot-wrap {
  position: relative;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.station-panel canvas { display: block; width: 100%; height: 260px; }
