/* =====================================================================
   Turni CVL — foglio di stile unico, mobile-first.
   Progettato a 360x640 e allargato: 360 / 768 / 1024 / 1440.
   Nessun bundler: CSS moderno servito statico.
   ===================================================================== */

/* ---------- 1. Token ---------- */
:root {
  color-scheme: light dark;

  /* Palette istituzionale Croce Verde: verde + accenti ad alto contrasto */
  --verde-900: #052E2B;
  --verde-800: #064E3B;
  --verde-700: #0F766E;
  --verde-600: #0D9488;
  --verde-500: #14B8A6;
  --verde-100: #CCFBF1;
  --verde-050: #F0FDFA;

  --ambra-700: #B45309;
  --ambra-500: #F59E0B;
  --ambra-100: #FEF3C7;

  --rosso-700: #B91C1C;
  --rosso-500: #EF4444;
  --rosso-100: #FEE2E2;

  --blu-700: #1D4ED8;
  --blu-100: #DBEAFE;

  --viola-700: #6D28D9;
  --rosa-700: #BE185D;

  /* Superfici — tema chiaro */
  --sfondo:        #F1F5F9;
  --superficie:    #FFFFFF;
  --superficie-2:  #F8FAFC;
  --superficie-3:  #F1F5F9;
  --bordo:         #E2E8F0;
  --bordo-forte:   #CBD5E1;
  --testo:         #0F172A;
  --testo-2:       #475569;
  --testo-3:       #64748B;
  --accento:       var(--verde-700);
  --accento-testo: #FFFFFF;
  --accento-tenue: var(--verde-050);

  --ombra-1: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .1);
  --ombra-2: 0 4px 6px -1px rgb(15 23 42 / .08), 0 2px 4px -2px rgb(15 23 42 / .06);
  --ombra-3: 0 10px 15px -3px rgb(15 23 42 / .1), 0 4px 6px -4px rgb(15 23 42 / .1);
  --ombra-alta: 0 -8px 24px -8px rgb(15 23 42 / .18);

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --r-xl: 22px;
  --r-tondo: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --tocco: 44px;               /* target touch minimo */
  --barra-h: 62px;             /* altezza bottom tab bar */
  --testata-h: 56px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --transizione: 160ms cubic-bezier(.4, 0, .2, 1);
}

[data-tema="scuro"], :root:has(#tema-scuro:checked) {
  --sfondo:       #0B1220;
  --superficie:   #131C2E;
  --superficie-2: #1B2740;
  --superficie-3: #223050;
  --bordo:        #2A3A57;
  --bordo-forte:  #3A4D70;
  --testo:        #E9EEF6;
  --testo-2:      #B3C0D4;
  --testo-3:      #8A9AB3;
  --accento:      var(--verde-500);
  --accento-testo: #052E2B;
  --accento-tenue: #0E2A28;
  --verde-100: #0E3B36;
  --ambra-100: #3A2A08;
  --rosso-100: #3B1414;
  --blu-100:   #12244F;
  --ombra-1: 0 1px 2px rgb(0 0 0 / .4);
  --ombra-2: 0 4px 8px -2px rgb(0 0 0 / .45);
  --ombra-3: 0 12px 24px -8px rgb(0 0 0 / .55);
  --ombra-alta: 0 -8px 24px -8px rgb(0 0 0 / .6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="chiaro"]) {
    --sfondo:       #0B1220;
    --superficie:   #131C2E;
    --superficie-2: #1B2740;
    --superficie-3: #223050;
    --bordo:        #2A3A57;
    --bordo-forte:  #3A4D70;
    --testo:        #E9EEF6;
    --testo-2:      #B3C0D4;
    --testo-3:      #8A9AB3;
    --accento:      var(--verde-500);
    --accento-testo: #052E2B;
    --accento-tenue: #0E2A28;
    --verde-100: #0E3B36;
    --ambra-100: #3A2A08;
    --rosso-100: #3B1414;
    --blu-100:   #12244F;
    --ombra-1: 0 1px 2px rgb(0 0 0 / .4);
    --ombra-2: 0 4px 8px -2px rgb(0 0 0 / .45);
    --ombra-3: 0 12px 24px -8px rgb(0 0 0 / .55);
    --ombra-alta: 0 -8px 24px -8px rgb(0 0 0 / .6);
  }
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--testo);
  background: var(--sfondo);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accento); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:where(h1, h2, h3, h4) { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

:focus-visible {
  outline: 3px solid var(--accento);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.salta-a-contenuto {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accento); color: var(--accento-testo);
  padding: var(--sp-3) var(--sp-4); border-radius: 0 0 var(--r-m) 0; font-weight: 600;
}
.salta-a-contenuto:focus { left: 0; }

/* ---------- 3. Struttura ---------- */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.testata {
  position: sticky; top: 0; z-index: 40;
  background: var(--verde-800);
  color: #fff;
  padding: max(env(safe-area-inset-top), 0px) var(--sp-4) 0;
  box-shadow: var(--ombra-2);
}
[data-tema="scuro"] .testata { background: var(--verde-900); }
.testata-riga {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--testata-h);
}
.marchio { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; letter-spacing: -.02em; color: #fff; text-decoration: none; }
.marchio .croce { width: 26px; height: 26px; flex: none; }
.marchio-testo { display: flex; flex-direction: column; line-height: 1.1; }
.marchio-testo small { font-size: .625rem; font-weight: 500; opacity: .82; letter-spacing: .06em; text-transform: uppercase; }
.testata-azioni { margin-left: auto; display: flex; align-items: center; gap: var(--sp-1); }

.icona-btn {
  display: inline-grid; place-items: center;
  min-width: var(--tocco); min-height: var(--tocco);
  border: 0; background: transparent; color: inherit;
  border-radius: var(--r-m); cursor: pointer; position: relative;
  transition: background var(--transizione);
}
.icona-btn:hover, .icona-btn:focus-visible { background: rgb(255 255 255 / .14); }
.testata .icona-btn svg { width: 22px; height: 22px; }

.pastiglia-badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--ambra-500); color: #1B1200;
  font-size: .688rem; font-weight: 800; border-radius: var(--r-tondo);
  border: 2px solid var(--verde-800);
}

.contenuto {
  padding: var(--sp-4) var(--sp-4) calc(var(--barra-h) + env(safe-area-inset-bottom) + var(--sp-6));
  max-width: 1440px; width: 100%; margin-inline: auto;
  min-width: 0;
}
/* Nessuna pagina deve poter scorrere orizzontalmente: le tabelle larghe
   scorrono dentro il proprio contenitore, non dentro la finestra. */
html, body { max-width: 100%; overflow-x: hidden; }
.app { min-width: 0; }
.intestazione-pagina h1, .scheda-testa h2, .scheda-testa h3 { overflow-wrap: anywhere; min-width: 0; }

/* Barra di navigazione inferiore (mobile) */
.barra-nav {
  position: fixed; inset: auto 0 0 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--superficie) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--bordo);
  box-shadow: var(--ombra-alta);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: var(--barra-h); padding: var(--sp-1);
  color: var(--testo-3); text-decoration: none; font-size: .688rem; font-weight: 600;
  position: relative; transition: color var(--transizione);
}
.barra-nav a svg { width: 24px; height: 24px; }
.barra-nav a.attivo { color: var(--accento); }
.barra-nav a.attivo::before {
  content: ''; position: absolute; top: 0; left: 50%; translate: -50% 0;
  width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accento);
}
.barra-nav .pastiglia-badge { top: 6px; right: 50%; margin-right: -22px; border-color: var(--superficie); }

/* Sidebar (desktop) */
.lato { display: none; }

@media (min-width: 1024px) {
  .barra-nav { display: none; }
  .app { grid-template-columns: 264px 1fr; grid-template-rows: auto 1fr; }
  .testata { grid-column: 1 / -1; }
  .lato {
    display: block; position: sticky; top: var(--testata-h);
    height: calc(100dvh - var(--testata-h)); overflow-y: auto;
    background: var(--superficie); border-right: 1px solid var(--bordo);
    padding: var(--sp-4) var(--sp-3);
  }
  .lato h4 {
    font-size: .688rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--testo-3); margin: var(--sp-5) var(--sp-3) var(--sp-2);
  }
  .lato h4:first-child { margin-top: 0; }
  .lato a {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-3); border-radius: var(--r-m);
    color: var(--testo-2); text-decoration: none; font-weight: 600; font-size: .938rem;
    min-height: var(--tocco); transition: background var(--transizione), color var(--transizione);
  }
  .lato a svg { width: 20px; height: 20px; flex: none; }
  .lato a:hover { background: var(--superficie-3); color: var(--testo); }
  .lato a.attivo { background: var(--accento-tenue); color: var(--accento); }
  .lato .conta {
    margin-left: auto; background: var(--ambra-500); color: #1B1200;
    font-size: .688rem; font-weight: 800; padding: 1px 7px; border-radius: var(--r-tondo);
  }
  .contenuto { padding: var(--sp-6); padding-bottom: var(--sp-10); }
}

/* ---------- 4. Componenti ---------- */
/* Nota: la scheda NON usa overflow:hidden. Un antenato con overflow diverso da
   visible diventa il contenitore di scorrimento degli elementi sticky interni e
   sposterebbe le intestazioni di mese in basso, sovrapponendole alla lista.
   I bordi arrotondati sono quindi applicati al primo e all'ultimo figlio. */
.scheda {
  background: var(--superficie);
  border: 1px solid var(--bordo);
  border-radius: var(--r-l);
  box-shadow: var(--ombra-1);
}
.scheda > :first-child,
.scheda > .elenco > li:first-child > * {
  border-top-left-radius: calc(var(--r-l) - 1px);
  border-top-right-radius: calc(var(--r-l) - 1px);
}
.scheda > :last-child,
.scheda > .elenco > li:last-child > * {
  border-bottom-left-radius: calc(var(--r-l) - 1px);
  border-bottom-right-radius: calc(var(--r-l) - 1px);
}
.scheda > summary:first-child { border-radius: calc(var(--r-l) - 1px) calc(var(--r-l) - 1px) 0 0; }
.scheda + .scheda { margin-top: var(--sp-4); }
.scheda-testa {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); border-bottom: 1px solid var(--bordo);
  background: var(--superficie-2);
}
.scheda-testa h2, .scheda-testa h3 { font-size: 1rem; }
.scheda-testa .azioni { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.scheda-testa { flex-wrap: wrap; }
.scheda-corpo { padding: var(--sp-4); }
.scheda-corpo.stretta { padding: var(--sp-3); }

.intestazione-pagina {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  margin-bottom: var(--sp-4); flex-wrap: wrap;
}
.intestazione-pagina h1 { font-size: 1.375rem; }
.intestazione-pagina p { color: var(--testo-2); font-size: .875rem; }
.intestazione-pagina .azioni { margin-left: auto; display: flex; gap: var(--sp-2); flex-wrap: wrap; max-width: 100%; }
@media (max-width: 600px) {
  .intestazione-pagina { flex-direction: column; align-items: stretch; }
  .intestazione-pagina .azioni { margin-left: 0; }
}

/* Pulsanti */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tocco); padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--r-m);
  background: var(--superficie-3); color: var(--testo);
  font-weight: 650; font-size: .938rem; text-decoration: none; cursor: pointer;
  transition: background var(--transizione), transform var(--transizione), box-shadow var(--transizione);
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--bordo); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primario { background: var(--accento); color: var(--accento-testo); box-shadow: var(--ombra-1); }
.btn-primario:hover { background: color-mix(in srgb, var(--accento) 88%, #000); }
.btn-contorno { background: transparent; border-color: var(--bordo-forte); }
.btn-contorno:hover { background: var(--superficie-3); }
.btn-pericolo { background: var(--rosso-700); color: #fff; }
.btn-pericolo:hover { background: #991B1B; }
.btn-piccolo { min-height: 36px; padding: 0 var(--sp-3); font-size: .813rem; border-radius: var(--r-s); }
.btn-largo { width: 100%; }
.btn-fantasma { background: transparent; }
.btn-fantasma:hover { background: var(--superficie-3); }

.gruppo-btn { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* Segmented control */
.segmenti {
  display: flex; background: var(--superficie-3);
  border-radius: var(--r-m); padding: 3px; gap: 2px; border: 1px solid var(--bordo);
  max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.segmenti::-webkit-scrollbar { display: none; }
.segmenti > * { flex: 0 0 auto; }
.segmenti a, .segmenti button, .segmenti label {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 var(--sp-3);
  border: 0; background: transparent; color: var(--testo-2);
  border-radius: calc(var(--r-m) - 3px); font-weight: 650; font-size: .875rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.segmenti .attivo, .segmenti [aria-pressed="true"] {
  background: var(--superficie); color: var(--testo); box-shadow: var(--ombra-1);
}

/* Pastiglie e badge */
.pastiglia {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-tondo);
  font-size: .75rem; font-weight: 700; line-height: 1.5;
  background: var(--superficie-3); color: var(--testo-2);
  border: 1px solid var(--bordo);
}
.pastiglia svg { width: 13px; height: 13px; }
.pastiglia.ok    { background: var(--verde-100); color: var(--verde-800); border-color: transparent; }
.pastiglia.ko    { background: var(--rosso-100); color: var(--rosso-700); border-color: transparent; }
.pastiglia.attesa{ background: var(--ambra-100); color: var(--ambra-700); border-color: transparent; }
.pastiglia.info  { background: var(--blu-100);   color: var(--blu-700);   border-color: transparent; }
.pastiglia.neutro{ background: var(--superficie-3); color: var(--testo-3); }
[data-tema="scuro"] .pastiglia.ok { color: var(--verde-100); }
[data-tema="scuro"] .pastiglia.ko { color: #FCA5A5; }
[data-tema="scuro"] .pastiglia.attesa { color: #FCD34D; }
[data-tema="scuro"] .pastiglia.info { color: #93C5FD; }

/* Sigla turno: doppia codifica colore + testo + icona */
.sigla {
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 40px; padding: 3px 7px;
  border-radius: var(--r-s); font-weight: 800; font-size: .813rem;
  font-family: var(--mono); letter-spacing: .02em;
  color: #fff; background: var(--verde-700);
  border: 1px solid rgb(0 0 0 / .12);
}
.sigla svg { width: 12px; height: 12px; opacity: .9; }
.sigla.giust {
  background: transparent; color: var(--testo-2);
  border: 1.5px dashed var(--bordo-forte);
}

/* Messaggi flash / avvisi */
.avviso {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-m);
  border: 1px solid var(--bordo); background: var(--superficie-2);
  font-size: .875rem; margin-bottom: var(--sp-3);
}
.avviso svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.avviso.ok      { background: var(--verde-100); border-color: transparent; color: var(--verde-800); }
.avviso.errore  { background: var(--rosso-100); border-color: transparent; color: var(--rosso-700); }
.avviso.avviso-attesa, .avviso.avvisoi { background: var(--ambra-100); border-color: transparent; color: var(--ambra-700); }
.avviso.info    { background: var(--blu-100); border-color: transparent; color: var(--blu-700); }
[data-tema="scuro"] .avviso.ok { color: #A7F3D0; }
[data-tema="scuro"] .avviso.errore { color: #FCA5A5; }
[data-tema="scuro"] .avviso.avviso-attesa { color: #FCD34D; }
[data-tema="scuro"] .avviso.info { color: #93C5FD; }
.avviso strong { display: block; }

/* Form */
.campo { margin-bottom: var(--sp-4); }
.campo label, .etichetta {
  display: block; font-weight: 650; font-size: .875rem;
  margin-bottom: var(--sp-2); color: var(--testo);
}
.campo .aiuto { font-size: .813rem; color: var(--testo-3); margin-top: var(--sp-2); }
.campo .errore-campo { font-size: .813rem; color: var(--rosso-700); margin-top: var(--sp-2); font-weight: 600; }
[data-tema="scuro"] .campo .errore-campo { color: #FCA5A5; }

input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="date"], input[type="time"], input[type="number"], input[type="tel"],
select, textarea {
  width: 100%; min-height: var(--tocco);
  padding: 10px var(--sp-3);
  font-size: 16px;             /* >= 16px: evita lo zoom automatico su iOS */
  background: var(--superficie);
  border: 1.5px solid var(--bordo-forte);
  border-radius: var(--r-m);
  color: var(--testo);
  transition: border-color var(--transizione), box-shadow var(--transizione);
  appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
  padding-right: 40px;
}
select[multiple] {
  background-image: none; padding-right: var(--sp-3); min-height: 132px; padding: 6px;
}
select[multiple] option {
  padding: 7px 10px; border-radius: var(--r-s); margin-bottom: 2px;
}
select[multiple] option:checked {
  background: var(--accento) linear-gradient(0deg, var(--accento) 0%, var(--accento) 100%);
  color: var(--accento-testo); font-weight: 650;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accento);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accento) 22%, transparent);
}
input[aria-invalid="true"], .campo.ko input, .campo.ko select { border-color: var(--rosso-500); }
input::placeholder, textarea::placeholder { color: var(--testo-3); }

.checkbox, .radio {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  min-height: var(--tocco); padding: var(--sp-2) 0; cursor: pointer;
}
.checkbox input, .radio input {
  width: 22px; height: 22px; margin: 2px 0 0; flex: none;
  accent-color: var(--accento); cursor: pointer;
}
.checkbox span, .radio span { font-size: .938rem; }
.checkbox small, .radio small { display: block; color: var(--testo-3); font-size: .813rem; }

.riquadro-radio {
  display: block; border: 1.5px solid var(--bordo-forte); border-radius: var(--r-m);
  padding: var(--sp-3) var(--sp-4); cursor: pointer; transition: all var(--transizione);
  background: var(--superficie);
}
.riquadro-radio:has(input:checked) {
  border-color: var(--accento); background: var(--accento-tenue);
  box-shadow: 0 0 0 1px var(--accento);
}
.riquadro-radio + .riquadro-radio { margin-top: var(--sp-2); }

.griglia-form { display: grid; gap: var(--sp-3); }
@media (min-width: 768px) {
  .griglia-form.due { grid-template-columns: 1fr 1fr; }
  .griglia-form.tre { grid-template-columns: repeat(3, 1fr); }
}

fieldset { border: 0; padding: 0; }
legend { font-weight: 700; margin-bottom: var(--sp-2); padding: 0; }

/* Barra filtri */
.filtri {
  display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end;
  padding: var(--sp-3); background: var(--superficie); border: 1px solid var(--bordo);
  border-radius: var(--r-l); margin-bottom: var(--sp-4);
}
.filtri .campo { margin: 0; flex: 1 1 140px; min-width: 0; }
.filtri input, .filtri select, .filtri textarea { min-width: 0; max-width: 100%; }
.filtri .btn { flex: 0 0 auto; }
.filtri .checkbox { flex: 1 1 100%; align-items: center; }
.filtri form { display: contents; }
@media (max-width: 600px) {
  /* Su schermo stretto ogni controllo del filtro occupa la sua riga:
     un pulsante schiacciato accanto a un'etichetta lunga e intoccabile. */
  .filtri { flex-direction: column; align-items: stretch; }
  .filtri .campo, .filtri .btn, .filtri .checkbox { flex: 1 1 auto; width: 100%; }
  .filtri .btn { justify-content: center; }
}
.filtri .campo label { font-size: .75rem; margin-bottom: 4px; color: var(--testo-3); }

/* Elenchi */
.elenco { list-style: none; padding: 0; margin: 0; }
.elenco li + li { border-top: 1px solid var(--bordo); }
.elenco-riga {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); min-height: 60px;
  color: inherit; text-decoration: none; width: 100%;
  background: transparent; border: 0; text-align: left; cursor: pointer;
  transition: background var(--transizione);
}
.elenco-riga:hover { background: var(--superficie-2); }
.elenco-riga .principale { flex: 1 1 auto; min-width: 0; display: block; }
.elenco-riga .titolo {
  display: block; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.elenco-riga .secondario {
  display: block; font-size: .813rem; color: var(--testo-3);
  overflow-wrap: anywhere;
}
.elenco-riga .fine { margin-left: auto; text-align: right; flex: 0 0 auto; max-width: 45%; }
.elenco-riga .freccia { color: var(--testo-3); width: 18px; height: 18px; flex: none; }

.intestazione-sticky {
  position: sticky; top: var(--testata-h); z-index: 20;
  background: var(--superficie-2); padding: var(--sp-2) var(--sp-4);
  margin: 0;
  font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--testo-3); border-bottom: 1px solid var(--bordo);
}

/* Card prossimo turno */
.turno-hero {
  border-radius: var(--r-xl); padding: var(--sp-5);
  background: linear-gradient(140deg, var(--verde-700), var(--verde-800) 70%);
  color: #fff; box-shadow: var(--ombra-3); position: relative; overflow: hidden;
}
.turno-hero::after {
  content: ''; position: absolute; inset: auto -60px -80px auto;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgb(255 255 255 / .07);
}
.turno-hero .quando {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgb(255 255 255 / .18); padding: 5px 12px;
  border-radius: var(--r-tondo); font-size: .813rem; font-weight: 700;
  backdrop-filter: blur(4px);
}
.turno-hero h2 { font-size: 1.5rem; margin: var(--sp-3) 0 var(--sp-1); position: relative; }
.turno-hero .dettaglio { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: .938rem; opacity: .95; position: relative; }
.turno-hero .dettaglio > span { display: inline-flex; align-items: center; gap: 6px; }
.turno-hero .dettaglio svg { width: 16px; height: 16px; }
.turno-hero .azioni-rapide { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; position: relative; }
.turno-hero .azioni-rapide .btn {
  background: rgb(255 255 255 / .16); color: #fff; border-color: rgb(255 255 255 / .28);
  backdrop-filter: blur(4px);
}
.turno-hero .azioni-rapide .btn:hover { background: rgb(255 255 255 / .26); }
.turno-hero.in-corso { background: linear-gradient(140deg, var(--ambra-700), #7C2D12 70%); }
.turno-hero.vuoto { background: var(--superficie); color: var(--testo); border: 1px dashed var(--bordo-forte); box-shadow: none; }
.turno-hero.vuoto .quando { background: var(--superficie-3); color: var(--testo-2); }

/* Statistiche */
.statistiche { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
@media (min-width: 768px) { .statistiche { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--superficie); border: 1px solid var(--bordo);
  border-radius: var(--r-m); padding: var(--sp-3) var(--sp-4);
}
.stat .valore { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .etichetta {
  font-size: .688rem; color: var(--testo-3); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 700; line-height: 1.35;
}
.statistiche { align-items: stretch; }
.stat { display: flex; flex-direction: column; justify-content: center; min-height: 76px; }

/* Calendario mensile */
.calendario { --gap: 3px; }
.calendario-testa {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--gap);
  margin-bottom: var(--gap);
}
.calendario-testa span {
  text-align: center; font-size: .688rem; font-weight: 800;
  color: var(--testo-3); text-transform: uppercase; letter-spacing: .04em; padding: 4px 0;
}
.calendario-griglia { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--gap); }
.giorno {
  aspect-ratio: 1 / 1.12; min-height: 46px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px; border-radius: var(--r-s);
  background: var(--superficie); border: 1px solid var(--bordo);
  font-size: .75rem; cursor: pointer; position: relative;
  transition: background var(--transizione), border-color var(--transizione);
}
.giorno:hover { background: var(--superficie-2); }
.giorno .numero { font-weight: 700; font-variant-numeric: tabular-nums; }
.giorno.fuori { opacity: .34; }
.giorno.weekend, .giorno.festivo { background: var(--rosso-100); }
.giorno.festivo { border-color: var(--rosso-500); }
.giorno.oggi { border-color: var(--accento); border-width: 2px; box-shadow: 0 0 0 1px var(--accento); }
.giorno.oggi .numero { color: var(--accento); }
.giorno .sigle { display: flex; flex-direction: column; gap: 1px; width: 100%; align-items: center; }
.giorno .mini-sigla {
  font-size: .625rem; font-weight: 800; font-family: var(--mono);
  padding: 1px 3px; border-radius: 3px; color: #fff;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.giorno .mini-sigla.giust {
  background: transparent !important; color: var(--testo-2) !important;
  border: 1px dashed var(--bordo-forte);
}
.giorno.ha-giustificativo::before {
  content: ''; position: absolute; inset: 0; border-radius: var(--r-s);
  background: repeating-linear-gradient(45deg, transparent, transparent 4px,
              color-mix(in srgb, var(--testo-3) 16%, transparent) 4px,
              color-mix(in srgb, var(--testo-3) 16%, transparent) 8px);
  pointer-events: none;
}

/* Bottom sheet */
dialog.foglio {
  border: 0; padding: 0; background: transparent;
  width: 100%; max-width: 100%; max-height: 100dvh;
  margin: 0; margin-top: auto; margin-bottom: 0;
  position: fixed; inset: auto 0 0 0;
}
dialog.foglio::backdrop { background: rgb(2 6 23 / .55); backdrop-filter: blur(3px); }
.foglio-corpo {
  background: var(--superficie); color: var(--testo);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
  animation: sali .22s cubic-bezier(.3, 1, .4, 1);
}
@keyframes sali { from { transform: translateY(100%); } to { transform: none; } }
.foglio-maniglia {
  width: 40px; height: 4px; border-radius: var(--r-tondo);
  background: var(--bordo-forte); margin: 0 auto var(--sp-3);
}
.foglio-testa { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.foglio-testa h3 { flex: 1; }

@media (min-width: 768px) {
  dialog.foglio { inset: 0; margin: auto; max-width: 560px; max-height: 86dvh; }
  .foglio-corpo { border-radius: var(--r-xl); max-height: 86dvh; animation: apri .18s ease-out; padding-bottom: var(--sp-6); }
  .foglio-maniglia { display: none; }
  @keyframes apri { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
}

/* Definizioni chiave/valore */
.dati { display: grid; gap: var(--sp-3); }
.dati > div { display: grid; grid-template-columns: 130px 1fr; gap: var(--sp-3); align-items: start; }
.dati dt { color: var(--testo-3); font-size: .875rem; font-weight: 600; }
.dati dd { margin: 0; font-weight: 600; }
@media (max-width: 480px) { .dati > div { grid-template-columns: 108px 1fr; } }

/* Tabelle (solo desktop) */
.tabella-contenitore {
  overflow: auto; border: 1px solid var(--bordo); border-radius: var(--r-l);
  background: var(--superficie); -webkit-overflow-scrolling: touch;
}
table.tabella { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
table.tabella th, table.tabella td {
  padding: var(--sp-2) var(--sp-3); text-align: left;
  border-bottom: 1px solid var(--bordo); white-space: nowrap;
}
table.tabella th {
  position: sticky; top: 0; z-index: 2;
  background: var(--superficie-2); font-size: .75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; color: var(--testo-3);
}
table.tabella tbody tr:hover td { background: var(--superficie-2); }
table.tabella td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Matrice ODS: prima colonna e header congelati */
.matrice-contenitore { overflow: auto; max-height: 74dvh; border: 1px solid var(--bordo); border-radius: var(--r-l); background: var(--superficie); }
table.matrice { border-collapse: separate; border-spacing: 0; font-size: .75rem; width: max-content; min-width: 100%; }
table.matrice th, table.matrice td {
  padding: 3px 5px; border-bottom: 1px solid var(--bordo); border-right: 1px solid var(--bordo);
  white-space: nowrap; text-align: center; height: 30px;
}
table.matrice thead th {
  position: sticky; top: 0; z-index: 3; background: var(--superficie-2);
  font-size: .688rem; font-weight: 800; min-width: 46px;
}
table.matrice thead th.giorno-weekend { background: var(--rosso-100); color: var(--rosso-700); }
table.matrice .col-nome {
  position: sticky; left: 0; z-index: 2; background: var(--superficie);
  text-align: left; min-width: 168px; max-width: 168px;
  overflow: hidden; text-overflow: ellipsis; font-weight: 600;
  border-right: 2px solid var(--bordo-forte);
}
table.matrice thead th.col-nome { z-index: 4; background: var(--superficie-2); }
table.matrice tr.gruppo-reparto td {
  position: sticky; left: 0; background: var(--verde-700); color: #fff;
  font-weight: 800; text-align: left; text-transform: uppercase;
  letter-spacing: .05em; font-size: .688rem; z-index: 2;
}
table.matrice tr.gruppo-profilo td {
  position: sticky; left: 0; background: var(--superficie-3); color: var(--testo-2);
  font-weight: 700; text-align: left; font-size: .688rem; z-index: 2;
}
table.matrice td.cella-weekend { background: color-mix(in srgb, var(--rosso-100) 55%, transparent); }
table.matrice td .cella-sigla {
  display: inline-block; padding: 1px 4px; border-radius: 3px;
  font-family: var(--mono); font-weight: 800; font-size: .688rem; color: #fff;
}
table.matrice td .cella-sigla.giust { background: transparent !important; color: var(--testo-2) !important; border: 1px dashed var(--bordo-forte); }

/* Griglia di pianificazione */
.griglia-pian { overflow: auto; max-height: 72dvh; border: 1px solid var(--bordo); border-radius: var(--r-l); background: var(--superficie); }
table.pian { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: .75rem; }
table.pian th, table.pian td { border-bottom: 1px solid var(--bordo); border-right: 1px solid var(--bordo); vertical-align: top; }
table.pian thead th { position: sticky; top: 0; z-index: 3; background: var(--superficie-2); padding: var(--sp-2); font-size: .688rem; }
table.pian .col-turno {
  position: sticky; left: 0; z-index: 2; background: var(--superficie);
  min-width: 190px; max-width: 190px; padding: var(--sp-2); text-align: left;
  border-right: 2px solid var(--bordo-forte);
}
table.pian thead th.col-turno { z-index: 4; background: var(--superficie-2); }
.cella-pian { min-width: 132px; padding: 4px; position: relative; }
.cella-pian.scoperta { background: color-mix(in srgb, var(--rosso-100) 60%, transparent); }
.cella-pian.esubero  { background: color-mix(in srgb, var(--ambra-100) 60%, transparent); }
.cella-pian.completa { background: color-mix(in srgb, var(--verde-100) 45%, transparent); }
.cella-pian .conteggio {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  font-size: .625rem; font-weight: 800; color: var(--testo-3); margin-bottom: 3px;
}
.chip-op {
  display: flex; align-items: center; gap: 4px;
  background: var(--superficie-3); border: 1px solid var(--bordo);
  border-radius: var(--r-s); padding: 2px 5px; margin-bottom: 2px;
  font-size: .688rem; font-weight: 600;
}
.chip-op .x {
  margin-left: auto; border: 0; background: transparent; cursor: pointer;
  color: var(--testo-3); font-weight: 900; line-height: 1; padding: 2px 3px; border-radius: 3px;
}
.chip-op .x:hover { background: var(--rosso-100); color: var(--rosso-700); }
.cella-pian.inattiva { background: var(--superficie-2); }
.cella-pian.inattiva .conteggio { opacity: .35; }
.cella-pian.inattiva .aggiungi { opacity: .28; }
.cella-pian.inattiva:hover .aggiungi { opacity: 1; }
.cella-pian .aggiungi {
  width: 100%; min-height: 24px; border: 1px dashed var(--bordo-forte);
  background: transparent; border-radius: var(--r-s); color: var(--testo-3);
  cursor: pointer; font-size: .688rem; font-weight: 700;
}
.cella-pian .aggiungi:hover { border-color: var(--accento); color: var(--accento); background: var(--accento-tenue); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--superficie-3) 25%, var(--bordo) 50%, var(--superficie-3) 75%);
  background-size: 200% 100%; animation: sk 1.4s infinite linear; border-radius: var(--r-s);
}
@keyframes sk { to { background-position: -200% 0; } }
.skeleton-riga { height: 56px; margin-bottom: var(--sp-2); }

/* Stato vuoto */
.vuoto-stato {
  text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--testo-3);
}
.vuoto-stato svg { width: 52px; height: 52px; margin: 0 auto var(--sp-3); opacity: .45; }
.vuoto-stato h3 { color: var(--testo-2); margin-bottom: var(--sp-2); font-size: 1rem; }
.vuoto-stato p { font-size: .875rem; max-width: 44ch; margin: 0 auto var(--sp-4); }

/* Timeline stati richiesta */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 8px; bottom: 8px;
  width: 2px; background: var(--bordo);
}
.timeline li { position: relative; padding-bottom: var(--sp-4); }
.timeline li::before {
  content: ''; position: absolute; left: -22px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--superficie); border: 2px solid var(--bordo-forte);
}
.timeline li.fatto::before { background: var(--accento); border-color: var(--accento); }
.timeline li.ko::before { background: var(--rosso-500); border-color: var(--rosso-500); }
.timeline .quando { font-size: .75rem; color: var(--testo-3); }

/* Barra di copertura */
.barra-cop {
  display: block; height: 8px; width: 100%; max-width: 320px;
  border-radius: var(--r-tondo); background: var(--superficie-3); overflow: hidden;
}
.barra-cop > span { display: block; height: 100%; background: var(--accento); }
.barra-cop.bassa > span { background: var(--rosso-500); }
.barra-cop.media > span { background: var(--ambra-500); }

/* Toast */
.toast-area { position: fixed; left: 50%; translate: -50% 0; bottom: calc(var(--barra-h) + 16px); z-index: 90; display: grid; gap: 8px; width: min(92vw, 460px); }
@media (min-width: 1024px) { .toast-area { bottom: 24px; } }
.toast {
  background: var(--testo); color: var(--sfondo); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-m); box-shadow: var(--ombra-3); font-size: .875rem; font-weight: 600;
  animation: sali .2s ease-out;
}

/* Utility */
.flex { display: flex; }
.tra { justify-content: space-between; }
.centro { align-items: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.avvolgi { flex-wrap: wrap; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.piccolo { font-size: .813rem; }
.tenue { color: var(--testo-3); }
.forte { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.solo-desktop { display: none; }
.solo-mobile { display: block; }
@media (min-width: 1024px) {
  .solo-desktop { display: block; }
  .solo-mobile { display: none; }
  .solo-desktop.flex { display: flex; }
}

/* Stampa */
@media print {
  .testata, .barra-nav, .lato, .filtri, .azioni, .btn, .no-stampa { display: none !important; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .contenuto { padding: 0; max-width: none; }
  .scheda { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
  table.matrice { font-size: 7pt; }
  @page { size: A4 landscape; margin: 10mm; }
}
