:root {
  --ink: #15221c;
  --muted: #67746d;
  --paper: #f4f2ec;
  --panel: #fbfaf6;
  --line: #dcded7;
  --forest: #183f31;
  --forest-dark: #10251d;
  --moss: #708a45;
  --lime: #b7d568;
  --gold: #eab44e;
  --orange: #e87535;
  --red: #c93f2f;
  --shadow: 0 12px 38px rgba(15, 35, 27, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 9999; background: white; padding: 10px 16px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  background: var(--forest-dark);
  color: white;
  border-bottom: 1px solid rgba(255,255,255,.1);
  position: relative;
  z-index: 1001;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #d8e7b7; color: var(--forest); }
.brand-mark svg { width: 28px; fill: currentColor; }
.brand h1 { font-family: Georgia, serif; font-weight: 500; font-size: 25px; line-height: 1; margin: 3px 0 0; letter-spacing: -.02em; }
.eyebrow { display: block; font-size: 10px; line-height: 1.3; font-weight: 800; letter-spacing: .14em; opacity: .68; }
.freshness { margin-left: auto; display: flex; align-items: center; gap: 9px; font-size: 12px; color: #d7e1db; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #a5cf70; box-shadow: 0 0 0 5px rgba(165,207,112,.1); }
.freshness.demo .status-dot { background: var(--gold); box-shadow: 0 0 0 5px rgba(234,180,78,.12); }
.freshness.error .status-dot { background: var(--red); }

.workspace { height: calc(100% - 72px); display: grid; grid-template-columns: 286px minmax(440px, 1fr); }
.control-panel { background: var(--panel); overflow-y: auto; position: relative; z-index: 600;
                 border-right: 1px solid var(--line); padding: 22px 20px; }

/* ==== i livelli si aprono sui loro filtri ==================================
   Il pannello era una colonna sempre srotolata: otto blocchi, circa
   milleottocento pixel in una colonna da 286. Adesso e' un elenco di livelli,
   e ogni livello tiene i **suoi** filtri dentro di se', aperti uno per volta.
   Chiuso sta in poco piu' di cinquecento pixel.

   Lo sfondo cartografico e' uscito del tutto: sta sulla mappa (.basemap-panel),
   perche' e' una scelta su come si legge la mappa e la si fa guardandola. */
.layers-head { display: flex; align-items: baseline; gap: 8px; }
.layers-head .field-label { margin-bottom: 6px; }
.layers-head #layersCount { margin-left: auto; font-size: 9px; color: var(--muted); }

.layer-row { border-bottom: 1px solid #ececE4; }
.layer-row:last-child { border-bottom: 0; }
.layer-row.open { background: #f6f7f2; margin: 0 -20px; padding: 0 20px; border-color: var(--line); }
.layer-head { display: grid; grid-template-columns: 14px 1fr 24px 34px; gap: 9px;
              align-items: center; padding: 9px 0; }
.layer-name { text-align: left; border: 0; background: none; padding: 0; min-width: 0; }
button.layer-name { cursor: pointer; }
.layer-name strong { display: block; font-size: 12px; }
.layer-name small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.layer-chevron { border: 0; background: none; padding: 0; cursor: pointer; display: grid;
                 place-items: center; color: #8a938c; }
.layer-chevron svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2;
                     stroke-linecap: round; stroke-linejoin: round; transition: transform .18s ease; }
.layer-row.open .layer-chevron { color: var(--forest); }
.layer-row.open .layer-chevron svg { transform: rotate(180deg); }
.layer-switch { cursor: pointer; display: block; }
.layer-switch input { position: absolute; opacity: 0; pointer-events: none; }
.layer-switch i { display: block; width: 32px; height: 18px; border-radius: 20px; background: #c8cdc6;
                  position: relative; transition: .2s; }
.layer-switch i::after { content: ""; position: absolute; width: 14px; height: 14px; background: white;
                         border-radius: 50%; left: 2px; top: 2px; transition: .2s;
                         box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.layer-switch input:checked + i { background: var(--forest); }
.layer-switch input:checked + i::after { transform: translateX(14px); }
.layer-switch input:focus-visible + i { outline: 2px solid var(--forest); outline-offset: 2px; }

/* I filtri stanno rientrati e con un filo a sinistra: si vede a chi
   appartengono, invece di sembrare una sezione nuova. */
.layer-filters { display: none; padding: 2px 0 12px 21px; margin: 0 0 6px 5px;
                 border-left: 2px solid #e2e5dc; }
.layer-row.open .layer-filters { display: block; }
.filter-label { display: block; font-size: 9px; font-weight: 800; letter-spacing: .08em;
                text-transform: uppercase; color: #8a938c; margin-bottom: 5px; }
.toggle-row-inline { grid-template-columns: 14px 1fr 32px; padding: 8px 0 2px;
                     margin-top: 8px; border-top: 1px solid #e9ebe4; }

/* ==== lo sfondo, sulla mappa ============================================== */
.map-tool-wrap { position: relative; }
.basemap-panel { position: absolute; right: 0; top: 45px; width: 246px; padding: 12px 13px 13px;
                 background: rgba(253,252,248,.97); backdrop-filter: blur(9px);
                 border: 1px solid rgba(36,56,46,.14); border-radius: 12px; box-shadow: var(--shadow); }
.basemap-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.basemap-head .field-label { margin-bottom: 0; }
.basemap-head .layer-switch { margin-left: auto; }
.basemap-panel .layer-opacity { width: 100%; margin: 8px 0 0; }
.basemap-panel .field-note { margin-top: 8px; }

/* ==== l'angolo di lettura: legenda sopra, giorno sotto ====================
   Stavano ai due angoli opposti, e la barra del giorno finiva sotto al
   pannello di dettaglio ogni volta che si apriva un bosco - cioe' proprio
   mentre se ne scorrevano i giorni. */
.map-corner { position: absolute; z-index: 500; left: 18px; bottom: 20px; width: 290px;
              display: flex; flex-direction: column; gap: 10px; }

/* ==== il dettaglio: c'e' solo quando hai cliccato qualcosa ================
   Al suo posto restava sempre una colonna da 336 px che diceva "Esplora la
   mappa": trecento pixel per un invito. Allargata a 400: le tre righe di
   fatto e il calendario a tre righe del bosco ci stavano troppo stretti. */
.inspector { position: absolute; z-index: 640; right: 0; top: 0; bottom: 0; width: 400px;
             overflow-y: auto; background: rgba(251,250,246,.97); backdrop-filter: blur(10px);
             border-left: 1px solid rgba(36,56,46,.16); box-shadow: -10px 0 30px rgba(15,35,27,.13);
             transform: translateX(100%); transition: transform .22s ease; }
.inspector.open { transform: translateX(0); }

.control-section { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.field-label { display: block; font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: .1em; margin-bottom: 9px; color: #4d5e55; }
.field-note { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 8px 0 0; }
.date-control { display: grid; grid-template-columns: 36px 1fr 36px; border: 1px solid #cfd4cc; border-radius: 10px; overflow: hidden; background: white; }
.date-control button { border: 0; background: transparent; font-size: 22px; cursor: pointer; }
.date-control button:hover { background: #edf1e8; }
.date-control input { min-width: 0; border: 0; border-left: 1px solid #e4e5df; border-right: 1px solid #e4e5df; padding: 10px 7px; color: var(--ink); background: white; }
select { width: 100%; border: 1px solid #cfd4cc; background: white; border-radius: 10px; padding: 10px 12px; color: var(--ink); }
.species-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.species-tab { border: 1px solid #d4d8d1; border-radius: 11px; background: white; padding: 11px 8px; display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.species-tab.active { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); background: #f2f5ed; }
.species-tab strong { display: block; font-size: 12px; }
.species-tab small { display: block; color: var(--muted); font-size: 9px; margin-top: 2px; }
.species-icon { width: 15px; height: 15px; border-radius: 55% 55% 42% 42%; position: relative; flex: 0 0 auto; }
.species-icon::after { content: ""; position: absolute; width: 6px; height: 7px; border-radius: 0 0 2px 2px; background: #d9ceb6; top: 9px; left: 5px; }
.species-icon.cool { background: #8c624b; }
.species-icon.warm { background: #543829; }
.layer-section { border-bottom: 0; margin-bottom: 7px; }
.toggle-row { display: grid; grid-template-columns: 16px 1fr 34px; gap: 10px; align-items: center; padding: 8px 0; cursor: pointer; }
.toggle-row-static { grid-template-columns: 16px 1fr; cursor: default; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 12px; }
.toggle-row small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { width: 32px; height: 18px; border-radius: 20px; background: #c8cdc6; position: relative; transition: .2s; }
.toggle-row i::after { content: ""; position: absolute; width: 14px; height: 14px; background: white; border-radius: 50%; left: 2px; top: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.toggle-row input:checked + i { background: var(--forest); }
.toggle-row input:checked + i::after { transform: translateX(14px); }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.swatch.suitability { background: linear-gradient(135deg,var(--lime),var(--red)); }
.swatch.station { background: white; border: 3px solid #263e34; border-radius: 50%; }
.method-card { background: #e9ede4; border: 1px solid #d9ded4; border-radius: 12px; padding: 14px; }
.method-title { font-size: 12px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.method-title span { width: 20px; height: 20px; border-radius: 6px; background: var(--forest); color: white; display: grid; place-items: center; font-family: Georgia,serif; }
.method-card p { font-size: 10px; margin: 5px 0; color: #4e5d55; }
.text-button { padding: 7px 0 0; border: 0; background: none; color: var(--forest); font-size: 10px; font-weight: 800; cursor: pointer; }

.map-shell { position: relative; overflow: hidden; background: #dfe4d8; }
#map { height: 100%; width: 100%; background: radial-gradient(circle at 45% 35%,#e7eadf,#cfd8cb); }
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 9px !important; }
.map-top-tools { position: absolute; z-index: 500; top: 16px; right: 16px; display: flex; gap: 7px; }
.map-tool, .icon-button { border: 1px solid rgba(20,40,30,.15); background: rgba(255,255,255,.94); border-radius: 9px; cursor: pointer; display: grid; place-items: center; }
.map-tool { width: 38px; height: 38px; box-shadow: 0 4px 14px rgba(20,40,30,.12); }
.map-tool svg, .icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.map-tool.active { color: var(--forest); }
.icon-button { width: 34px; height: 34px; font-size: 24px; }
.legend { width: 100%; padding: 13px 14px; background: rgba(253,252,248,.94); backdrop-filter: blur(9px); border: 1px solid rgba(36,56,46,.14); border-radius: 12px; box-shadow: var(--shadow); }
.legend-head { display: flex; justify-content: space-between; font-size: 11px; font-weight: 800; margin-bottom: 8px; }
.gradient-bar { height: 8px; border-radius: 6px; background: linear-gradient(90deg,#d6d5ca 0 20%,#8db64d 38%,#e9c94b 58%,#ec8339 76%,#c93f2f 100%); }
.legend-ticks { display: flex; justify-content: space-between; color: #59675f; font-size: 9px; margin-top: 4px; }
.legend-labels { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; margin-top: 3px; font-size: 8px; color: #768078; }
.legend-labels span:nth-child(2), .legend-labels span:nth-child(3) { text-align: center; }
.legend-labels span:last-child { text-align: right; }
.legend-foot { border-top: 1px solid #dedfd8; margin-top: 9px; padding-top: 8px; font-size: 9px; color: var(--muted); }
.legend-foot i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); margin-right: 5px; }
.map-message { position: absolute; z-index: 501; left: 50%; top: 16px; transform: translateX(-50%); max-width: min(580px,80%); padding: 10px 14px; border-radius: 10px; background: #fff6dd; color: #684a14; border: 1px solid #e8ce91; box-shadow: var(--shadow); font-size: 11px; }
.loading-overlay { position: absolute; z-index: 700; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(237,239,231,.72); backdrop-filter: blur(3px); color: var(--forest); font-size: 12px; font-weight: 700; }
.loader { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(25,65,49,.18); border-top-color: var(--forest); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.station-marker { background: transparent; border: 0; }
.station-marker span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: white; font-weight: 900; font-size: 9px; border: 3px solid white; box-shadow: 0 2px 9px rgba(16,37,29,.38); }
.station-marker.selected span { width: 34px; height: 34px; margin: -3px; border-color: #12291f; box-shadow: 0 0 0 4px rgba(255,255,255,.7),0 3px 12px rgba(10,30,22,.45); }
.leaflet-tooltip.station-tooltip { background: #142b21; color: white; border: 0; border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 10px; }
.leaflet-tooltip.station-tooltip::before { border-top-color: #142b21; }

.empty-state { height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; padding: 34px; color: var(--muted); }
.empty-state h2 { font-family: Georgia,serif; color: var(--ink); font-weight: 500; margin: 15px 0 8px; }
.empty-state p { max-width: 240px; font-size: 12px; line-height: 1.55; }
.empty-orbit { width: 64px; height: 64px; border: 1px dashed #a8b1aa; border-radius: 50%; position: relative; }
.empty-orbit::before { content: ""; position: absolute; inset: 13px; border: 1px solid #bdc5be; border-radius: 50%; }
.empty-orbit span { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--moss); top: 3px; left: 27px; }
.station-detail { padding: 24px 22px; }
.station-head { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.station-head h2 { font-family: Georgia,serif; font-size: 24px; line-height: 1.1; font-weight: 500; margin: 5px 0 4px; }
.station-head p { color: var(--muted); font-size: 10px; margin: 0; }
.score-block { display: grid; grid-template-columns: 105px 1fr; gap: 15px; align-items: center; padding: 21px 0; }
.score-block > div:first-child { width: 96px; height: 72px; border-radius: 15px; background: #e9eee1; display: flex; align-items: baseline; justify-content: center; padding-top: 12px; }
.score-block #scoreValue { font-family: Georgia,serif; font-size: 36px; line-height: 1; }
.score-block small { color: var(--muted); font-size: 11px; }
.score-block > div:last-child strong, .score-block > div:last-child span { display: block; }
.score-block > div:last-child strong { font-size: 16px; text-transform: capitalize; }
.score-block > div:last-child span { font-size: 11px; color: var(--muted); margin-top: 4px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.metric-grid > div { padding: 12px; min-width: 0; }
.metric-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
.metric-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.metric-grid span { display: block; color: var(--muted); font-size: 9px; margin-bottom: 4px; }
.metric-grid strong { font-family: Georgia,serif; font-size: 22px; font-weight: 500; }
.metric-grid small { color: var(--muted); font-size: 9px; margin-left: 3px; }
.timeline-card { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: white; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.card-head strong { font-size: 11px; }
.card-head span { color: var(--muted); font-size: 8px; }
.series-chart { height: 135px; }
.series-chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: #e7e8e3; stroke-width: 1; }
.chart-temp { fill: none; stroke: #c4542e; stroke-width: 2.2; }
.chart-rain { fill: #82a9b1; opacity: .5; }
.chart-dot { fill: white; stroke: #c4542e; stroke-width: 1.5; }
.chart-label { font-size: 7px; fill: #778079; }
.diagnostic { margin-top: 16px; border-left: 3px solid var(--moss); padding: 9px 11px; background: #eef1e9; font-size: 10px; line-height: 1.5; color: #526159; }

dialog { width: min(620px,calc(100% - 30px)); border: 0; border-radius: 17px; padding: 0; color: var(--ink); box-shadow: 0 30px 80px rgba(9,25,18,.34); }
dialog::backdrop { background: rgba(11,27,20,.62); backdrop-filter: blur(3px); }
.dialog-card { padding: 25px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; }
.dialog-head h2 { font-family: Georgia,serif; font-weight: 500; margin: 4px 0 12px; font-size: 28px; }
.dialog-card p, .dialog-card li { font-size: 12px; line-height: 1.6; }
.dialog-card ol { padding-left: 20px; }
.dialog-callout { background: #eef1e9; border-left: 3px solid var(--moss); padding: 11px 13px; }
.primary-button { border: 0; background: var(--forest); color: white; padding: 11px 17px; border-radius: 9px; font-weight: 700; cursor: pointer; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 250px minmax(420px,1fr); }
}
@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .topbar { height: 62px; padding: 0 12px; }
  .brand { min-width: 0; }
  .brand-mark { width: 35px; height: 35px; }
  .brand h1 { font-size: 21px; }
  .brand .eyebrow, .freshness { display: none; }
  .topbar .mobile-only { margin-left: auto; }
  .workspace { height: calc(100% - 62px); grid-template-columns: 1fr; }
  /* Su schermo stretto il pannello torna un cassetto: la mappa ha bisogno di
     tutta la larghezza che c'e'. */
  .control-panel { position: fixed; z-index: 1100; inset: 62px 0 0 0; width: min(330px,88vw);
                   box-shadow: 14px 0 40px rgba(10,28,20,.2); transform: translateX(-105%);
                   transition: transform .25s ease; }
  .control-panel.open { transform: translateX(0); }
  .panel-mobile-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
  .inspector { top: auto; height: min(78vh,630px); width: 100%; border-radius: 18px 18px 0 0; transform: translateY(105%); }
  .inspector.open { transform: translateY(0); }
  /* Con tre livelli in legenda (griglia, boschi, sentieri) il contenuto e'
     alto quanto lo schermo di un telefono e ci stava comodamente per intero:
     non veniva tagliato, semplicemente occupava tutto lo schermo, mappa
     compresa. 46vh lascia la meta' dello schermo alla mappa; la legenda
     scorre al suo interno, la barra del giorno - il controllo che si usa
     di piu' - resta sempre visibile in fondo. */
  .map-corner { width: calc(100% - 32px); left: 16px; bottom: 16px;
                max-height: 46vh; overflow: hidden; }
  .legend { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .time-bar { flex: none; }
  .inspector { width: 100%; }
  .map-top-tools { top: 12px; right: 12px; }
}


/* Barra temporale: giorno mostrato sulla mappa, da oggi a +10.
   Sta sopra la mappa a destra della legenda, per restare leggibile anche
   quando l'inspector e chiuso. */
.time-bar { position: relative; width: 100%; padding: 12px 14px 10px; background: rgba(253,252,248,.94); backdrop-filter: blur(9px); border: 1px solid rgba(36,56,46,.14); border-radius: 12px; box-shadow: var(--shadow); }
.time-bar-head { display: flex; align-items: baseline; gap: 7px; margin-bottom: 6px; }
.time-bar-head .field-label { margin-bottom: 0; }
.time-bar-head strong { font-size: 13px; }
.time-bar-head span:last-child { margin-left: auto; font-size: 11px; color: var(--muted); }
.time-bar input[type=range] { width: 100%; accent-color: #c8712f; }
.time-bar-scale { display: flex; justify-content: space-between; font-size: 9px; color: #768078; }
.time-bar small { display: block; margin-top: 6px; padding-top: 7px; border-top: 1px solid #dedfd8; font-size: 9px; color: var(--muted); }

/* Striscia dei prossimi giorni nel dettaglio stazione. */
.timeline { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.timeline-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 3px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; font: inherit; }
.timeline-cell i { display: block; width: 100%; height: 16px; border-radius: 3px; }
.timeline-cell span { font-size: 8px; color: var(--muted); }
.timeline-cell:hover { border-color: rgba(36,56,46,.2); }
.timeline-cell.selected { border-color: #c8712f; background: rgba(200,113,47,.09); }
.timeline-cell.selected span { color: #a2551d; font-weight: 700; }

@media (max-width: 900px) {
  .time-bar { right: 12px; left: 12px; bottom: 84px; width: auto; }
}

/* Filtro famiglia a tre stati: "Tutte" occupa la riga intera. */
.species-tab.wide { grid-column: 1 / -1; }
.species-icon.both { background: linear-gradient(135deg, #8c624b 50%, #543829 50%); }
.field-label em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); margin-left: 5px; }
.source-fixed { margin: 0; font-size: 12px; }
.source-fixed b { font-weight: 700; }

/* Metriche condivise fra le famiglie: tre celle su una riga. */
.metric-grid { grid-template-columns: 1fr 1fr 1fr; }
.metric-grid > div:nth-child(odd) { border-right: none; }
.metric-grid > div:not(:last-child) { border-right: 1px solid var(--line); }
.metric-grid > div:nth-child(-n+2) { border-bottom: none; }

/* Una scheda per famiglia: sempre entrambe, anche a mappa filtrata. */
.family-cards { display: grid; gap: 10px; margin-top: 14px; }
/* min-width:0 e' il pezzo che mancava: .family-cards e' una grid a colonna
   implicita, e per difetto non si restringe sotto il contenuto piu' largo -
   il calendario del bosco (vedi .forest-cal) faceva "scoppiare" la scheda
   fuori dal pannello invece di scorrere al proprio interno. */
.family-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: white; min-width: 0; }
.family-card.muted { opacity: .62; }
.family-card header { display: flex; align-items: baseline; gap: 7px; }
.family-card header strong { font-size: 13px; }
.family-card header small { color: var(--muted); font-size: 9px; margin-left: 4px; }
.family-card header b { margin-left: auto; font-family: Georgia,serif; font-size: 24px; font-weight: 500; }
.family-phase { margin: 5px 0 0; font-size: 11px; text-transform: capitalize; }
.family-phase em { font-style: normal; text-transform: none; font-size: 9px; color: #a2551d; background: rgba(200,113,47,.12); border-radius: 4px; padding: 1px 5px; margin-left: 4px; }
.family-note { margin: 3px 0 9px; font-size: 9px; color: var(--muted); }
.timeline.dense span { display: none; }
.timeline.dense .timeline-cell { padding: 4px 0; }

/* Scheda bosco: due fatti separati (si raccoglie / fase) invece di una frase
   sola che poteva contraddirsi - vedi pipeline/zonal.py aggregate(). */
.fact-lines { margin: 5px 0 0; display: grid; gap: 3px; }
.fact-line { display: flex; align-items: baseline; gap: 6px; font-size: 11px; line-height: 1.4; margin: 0; }
.fact-line .dot { flex: none; width: 7px; height: 7px; border-radius: 50%; margin-top: 2px; }
.fact-line .dot.on { background: var(--forest-dark); }
.fact-line .dot.off { background: none; border: 1.4px solid var(--muted); }

/* Il calendario del bosco: tre righe di caselle (si raccoglie / fase / fra
   quanti giorni), non una sola. Le rampe dell'indice e del "fra quanti
   giorni" sono quelle gia' in uso su raster e legenda; la fase usa una
   palette a parte (vedi PHASE_STRONG in v1.js). */
/* Colonne a larghezza fissa (vedi v1.js): con l'orizzonte lungo non tutte
   entrano nei 400px del pannello, quindi la riga scorre invece di
   schiacciarsi sotto la larghezza leggibile del testo - prima restava
   tagliata a meta' oltre +12. L'etichetta di riga resta ferma a sinistra
   mentre si scorre, come la prima colonna di un foglio di calcolo. */
.forest-cal { display: grid; gap: 3px 2px; align-items: center; margin: 10px 0 2px; overflow-x: auto; padding-bottom: 2px; }
.forest-cal .cal-day-head, .forest-cal .cal-row-label { font-size: 8px; color: var(--muted); }
.forest-cal .cal-row-label {
  font-weight: 700; padding-right: 3px; position: sticky; left: 0;
  background: white;
}
.forest-cal .cal-cell {
  height: 16px; border-radius: 3px; display: grid; place-items: center;
  font-size: 7.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.forest-cal .cal-cell.dim { background: var(--paper); color: var(--muted); font-weight: 400; border-style: dashed; border-color: var(--line); opacity: .7; }
/* Il giorno mostrato dalla barra del tempo: senza questo, scorrendola non si
   vedeva piu' quale colonna fosse accesa - lo faceva la vecchia striscia. */
.forest-cal .cal-day-head {
  text-align: center; border: 0; background: none; padding: 1px 0; font: inherit;
  cursor: pointer; border-radius: 4px;
}
.forest-cal .cal-day-head:hover { background: rgba(200,113,47,.09); }
.forest-cal .cal-day-head.selected { color: #a2551d; font-weight: 700; background: rgba(200,113,47,.14); }
.forest-cal .cal-cell.selected { border-color: #c8712f; box-shadow: inset 0 0 0 1px #c8712f; }
.forest-cal .cal-cell { cursor: pointer; }

/* Boschi non idonei per categoria forestale: tinta fuori scala. */
.swatch.unsuitable { background: #6f7b93; }
.legend-foot b.swatch { display: inline-block; margin-right: 5px; vertical-align: -1px; }
.station-tooltip em { font-style: normal; color: #cdd4e2; }

/* v1: badge di versione e livello raster. */
.version-badge { font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
                 background: #2f4a3a; color: #eef3ea; padding: 3px 8px; border-radius: 20px;
                 margin-left: 9px; vertical-align: 3px; font-weight: 700; }
.version-badge b { font-weight: 700; opacity: .75; margin-left: 4px; }
.swatch.raster { background: linear-gradient(135deg,#c9c75b,#e77b36,#c83f2f); }

.swatch.outline { background: transparent; border: 1.5px solid #2f4a3a; }

/* v1: la legenda separa i due livelli, che rispondono a domande diverse. */
.legend-layer + .legend-layer { border-top: 1px solid #dedfd8; margin-top: 10px; padding-top: 9px; }
.legend-head i.swatch { display: inline-block; margin-right: 6px; vertical-align: -1px; }
.legend-note { margin: 7px 0 0; font-size: 9px; line-height: 1.5; color: var(--muted); }
.legend-note b.swatch { display: inline-block; margin-right: 4px; vertical-align: -1px; }

/* v1: il valore della cella sotto il cursore. Si puo' leggere perche' il PNG
   del livello a 100 m porta valori nei canali, non colori gia' scelti. */
.cell-readout { position: absolute; z-index: 500; top: 16px; left: 18px; min-width: 148px;
                padding: 9px 12px; background: rgba(253,252,248,.94); backdrop-filter: blur(9px);
                border: 1px solid rgba(36,56,46,.14); border-radius: 12px; box-shadow: var(--shadow);
                pointer-events: none; }
.cell-readout-head { display: block; font-size: 8px; letter-spacing: .09em; text-transform: uppercase;
                     color: var(--muted); font-weight: 800; }
.cell-readout-body { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.cell-readout-body strong { font-family: Georgia,serif; font-size: 26px; font-weight: 500; line-height: 1; }
.cell-readout-body div { font-size: 10px; line-height: 1.35; }
.cell-readout-body small { display: block; color: var(--muted); font-size: 9px; }

/* v1: il pannello di un bosco, accanto a quello di una stazione. */
.forest-detail { padding: 24px 22px; }
.forest-extent { margin: 10px 0 0; font-size: 9px; line-height: 1.55; color: var(--muted); }
.forest-detail .family-cards { margin-top: 14px; }
.forest-detail .text-button { margin-top: 14px; }

/* v1: ogni livello ha la sua trasparenza, perche' quale deve stare sopra
   dipende da cosa stai cercando e non da una scelta fatta una volta per tutte. */
.layer-row { padding-bottom: 4px; }
.layer-row .toggle-row { padding-bottom: 3px; }
.layer-opacity { -webkit-appearance: none; appearance: none; display: block; width: 100%;
                 height: 3px; margin: 0 0 6px; border-radius: 3px; background: #d9ded6;
                 cursor: pointer; accent-color: var(--forest); }
.layer-opacity::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px;
                 border-radius: 50%; background: var(--forest); border: 2px solid #fff;
                 box-shadow: 0 1px 3px rgba(16,37,29,.35); }
.layer-opacity::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%;
                 background: var(--forest); border: 2px solid #fff; }
.swatch.forest-fill { background: #6f9350; border: 1px solid #4f6d38; }
.swatch.basemap { background: linear-gradient(135deg,#e8e4d8,#c6cbbd); border: 1px solid #b3b9a9; }

/* v1: le categorie forestali presenti nella vista, non l'elenco completo. */
.legend-categories { display: grid; gap: 3px 10px; grid-template-columns: 1fr 1fr;
                     margin: 8px 0 2px; font-size: 9px; color: #4d5e55; }
.legend-categories span { display: flex; align-items: center; gap: 5px; min-width: 0; }
.legend-categories i { flex: none; width: 9px; height: 9px; border-radius: 2px; }
.legend-categories span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* v1: nel tooltip di un bosco, le due famiglie con minimo e massimo. La media
   da sola non descrive un bosco che copre 800 metri di dislivello. */
.zonal-table { border-collapse: collapse; margin: 7px 0 5px; font-size: 10px; }
.zonal-table th, .zonal-table td { padding: 2px 6px 2px 0; text-align: right; font-weight: 500; }
.zonal-table thead th { font-size: 8px; text-transform: uppercase; letter-spacing: .06em;
                        color: #97a5b3; font-weight: 700; }
.zonal-table tbody th { text-align: left; padding-right: 10px; font-weight: 700; }
.zonal-table tbody th small { display: block; font-size: 8px; color: #a9b6c2; font-weight: 400; }
.zonal-table tbody tr.on th { color: var(--gold); }
.zonal-table td:last-child { text-align: left; padding-left: 8px; color: #cdd4e2; }

/* v1: cosa succede nei giorni davanti, che e' la domanda vera. */
.family-future { margin: 6px 0 8px; padding: 7px 9px; border-radius: 8px; background: #eef1e9;
                 font-size: 10px; line-height: 1.5; color: #3f5147; }
.family-future span { color: var(--muted); }
.family-future.none { background: #f2f1ec; color: var(--muted); }

/* v1: la fase entra nel colore del raster. Pieno dove si produce, sbiadito
   dove sta maturando: l'indice dice quanto rende, la fase se rende adesso. */
.legend-phases { display: grid; gap: 3px 10px; grid-template-columns: 1fr 1fr;
                 margin: 8px 0 2px; font-size: 9px; color: #4d5e55; }
.legend-phases span { display: flex; align-items: center; gap: 5px; min-width: 0;
                      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-phases i { flex: none; width: 12px; height: 9px; border-radius: 2px;
                   border: 1px solid rgba(36,56,46,.18); }
/* v1: un modo alla volta colora la mappa. Non quattro interruttori ma una
   scelta, perche' due scale di colore sullo stesso pixel non si leggono. */
.colour-modes { display: grid; gap: 4px; margin: 4px 0 8px; }

/* Nel modo "fase e indice" ogni voce e' una rampa e non un quadretto: e' la
   rampa a dire che dentro la fase il colore continua a misurare l'indice. */
.legend-phases.tone { grid-template-columns: 1fr 1fr; }
.legend-phases.tone i { width: 26px; height: 8px; }
.legend-note.legend-wide { grid-column: 1 / -1; margin: 0 0 4px; }

/* v1: i boschi hanno i loro modi e il loro filtro, come il raster a 100 m. */
/* Stesso aspetto per i modi dei boschi e per la scelta dello sfondo: sono lo
   stesso gesto, "quale di questi tre". Le classi restano pero' distinte, cosi'
   un `querySelectorAll('.forest-mode')` non raccoglie anche i pulsanti dello
   sfondo - che e' esattamente il modo in cui due controlli diversi finiscono a
   spegnersi a vicenda. */
.forest-mode, .basemap-choice { text-align: left; padding: 6px 9px; border: 1px solid var(--line);
               border-radius: 8px; background: #fff; cursor: pointer; }
.forest-mode strong, .basemap-choice strong { display: block; font-size: 11px; }
.forest-mode small, .basemap-choice small { display: block; color: var(--muted); font-size: 9px; margin-top: 1px; }
.forest-mode.active, .basemap-choice.active { border-color: var(--forest); background: #eef3ea; }
.forest-mode.active strong, .basemap-choice.active strong { color: var(--forest); }

.category-filter { margin: 6px 0 4px; padding-top: 7px; border-top: 1px solid var(--line); }
.category-head { display: flex; align-items: baseline; gap: 8px; }
.category-head .field-label { margin-bottom: 4px; }
.category-head #categoryCount { margin-right: auto; font-size: 9px; color: var(--muted); }
.category-head .text-button { padding: 0; font-size: 9px; }
#categoryList { max-height: 176px; overflow-y: auto; padding-right: 3px; }
.category-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.category-row label { display: grid; grid-template-columns: 13px 10px 1fr; gap: 6px;
                      align-items: center; flex: 1; min-width: 0; cursor: pointer; }
.category-row input { margin: 0; accent-color: var(--forest); }
.category-row i { width: 10px; height: 10px; border-radius: 2px; }
.category-row span { font-size: 10px; overflow: hidden; text-overflow: ellipsis;
                     white-space: nowrap; }
.category-only { flex: none; border: 0; background: none; cursor: pointer; padding: 0 2px;
                 font-size: 9px; font-weight: 800; color: var(--muted); }
.category-only:hover { color: var(--forest); text-decoration: underline; }

/* Le voci della legenda si accendono e si spengono: quando vuoi togliere un
   tipo di bosco stai guardando la legenda, non il pannello. */
.legend-toggle { cursor: pointer; }
.legend-toggle:hover { color: var(--forest); }

.legend-categories.tone i, .legend-categories.wide i { width: 26px; height: 8px; }

/* ==== come ci si arriva ====================================================
   Tre sorgenti in un livello solo, perche' chi lo accende fa una domanda sola.
   I colori stanno apposta lontani sia dalla rampa dell'indice (grigio ->
   giallo -> arancio -> rosso) sia dalla tavolozza forestale (verdi e bruni):
   un accesso non e' un rendimento e non e' un tipo di bosco. */
.swatch.trails { background: linear-gradient(135deg,#7d3c98,#1b4f9c); }
.trail-sources { display: grid; gap: 3px; margin: 5px 0 2px; }
.trail-source { display: grid; grid-template-columns: 13px 16px 1fr; gap: 6px;
                align-items: center; cursor: pointer; padding: 2px 0; }
.trail-source input { margin: 0; accent-color: var(--forest); }
.trail-source strong { display: block; font-size: 11px; }
.trail-source small { display: block; color: var(--muted); font-size: 9px; margin-top: 1px; }
/* Il campione e' una linea e non un quadretto: e' una linea sulla mappa, e il
   tratteggio distingue la strada dalla pista quanto il colore. */
.trail-key { display: inline-block; width: 16px; height: 0; border-top-width: 2px;
             border-top-style: solid; vertical-align: middle; }
.trail-key.rpe { border-top-color: #b8412f; border-top-width: 2.5px; }
/* Le tratte senza numero di percorso restano sullo sfondo: ci sono, ma
   non competono con la rete segnalata. */
.trail-key.rpe-altro { border-top-color: #b8412f; border-top-width: 1px;
                       border-top-style: dotted; opacity: .5; }
.trail-key.mulattiere { border-top-color: #7d3c98; border-top-style: dotted; border-top-width: 3px; }
.trail-key.forestale { border-top-color: #1b4f9c; border-top-width: 3px; }
.trail-key.forestale-pista { border-top-color: #1b4f9c; border-top-style: dashed; border-top-width: 2px; }
#trailsNote { margin-top: 6px; }
.legend-trails { display: grid; gap: 3px; margin: 8px 0 2px; font-size: 9px; color: #4d5e55; }
.legend-trails span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.legend-trails i { flex: none; }
.legend-trails small { color: var(--muted); }
/* Il pannello di un sentiero: le tre sorgenti finiscono nello stesso posto,
   perche' rispondono alla stessa domanda. */
.trail-detail { padding: 20px 18px 26px; }
.trail-fields { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line);
                border-radius: 12px; overflow: hidden; margin: 12px 0 4px; }
.trail-fields div { display: flex; gap: 10px; background: #fff; padding: 9px 12px; font-size: 11px; }
.trail-fields span { flex: none; width: 104px; color: var(--muted); }
.trail-fields b { font-weight: 700; }

/* Gli attributi di un sentiero RPE, un click alla volta: e' il limite di un
   WMS, che manda un'immagine e non geometrie. */
.leaflet-popup.trail-popup .leaflet-popup-content-wrapper { background: #142b21; color: white;
    border-radius: 10px; box-shadow: var(--shadow); }
.leaflet-popup.trail-popup .leaflet-popup-tip { background: #142b21; }
.leaflet-popup.trail-popup .leaflet-popup-content { margin: 10px 12px; font-size: 10px; line-height: 1.5; }
.leaflet-popup.trail-popup strong { display: block; font-size: 11px; margin-bottom: 4px; }
.leaflet-popup.trail-popup .trail-feature { display: block; }
.leaflet-popup.trail-popup .trail-feature + .trail-feature { margin-top: 6px; padding-top: 5px;
    border-top: 1px dashed rgba(255,255,255,.16); }
.leaflet-popup.trail-popup .trail-feature div { display: flex; gap: 8px; }
.leaflet-popup.trail-popup .trail-feature div span { flex: none; width: 82px; opacity: .62; }
.leaflet-popup.trail-popup small { display: block; margin-top: 6px; padding-top: 5px;
    border-top: 1px solid rgba(255,255,255,.16); opacity: .58; font-size: 8px; }
.leaflet-popup.trail-popup a.leaflet-popup-close-button { color: rgba(255,255,255,.6); }

/* ==== ricerca localita =====================================================
   Nella barra degli strumenti sulla mappa e non nel pannello: cercare un posto
   e' un gesto sulla mappa, e il pannello sono i parametri del modello. */
.map-search { position: relative; display: flex; align-items: center; gap: 6px;
    width: 226px; padding: 0 10px; border: 1px solid rgba(20,40,30,.15);
    background: rgba(255,255,255,.94); border-radius: 9px; height: 38px;
    box-shadow: 0 4px 14px rgba(20,40,30,.12); }
.map-search svg { flex: none; width: 15px; fill: none; stroke: var(--muted);
    stroke-width: 1.9; stroke-linecap: round; }
.map-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none;
    font-size: 12px; color: var(--ink); }
.map-search input::-webkit-search-cancel-button { cursor: pointer; }
.place-results { position: absolute; z-index: 502; top: 44px; left: 0; right: 0;
    max-height: 262px; overflow-y: auto; padding: 5px; border-radius: 10px;
    background: rgba(253,252,248,.97); backdrop-filter: blur(9px);
    border: 1px solid rgba(36,56,46,.14); box-shadow: var(--shadow); }
.place-row { display: block; width: 100%; text-align: left; border: 0; background: none;
    padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.place-row:hover, .place-row:focus-visible { background: #eef3ea; }
.place-row strong { display: block; font-size: 11px; }
.place-row small { display: block; color: var(--muted); font-size: 9px; margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-empty { margin: 0; padding: 8px; font-size: 10px; color: var(--muted); }

/* Stesso punto di rottura del resto della pagina (760 px, dove il pannello
   diventa un cassetto): li' la ricerca prende la riga e i due pulsanti vanno
   sotto, perche' un campo largo 226 px accanto a due bottoni non ci sta. */
@media (max-width: 760px) {
  .map-top-tools { flex-wrap: wrap; justify-content: flex-end; left: 12px; }
  .map-search { width: 100%; }
}

/* ==== il secondo motore ====================================================
   La spunta non ricalcola niente: sceglie quale dei due prodotti caricare.
   La barra sbiadisce con la quota di previsione dentro l'indice del giorno
   mostrato, cosi' quanto ci si sta sbilanciando si vede prima di leggerlo. */
/* La spunta sta sulla barra temporale, non nel pannello: e' una scelta sui
   giorni, e i giorni si guardano li'. */
.forecast-switch { display: grid; grid-template-columns: 26px 1fr; gap: 8px;
    align-items: center; margin: 2px 0 8px; cursor: pointer; }
.forecast-switch input { position: absolute; opacity: 0; pointer-events: none; }
.forecast-switch i { width: 26px; height: 15px; border-radius: 20px; background: #c8cdc6;
    position: relative; transition: .2s; }
.forecast-switch i::after { content: ""; position: absolute; width: 11px; height: 11px;
    background: #fff; border-radius: 50%; left: 2px; top: 2px; transition: .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.forecast-switch input:checked + i { background: #3d6a8c; }
.forecast-switch input:checked + i::after { transform: translateX(11px); }
.forecast-switch span { font-size: 10px; font-weight: 700; line-height: 1.25; }
.forecast-switch small { display: block; font-weight: 400; color: var(--muted); font-size: 9px; }
.forecast-switch input:focus-visible + i { outline: 2px solid var(--forest); outline-offset: 2px; }
.time-bar.forecasting { border-color: rgba(60,110,150,.4); }
.time-bar.forecasting #timeBarNote { color: #3d6a8c; }
.time-bar.forecasting input[type=range] {
  opacity: calc(1 - .35 * var(--forecast-share, 0));
}
.time-bar.forecasting::after {
  content: ""; position: absolute; inset: 0; border-radius: 12px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(120,160,190,.16));
  opacity: var(--forecast-share, 0);
}
