/* ==========================================================================
   StileWeb — tema comune delle web app
   Palette: blu notte → blu → azzurro, con accenti gialli. Temi scuro e chiaro.
   Libreria: Progetti/_Comune/StileWeb (non modificare la copia nel progetto)
   ========================================================================== */

:root {
  /* Colori del marchio */
  --navy: #0A2463;
  --blue: #1E6FD9;
  --sky: #4FC3F7;
  --sun: #FFC83D;
  --sun-light: #FFF3B0;
  --on-sun: #2A1D00;

  /* Colori di stato (sempre accompagnati da un'icona, mai solo colore) */
  --ok: #22C55E;
  --warn: #F97316;
  --bad: #EF4444;
  --info: #A78BFA;
  --neutral: #94A3B8;

  --grad: linear-gradient(135deg, #0A2463 0%, #1E6FD9 55%, #4FC3F7 100%);
  --grad-soft: linear-gradient(135deg, rgba(30, 111, 217, .28), rgba(79, 195, 247, .12));
  --grad-sun: linear-gradient(135deg, #FFE27A 0%, #FFC83D 100%);

  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --panel-w: 392px;
  --drawer-w: min(420px, calc(100vw - var(--panel-w) - var(--gap) * 4));   /* scheda laterale (Tema.cassetto) */
  --gap: 16px;
  --top-h: 64px;
  --sheet-h: 132px;
}

/* Tema scuro (predefinito) */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050E26;
  --surface: rgba(8, 26, 70, .68);
  --surface-2: rgba(30, 80, 160, .22);
  --surface-strong: rgba(7, 21, 56, .95);
  --border: rgba(120, 190, 255, .18);
  --border-strong: rgba(120, 190, 255, .32);
  --text: #EAF4FF;
  --muted: #A3BCDD;
  --faint: #6F8DB8;
  --hover: rgba(79, 195, 247, .10);
  --shadow: 0 24px 60px -18px rgba(0, 6, 28, .85);
}

/* Tema chiaro */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #E6F1FF;
  --surface: rgba(255, 255, 255, .78);
  --surface-2: rgba(200, 225, 255, .55);
  --surface-strong: rgba(255, 255, 255, .97);
  --border: rgba(30, 111, 217, .16);
  --border-strong: rgba(30, 111, 217, .32);
  --text: #0A1F44;
  --muted: #45628D;
  --faint: #7F98BD;
  --hover: rgba(30, 111, 217, .08);
  --shadow: 0 24px 60px -22px rgba(10, 36, 99, .45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--sky); }
:root[data-theme="light"] a { color: var(--blue); }
svg { display: block; }

:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}
.glass-strong {
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

/* ---------- Barra di caricamento ---------- */
.loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 2000;
  overflow: hidden;
}
.loader span {
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--sky), var(--sun), transparent);
  animation: loading 1.1s ease-in-out infinite;
}
@keyframes loading { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- Avanzamento di un calcolo lungo ----------
   <div class="progresso" role="status" aria-live="polite"><div class="progresso-testa"><span class="progresso-giro"></span>
   <span class="progresso-testo">Cerco le colonnine…</span><b class="progresso-pct">40%</b></div>
   <div class="progresso-barra"><span style="width:40%"></span></div></div>  (Tema.progresso(el, pct, testo) lo aggiorna) */
.progresso { margin: 10px 0 14px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.progresso-testa { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.progresso-testo { flex: 1; min-width: 0; }
.progresso-pct { font-variant-numeric: tabular-nums; color: var(--sun); }
:root[data-theme="light"] .progresso-pct { color: var(--blue); }
.progresso-giro { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--sun); animation: progresso-giro .8s linear infinite; }
.progresso-barra { margin-top: 10px; height: 8px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.progresso-barra span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad-sun); transition: width .35s ease; }
@keyframes progresso-giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .progresso-giro { animation-duration: 2.4s; } }

/* ---------- Barra superiore ---------- */
.topbar {
  position: fixed;
  /* sotto l'area di sistema (ora, batteria, isola) dei telefoni: con viewport-fit=cover la pagina arriva fin lassù */
  top: calc(var(--gap) + env(safe-area-inset-top, 0px));
  left: var(--gap);
  right: var(--gap);
  height: var(--top-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px 0 12px;
  border-radius: var(--radius);
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; width: calc(var(--panel-w) - 160px); }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad);
  box-shadow: 0 6px 18px -4px rgba(30, 111, 217, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; fill: var(--sun); filter: drop-shadow(0 0 6px rgba(255, 200, 61, .6)); }
.brand-mark.big { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; }
.brand-mark.big svg { width: 34px; height: 34px; }
.brand-name { font-size: 22px; font-weight: 500; letter-spacing: -.02em; }
.brand-name b {
  font-weight: 800;
  background: linear-gradient(90deg, var(--sky), var(--sun-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
:root[data-theme="light"] .brand-name b { background: linear-gradient(90deg, var(--blue), var(--sky)); -webkit-background-clip: text; background-clip: text; }

.search { position: relative; flex: 1; max-width: 560px; }
.search-ico {
  position: absolute; left: 14px; top: 50%;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  border-color: var(--sun);
  box-shadow: 0 0 0 4px rgba(255, 200, 61, .18);
  background: var(--surface-strong);
}

/* Suggerimenti sotto la ricerca (ul.suggestions.glass-strong con li role=option) */
.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  border-radius: 16px;
  max-height: 60vh;
  overflow-y: auto;
}
/* Sul telefono il campo di ricerca è stretto (accanto ai pulsanti): i suggerimenti prendono tutta la larghezza della barra
   in alto (la barra è "fixed", quindi fa da riferimento) invece di restare una colonna larga quanto il campo */
@media (max-width: 760px) { .topbar .search { position: static; } .topbar .suggestions { left: 0; right: 0; } }
.suggestions li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--hover); }
.suggestions li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--sun); }
.suggestions .sg-pin {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--grad-soft);
  flex: none;
}
.suggestions .sg-pin svg { width: 15px; height: 15px; fill: var(--sky); }
.suggestions mark { background: none; color: var(--sun); font-weight: 700; }
:root[data-theme="light"] .suggestions mark { color: var(--blue); }
.suggestions .sg-tag {
  margin-left: auto;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.suggestions .sg-empty { color: var(--muted); cursor: default; }
/* Intestazione di un gruppo di suggerimenti (li.sg-head, non selezionabile) */
.suggestions .sg-head {
  padding: 10px 12px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint);
  cursor: default;
}
.suggestions .sg-head:hover { background: none; }
.suggestions .sg-sub { display: block; font-size: 12px; color: var(--muted); }

.top-actions { display: flex; gap: 6px; margin-left: auto; position: relative; }
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: background .2s, border-color .2s, transform .15s;
}
.icon-btn:hover { border-color: var(--sun); background: var(--hover); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.is-on { background: var(--grad-sun); color: var(--on-sun); border-color: transparent; }
/* Pulsante dell'utente collegato: iniziali su sfondo a gradiente */
.icon-btn.has-user { background: var(--grad); color: #fff; border-color: rgba(255, 243, 176, .6); font-weight: 800; font-size: 15px; }
.icon-btn-sm { width: 36px; height: 36px; border-radius: 11px; }
.icon-btn-sm svg { width: 17px; height: 17px; }
:root[data-theme="dark"] .ico-sun, :root:not([data-theme]) .ico-sun { display: none; }
:root[data-theme="light"] .ico-moon { display: none; }

/* ---------- Pannello laterale (desktop) / foglio dal basso (telefono) ---------- */
.panel {
  position: fixed;
  z-index: 900;
  top: calc(var(--gap) * 2 + var(--top-h) + env(safe-area-inset-top, 0px));
  left: var(--gap);
  bottom: var(--gap);
  width: var(--panel-w);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-handle { display: none; }
/* Pannello in vetro più trasparente sul computer (02/11/2026): si intravede la mappa. I riquadri interni hanno il loro fondo
   (--surface-2), quindi i testi restano leggibili. Sul telefono il foglio resta coprente (si usa in movimento e al sole;
   la sfocatura su una superficie grande pesa sui telefoni). Con "riduci trasparenza" del sistema torna coprente. */
@media (min-width: 761px) {
  :root, :root[data-theme="dark"] { --surface-panel: rgba(8, 26, 70, .40); }
  :root[data-theme="light"] { --surface-panel: rgba(255, 255, 255, .48); }
  .panel.glass { background: var(--surface-panel); backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%); }
}
@media (min-width: 761px) and (prefers-reduced-transparency: reduce) {
  .panel.glass { background: var(--surface-strong); }
}
/* Pannello richiuso sul computer (Tema.pannello.riduci): esce a sinistra, resta la freccia per riaprirlo */
.panel { transition: transform .3s ease, opacity .3s ease; }
.panel.is-ridotto { transform: translateX(calc(-100% - var(--gap) - 4px)); opacity: 0; pointer-events: none; }
.panel-toggle {
  position: fixed; z-index: 901;
  top: calc(var(--gap) * 2 + var(--top-h) + env(safe-area-inset-top, 0px) + 18px); left: calc(var(--gap) + var(--panel-w) - 14px);
  width: 28px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); background: var(--surface-strong); color: var(--text);
  box-shadow: var(--shadow); cursor: pointer;
  transition: left .3s ease, border-color .2s;
}
.panel-toggle:hover { border-color: var(--sun); }
.panel-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s; }
.panel-toggle.is-ridotto { left: var(--gap); }
.panel-toggle.is-ridotto svg { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .panel, .panel-toggle, .panel-toggle svg { transition: none; } }
.pannello-ridotto .stage, .pannello-ridotto .ad-slot { left: var(--gap); }

/* ---------- Scheda laterale (Tema.cassetto): aside.drawer > .drawer-head (h2 + .drawer-close[data-close]) + .drawer-body ----------
   A destra sul computer, a tutto schermo sul telefono; scorre dal bordo. */
.drawer {
  position: fixed; z-index: 950;
  top: calc(var(--gap) * 2 + var(--top-h) + env(safe-area-inset-top, 0px)); right: var(--gap); bottom: var(--gap);
  width: var(--drawer-w);
  border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(calc(100% + var(--gap) + 8px)); opacity: 0;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .28s;
}
.drawer.is-open { transform: none; opacity: 1; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { flex: 1; margin: 0; font-size: 18px; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 24px; scrollbar-width: thin; }
@media (max-width: 760px) {
  .drawer {
    top: 0; right: 0; bottom: 0; left: 0; width: auto; z-index: 1300; border-radius: 0;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
  }
}
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* ---------- Bacheca dei suggerimenti (js/bacheca.js) ---------- */
.bq-intro p, .bq-intro-breve { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.notice.bq-regole { margin: 0 0 14px; line-height: 1.45; }
.bq-regole p { margin: 0; }
.bq-regole p + p { margin-top: 4px; }
.bq-filtri { margin: 12px 0 8px; }
.bq-ordine { margin-bottom: 12px; }
.bq-lista { display: flex; flex-direction: column; gap: 10px; }
.bq-card { border: 1px solid var(--border); border-radius: 16px; background: var(--hover); overflow: hidden; }
.bq-apri { display: block; width: 100%; padding: 12px 14px 6px; border: none; background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.bq-apri:hover .bq-titolo { color: var(--sun); }
.bq-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bq-tags .tag { margin: 0; }
.bq-tags .stato { font-size: 12px; }
.bq-titolo { margin: 8px 0 2px; font-size: 16px; line-height: 1.3; }
.bq-meta { margin: 0; font-size: 12px; color: var(--muted); }
.bq-anteprima { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bq-azioni { display: flex; align-items: center; gap: 8px; padding: 6px 10px 10px; }
.bq-voto, .bq-risp {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.bq-voto svg, .bq-risp svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.bq-voto b { font-variant-numeric: tabular-nums; }
.bq-voto.is-on { background: var(--grad-sun); color: var(--on-sun); border-color: transparent; }
.bq-voto:hover, .bq-risp:hover { border-color: var(--sun); }
.bq-risp { margin-left: auto; }
.bq-dettaglio { padding: 4px 0 8px; }
.bq-dettaglio .bq-azioni { padding: 8px 0 0; }
.bq-testo { margin: 10px 0 0; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.bq-gestione { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: 14px; border: 1px dashed var(--sun); }
.bq-gestione .input { width: 150px; height: 34px; }
.bq-risposte { display: flex; flex-direction: column; gap: 8px; }
.bq-risposta { padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.bq-risposta .bq-testo { margin-top: 6px; }
.bq-form { margin-top: 14px; }
.bq-area { height: auto; padding: 10px 14px; resize: vertical; font: inherit; line-height: 1.45; }
.bq-gestore { margin-top: 16px; font-size: 13px; }
.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* Area principale a destra del pannello, per le app senza mappa */
.stage {
  position: fixed;
  top: calc(var(--gap) * 2 + var(--top-h) + env(safe-area-inset-top, 0px));
  left: calc(var(--panel-w) + var(--gap) * 2);
  right: var(--gap);
  bottom: 0;
  overflow-y: auto;
  padding-bottom: var(--gap);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { padding: 18px; border-radius: 20px; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Riquadro statistiche ---------- */
.stats {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: var(--grad);
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 30px -14px rgba(30, 111, 217, .9);
}
.stats::after {
  content: '';
  position: absolute;
  right: -40px; top: -60px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 61, .45), transparent 65%);
  pointer-events: none;
}
.stat { display: flex; flex-direction: column; gap: 2px; position: relative; z-index: 1; }
.stat + .stat { padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .2); }
.stat-num { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-main .stat-num { color: var(--sun-light); }
.stat-label { font-size: 12px; color: rgba(234, 244, 255, .82); }

/* ---------- Filtri e campi ---------- */
.filters { display: flex; flex-direction: column; gap: 16px; margin: 20px 0 8px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.select-btn {
  width: 100%;
  height: 46px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  transition: border-color .2s;
}
.select-btn:hover, .select-btn[aria-expanded="true"] { border-color: var(--sun); }
.select-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .2s; }
.select-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.select-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Selezione multipla con ricerca: .ms > .select-btn + .ms-menu (input, .ms-list di .ms-row, .ms-actions) */
.ms { position: relative; }
.ms-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 20;
  border-radius: 16px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.ms-menu input {
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
}
.ms-menu input:focus { border-color: var(--sun); }
.ms-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ms-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.ms-row:hover { background: var(--hover); }
.ms-row input { position: absolute; opacity: 0; pointer-events: none; }
.ms-check {
  width: 20px; height: 20px; flex: none;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.ms-row input:checked + .ms-check { background: var(--grad-sun); border-color: transparent; }
.ms-row input:checked + .ms-check::after { content: '✓'; font-size: 13px; font-weight: 800; color: var(--on-sun); }
.ms-row input:focus-visible + .ms-check { outline: 2px solid var(--sun); outline-offset: 2px; }
.ms-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-count {
  font-size: 12px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ms-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 4px; border-top: 1px solid var(--border); }
.empty-small { color: var(--muted); margin: 8px 4px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  background: var(--sun-light);
  color: var(--on-sun);
  border: none;
  font-size: 13px; font-weight: 600;
}
.chip i {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(42, 29, 0, .12);
  font-style: normal; font-size: 12px;
}
.chip:hover i { background: rgba(42, 29, 0, .25); }

/* Scelta a segmenti: button role=radio con aria-checked */
.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding: 4px;
  gap: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented button {
  height: 36px;
  border: none;
  border-radius: 10px;
  background: none;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  transition: background .2s, color .2s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--grad-sun); color: var(--on-sun); box-shadow: 0 4px 12px -4px rgba(255, 200, 61, .7); }

/* Interruttore: label.toggle > input[type=checkbox] + .toggle-track > .toggle-thumb, poi il testo */
/* position: relative: la casella nascosta resta dentro la sua riga. Senza, al focus il browser fa scorrere il contenitore
   più esterno (anche se ha overflow: hidden, es. il pannello) e una parte del contenuto sparisce. */
.toggle { position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.toggle input { position: absolute; left: 0; top: 50%; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.toggle-track {
  width: 44px; height: 26px; flex: none;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background .2s;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted);
  transition: transform .2s, background .2s;
}
.toggle input:checked + .toggle-track { background: var(--grad); border-color: transparent; }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: var(--sun); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--sun); outline-offset: 2px; }

/* ---------- Elenco ---------- */
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 2px 10px;
}
.results-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.results-head .count { font-size: 13px; color: var(--muted); }

/* Nota "dati dal vivo" con pallino verde */
.live-note { margin: -4px 2px 12px; font-size: 12px; color: var(--faint); }
.live-note:empty { display: none; }
.live-note::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .2);
}

/* Riga dell'elenco: button.item con --st = colore di stato */
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  transition: border-color .2s, transform .15s, background .2s;
}
.item:hover { border-color: var(--border-strong); background: var(--hover); transform: translateY(-1px); }
.item.is-active { border-color: var(--sun); box-shadow: 0 0 0 3px rgba(255, 200, 61, .18); }
.item-status {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad);
  box-shadow: inset 0 0 0 2px var(--st);
  color: var(--st);
  font-weight: 800; font-size: 16px;
  position: relative;
}
.item-status::after {
  content: '';
  position: absolute; right: -3px; top: -3px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--st);
  border: 2px solid var(--surface-strong);
}
.item-status.is-dim { opacity: .6; }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 13px; color: var(--sky); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="light"] .item-sub { color: var(--blue); }
.item-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.item-state { font-size: 11px; color: var(--st); font-weight: 600; white-space: nowrap; }

/* Etichetta tonda con un valore (es. "22 kW"); .badge-sun per evidenziare */
.badge {
  font-size: 12px; font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge-sun { background: var(--grad-sun); color: var(--on-sun); border-color: transparent; }
.badge-ok { background: rgba(34, 197, 94, .16); border-color: rgba(34, 197, 94, .45); color: var(--ok); }
:root[data-theme="light"] .badge-ok { color: #15803D; }

/* Riga dell'elenco con un'azione a destra: li.item-row > button.item + button.item-act */
.item-row { display: flex; gap: 6px; align-items: stretch; }
.item-row .item { flex: 1; min-width: 0; }
.item-act {
  width: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
  transition: color .2s, border-color .2s;
}
.item-act:hover { color: var(--bad); border-color: var(--bad); }

/* Pastiglie-filtro con icona e conteggio: button.chip-toggle (.is-on) > testo + span.n */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
/* Su una riga sola, con scorrimento orizzontale (es. le sezioni di un sito in cima alle pagine) */
.chip-row.is-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row.is-scroll::-webkit-scrollbar { display: none; }
.chip-row.is-scroll > * { flex: none; }
/* Sul computer niente scorrimento (col mouse non si capiva che la fila continua e sembrava tagliata): si va a capo.
   Sul telefono resta lo scorrimento con il dito, con una sfumatura a destra che fa capire che ci sono altre voci. */
@media (min-width: 761px) { .chip-row.is-scroll { flex-wrap: wrap; overflow: visible; } }
@media (max-width: 760px) {
  .chip-row.is-scroll { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); padding-right: 24px; }
}
.chip-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 13px; font-weight: 600;
  transition: background .2s, color .2s, border-color .2s;
}
.chip-toggle .n { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-toggle:hover { border-color: var(--sun); }
.chip-toggle.is-on { background: var(--grad-sun); color: var(--on-sun); border-color: transparent; }
.chip-toggle.is-on .n { color: var(--on-sun); opacity: .75; }
a.chip-toggle { text-decoration: none; color: var(--text); }
a.chip-toggle.is-on { color: var(--on-sun); }

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
  list-style: none;
}
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.more { text-align: center; font-size: 13px; color: var(--muted); padding: 10px; list-style: none; }

/* ---------- Percorso a tappe (es. aree di servizio lungo un'autostrada) ----------
   ol.timeline > li.tl-item (--st, .is-empty, .is-open) > span.tl-dot + button.tl-head (.tl-title, .tl-meta, .tl-tag) [+ ul.results.tl-list]
   Un secondo gruppo nella tappa: .tl-subhead + ul.results.tl-list.is-secondary (voci attenuate) */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute; left: 19px; top: 14px; bottom: 14px;
  width: 3px; border-radius: 3px;
  background: linear-gradient(var(--sky), var(--sun));
  opacity: .45;
}
.tl-item { position: relative; padding-left: 46px; margin-bottom: 6px; }
.tl-dot {
  position: absolute; left: 6px; top: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--grad);
  box-shadow: inset 0 0 0 2px var(--st), 0 0 0 4px var(--bg);
  color: var(--st);
  font-size: 13px; font-weight: 800;
}
.tl-head {
  width: 100%;
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  transition: border-color .2s, background .2s;
}
.tl-head:hover { border-color: var(--border-strong); background: var(--hover); }
.tl-item.is-open .tl-head { border-color: var(--sun); box-shadow: 0 0 0 3px rgba(255, 200, 61, .15); }
.tl-title { font-weight: 600; }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-meta b { color: var(--st); }
.tl-item.is-empty .tl-dot { width: 14px; height: 14px; left: 14px; top: 13px; background: var(--surface-strong); box-shadow: inset 0 0 0 2px var(--border-strong), 0 0 0 4px var(--bg); }
.tl-item.is-empty .tl-head { padding: 6px 12px; background: none; border-color: transparent; }
.tl-item.is-empty .tl-title { font-weight: 500; color: var(--muted); font-size: 14px; }
.tl-list { margin-top: 8px; }
.tl-tag {
  align-self: flex-start; margin-top: 4px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--sun); color: var(--on-sun);
}
.tl-item.is-empty .tl-tag { margin-top: 2px; }
.tl-subhead {
  margin: 12px 0 0; padding: 8px 12px;
  border-left: 3px solid var(--sun); border-radius: 0 10px 10px 0;
  background: rgba(255, 200, 61, .1);
  font-size: 12px; color: var(--muted);
}
.tl-subhead b { color: var(--text); }
.tl-list.is-secondary .item { opacity: .82; border-style: dashed; }
.tl-list.is-secondary .item:hover { opacity: 1; }

/* ---------- Dettaglio ---------- */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none;
  color: var(--muted);
  padding: 4px 0;
  margin-bottom: 12px;
  font-weight: 600;
}
.back-btn:hover { color: var(--sun); }
.back-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; }

/* Testata a gradiente: .status-pill, h2, .hero-sub, .hero-meta, .hero-kpis > .hero-kpi */
.hero {
  padding: 18px;
  border-radius: 20px;
  background: var(--grad);
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 34px -16px rgba(30, 111, 217, .95);
}
.hero::after {
  content: '';
  position: absolute; right: -50px; bottom: -70px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 61, .4), transparent 65%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
/* Stella (preferito) nell'angolo della testata: button.star-btn (.is-on) */
.star-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(5, 14, 38, .35);
  color: #fff;
  font-size: 21px; line-height: 1;
  transition: transform .15s, background .2s;
}
.star-btn:hover { transform: scale(1.06); border-color: var(--sun-light); }
.star-btn.is-on { background: var(--grad-sun); color: var(--on-sun); border-color: transparent; box-shadow: 0 6px 16px -6px rgba(255, 200, 61, .9); }
.hero > .star-btn { position: absolute; top: 14px; right: 14px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: rgba(5, 14, 38, .45);
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: 13px; font-weight: 700;
}
.status-pill .dot {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--st); color: #06122E;
  font-size: 11px; font-weight: 900;
}
.hero h2 { margin: 12px 0 4px; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.hero-sub { color: var(--sun-light); font-weight: 600; }
.hero-meta { margin-top: 8px; color: rgba(234, 244, 255, .85); font-size: 14px; }
.hero-kpis { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.hero-kpi {
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .16);
  font-size: 13px;
}
.hero-kpi b { font-size: 16px; }

/* ---------- Pulsanti ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 6px; }
.actions.actions-one { grid-template-columns: 1fr; }
.actions > :only-child { grid-column: 1 / -1; }   /* un solo pulsante: tutta la larghezza */
.btn-ghost.is-on { border-color: var(--sun); color: var(--sun); }
:root[data-theme="light"] .btn-ghost.is-on { color: #9A6B00; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px;                 /* altezza minima: un testo lungo va a capo dentro il pulsante, non fuori */
  padding: 6px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 700; line-height: 1.2; text-align: center;
  text-decoration: none;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-sun { background: var(--grad-sun); color: var(--on-sun) !important; box-shadow: 0 8px 20px -8px rgba(255, 200, 61, .8); }
.btn-sun:hover { box-shadow: 0 10px 26px -6px rgba(255, 200, 61, .9); }
.btn-ghost { background: var(--surface-2); border-color: var(--border-strong); color: var(--text) !important; }
.btn-ghost:hover { border-color: var(--sky); }
.btn-danger { background: var(--bad); color: #fff !important; box-shadow: 0 8px 20px -10px rgba(239, 68, 68, .8); }
.btn-danger:hover { box-shadow: 0 10px 24px -8px rgba(239, 68, 68, .9); }
.btn-sm { min-height: 34px; padding: 4px 14px; border-radius: 10px; font-size: 13px; }
.btn svg { flex: none; }
.link-btn { border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 6px 4px; }
.link-btn:hover { color: var(--sun); }

.section-title { margin: 22px 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* Righe di dettaglio: .lines > .line (.line-ico, .line-body > .line-name + .line-meta, .line-value) */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.line-ico {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--grad-soft);
  border: 1px solid var(--border);
}
.line-ico svg { width: 20px; height: 20px; fill: none; stroke: var(--sky); stroke-width: 2; }
/* Icona "a bollino": disegno bianco su riquadro blu sfumato (svg a tratto; .is-fill per un disegno pieno) */
.line-ico.is-badge { background: var(--grad); border: none; box-shadow: 0 6px 14px -8px rgba(30, 111, 217, .9); }
.line-ico.is-badge svg { stroke: #fff; stroke-linecap: round; stroke-linejoin: round; }
.line-ico.is-badge svg.is-fill { fill: #fff; stroke: none; }
.line-ico.is-status {
  background: var(--grad);
  box-shadow: inset 0 0 0 2px var(--st);
  border: none;
  color: var(--st);
  font-weight: 800; font-size: 16px;
}
.line-body { flex: 1; min-width: 0; }
.line-name { font-weight: 600; }
.line-meta { font-size: 12px; color: var(--muted); }
.line-value { font-weight: 800; font-size: 17px; white-space: nowrap; }
.line-value small { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Etichetta piccola dentro il testo (es. AC / DC). Non si spezza mai a metà ("più | conveniente"): va a capo intera.
   Più etichette sotto un titolo: <div class="tags"> (riga a parte, si dispongono da sole) */
.tag { display: inline-block; white-space: nowrap; line-height: 1.3; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; }
.tags .tag { margin-left: 0; vertical-align: 0; }
.tag-sun { background: var(--sun); color: var(--on-sun); }
.tag-sky { background: var(--sky); color: #06122E; }
/* Stato in una tabella o in un testo: span.stato (colore in --st) > i (icona) + testo. Es. <span class="stato" style="--st:var(--ok)"><i>✓</i>confermato</span> */
.stato { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.stato i { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-style: normal; font-size: 11px; color: #fff; background: var(--st); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--faint); }

.info { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }

/* Avviso: giallo di base, .is-ok verde */
.notice {
  display: flex; gap: 10px;
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 200, 61, .1);
  border: 1px solid rgba(255, 200, 61, .35);
  font-size: 13px;
  color: var(--text);
}
.notice svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--sun); stroke-width: 2; margin-top: 1px; }
:root[data-theme="light"] .notice { background: rgba(255, 200, 61, .18); }
:root[data-theme="light"] .notice svg { stroke: #B7860B; }
.notice.is-ok { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .35); }
.notice.is-ok svg { stroke: var(--ok); }
:root[data-theme="light"] .notice.is-ok { background: rgba(34, 197, 94, .12); }
:root[data-theme="light"] .notice.is-ok svg { stroke: #15803D; }

/* ---------- Finestra (modale): .modal-backdrop > .modal.glass-strong ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 4000;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(3, 10, 30, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border-radius: 26px;
  padding: 26px;
}
.modal.modal-wide { max-width: 680px; }   /* finestra larga, per esempio una griglia (.fn-gruppi) */
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal-head { text-align: center; margin-bottom: 18px; }
.modal-head h2 { margin: 0 0 6px; font-size: 22px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Moduli: form.form > label.field (.field-label + .input/.select), .form-row, .form-error ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input, .select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { border-color: var(--sun); box-shadow: 0 0 0 4px rgba(255, 200, 61, .18); }
.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237F98BD' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}
.select option { background: var(--bg); color: var(--text); }
.select-sm { height: 36px; padding: 0 34px 0 10px; font-size: 14px; font-weight: 600; border-radius: 10px; background-position: right 8px center; }
/* "Password dimenticata?" sotto il campo password */
.acc-forgot { align-self: flex-end; margin-top: -8px; font-size: 13px; }
/* Vantaggi dell'account nella registrazione (opzione vantaggi di Accesso.crea) */
.acc-vantaggi { margin: -4px 0 14px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.acc-vantaggi[hidden] { display: none; }
.acc-vantaggi ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.acc-vantaggi li { display: flex; gap: 6px; align-items: baseline; line-height: 1.35; }
.acc-vantaggi li i { font-style: normal; font-weight: 800; color: var(--ok); }
.acc-vantaggi a { display: inline-block; margin-top: 8px; font-weight: 700; }
@media (max-width: 380px) { .acc-vantaggi ul { grid-template-columns: 1fr; } }
/* Campo per un codice a cifre (es. conferma via email) */
.input-code {
  height: 60px;
  text-align: center;
  font-size: 30px; font-weight: 800;
  letter-spacing: .5em; padding-left: .5em;
  font-variant-numeric: tabular-nums;
}
.select:disabled { opacity: .5; }
.form-hint { margin: -6px 2px 0; font-size: 12px; color: var(--faint); }
/* Fuori dai moduli (sotto un elenco, una notifica, un riquadro) la nota non deve risalire sull'elemento sopra */
.lines + .form-hint, .notice + .form-hint, .stats + .form-hint, .timeline + .form-hint { margin-top: 10px; }
.form-error { margin: 0; color: #FF8A8A; font-size: 13px; }
:root[data-theme="light"] .form-error { color: #C62828; }
.btn-block { width: 100%; }
.form-switch { margin: 14px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.form-switch button { border: none; background: none; color: var(--sun); font-weight: 700; padding: 0; }
:root[data-theme="light"] .form-switch button { color: var(--blue); }

/* Casella di spunta: label.check > input[type=checkbox] + span.check-box + testo (anche con link) */
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1.45; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 20px; height: 20px; flex: none; margin-top: 1px;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check input:checked + .check-box { background: var(--grad-sun); border-color: transparent; }
.check input:checked + .check-box::after { content: '✓'; font-size: 13px; font-weight: 800; color: var(--on-sun); }
.check input:focus-visible + .check-box { outline: 2px solid var(--sun); outline-offset: 2px; }
.check a { color: var(--sky); font-weight: 600; }
:root[data-theme="light"] .check a { color: var(--blue); }

/* Collegamenti legali in fondo a un pannello o a una pagina */
.legal-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px;
  margin: 28px 0 4px; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.legal-links a { color: var(--faint); text-decoration: none; }
.legal-links a:hover { color: var(--sun); text-decoration: underline; }

/* ---------- Pagina di testo (documenti legali, guide): body.page-doc > .doc ---------- */
body.page-doc { overflow: auto; }
.doc-wrap { max-width: 820px; margin: 0 auto; padding: 24px 16px 60px; }
.doc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.doc-head a { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 10px; }
.doc-tabs { margin: 0 0 18px; }
.doc { padding: 28px 30px; border-radius: var(--radius); line-height: 1.6; font-size: 15px; }
.doc h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.01em; }
.doc .doc-date { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.doc h2 { margin: 28px 0 8px; font-size: 18px; }
.doc h3 { margin: 18px 0 6px; font-size: 15px; }
.doc p, .doc li { color: var(--text); }
.doc ul { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.doc th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.doc-warn { margin: 0 0 18px; }
@media (max-width: 760px) { .doc { padding: 20px 16px; } .doc table { font-size: 13px; } }
/* Pagine con tabelle larghe (es. gestione.html): .doc-wrap.doc-wide e tabelle dentro .table-scroll */
.doc-wrap.doc-wide { max-width: 1120px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0; }
.table-scroll table { margin: 0; min-width: 560px; }
/* Riga di gruppo dentro una tabella (titolo di sezione su tutte le colonne) */
.doc tr.tr-gruppo th { padding-top: 18px; color: var(--text); font-size: 13px; border-bottom: 1px solid var(--border-strong); }
.doc tbody tr.tr-gruppo:first-child th { padding-top: 10px; }
/* Tabella di confronto a 3 colonne (funzione, A, B): sta nel telefono senza scorrere */
.table-scroll table.tab-confronto { min-width: 0; table-layout: fixed; }
.tab-confronto th:first-child, .tab-confronto td:first-child { width: 46%; }
.tab-confronto td small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.35; }
.tab-confronto .stato { white-space: nowrap; }
@media (max-width: 560px) { .tab-confronto th:first-child, .tab-confronto td:first-child { width: 40%; } .doc .tab-confronto th, .doc .tab-confronto td { padding: 8px 6px; } }
.doc td.num, .doc th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats + .stats { margin-top: 8px; }
.doc-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0 6px; }
.doc-tools .input { flex: 1 1 220px; min-width: 0; }

/* ---------- Menu a comparsa sotto un pulsante: .menu-pop.glass-strong > .menu-head + .menu-item ---------- */
.menu-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1100;
  min-width: 270px;
  padding: 8px;
  border-radius: 18px;
  /* mai più alto dello schermo: le voci in fondo si raggiungono scorrendo dentro il menu */
  box-sizing: border-box;
  max-height: calc(100vh - var(--top-h) - var(--gap) * 2 - 10px);
  max-height: calc(100dvh - var(--top-h) - var(--gap) * 2 - 10px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.menu-head { padding: 10px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
/* Voci più usate: griglia a due colonne (voce con griglia: true) */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 2px 6px; }
.menu-tile {
  min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 10px;
  border: 1px solid var(--border); border-radius: 13px;
  background: var(--surface-2);
  text-align: left; font-weight: 600; font-size: 14px;
}
.menu-tile:hover { background: var(--hover); }
.menu-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* numero dispari: l'ultimo occupa la riga */
.menu-tile svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-tile .badge { margin-left: auto; }
/* Titolino di un gruppo di voci (voce con gruppo: '…') */
.menu-group { padding: 10px 12px 2px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu-txt { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-txt small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.menu-nota { margin-left: auto; flex: none; font-size: 12px; font-weight: 400; color: var(--muted); }
.menu-item .menu-chev { margin-left: auto; width: 16px; height: 16px; opacity: .6; }
.menu-foot { display: flex; gap: 4px; }
.menu-foot .menu-item { width: auto; flex: 1 1 auto; min-width: 0; }
.menu-foot .menu-esci { flex: none; }
.menu-back { font-size: 15px; }
.menu-head b { display: block; font-size: 16px; }
.menu-head span { font-size: 13px; color: var(--muted); }
.menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: none; border-radius: 11px;
  background: none;
  text-align: left;
  font-weight: 600;
}
.menu-item:hover { background: var(--hover); }
.menu-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-item .badge { margin-left: auto; }
.menu-item.is-danger { color: #FF8A8A; }
:root[data-theme="light"] .menu-item.is-danger { color: #C62828; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

/* ---------- Spazi pubblicitari (pubblicita.js): .ad-slot.ad-header nella .topbar, .ad-slot.ad-footer in fondo ---------- */
:root { --ad-header-h: 0px; --ad-footer-h: 0px; }
.ad-slot {
  position: relative;
  display: grid; place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
}
.ad-slot[hidden] { display: none !important; }
.ad-slot img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ad-slot a { display: block; width: 100%; height: 100%; }
.ad-slot a.ad-text, .ad-slot a.ad-placeholder { display: flex; }
/* Etichetta obbligatoria: la pubblicità deve essere riconoscibile */
.ad-label {
  position: absolute; top: 4px; left: 6px; z-index: 2;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(5, 14, 38, .55);
  color: #fff;
  font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  pointer-events: none;
}
/* Testo e segnaposto lasciano a sinistra lo spazio per l'etichetta "Pubblicità" */
.ad-text { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 84px; width: 100%; height: 100%; text-decoration: none; color: var(--text); font-size: 13px; line-height: 1.25; }
.ad-text b { color: var(--sun); }
:root[data-theme="light"] .ad-text b { color: #9A6B00; }
.ad-placeholder {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 100%;
  padding: 0 12px 0 84px;
  border: 1px dashed var(--border-strong); border-radius: 12px;
  color: var(--muted); font-size: 12px; text-decoration: none;
}
.ad-placeholder:hover { color: var(--sun); border-color: var(--sun); }
.ad-placeholder b { color: var(--muted); font-weight: 700; }

/* Header: dentro la barra in alto (468×60 su schermi grandi, 320×50 su medi, nascosto quando non c'è spazio) */
.topbar .ad-header { flex: none; width: 320px; height: 50px; }
@media (min-width: 1280px) { .topbar .ad-header { width: 468px; height: 60px; } }
@media (min-width: 761px) and (max-width: 999px) { .topbar .ad-header { display: none; } }

/* Footer: in basso nell'area libera a destra del pannello (728×90) */
.ad-footer {
  position: fixed; z-index: 850;
  bottom: var(--gap);
  left: calc(var(--panel-w) + var(--gap) * 2);
  right: calc(var(--gap) + 58px);
  margin: 0 auto;
  max-width: 728px; height: 90px;
  box-shadow: var(--shadow);
}

/* ---------- Banner di consenso ai cookie (consenso.js) ---------- */
.cmp {
  position: fixed; z-index: 3500;
  left: 50%; bottom: var(--gap);
  transform: translateX(-50%);
  width: min(680px, calc(100vw - var(--gap) * 2));
  max-height: calc(100dvh - var(--gap) * 2);
  overflow-y: auto;
  padding: 20px 22px 18px;
  border-radius: var(--radius);
}
.cmp h2 { margin: 0 40px 6px 0; font-size: 18px; }
.cmp p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }
.cmp p a { font-weight: 600; }
.cmp-close { position: absolute; top: 12px; right: 12px; }
.cmp-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 16px; }
.cmp-actions [hidden] { display: none !important; }
.cmp-cats { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cmp-cat { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }
.cmp-cat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cmp-cat-text { font-size: 13px; color: var(--muted); line-height: 1.45; }
.cmp-cat .toggle input:disabled + .toggle-track { opacity: .6; }
/* Pulsante "Preferenze cookie" nei collegamenti legali */
.legal-links button { border: none; background: none; padding: 0; color: var(--faint); font-size: 12px; cursor: pointer; }
.legal-links button:hover { color: var(--sun); text-decoration: underline; }

/* ---------- Pulsante grande che porta a una funzione: button.cta-card > .cta-ico + .cta-text (b + span) + svg.cta-go ---------- */
.cta-card {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 200, 61, .45);
  background: linear-gradient(135deg, rgba(255, 200, 61, .16), rgba(79, 195, 247, .1));
  color: var(--text); text-align: left;
  cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.cta-card:hover { border-color: var(--sun); transform: translateY(-1px); }
.cta-ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--sun); }
.cta-ico svg { width: 22px; height: 22px; fill: none; stroke: var(--on-sun); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cta-text span { font-size: 12px; color: var(--muted); }
.cta-go { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }

/* ---------- Riquadri delle funzioni, in fila con scorrimento: nav.tiles > (a | button).tile > .tile-ico + .tile-text (+ i.tile-new) ----------
   Mettono in vista le funzioni dell'app (invece dei soli collegamenti in fondo alla pagina). */
.tiles {
  display: grid; grid-auto-flow: column; grid-auto-columns: 92px; gap: 8px;
  margin: 0 -2px 14px; padding: 2px 2px 6px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px;
  min-height: 84px; padding: 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--hover); color: var(--text);
  font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  scroll-snap-align: start;
  transition: border-color .2s, transform .2s;
}
.tile:hover { border-color: var(--sun); transform: translateY(-1px); }
.tiles a.tile, .tiles a.tile:visited, :root[data-theme="light"] .tiles a.tile { color: var(--text); }   /* non il colore dei collegamenti */
.tile-ico { font-size: 22px; line-height: 1; }
/* Con un'icona svg il riquadro diventa "a bollino": disegno bianco su blu sfumato, giallo per il riquadro "Nuovo" */
.tile-ico:has(svg) {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 6px 14px -8px rgba(30, 111, 217, .9);
}
.tile-ico svg { width: 21px; height: 21px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile:has(.tile-new) .tile-ico:has(svg) { background: var(--grad-sun); box-shadow: 0 6px 14px -8px rgba(255, 200, 61, .9); }
.tile:has(.tile-new) .tile-ico svg { stroke: var(--on-sun); }
.tile-text { font-size: 12px; font-weight: 600; line-height: 1.25; }
.tile-new {
  position: absolute; top: 6px; right: 6px;
  padding: 1px 5px; border-radius: 6px;
  background: var(--sun); color: var(--on-sun);
  font-size: 9px; font-weight: 800; font-style: normal; text-transform: uppercase; letter-spacing: .03em;
}

/* ---------- Barra di icone a pannello chiuso (solo computer): nav.rail.glass > button.rail-btn (svg + span) + .rail-sep ----------
   Compare quando il pannello è richiuso (html.pannello-ridotto) e la pagina ha html.ha-rail: prende il posto della freccia
   per riaprirlo, con le funzioni principali a un tocco. Etichette corte sotto l'icona (una parola). Dal 15/11/2026. */
.rail { display: none; }
@media (min-width: 761px) {
  .ha-rail.pannello-ridotto .rail { display: flex; }
  .ha-rail.pannello-ridotto .panel-toggle { display: none; }
}
.rail {
  position: fixed; z-index: 901;
  top: calc(var(--gap) * 2 + var(--top-h) + env(safe-area-inset-top, 0px)); left: var(--gap);
  flex-direction: column; gap: 2px; padding: 6px;
  max-height: calc(100vh - var(--top-h) - var(--gap) * 3 - env(safe-area-inset-top, 0px));
  overflow-y: auto; scrollbar-width: none;
  border-radius: var(--radius);
}
.rail-btn {
  width: 60px; min-height: 54px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text);
  font: inherit; font-size: 11px; font-weight: 600; line-height: 1.1; text-align: center; cursor: pointer;
  transition: background .2s, border-color .2s;
}
.rail-btn svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:hover { background: var(--hover); border-color: var(--border); }
.rail-btn.is-main { background: var(--grad-sun); color: var(--on-sun); }
.rail-btn.is-main:hover { border-color: var(--sun); }
.rail-sep { height: 1px; margin: 4px 8px; background: var(--border); flex: none; }

/* ---------- Riquadro richiudibile: details.riquadro > summary (.riquadro-tit + .riquadro-sub + svg freccia) + .riquadro-body ----------
   Per raccogliere una sezione lunga (per esempio i filtri) in una riga con il riassunto di cosa è acceso. Dal 15/11/2026. */
.riquadro { margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--hover); }
.riquadro > summary {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  list-style: none; cursor: pointer; border-radius: var(--radius-sm);
}
.riquadro > summary::-webkit-details-marker { display: none; }
.riquadro > summary:hover { background: var(--hover); }
.riquadro > summary > svg:first-child { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--sky); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="light"] .riquadro > summary > svg:first-child { stroke: var(--blue); }
.riquadro-testo { flex: 1; min-width: 0; display: grid; gap: 1px; }
.riquadro-tit { font-weight: 700; }
.riquadro-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riquadro-sub.is-on { color: var(--text); }
.riquadro-n { flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center;
  background: var(--sun); color: var(--on-sun); font-size: 12px; font-weight: 800; }
.riquadro-n[hidden] { display: none; }
.riquadro-freccia { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; transition: transform .2s; }
.riquadro[open] > summary .riquadro-freccia { transform: rotate(180deg); }
.riquadro[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.riquadro-body { padding: 12px; }
.riquadro-body > .filters { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .riquadro-freccia { transition: none; } }

/* ---------- Tutte le funzioni, a gruppi: .fn-gruppi > section.fn-gruppo > h3 + .fn-griglia > (button | a).fn-voce (.tile-ico + span) ----------
   Dentro una finestra (.modal): tutte le funzioni dell'app divise per argomento, anche quelle tolte dalla fila dei tasselli. */
.fn-gruppi { display: grid; gap: 16px; }
.fn-gruppo h3 { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fn-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.fn-voce {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--hover); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.25; text-align: left; text-decoration: none; cursor: pointer;
  transition: border-color .2s;
}
a.fn-voce, a.fn-voce:visited, :root[data-theme="light"] a.fn-voce { color: var(--text); }
.fn-voce:hover { border-color: var(--sun); }
.fn-voce .tile-ico:has(svg) { width: 34px; height: 34px; flex: none; border-radius: 10px; }
.fn-voce .tile-ico svg { width: 19px; height: 19px; }
.fn-voce.is-new .tile-ico:has(svg) { background: var(--grad-sun); }
.fn-voce.is-new .tile-ico svg { stroke: var(--on-sun); }
@media (max-width: 760px) { .fn-griglia { grid-template-columns: 1fr 1fr; } .fn-voce { font-size: 13px; } }

/* ---------- Cursore: input[type=range].range ---------- */
.range {
  width: 100%; height: 28px; margin: 0;
  appearance: none; -webkit-appearance: none;
  background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--sky)); }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--sky)); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: var(--sun); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--sun);
}
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--sun); border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--sun); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--sun), 0 0 0 6px rgba(255, 200, 61, .3); }

/* ---------- App installabile (pwa.js): invito e avviso offline ---------- */
.pwa-card {
  position: fixed; z-index: 3400;
  left: 50%; bottom: var(--gap);
  transform: translateX(-50%);
  width: min(520px, calc(100vw - var(--gap) * 2));
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px 14px 16px;
  border-radius: var(--radius);
  animation: pwa-in .35s ease-out;
}
.pwa-card::before {
  content: ''; flex: none;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--grad) center / cover;
  background-image: var(--pwa-icon, var(--grad));
}
.pwa-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-right: 22px; }
.pwa-body span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.pwa-body span b { color: var(--text); }
.pwa-close { position: absolute; top: 8px; right: 8px; }
.pwa-card .btn { flex: none; margin-right: 26px; }
.pwa-ios { width: 16px; height: 16px; vertical-align: -3px; fill: none; stroke: var(--sky); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Istruzioni passo passo per iPhone (Pwa.istruzioniIos) */
.pwa-steps { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pwa-steps li { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.pwa-step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-sun); color: var(--on-sun); font-weight: 800; font-size: 14px; }
.pwa-steps .pwa-ios { display: inline-block; width: 20px; height: 20px; vertical-align: -5px; margin: 0 1px; }
.pwa-ios { display: inline-block; }
:root[data-theme="light"] .pwa-ios { stroke: var(--blue); }
@keyframes pwa-in { from { opacity: 0; transform: translate(-50%, 16px); } }
@media (max-width: 560px) {
  .pwa-card { flex-wrap: wrap; align-items: flex-start; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .pwa-body { flex-basis: calc(100% - 58px); }
  .pwa-card .btn { width: 100%; margin-right: 0; }
}

/* Finestra del codice QR (Pwa.mostraQr) */
.pwa-qr { width: 232px; margin: 4px auto 8px; padding: 10px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.pwa-qr svg { display: block; width: 100%; height: auto; }
.pwa-qr-url { margin: 0 0 12px; text-align: center; font-size: 12px; color: var(--faint); word-break: break-all; }
.pwa-qr-passi { margin: 0 0 12px; padding-left: 20px; font-size: 13px; color: var(--muted); line-height: 1.55; }
.pwa-qr-passi b { color: var(--text); }
.pwa-share { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pwa-share[hidden] { display: none; }
.pwa-share .btn { flex: 1 1 auto; }

.offline-bar {
  position: fixed; z-index: 1050;
  left: 50%; top: calc(var(--gap) * 2 + var(--top-h) + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - var(--gap) * 2);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--sun); color: var(--on-sun);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.offline-bar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- Notifica ---------- */
.toast {
  position: fixed;
  z-index: 3000;
  left: 50%; bottom: 32px;
  transform: translate(-50%, 20px);
  width: max-content;               /* senza, a left:50% si ferma a metà schermo e va a capo troppo presto */
  max-width: min(90vw, 460px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }   /* un tocco la chiude */
.toast.warn { border-color: var(--sun); }

/* ---------- Telefono ---------- */
@media (max-width: 760px) {
  :root { --gap: 10px; --top-h: 58px; }
  .panel-toggle { display: none; }          /* sul telefono c'è la maniglia del foglio */
  .panel.is-ridotto { transform: none; opacity: 1; pointer-events: auto; }

  .topbar { gap: 8px; padding: 0 7px; border-radius: 18px; }
  .brand { width: auto; }
  .brand-name { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  .search input { height: 42px; }
  .icon-btn { width: 40px; height: 40px; border-radius: 12px; }

  .panel {
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: auto;
    height: var(--sheet-h);
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    transition: height .3s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-handle {
    display: grid; place-items: center;
    width: 100%; height: 26px;
    flex: none;
    border: none; background: none;
    padding: 0;
  }
  .sheet-handle span { width: 44px; height: 5px; border-radius: 99px; background: var(--border-strong); }
  /* overflow-x: niente scorrimento di lato se un elemento è più largo del foglio (su iPhone spostava tutto a sinistra) */
  .view { padding: 4px 14px 20px; overflow-x: hidden; }
  .panel[data-state="peek"] .view { overflow: hidden; }
  .sheet-handle { touch-action: none; }   /* il trascinamento della maniglia non fa scorrere la pagina */

  .stage { left: var(--gap); bottom: var(--sheet-h); }

  .stat-num { font-size: 22px; }
  .toast { bottom: calc(var(--sheet-h) + 16px); }
  .modal { padding: 22px 18px; }
  .cmp { bottom: 0; width: 100vw; border-radius: 22px 22px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .cmp-actions { grid-template-columns: 1fr 1fr; }
  .cmp-actions [data-cmp="personalizza"], .cmp-actions [data-cmp="salva"] { grid-column: 1 / -1; grid-row: 2; }
  /* Pubblicità sul telefono: striscia 320×50 sotto la barra e sopra il foglio dal basso */
  .topbar .ad-header { position: absolute; top: calc(100% + 8px); left: 0; right: 0; width: auto; height: 50px; margin: 0 auto; max-width: 320px; }
  .ad-footer { left: var(--gap); right: var(--gap); bottom: calc(var(--sheet-h) + 8px); max-width: 320px; height: 50px; transition: bottom .3s; }
  /* Con il foglio aperto del tutto non c'è spazio: l'annuncio in basso finirebbe sopra quello in alto */
  .panel[data-state="full"] ~ .ad-footer { visibility: hidden; }
  .toast { bottom: calc(var(--sheet-h) + var(--ad-footer-h) + 16px); }
  .menu-pop { position: fixed; top: calc(var(--gap) + var(--top-h) + env(safe-area-inset-top, 0px) + 8px); left: var(--gap); right: var(--gap); min-width: 0;
    /* (la barra in vetro fa da riferimento al menu "fixed": parte un --gap più in basso, quindi qui se ne tolgono tre) */
    max-height: calc(100vh - var(--gap) * 3 - var(--top-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 10px);
    max-height: calc(100dvh - var(--gap) * 3 - var(--top-h) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 10px); }
  .actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Testo letto dai lettori di schermo e dai motori di ricerca ma non disegnato (es. l'H1 di una pagina che è tutta mappa:
   dentro <noscript> i motori che eseguono JavaScript, come Bing, non lo vedono) */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
