/* ═══════════════════════════════════════════════════════════════════════════
   AQI Monitor Italia — Stylesheet
   Versione: 1.0 — Mobile Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CUSTOM PROPERTIES ────────────────────────────────────────────────────── */
:root {
  --bg:      #07080d;
  --panel:   #0c0e18;
  --panel2:  #0f1120;
  --border:  #1a1e30;
  --border2: #242840;
  --accent:  #0ea5e9;
  --accent2: #38bdf8;
  --accent3: #7dd3fc;
  --text:    #dde1f0;
  --muted:   #4a5070;
  --muted2:  #6b7590;
  --grid:    #10121e;
  --green:   #22c55e;
  --blue:    #3b82f6;
  --mono:    'IBM Plex Mono', monospace;
  --sans:    'Space Grotesk', sans-serif;

  /* AQI scale */
  --aqi-good:  #22c55e;
  --aqi-mod:   #fbbf24;
  --aqi-usg:   #f97316;
  --aqi-bad:   #ef4444;
  --aqi-very:  #a855f7;
  --aqi-haz:   #7f1d1d;

  /* Layout dimensions */
  --header-h:  50px;
  --footer-h:  28px;
  --seismo-h:  44px;
  --left-w:    258px;
  --right-w:   288px;
}

/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 3px,
    rgba(0,0,0,.025) 3px, rgba(0,0,0,.025) 4px
  );
  pointer-events: none;
  z-index: 9998;
}

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb { background: var(--border2); }
::-webkit-scrollbar-track { background: transparent; }

/* ── LOADING SCREEN ───────────────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  gap: 18px;
  transition: opacity .7s;
}
#loading.hide { opacity: 0; pointer-events: none; }

.ld-logo  { font-family: var(--mono); font-size: 30px; font-weight: 600; color: var(--accent); letter-spacing: .12em; }
.ld-sub   { font-family: var(--mono); font-size: 10px; color: var(--muted2); letter-spacing: .28em; text-transform: uppercase; text-align: center; padding: 0 20px; }
.ld-track { width: 260px; height: 2px; background: var(--border2); overflow: hidden; }
.ld-bar   { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s ease; }
.ld-msg   { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .08em; }

/* ── HEADER ───────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  z-index: 1000;
  flex-shrink: 0;
  gap: 12px;
}

.logo-wrap { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* Animated bars — same as INGV seismo but in sky-blue */
.logo-aqi { display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.logo-aqi span {
  display: inline-block;
  width: 3px;
  border-radius: 1px;
  background: var(--accent);
  animation: logowave 2.2s ease-in-out infinite;
}
.logo-aqi span:nth-child(1) { height: 5px;  animation-delay: 0s; }
.logo-aqi span:nth-child(2) { height: 12px; animation-delay: .18s; }
.logo-aqi span:nth-child(3) { height: 20px; animation-delay: .36s; }
.logo-aqi span:nth-child(4) { height: 9px;  animation-delay: .54s; }
.logo-aqi span:nth-child(5) { height: 16px; animation-delay: .72s; }
.logo-aqi span:nth-child(6) { height: 7px;  animation-delay: .90s; }
.logo-aqi span:nth-child(7) { height: 4px;  animation-delay: 1.08s; }

@keyframes logowave {
  0%, 100% { transform: scaleY(1);   opacity: 1; }
  50%       { transform: scaleY(.3); opacity: .5; }
}

.logo-text .l1 { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: .06em; }
.logo-text .l2 { font-family: var(--mono); font-size: 8px; color: var(--muted); letter-spacing: .22em; text-transform: uppercase; margin-top: 2px; }

.hdr-filters { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; overflow-x: auto; }
.hdr-filters::-webkit-scrollbar { height: 0; }

.filter-btn {
  background: var(--grid);
  border: 1px solid var(--border2);
  color: var(--muted2);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
  padding: 5px 10px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(14,165,233,.1);
}

.hdr-right { display: flex; align-items: center; gap: 18px; flex-shrink: 0; }

.live-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--green);
  letter-spacing: .08em;
}

.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--green); }
  50%       { opacity: .3; box-shadow: none; }
}

#hdr-time { font-family: var(--mono); font-size: 11px; color: var(--muted2); letter-spacing: .05em; }

.refresh-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted2);
  font-family: var(--mono);
  font-size: 9px;
  padding: 5px 10px;
  cursor: pointer;
  letter-spacing: .1em;
  text-transform: uppercase;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.refresh-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.refresh-btn.spinning svg { animation: spin .6s linear infinite; }

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

/* ── MAIN APP LAYOUT ──────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: calc(100vh - var(--header-h) - var(--footer-h));
  overflow: hidden;
}

/* ── LEFT PANEL ───────────────────────────────────────────────────────────── */
.panel-left {
  width: var(--left-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  overflow: hidden;
}

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.kpi {
  padding: 11px 14px;
  position: relative;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.kpi:nth-child(even)  { border-right: none; }
.kpi:nth-child(3),
.kpi:nth-child(4)     { border-bottom: none; }

.kpi-n { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1.1; }
.kpi-l { font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); margin-top: 3px; }
.kpi-s { font-family: var(--mono); font-size: 9px; color: var(--muted2); margin-top: 2px; }

.c-r { color: var(--aqi-bad); }
.c-o { color: var(--aqi-usg); }
.c-y { color: var(--aqi-mod); }
.c-g { color: var(--green); }
.c-b { color: var(--accent); }

.list-head {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.list-title { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); }
.list-badge { font-family: var(--mono); font-size: 9px; color: var(--accent); background: rgba(14,165,233,.15); padding: 2px 8px; border-radius: 20px; }

/* Filtri regione / cerca */
.list-filters {
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lf-select {
  width: 100%;
  background: var(--grid);
  border: 1px solid var(--border2);
  border-radius: 3px;
  color: var(--muted2);
  font-family: var(--mono);
  font-size: 9px;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a5070'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
  transition: border-color .15s;
}
.lf-select:focus { border-color: var(--accent2); color: var(--text); }

.lf-search-wrap {
  display: flex;
  align-items: center;
  background: var(--grid);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 0 6px;
  gap: 5px;
  transition: border-color .15s;
}
.lf-search-wrap:focus-within { border-color: var(--accent2); }

.lf-ico  { width: 11px; height: 11px; color: var(--muted); flex-shrink: 0; }

.lf-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 9px;
  padding: 5px 0;
  min-width: 0;
}
.lf-input::placeholder { color: var(--muted); }

.lf-clear {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 3px;
  flex-shrink: 0;
  transition: color .1s;
  line-height: 1;
}
.lf-clear:hover { color: var(--accent); }

.lf-status { min-height: 14px; display: flex; align-items: center; }

#zoom-badge {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--accent);
  background: rgba(14,165,233,.12);
  border: 1px solid rgba(14,165,233,.25);
  padding: 1px 7px;
  border-radius: 2px;
  letter-spacing: .04em;
}

/* Station list */
.st-scroll { flex: 1; overflow-y: auto; }
.st-scroll::-webkit-scrollbar { width: 3px; }
.st-scroll::-webkit-scrollbar-thumb { background: var(--border2); }

.st-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(26,30,48,.5);
  cursor: pointer;
  transition: background .1s;
  position: relative;
  overflow: hidden;
}
.st-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: transparent;
  transition: background .15s;
}
.st-item:hover { background: rgba(255,255,255,.02); }
.st-item.sel   { background: rgba(14,165,233,.07); }
.st-item.sel::before,
.st-item:hover::before { background: var(--accent); }
.st-item.fl { animation: flash .7s ease; }

@keyframes flash {
  0%   { background: rgba(14,165,233,.25); }
  100% { background: transparent; }
}

.aqi-badge {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1;
  flex-direction: column;
  gap: 1px;
}

.st-meta { flex: 1; min-width: 0; }
.st-loc  { font-size: 10px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.st-info { font-family: var(--mono); font-size: 8px; color: var(--muted); letter-spacing: .03em; display: flex; align-items: center; gap: 6px; }

.st-r    { text-align: right; flex-shrink: 0; }
.st-cat  { font-family: var(--mono); font-size: 8px; color: var(--muted); }
.st-poll { font-family: var(--mono); font-size: 9px; color: var(--muted2); }

/* ── MAIN / MAP ───────────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
#map  { flex: 1; position: relative; background: #05060e; }

.leaflet-container { background: #05060e !important; }
.leaflet-tile { filter: invert(1) hue-rotate(200deg) saturate(0.22) brightness(0.72) contrast(1.12); }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--muted2) !important; border-color: var(--border2) !important; font-size: 14px !important; }
.leaflet-control-zoom a:hover { background: var(--grid) !important; color: var(--text) !important; }

.tt-custom {
  background: rgba(12,14,24,.95) !important;
  border: 1px solid #242840 !important;
  border-radius: 2px !important;
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 10px !important;
  color: #dde1f0 !important;
  padding: 8px 11px !important;
  box-shadow: 0 6px 24px rgba(0,0,0,.6) !important;
  white-space: nowrap;
  line-height: 1.6;
}

/* Map legend */
.map-legend {
  position: absolute;
  bottom: 60px;
  left: 12px;
  z-index: 500;
  background: rgba(12,14,24,.93);
  border: 1px solid var(--border2);
  backdrop-filter: blur(10px);
  padding: 10px 12px;
  min-width: 145px;
}
.legend-h   { font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); margin-bottom: 8px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.legend-row:last-child { margin-bottom: 0; }
.leg-dot    { border-radius: 50%; flex-shrink: 0; }
.leg-lbl    { font-family: var(--mono); font-size: 9px; color: var(--muted2); }

/* Alert bar */
.alert-bar {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 700;
  background: var(--aqi-bad);
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 10px;
  color: #fff;
  letter-spacing: .04em;
  animation: slideDown .3s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* Station popup */
.ev-popup {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 600;
  background: rgba(12,14,24,.97);
  border: 1px solid var(--border2);
  backdrop-filter: blur(16px);
  width: 260px;
  display: none;
}
.ev-popup.show { display: block; animation: popIn .2s ease; }
@keyframes popIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }

.pp-head   { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; }
.pp-mag    { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; }
.pp-mtype  { font-family: var(--mono); font-size: 9px; color: var(--muted); margin-top: 2px; }
.pp-close  { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 2px; transition: color .1s; }
.pp-close:hover { color: var(--text); }
.pp-body   { padding: 10px 14px; }
.pp-row    { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; border-bottom: 1px solid rgba(26,30,48,.4); }
.pp-row:last-child { border: none; }
.pp-k      { font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.pp-v      { font-family: var(--mono); font-size: 10px; color: var(--text); text-align: right; max-width: 165px; }
.pp-ext    { display: block; padding: 8px 14px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 9px; color: var(--accent); text-decoration: none; letter-spacing: .03em; transition: color .1s; }
.pp-ext:hover { color: var(--accent2); }

/* Spectrum Meter (replaces seismograph) */
.seismo-bar {
  height: var(--seismo-h);
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  flex-shrink: 0;
}
.seismo-lbl  { font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); flex-shrink: 0; display: flex; flex-direction: column; gap: 3px; }
.sl-tag      { color: var(--accent); }
.sl-name     { font-size: 7px; color: var(--muted); }
#meter       { flex: 1; height: 32px; }
.seismo-live { font-family: var(--mono); font-size: 8px; color: var(--accent); flex-shrink: 0; display: flex; align-items: center; gap: 5px; }
.seismo-live::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 2s infinite; }

/* ── RIGHT PANEL ──────────────────────────────────────────────────────────── */
.panel-right {
  width: var(--right-w);
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  overflow: hidden;
}

.stat-row { display: grid; grid-template-columns: 1fr 1fr 1fr; border-bottom: 1px solid var(--border); }
.stat-c   { padding: 9px; text-align: center; border-right: 1px solid var(--border); }
.stat-c:last-child { border-right: none; }
.stat-v   { font-family: var(--mono); font-size: 17px; font-weight: 500; line-height: 1; margin-bottom: 2px; }
.stat-l   { font-family: var(--mono); font-size: 7px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }

.chart-block { border-bottom: 1px solid var(--border); padding: 11px 13px; display: flex; flex-direction: column; }
.chart-block.grow { flex: 1; min-height: 0; }
.chart-t  { font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); margin-bottom: 9px; }
.chart-w  { position: relative; }
.chart-w.h120 { height: 120px; }
.chart-w.h100 { height: 100px; }

/* ── FOOTER ───────────────────────────────────────────────────────────────── */
footer {
  height: var(--footer-h);
  flex-shrink: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
}

.ft-src   { display: flex; align-items: center; flex: 1; overflow: hidden; min-width: 0; }
.ft-lbl   { font-family: var(--mono); font-size: 8px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); flex-shrink: 0; margin-right: 8px; padding-right: 8px; border-right: 1px solid var(--border2); }
.ft-links { display: flex; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.ft-link  { font-family: var(--mono); font-size: 9px; color: var(--muted2); text-decoration: none; letter-spacing: .02em; transition: color .12s; white-space: nowrap; padding: 0 7px; }
.ft-link:hover { color: var(--accent2); }
.ft-link b { font-size: 8px; color: var(--muted); font-weight: 400; margin-right: 3px; }
.ft-div   { color: var(--border2); font-size: 11px; user-select: none; }
.ft-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.ft-copy  { font-family: var(--mono); font-size: 8px; color: var(--muted); letter-spacing: .05em; white-space: nowrap; }

/* ── MAP CONTROLS ─────────────────────────────────────────────────────────── */
.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 500;
  background: rgba(12,14,24,.93);
  border: 1px solid var(--border2);
  backdrop-filter: blur(12px);
  padding: 10px 12px;
  min-width: 178px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.mc-title {
  font-family: var(--mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--muted);
  margin-bottom: 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.mc-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 3px 0;
  border-radius: 3px;
  transition: background .1s;
  user-select: none;
}
.mc-row:hover { background: rgba(255,255,255,.03); }
.mc-row input[type="checkbox"] { display: none; }
.mc-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: .5;
  transition: opacity .2s;
}
.mc-row.active .mc-dot,
.mc-row:has(input:checked) .mc-dot { opacity: 1; }
.mc-lbl {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted2);
  flex: 1;
  transition: color .15s;
}
.mc-row.active .mc-lbl,
.mc-row:has(input:checked) .mc-lbl { color: var(--text); }
.mc-zoom-lv {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--muted);
  background: var(--grid);
  padding: 1px 5px;
  border-radius: 2px;
  flex-shrink: 0;
}
#zoom-filter-label.active { border-left: 2px solid var(--accent); padding-left: 4px; }
#label-toggle-label.active { border-left: 2px solid var(--accent2); padding-left: 4px; }

/* ── MOBILE TOGGLE BUTTONS ────────────────────────────────────────────────── */
.mob-toggle {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  background: var(--panel);
  border: 1px solid var(--border2);
  color: var(--muted2);
  font-family: var(--mono);
  font-size: 11px;
  width: 28px;
  height: 52px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  transition: background .15s, color .15s, border-color .15s;
  padding: 0;
  backdrop-filter: blur(8px);
}
.mob-toggle:hover,
.mob-toggle.active { background: rgba(14,165,233,.15); color: var(--accent); border-color: var(--accent); }
.mob-toggle-left  { left: 0;  border-left: none;  border-radius: 0 4px 4px 0; }
.mob-toggle-right { right: 0; border-right: none; border-radius: 4px 0 0 4px; }

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 889;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}
.drawer-overlay.show { display: block; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  (max 1024px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --left-w: 220px; --right-w: 240px; }
  .logo-text .l2 { display: none; }
  #hdr-time      { display: none; }
  .chart-w.h120  { height: 100px; }
  .chart-w.h100  { height: 85px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  (max 768px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --header-h: 96px; --footer-h: 36px; --left-w: 88vw; --right-w: 88vw; }

  header { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 8px; }
  .logo-wrap   { order: 1; }
  .hdr-right   { order: 2; gap: 10px; }
  .hdr-filters { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; gap: 4px; }
  .hdr-filters::-webkit-scrollbar { height: 0; }
  .filter-btn { padding: 5px 9px; font-size: 8px; }
  #hdr-time { display: none; }

  .app { position: relative; height: calc(100dvh - var(--header-h) - var(--footer-h)); overflow: hidden; }

  .panel-left {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    width: var(--left-w); max-width: 320px;
    z-index: 890;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    border-right: 1px solid var(--border2);
    box-shadow: 4px 0 24px rgba(0,0,0,.6);
    overflow-y: auto;
  }
  .panel-left.open { transform: translateX(0); }

  .panel-right {
    position: absolute;
    top: 0; bottom: 0; right: 0;
    width: var(--right-w); max-width: 320px;
    z-index: 890;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    border-left: 1px solid var(--border2);
    box-shadow: -4px 0 24px rgba(0,0,0,.6);
    overflow-y: auto;
  }
  .panel-right.open { transform: translateX(0); }

  .main { width: 100%; }
  .mob-toggle { display: flex; }

  .ev-popup {
    top: auto;
    bottom: calc(var(--seismo-h) + 8px);
    right: 36px; left: 36px;
    width: auto;
  }
  .map-legend  { padding: 7px 9px; bottom: 50px; left: 36px; }
  .legend-h    { font-size: 7px; margin-bottom: 5px; }
  .leg-lbl     { font-size: 8px; }
  footer { height: var(--footer-h); padding: 0 12px; gap: 8px; }
  .ft-src  { display: none; }
  .ft-right { gap: 8px; }
  .ft-copy { font-size: 8px; }
  .seismo-bar { height: 36px; }
  .sl-name { display: none; }
  .chart-w.h120 { height: 110px; }
  .chart-w.h100 { height: 90px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE PORTRAIT  (max 480px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  :root { --header-h: 88px; --left-w: 94vw; --right-w: 94vw; }
  .logo-text .l1 { font-size: 13px; }
  .logo-aqi      { display: none; }
  .filter-btn    { padding: 4px 7px; font-size: 8px; }
  .ev-popup      { right: 32px; left: 32px; }
  .pp-mag        { font-size: 24px; }
  .map-legend    { display: none; }
  .alert-bar     { font-size: 9px; padding: 6px 10px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOUCH IMPROVEMENTS
   ═══════════════════════════════════════════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
  .filter-btn  { padding: 7px 12px; }
  .st-item     { padding: 12px 14px; min-height: 48px; }
  .pp-close    { padding: 6px 10px; font-size: 20px; }
  .refresh-btn { padding: 8px 14px; }
  .mob-toggle  { width: 32px; height: 56px; }
  .st-item:hover { background: transparent; }
  .filter-btn:hover:not(.active) {
    background: var(--grid);
    color: var(--muted2);
    border-color: var(--border2);
  }
}

/* ── MAP controls shift right on mobile ─── */
@media (max-width: 768px) {
  .map-controls { left: 40px; top: 10px; min-width: 160px; padding: 8px 10px; }
}
@media (max-width: 480px) {
  .map-controls { font-size: 8px; }
  .mc-lbl { font-size: 8px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  header, footer, .seismo-bar, .panel-right,
  #loading, #cookie-banner, #privacy-modal,
  .mob-toggle, .drawer-overlay { display: none !important; }
  body, html { overflow: visible !important; background: white !important; color: black !important; }
  .panel-left { width: 200px; position: static; transform: none; }
  #map { height: 500px !important; filter: none !important; }
}
