/* CVAP Turnistica — stile. Sempre tema chiaro (scelta dell'utente), stampa in fondo.
   Direzione: calmo e pratico, come un tabellone turni. Pochi colori, ognuno con un significato:
   rosso CVAP solo per il marchio e i problemi, verde per i volontari e le conferme, blu per le azioni. */

:root {
  --bg: #c7ced8;
  --surface: #e2e6eb;
  --surface-2: #d5dbe2;
  --text: #1b2330;
  --muted: #3d4857;
  --border: #b3bcc8;
  --border-strong: #7f8a99;
  --control-border: #5e6878;  /* bordi di campi e pulsanti: almeno 3:1 */
  --accent: #009541;          /* verde Croce Verde, come il logo */
  --accent-text: #ffffff;
  --primary: #25509d;
  --primary-hover: #1d4384;
  --primary-soft: #cbd8ee;
  --primary-text: #ffffff;
  --focus: #0a3fa8;           /* 9:1 sul bianco */
  --weekend: #e8dbbd;
  --festivo: #f6cdd6;          /* festività: rosa chiaro, distinto dal weekend beige */
  --festivo-testo: #8e1838;
  --giorno: #b07400;          /* icona del sole */
  --notte: #4654b8;           /* icona della luna */

  --vol-bg: #cfe9d7;  --vol-border: #2f9a55;  --vol-text: #14532d;
  --man-bg: #d3e0f5;  --man-border: #2f5fc4;  --man-text: #12347d;
  --gen-bg: #eceff3;  --gen-border: #a9b3c0;  --gen-text: #1b2330;

  --err: #b51d2b;  --err-bg: #f3dde0;
  --warn: #7a4f00; --warn-bg: #f1e5c6; --warn-border: #d99000;
  --ok: #1f6d45;   --ok-bg: #d3eadb;
  --info-bg: #cbd8ee;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(30, 41, 59, .07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;                /* altezza minima dei comandi principali */
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }

a { color: var(--primary); }

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

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: var(--radius);
  border: 2px solid var(--focus);
}
.skip-link:focus { top: 8px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .88rem; margin: .35rem 0 0; }
.loading { padding: 2rem 0; }

/* ---------- Header e navigazione ---------- */

.app-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 0 clamp(.75rem, 3vw, 2rem);
  min-height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }
.brand-logo { display: block; height: 52px; width: auto; }
.brand-text {
  padding-left: .75rem; border-left: 2px solid var(--border-strong);
  font-size: 1.15rem; font-weight: 700; color: var(--text); letter-spacing: .01em;
}
.nav { display: flex; gap: .15rem; margin-left: auto; align-self: stretch; }
.nav a {
  display: flex; align-items: center; gap: .45rem;
  padding: 0 .85rem; text-decoration: none;
  color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.nav-icona { width: 20px; height: 20px; flex: none; }
.nav-testo-breve { display: none; }
.nav a[aria-current="page"] .nav-icona { color: var(--accent); }

main {
  padding: 1.25rem clamp(.75rem, 3vw, 2rem) 3rem;
  max-width: 1500px; margin: 0 auto;
}
main:focus { outline: none; }

.view-header { margin-bottom: 1.25rem; }
.view-header p { margin: .4rem 0 0; color: var(--muted); max-width: 70ch; }

/* ---------- Bottoni ---------- */

.btn {
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .4rem 1rem;
  border-radius: var(--radius-sm); border: 1px solid var(--control-border);
  background: var(--surface); color: var(--text); cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.btn-success:hover:not(:disabled) { filter: brightness(1.1); background: var(--ok); }
.btn-danger { color: var(--err); border-color: var(--err); }
.btn-danger:hover:not(:disabled) { background: var(--err-bg); }
.dialog-conferma .btn-danger { background: var(--err); color: var(--surface); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-grande { min-height: var(--tap); padding: .5rem 1.25rem; font-size: 1.02rem; }
.btn-small { min-height: 32px; padding: .2rem .7rem; font-size: .88rem; }
.btn-filter { border-radius: 999px; }
.btn-filter.attivo { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ---------- Badge / banner ---------- */

.badge {
  display: inline-block; padding: .12rem .6rem; border-radius: 999px;
  font-size: .8rem; font-weight: 650; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.badge-nuova { background: var(--surface-2); }
.badge-bozza { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-confermata { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.badge-errore { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.badge-avviso { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-dipendente { background: var(--man-bg); color: var(--man-text); border-color: var(--man-border); }
.badge-volontario { background: var(--vol-bg); color: var(--vol-text); border-color: var(--vol-border); }
.badge-attivo { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.badge-inattivo { color: var(--muted); }
.badge-tipo { background: transparent; color: var(--muted); border-color: var(--border); }

.banner {
  padding: .8rem 1rem; border-radius: var(--radius); margin: .75rem 0;
  border: 1px solid var(--border); background: var(--surface);
}
.banner-errore { background: var(--err-bg); border-color: var(--err); color: var(--text); }
.banner-info { background: var(--info-bg); border-color: var(--man-border); }

/* ---------- Testata settimana ---------- */

.week-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem;
  margin-bottom: 1rem;
}
.week-title { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; }
.week-title h1 { font-size: 1.75rem; }
.week-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.week-tipo { font-weight: 650; }
.week-range { font-weight: inherit; }
.week-postazioni { font-size: .9rem; }
.week-nav { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.week-nav .btn { min-height: var(--tap); }
.btn-freccia { width: var(--tap); padding: 0; font-size: 1.35rem; line-height: 1; }

input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--control-border); border-radius: var(--radius-sm);
  min-height: 40px; padding: .35rem .6rem;
}
.week-nav input[type="date"] { min-height: var(--tap); }
input[type="checkbox"] { min-height: 0; width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }

/* Passi della settimana: dove sei e cosa fare dopo */
.passi {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  list-style: none; margin: 0 0 1rem; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.passo {
  display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .9rem;
  border-right: 1px solid var(--border); color: var(--muted);
}
.passo:last-child { border-right: 0; }
.passo-num {
  flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border-strong); font-weight: 750; font-size: .9rem; background: var(--surface);
}
.passo-testo { display: flex; flex-direction: column; min-width: 0; }
.passo-titolo { font-weight: 700; color: var(--text); }
.passo-sotto { font-size: .85rem; }
.passo-fatto .passo-num { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.passo-attuale { background: var(--primary-soft); }
.passo-attuale .passo-num { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.passo-attuale .passo-sotto { color: var(--text); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: 1rem;
}
.toolbar-spacer { flex: 1; }
.altre-opzioni { position: relative; }
.altre-opzioni > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem;
  min-height: 40px; padding: .4rem .9rem; border-radius: var(--radius-sm); font-weight: 600; color: var(--muted);
}
.altre-opzioni > summary::-webkit-details-marker { display: none; }
.altre-opzioni > summary::after { content: "▾"; content: "▾" / ""; font-size: .8em; }
.altre-opzioni[open] > summary::after { content: "▴"; content: "▴" / ""; }
.altre-opzioni > summary:hover { background: var(--surface-2); color: var(--text); }
.altre-opzioni-menu {
  position: absolute; z-index: 15; top: calc(100% + .35rem); left: 0; min-width: 260px;
  display: flex; flex-direction: column; align-items: stretch; gap: .6rem;
  padding: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
}
.altre-opzioni-menu .btn { justify-content: flex-start; }

.legenda {
  display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; list-style: none; padding: 0; margin: 1.25rem 0 .5rem;
  font-size: .88rem; color: var(--muted);
}
.legenda li { display: flex; align-items: center; gap: .35rem; }

/* ---------- Report generazione ---------- */

.report {
  margin: 0 0 1rem; padding: .85rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  display: grid; grid-template-columns: auto 1fr; gap: .1rem .8rem; align-items: start;
}
.report > :not(.report-icona) { grid-column: 2; }
.report-icona {
  grid-row: 1 / span 4; display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: 50%; font-weight: 800; font-size: 1.05rem;
}
.report-ok .report-icona { background: var(--ok-bg); color: var(--ok); }
.report-avviso { border-color: var(--warn-border); }
.report-avviso .report-icona { background: var(--warn-bg); color: var(--warn); }
.report-errore { border-color: var(--err); background: var(--err-bg); }
.report-errore .report-icona { background: var(--err); color: var(--surface); }
.report-head { display: flex; flex-wrap: wrap; gap: .3rem 1.25rem; align-items: baseline; }
.report-head strong { font-size: 1.02rem; }
.report-msg { margin: .2rem 0 0; }
.report-scoperti-titolo { margin: .5rem 0 .2rem; font-weight: 700; color: var(--err); }
.report-scoperti { margin: 0; padding-left: 1.2rem; columns: 2 18rem; font-size: .92rem; }

/* ---------- Griglia turni ---------- */

.griglie { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; margin-top: .5rem; }
.griglia-titolo {
  font-size: 1.2rem; margin: 0 0 .5rem; display: flex; align-items: center; gap: .5rem;
}
.griglia-titolo::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex: none;
}
.griglia-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.griglia { width: 100%; min-width: 860px; border-collapse: collapse; table-layout: fixed; }
.griglia th, .griglia td { border: 1px solid var(--border); vertical-align: top; }
.griglia tr > :first-child { border-left: 0; }
.griglia tr > :last-child { border-right: 0; }
.griglia tbody tr:last-child > * { border-bottom: 0; }
.griglia thead th {
  background: var(--surface); padding: .55rem .35rem; font-size: .9rem; text-align: center;
  border-top: 0; border-bottom: 2px solid var(--border-strong);
}
.giorno-nome { font-weight: 750; }
.giorno-data { color: var(--muted); font-weight: 500; }
.griglia .col-turno {
  width: 140px; text-align: left; padding: .5rem .65rem; background: var(--surface-2);
  position: sticky; left: 0; z-index: 1;
}
.griglia tbody .col-turno { font-weight: 400; }
.fascia-label {
  display: flex; align-items: center; gap: .3rem;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700;
}
.fascia-icona { font-size: 1rem; line-height: 1; text-transform: none; }
.fascia-giorno .fascia-icona { color: var(--giorno); }
.fascia-notte .fascia-icona { color: var(--notte); }
.ruolo-label { display: block; font-weight: 700; }
.griglia tr.inizio-fascia > * { border-top: 2px solid var(--border-strong); }
/* stacco netto tra i turni di giorno e quelli di notte */
.griglia tr.fascia-notte.inizio-fascia > * { border-top: 3px solid var(--text); }
.griglia thead + tbody tr.inizio-fascia:first-child > * { border-top: 0; }
.griglia .weekend { background: var(--weekend); }
.griglia thead th.weekend { background: var(--weekend); }

.cella { padding: 0; height: 1px; }
.cella-btn {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  width: 100%; height: 100%; min-height: 56px; padding: 6px;
  font: inherit; text-align: left; color: inherit;
  background: transparent; border: 0; cursor: pointer;
}
.cella-btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.cella-btn:focus-visible { outline-offset: -3px; }
.cella-evidenziata { box-shadow: inset 0 0 0 2px var(--err); }
.cella-evidenziata .scoperto { animation: pulse 1.6s ease-in-out 2; }
@keyframes pulse { 50% { background: var(--err); color: var(--surface); } }

.chip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px 5px;
  padding: 3px 8px; border-radius: var(--radius-sm); font-size: .88rem; line-height: 1.25;
  border: 1px solid; border-left-width: 4px; overflow-wrap: anywhere;
}
.legenda .chip { display: inline-flex; }
.chip-volontario { background: var(--vol-bg); border-color: var(--vol-border); color: var(--vol-text); }
.chip-manuale { background: var(--man-bg); border-color: var(--man-border); color: var(--man-text); }
.chip-generato { background: var(--gen-bg); border-color: var(--gen-border); color: var(--gen-text); }
/* sostituzione dopo la generazione: ore extra, arancione acceso */
.chip-sostituzione { background: #ffe2b8; border-color: #e07800; color: #6b3500; }
.ore-extra { color: #a14d00; font-weight: 700; white-space: nowrap; }
.riep-extra {
  display: inline-block; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  background: #ffe2b8; color: #6b3500; border: 1px solid #e07800; border-radius: 999px; padding: 0 .5rem;
}
.riep-ore-extra { display: block; font-size: .85rem; }
.chip-sostituzione .chip-tag { opacity: 1; font-weight: 800; color: #a14d00; }
.chip-nome { font-weight: 650; }
.chip-seg { font-size: .76rem; font-variant-numeric: tabular-nums; opacity: .9; }
.chip-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; opacity: .85; }
.chip-alert {
  margin-left: auto; display: inline-grid; place-items: center; width: 17px; height: 17px;
  border-radius: 50%; font-size: .72rem; font-weight: 800;
}
.chip-viol-errore { outline: 2px solid var(--err); outline-offset: -1px; }
.chip-viol-errore .chip-alert { background: var(--err); color: var(--surface); }
.chip-viol-avviso .chip-alert { background: var(--warn-border); color: #000; }

.scoperto {
  display: inline-block; align-self: flex-start;
  padding: 2px 8px; border-radius: var(--radius-sm); font-size: .82rem; font-weight: 700;
  color: var(--err); background: var(--err-bg); border: 1px dashed var(--err);
}
.scoperto-text { color: var(--err); font-weight: 600; margin: .3rem 0; }

/* ---------- Assistenze ed Extra: in ogni giorno le richieste, ognuna con i suoi posti ---------- */

.cella-extra { padding: 6px; }
.extra-scheda {
  border: 1px solid var(--border); border-left: 4px solid var(--giorno); border-radius: var(--radius-sm);
  background: var(--surface); margin-bottom: 6px; overflow: hidden;
}
.extra-scheda.fascia-notte { border-left-color: var(--notte); }
.extra-testa { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding: 4px 6px; background: var(--surface-2); }
.extra-nome { font-weight: 750; overflow-wrap: anywhere; }
.extra-orario { font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 650; }
.extra-modifica { margin-left: auto; min-height: 26px; padding: 0 .5rem; font-size: .8rem; }
.extra-posto { border-top: 1px solid var(--border); }
.extra-posto > .ruolo-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 3px 6px 0; }
.extra-posto .cella { height: auto; }  /* fuori dalla tabella: niente altezza minima della griglia */
.extra-posto .cella-btn { min-height: 36px; }
.extra-aggiungi { width: 100%; justify-content: center; }

@media print {
  .no-print { display: none !important; }
  .scoperto { animation: none !important; }
  /* senza richieste il tabellone non si stampa */
  .griglia-extra.griglia-vuota { display: none !important; }
  #view-settimana .griglia-extra .cella-extra { background: #fff !important; }
  #view-settimana .griglia-extra .extra-scheda { border-color: #555; break-inside: avoid; }
  #view-settimana .griglia-extra .extra-scheda.fascia-giorno .extra-testa { background: #ffe9a8; }
  #view-settimana .griglia-extra .extra-scheda.fascia-notte .extra-testa { background: #d3dbf7; }
  #view-settimana .griglia-extra .extra-nome { font-size: 12pt; color: #000; }
  #view-settimana .griglia-extra .extra-orario { font-size: 11pt; color: #000; }
  #view-settimana .griglia-extra .extra-posto > .ruolo-label { font-size: 9pt; color: #000; }
  #view-settimana .griglia-extra .extra-posto .cella { height: auto; }
  #view-settimana .griglia-extra .extra-posto .cella-btn { min-height: 0; }
  #view-settimana .griglia-extra .chip { font-size: 12pt; }
}

/* ---------- Pannelli (violazioni, riepilogo) ---------- */

.pannelli {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem; margin-top: 1.75rem; align-items: start;
}
@media (min-width: 1150px) {
  .pannelli { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); }
}
.pannello .tabella tbody th { white-space: nowrap; }
.pannello, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.card { margin-bottom: 1rem; max-width: 900px; }
.card-title { margin-bottom: .75rem; }
.card.info ul { margin: 0; padding-left: 1.2rem; }
.card.info li { margin: .25rem 0; }
.pannello h2 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.conteggi { display: inline-flex; gap: .35rem; margin-left: auto; font-size: .85rem; font-weight: 400; }
.ok-text { color: var(--ok); font-weight: 600; margin: 0; }

.violazioni { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; max-height: 480px; overflow-y: auto; }
.viol {
  display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .65rem; border-radius: var(--radius-sm);
  border-left: 4px solid;
}
.viol-errore { background: var(--err-bg); border-color: var(--err); }
.viol-avviso { background: var(--warn-bg); border-color: var(--warn-border); }
.viol-livello { font-weight: 700; font-size: .78rem; text-transform: uppercase; min-width: 4.2rem; padding-top: .1rem; }
.viol-errore .viol-livello { color: var(--err); }
.viol-avviso .viol-livello { color: var(--warn); }
.viol-meta { display: block; font-size: .84rem; color: var(--muted); }

/* ---------- Tabelle ---------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }  /* tiene dentro i testi sr-only */
.tabella { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tabella th, .tabella td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; }
.tabella thead th {
  background: var(--surface-2); font-size: .8rem; white-space: nowrap; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.tabella tbody th { font-weight: 650; }
.tabella .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabella tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tabella .azioni { text-align: right; white-space: nowrap; }
.tabella .azioni .btn + .btn { margin-left: .3rem; }
.fuori-media { background: var(--warn-bg); }
.scarto-alto { color: var(--err); font-weight: 700; }
tr.inattivo th, tr.inattivo td:not(.azioni) { color: var(--muted); }
tr.inattivo th { text-decoration: line-through; }
tr.festa-spenta th, tr.festa-spenta td:not(.azioni) { color: var(--muted); }
tr.in-modifica { background: var(--info-bg); }
tr.in-modifica input[type="text"] { width: 100%; min-width: 10rem; }

.tabella-persone, .tabella-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  border-collapse: separate; border-spacing: 0; overflow: hidden;
}
.tabella-persone tbody tr:last-child > *, .tabella-stat tbody tr:last-child > * { border-bottom: 0; }

.sort-btn {
  font: inherit; font-weight: 700; color: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; white-space: nowrap; text-transform: inherit; letter-spacing: inherit; min-height: 24px;
}
.sort-ind { color: var(--muted); font-weight: 400; }
th[aria-sort="ascending"] .sort-ind, th[aria-sort="descending"] .sort-ind { color: var(--primary); }

.saldo-pos { color: var(--warn); font-weight: 600; }
.saldo-neg { color: var(--primary); font-weight: 600; }

.cella-rapporto { min-width: 9rem; }
.rapporto-testo { display: block; }
.ore-dettaglio { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.festivi-voci { list-style: none; margin: 0; padding: 0; }
.festivi-voce { display: block; font-size: .78rem; color: var(--muted); }
.rapporto-bar {
  display: block; height: 6px; margin-top: 3px; border-radius: 3px; overflow: hidden;
  background: #39456b; /* notte */
}
.rapporto-giorno { display: block; height: 100%; background: #f0b323; /* giorno */ }

/* ---------- Form ---------- */

.campi { display: flex; flex-wrap: wrap; gap: .85rem 1rem; align-items: flex-end; }
.campo { display: flex; flex-direction: column; gap: .3rem; min-width: 10rem; }
.campo label { font-weight: 650; font-size: .9rem; }
.campo-largo { flex: 1 1 16rem; }
.campo-largo input { width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }
.filtri { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: 1.25rem 0 .75rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; margin-left: .5rem; cursor: pointer; }

/* ---------- Dialog ---------- */

.dialog {
  width: min(560px, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem);
  padding: 1.2rem 1.35rem; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.dialog::backdrop { background: rgba(10, 14, 20, .55); }
.dialog-head { position: relative; padding-right: 2.25rem; margin-bottom: .5rem; }
.dialog-head p { margin: .2rem 0 0; }
.dialog-title { font-size: 1.2rem; }
.dialog-text { margin: .75rem 0 0; }
.dialog-x {
  position: absolute; right: -.35rem; top: -.35rem; width: 40px; height: 40px;
  font-size: 1.5rem; line-height: 1; border: 0; background: none; color: var(--text);
  border-radius: 8px; cursor: pointer;
}
.dialog-x:hover { background: var(--surface-2); }
.dialog-section { border-top: 1px solid var(--border); padding-top: .85rem; margin-top: .85rem; }
.dialog-section h3 { margin-bottom: .5rem; }
.dialog-section .campo { flex: 1 1 12rem; }
.dialog-section select { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }
.lista-assegnati { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.lista-assegnati li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.lista-assegnati .btn { margin-left: auto; }

/* ---------- Email dei turni e accesso ---------- */
.dialog-email { width: min(640px, calc(100vw - 1.5rem)); }
.lista-email { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; max-height: 320px; overflow-y: auto; }
.lista-email li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.email-indirizzo { font-size: .9rem; overflow-wrap: anywhere; }
.lista-email .badge { margin-left: auto; }
.email-errore { flex: 1 1 100%; color: var(--err); font-size: .88rem; }
.cella-email { font-size: .9rem; overflow-wrap: anywhere; max-width: 16rem; }
.esci { margin-left: .5rem; align-self: center; }
body.senza-accesso .nav, body.senza-accesso .esci { display: none; }
.accesso {
  max-width: 380px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: .6rem; text-align: left;
}
.accesso h1 { font-size: 1.4rem; }
.accesso-logo { height: 64px; width: auto; align-self: flex-start; margin-bottom: .25rem; }
.accesso label { font-weight: 650; }
.accesso-errore { color: var(--err); font-weight: 650; margin: 0; min-height: 1.4em; }

.card-larga { max-width: 1200px; }
.tabella-riepiloghi .col-spunta { text-align: center; white-space: nowrap; width: 5.5rem; }
.tabella-riepiloghi thead th.col-spunta { text-transform: none; letter-spacing: 0; font-size: .78rem; }
.tabella-riepiloghi input[type="checkbox"] { width: 1.2rem; height: 1.2rem; }
.tabella-riepiloghi input[type="email"] { min-width: 14rem; }
.tabella-riepiloghi input[type="text"] { min-width: 8rem; }
.riepiloghi-nuovo, .riepiloghi-invio { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: .9rem; }
.riepiloghi-nuovo h3, .riepiloghi-invio h3 { margin-bottom: .5rem; }
.riepiloghi-spunte { border: 0; padding: 0; margin: .8rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; }
.riepiloghi-spunte legend { font-weight: 650; font-size: .9rem; margin-bottom: .3rem; padding: 0; }
.riepiloghi-spunte .check { margin-left: 0; }

/* ---------- Overlay / spinner ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(10, 14, 20, .5);
}
.overlay-box {
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: 1.6rem 2.2rem; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  font-weight: 650; text-align: center;
}
.overlay-sub { font-weight: 400; font-size: .88rem; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
  .cella-evidenziata .scoperto { animation: none; }
}

/* ---------- Toast ---------- */

.toast-area {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem));
}
.toast {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .75rem .85rem .75rem 1rem; border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-left: 5px solid var(--primary); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.toast-ok { border-left-color: var(--ok); }
.toast-avviso { border-left-color: var(--warn-border); }
.toast-errore { border-left-color: var(--err); background: var(--err-bg); }
.toast-msg { flex: 1; }
.toast-close {
  border: 0; background: none; color: inherit; font-size: 1.2rem; line-height: 1;
  cursor: pointer; padding: 0 .2rem; border-radius: 4px; min-width: 32px; min-height: 32px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .passi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .passo:nth-child(2) { border-right: 0; }
  .passo:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .nav a { padding: 0 .6rem; }
  .nav-testo-lungo { display: none; }
  .nav-testo-breve { display: inline; }
}

/* telefono: menu in basso, a portata di pollice */
@media (max-width: 640px) {
  html { scroll-padding-bottom: 84px; }
  body { font-size: 15px; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  h1, .week-title h1 { font-size: 1.35rem; }
  .app-header { min-height: 52px; }
  .brand-logo { height: 40px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav a {
    flex-direction: column; justify-content: center; gap: 2px; min-height: 60px; padding: .3rem .1rem;
    font-size: .75rem; text-align: center; min-width: 0; border-bottom: 0; border-top: 3px solid transparent; margin: 0;
  }
  .nav a[aria-current="page"] { border-top-color: var(--accent); }
  .nav-icona { width: 22px; height: 22px; }
  .nav a > span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toast-area { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .week-nav { width: 100%; }
  .week-nav input[type="date"] { flex: 1 1 8rem; }
  .passo { padding: .6rem; }
  .passo-sotto { display: none; }
  .toolbar .btn-grande { flex: 1 1 auto; }
  .toolbar-spacer { display: none; }
  .altre-opzioni-menu { left: auto; right: 0; }
  .griglia .col-turno { width: 104px; }
  .chip { font-size: .8rem; overflow-wrap: break-word; }
  .tabella-stat tbody th { white-space: nowrap; }
  .tabella .azioni { white-space: normal; }
  .tabella .azioni .btn { margin: .15rem 0 .15rem .3rem; }

  /* Personale: ogni persona è una scheda, con i comandi sotto */
  .tabella-persone thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tabella-persone, .tabella-persone tbody { display: block; }
  .tabella-persone tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem;
    padding: .7rem .8rem; border-bottom: 1px solid var(--border);
  }
  .tabella-persone tr > * { border: 0; padding: 0; }
  .tabella-persone tbody th { flex: 1 1 100%; font-size: 1.05rem; }
  .tabella-persone td.azioni { flex: 1 1 100%; text-align: left; margin-top: .35rem; }
  .tabella-persone tr:not(.in-modifica) td:nth-child(4) { display: none; }  /* "Autista programmati": senza intestazione non si capisce */
  .tabella-persone td.azioni .btn { margin: 0 .35rem 0 0; }
}

/* telefono in orizzontale o zoom forte: menu e testata non fissi, per lasciare spazio al contenuto */
@media (max-width: 360px) {
  .nav a { font-size: .66rem; letter-spacing: -.01em; }
}

@media (max-width: 640px) and (max-height: 500px) {
  .app-header { position: static; }
  .nav { position: static; display: flex; }
  body { padding-bottom: 0; }
  .toast-area { bottom: 1rem; }
}

/* ---------- Stampa ---------- */

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  /* stampa a colori, sempre con la tavolozza chiara (anche se lo schermo è in tema scuro) */
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #eef1f5; --text: #000; --muted: #3d4450;
    --border: #9aa3af; --border-strong: #333; --weekend: #fff1d1;
    --festivo: #fbd3db; --festivo-testo: #7a0f2b;
    --accent: #009541; --accent-text: #fff;
    --vol-bg: #d4f0dc;  --vol-border: #2f8a4a;  --vol-text: #0f4d22;
    --man-bg: #d6e3fb;  --man-border: #2f5fc4;  --man-text: #12347d;
    --gen-bg: #eceff3;  --gen-border: #6b7686;  --gen-text: #1d232c;
    --err: #b3121f;  --err-bg: #fde3e6;
    --warn: #7a4a00; --warn-bg: #ffeec2; --warn-border: #d99000;
    --ok: #1d6b35;   --ok-bg: #dcf2e3;
    --info-bg: #e1eafb;
    /* fasce: giorno giallo, notte blu */
    --stampa-giorno: #fff3c4; --stampa-giorno-bordo: #d99000;
    --stampa-notte: #dfe4fa;  --stampa-notte-bordo: #3949ab; --stampa-notte-cella: #f3f5fd;
    color-scheme: light;
  }
  body { font-size: 10pt; background: #fff; }
  .app-header, .skip-link, .toolbar, .week-nav, .passi, .pannelli, .turni-da-coprire, .report, .banner, .disponibilita, .richieste,
  .toast-area, .overlay, dialog, #view-personale, #view-impostazioni { display: none !important; }
  main { padding: 0; max-width: none; }
  .week-header { margin-bottom: 4mm; }
  .griglie { gap: 5mm; }
  .griglia-blocco { break-inside: avoid; page-break-inside: avoid; }
  .griglia-scroll { overflow: visible; box-shadow: none; border: 0; }
  .griglia { min-width: 0; font-size: 8.5pt; }
  .griglia .col-turno { position: static; width: 26mm; }
  .cella-btn { min-height: 0; padding: 1mm; }
  .chip { border-width: 1px 1px 1px 3px; padding: 0 2px; font-size: 8pt; }
  .chip-manuale .chip-nome { text-decoration: underline; }
  .chip-alert { display: none; }
  .scoperto { border: 1px dashed var(--err); font-size: 7.5pt; }
  .legenda { margin: 0 0 3mm; font-size: 8pt; }
  /* righe di giorno e di notte riconoscibili a colpo d'occhio */
  .griglia tr.fascia-giorno .col-turno { background: var(--stampa-giorno); border-left: 3px solid var(--stampa-giorno-bordo); }
  .griglia tr.fascia-notte .col-turno { background: var(--stampa-notte); border-left: 3px solid var(--stampa-notte-bordo); }
  .griglia tr.fascia-notte td:not(.weekend):not(.cella-non-richiesta) { background: var(--stampa-notte-cella); }
  .griglia .fascia-label { color: var(--text); }
  .griglia-titolo { border-left-color: var(--accent); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none !important; }
}

/* Gruppo violazioni "scoperto" */
.viol-gruppo { display: block; margin-bottom: .4rem; }
.viol-gruppo summary { display: flex; gap: .6rem; cursor: pointer; list-style-position: outside; }
.viol-gruppo summary::-webkit-details-marker { display: none; }
.viol-gruppo summary::after { content: "▾"; content: "▾" / ""; margin-left: auto; color: var(--muted); }
.viol-gruppo[open] summary::after { content: "▴"; content: "▴" / ""; }
.viol-sotto { margin: .4rem 0 0; padding-left: 1.2rem; max-height: 220px; overflow-y: auto; font-size: .85rem; }

/* ---------- Turni da coprire (assenti con turni già assegnati) e sostituti suggeriti ---------- */
.banner-avviso { background: var(--warn-bg); border-color: var(--warn-border); border-left-width: 5px; }
.banner-avviso .btn { margin-left: .25rem; }
.turni-da-coprire { margin-top: 1.75rem; border-left: 5px solid var(--warn-border); }
.turni-da-coprire + .pannelli { margin-top: 1.25rem; }
.coprire-intro { margin: -.25rem 0 .75rem; }
.coprire-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.coprire-voce {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .85rem;
}
.coprire-turno { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; margin-bottom: .5rem; }
.coprire-assente { display: inline-flex; align-items: center; gap: .35rem; }
.sostituti-attesa, .sostituti-nessuno, .sostituti-errore { margin: 0; }
.sostituti-nessuno { color: var(--warn); font-weight: 600; }
.sostituti-errore { color: var(--err); }
.candidati { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.candidato {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: .4rem .6rem;
}
.candidato-con-avvisi { border-left-color: #e07800; background: #fff1dc; }
.candidato-con-avvisi .badge-avviso { background: #ffd79a; color: #6b3500; border-color: #e07800; }
.coprire-nota-extra {
  margin: 0 0 .75rem; padding: .35rem .6rem; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600;
  background: #ffe2b8; color: #6b3500; border-left: 4px solid #e07800;
}
.candidato-dati { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .6rem; min-width: 0; }
.candidato-nome { font-weight: 700; }
.candidato-qualifica { font-size: .85rem; }
.candidato-ore { font-size: .9rem; }
.candidato-avvisi { flex-basis: 100%; font-size: .84rem; color: #8a4200; font-weight: 600; }
.candidato-note { flex-basis: 100%; font-size: .84rem; }
.candidato-assegna { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.candidato-assegna:hover:not(:disabled) { background: #007a35; border-color: #007a35; }
.candidati-altri { margin-top: .4rem; }
.candidati-altri > summary { cursor: pointer; font-size: .9rem; color: var(--primary); font-weight: 600; margin-bottom: .35rem; }
.lista-assegnati .sostituti-dialog { flex-basis: 100%; margin-top: .35rem; }
.lista-assegnati li > .btn + .btn { margin-left: 0; }
.sostituti-dialog > .hint { margin: 0 0 .35rem; }
.avviso-turni-ferie p { margin: 0 0 .5rem; }
.avviso-turni-settimane { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .5rem; }
.avviso-turni-elenco { margin: .3rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.btn-primary:visited { color: var(--primary-text); }
a.btn { text-decoration: none; }

/* ---------- Disponibilità e ferie ---------- */
.disponibilita { margin-bottom: 1rem; }
.disponibilita > summary, .richieste > summary { list-style: none; }
.disponibilita > summary::-webkit-details-marker, .richieste > summary::-webkit-details-marker { display: none; }
.disponibilita > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem; }
/* freccia che dice "si apre" e il comando esplicito a destra */
.disponibilita > summary::before, .richieste > summary::before {
  content: "▸"; content: "▸" / ""; color: var(--muted); font-size: 1.1rem; transition: transform .15s; display: inline-block;
}
.disponibilita[open] > summary::before, .richieste[open] > summary::before { transform: rotate(90deg); }
.disponibilita > summary::after, .richieste > summary::after {
  content: "Apri"; content: "Apri" / ""; margin-left: auto; color: var(--primary); font-weight: 650; font-size: .92rem;
}
.disponibilita[open] > summary::after, .richieste[open] > summary::after { content: "Chiudi"; content: "Chiudi" / ""; }
@media (prefers-reduced-motion: reduce) {
  .disponibilita > summary::before, .richieste > summary::before { transition: none; }
}
.disponibilita-titolo { display: inline; margin: 0; }
.tabella-disponibilita .disp-cella { text-align: center; }
.tabella-disponibilita .weekend { background: var(--weekend); }
.tabella-disponibilita input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
/* giorno con un'indisponibilità: la casella si vede subito */
.tabella-disponibilita td.disp-indisponibile, .tabella-disponibilita td.disp-indisponibile.weekend {
  background: var(--warn-bg); box-shadow: inset 0 0 0 2px var(--warn-border);
}
.tabella-disponibilita td.disp-indisponibile select { font-weight: 700; border-color: var(--warn-border); }
.badge-ferie { background: var(--info-bg); color: var(--man-text); border-color: var(--man-border); }
.badge-malattia { background: #f1dcec; color: #6e1d5a; border-color: #a3407f; }
.riepilogo-assenze { font-weight: normal; font-size: .85em; }
.ferie-passate > summary { cursor: pointer; margin: .75rem 0 .5rem; }

/* ---------- Turni di un dipendente ---------- */
.tabella-turni-persona tr.weekend { background: var(--weekend); }
.turni-persona { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.tabella-turni-persona .badge-errore { margin-left: .5rem; }
.totali-persona { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
.totali-persona dt { color: var(--muted); }
.totali-persona dd { margin: 0; font-weight: 600; }

/* ---------- Postazioni a richiesta: Standby e Programmati ---------- */
.richieste { margin-bottom: 1rem; }
.richieste > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem; }
.richieste-titolo { display: inline; margin: 0; }
.richieste-blocco { margin-top: .9rem; }
.richieste-blocco h3 { margin-bottom: .4rem; }
.richieste-blocco h3 .muted { font-weight: 400; }
.tabella-richieste .disp-cella { text-align: center; }
.tabella-richieste .weekend { background: var(--weekend); }
.tabella-richieste tbody th { white-space: nowrap; }
.tabella-richieste tbody th .fascia-label { display: inline; }
.tabella-richieste tbody th .ruolo-label { display: inline; }
.tabella-richieste tr.inizio-fascia > * { border-top: 2px solid var(--border-strong); }
.tabella-richieste input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
.input-quantita { width: 4.2rem; text-align: right; font-variant-numeric: tabular-nums; }
.input-quantita:disabled, .tabella-richieste input:disabled { opacity: .6; cursor: not-allowed; }

.griglia-sottotitolo { font-size: .82rem; font-weight: 400; }
.griglia-speciale .griglia-titolo { border-left-color: var(--man-border); }
.cella-non-richiesta {
  vertical-align: middle !important; text-align: center;
  background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--border) 35%, transparent) 6px 7px);
}
.cella-non-richiesta.weekend { background-color: var(--weekend); }
.non-richiesto { color: var(--muted); }
.eccesso {
  display: inline-block; align-self: flex-start;
  padding: 1px 6px; border-radius: 5px; font-size: .78rem; font-weight: 700;
  color: var(--warn); background: var(--warn-bg); border: 1px dashed var(--warn-border);
}
.eccesso-text { color: var(--warn); font-weight: 600; margin: .3rem 0; }
.badge-programmati { background: var(--vol-bg); color: var(--vol-text); border-color: var(--vol-border); }
.campo-check { min-width: 0; justify-content: flex-end; min-height: 36px; }
.campo-check .check { margin-left: 0; font-weight: 500; }

@media print {
  .eccesso { font-size: 7.5pt; }
  .griglia-sottotitolo { display: none; }
  .cella-non-richiesta, .cella-non-richiesta.weekend { background: #f6f7f9; }
}

/* ---------- Tempo massimo di generazione ---------- */
.tempo-generazione { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .9rem; }
.tempo-generazione input { width: 4.5rem; }

/* ---------- Dipendenti liberi ---------- */
.giorno-btn {
  font: inherit; color: inherit; background: none; border: 0; padding: .1rem .3rem; margin: -.1rem -.3rem;
  border-radius: 5px; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.giorno-btn:hover { background: var(--surface); }
.giorno-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.lista-liberi { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.lista-liberi li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.libero-nome { font-weight: 600; }
.stampa-liberi { display: none; }

/* ---------- Turni di un dipendente: tabella orizzontale solo in stampa ---------- */
.turni-orizzontali { display: none; }

@media print {
  .stampa-liberi { display: none !important; }
  .giorno-btn { text-decoration: none; padding: 0; margin: 0; }

  /* "Stampa liberi": solo intestazione della settimana e riepilogo dei liberi */
  body.stampa-liberi-attiva .griglie, body.stampa-liberi-attiva .week-postazioni,
  body.stampa-liberi-attiva .legenda { display: none !important; }
  body.stampa-liberi-attiva .stampa-liberi { display: block !important; }
  .stampa-liberi h2 { font-size: 12pt; margin: 0 0 3mm; }
  .tabella-liberi { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 8.5pt; }
  .tabella-liberi th, .tabella-liberi td { border: 1px solid #777; padding: 1.2mm; vertical-align: top; text-align: left; }
  .tabella-liberi tbody th { width: 20mm; }
  .tabella-liberi thead th { background: var(--surface-2); }
  .tabella-liberi .weekend { background: var(--weekend); }
  .tabella-liberi .riga-liberi th { background: var(--ok-bg); color: var(--ok); }
  .tabella-liberi .riga-indisponibili th { background: var(--warn-bg); color: var(--warn); }
  .tabella-liberi .riga-ferie th { background: var(--info-bg); color: var(--man-text); }
  .tabella-liberi .riga-indisponibili td, .tabella-liberi .riga-ferie td { color: var(--muted); }
  .tabella-liberi .lista-liberi { gap: 1mm; }
  .tabella-liberi .lista-liberi li { gap: 1mm; }
  .tabella-liberi .badge { font-size: 7pt; padding: 0 1mm; }
  .nota-stampa { font-size: 8pt; margin-top: 2mm; }

  /* "Turni dipendente": tabella orizzontale, senza ore né totali */
  #view-dipendente .pannello { display: none !important; }
  #view-dipendente .turni-orizzontali { display: block !important; }
  .tabella-turni-orizzontale { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 9pt; }
  .tabella-turni-orizzontale th, .tabella-turni-orizzontale td { border: 1px solid #777; padding: 1.5mm; vertical-align: top; text-align: left; }
  .tabella-turni-orizzontale thead th { background: var(--surface-2); }
  .tabella-turni-orizzontale .weekend { background: var(--weekend); }
  .tabella-turni-orizzontale .turni-persona { gap: 1mm; }
  .tabella-turni-orizzontale .chip { white-space: normal; color: var(--text); }
  .tabella-turni-orizzontale .turno-giorno .chip { background: var(--stampa-giorno); border-color: var(--stampa-giorno-bordo); }
  .tabella-turni-orizzontale .turno-notte .chip { background: var(--stampa-notte); border-color: var(--stampa-notte-bordo); }
}

/* ---------- Statistiche: schede e indisponibilità per giorno ---------- */
.schede { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.scheda {
  padding: .5rem .9rem; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0;
  color: var(--muted); text-decoration: none; font-weight: 600; margin-bottom: -1px;
}
.scheda:hover { color: var(--text); background: var(--surface-2); }
.scheda[aria-current="page"] { color: var(--text); background: var(--surface); border-color: var(--border); }
.periodo-indisp label { font-weight: 600; }
.tabella-indisp-stat td.indisp-cella { text-align: center; vertical-align: middle; min-width: 3.4rem; }
.tabella-indisp-stat th.weekend, .tabella-indisp-stat td.weekend.indisp-liv-0 { background: var(--weekend); }
.indisp-num { display: block; font-weight: 700; font-size: 1.05rem; }
.indisp-parti { display: block; font-size: .72rem; color: inherit; opacity: .85; white-space: nowrap; }
.indisp-liv-0 { color: var(--muted); }
.indisp-liv-1 { background: color-mix(in srgb, var(--warn-border) 15%, var(--surface)); }
.indisp-liv-2 { background: color-mix(in srgb, var(--warn-border) 30%, var(--surface)); }
.indisp-liv-3 { background: color-mix(in srgb, var(--err) 35%, var(--surface)); }
.indisp-liv-4 { background: color-mix(in srgb, var(--err) 55%, var(--surface)); color: var(--text); }
.indisp-totale { font-weight: 700; }
.view-header-riga { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.avviso-notte { background: color-mix(in srgb, #3949ab 14%, var(--surface)); color: var(--text); border-color: #5c6bc0; }
.solo-stampa { display: none; }
/* Statistiche → Festività: ordine di rotazione delle prossime festività e storico per anno */
.festivita-prossima, .festivita-storico { margin-top: 1.5rem; }
.festivita-storico h2 { margin-bottom: .2rem; }
.festivita-prossima {
  min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.festivita-prossima > summary, .festivita-fascia > summary {
  min-height: var(--tap); display: flex; align-items: center; gap: .65rem;
  padding: .8rem 1rem; cursor: pointer; list-style: none; border-radius: inherit;
}
.festivita-prossima > summary::-webkit-details-marker,
.festivita-fascia > summary::-webkit-details-marker { display: none; }
.festivita-prossima > summary::before, .festivita-fascia > summary::before {
  content: "▸"; content: "▸" / ""; flex: 0 0 .75rem; color: var(--muted);
}
.festivita-prossima[open] > summary::before, .festivita-fascia[open] > summary::before {
  content: "▾"; content: "▾" / "";
}
.festivita-prossima > summary:hover { background: var(--surface-2); }
.festivita-prossima > summary:focus-visible, .festivita-fascia > summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: -3px;
}
.festivita-prossima > summary h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.festivita-contenuto { min-width: 0; padding: 0 1rem 1rem; }
.festivita-contenuto > p { margin: .35rem 0 .85rem; }
.festivita-fasce { display: grid; gap: .65rem; min-width: 0; }
.festivita-fascia { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.festivita-fascia-giorno > summary { background: #fff3c4; color: var(--text); }
.festivita-fascia-notte > summary { background: #dfeafa; color: var(--text); }
.festivita-fascia-contenuto { min-width: 0; padding: .6rem; }
.festivita-fascia-contenuto > p { margin: .3rem 0; }
.festivita-fascia .table-scroll { max-width: 100%; }
.festivita-azioni { margin-top: .85rem; }
.festivita-azioni-tutte { margin: .25rem 0 .5rem; }
.tabella-ordine-festivita select { min-width: 9rem; }
@media (max-width: 640px) {
  .festivita-prossima > summary, .festivita-fascia > summary { padding: .75rem; }
  .festivita-contenuto { padding: 0 .65rem .75rem; }
  .festivita-fascia-contenuto { padding: .35rem; }
}
@media print {
  .festivita-prossima { break-inside: avoid; }
  .festivita-storico { break-before: page; }
  .tabella-ordine-festivita, .tabella-festivi-anno { font-size: 9pt; }
  body.stampa-festivita .view:not(#view-statistiche),
  body.stampa-festivita #view-statistiche > :not(.festivita-da-stampare) { display: none !important; }
  body.stampa-festivita .festivita-da-stampare {
    display: block !important; margin: 0; border: 0; break-inside: auto;
  }
  body.stampa-tutte-festivita .festivita-da-stampare + .festivita-da-stampare {
    break-before: page; page-break-before: always;
  }
  body.stampa-festivita .festivita-da-stampare > summary {
    display: block; padding: 0 0 3mm;
  }
  body.stampa-festivita .festivita-da-stampare > summary h2 { font-size: 13pt; }
  body.stampa-festivita .festivita-da-stampare summary::before { display: none; }
  body.stampa-festivita .festivita-contenuto { padding: 0; }
  body.stampa-festivita .festivita-fasce { display: block; }
  body.stampa-festivita .festivita-fascia { margin: 0 0 3mm; break-inside: auto; }
  body.stampa-festivita .festivita-fascia > summary { display: block; padding: 2mm; }
  body.stampa-festivita .festivita-fascia-contenuto { padding: 0; }
  body.stampa-festivita .tabella-ordine-festivita { width: 100%; font-size: 8pt; }
  body.stampa-festivita .tabella-ordine-festivita th,
  body.stampa-festivita .tabella-ordine-festivita td { padding: 1.1mm 1.5mm; }
  body.stampa-festivita .tabella-ordine-festivita tr { break-inside: avoid; }
  .tabella-ordine-festivita .col-voglia,
  .tabella-ordine-festivita .col-assenze { display: none !important; }
}

@media print {
  .solo-stampa { display: block; }
  .periodo-indisp { display: none !important; }
  /* Statistiche: senza schede né comandi, colori delle celle mantenuti */
  #view-statistiche .schede, #view-statistiche .btn, #view-statistiche .filtri,
  #view-statistiche .hint, .sort-ind { display: none !important; }
  .tabella-stat, .tabella-indisp-stat { font-size: 8.5pt; }
  .tabella-stat thead th, .tabella-indisp-stat thead th { background: var(--surface-2); }
  .tabella-indisp-stat th.weekend, .tabella-indisp-stat td.weekend.indisp-liv-0 { background: var(--weekend); }
  .table-scroll { overflow: visible; }
  .sort-btn { font-weight: 700; }
}

/* ---------- Stampa dei turni settimanali: essenziale e leggibile ---------- */
@media print {
  /* solo la data in alto: niente settimana A/B, stato, postazioni, legenda */
  #view-settimana .week-tipo, #view-settimana .badge-stato, #view-settimana .week-postazioni, #view-settimana .legenda { display: none !important; }
  #view-settimana .week-header h1 { font-size: 16pt; }
  #view-settimana .week-range { color: #000; font-weight: 700; font-size: inherit; }
  /* una tabella (postazione) per pagina */
  #view-settimana .griglia-blocco + .griglia-blocco { break-before: page; page-break-before: always; }

  /* colori tenui che separano: giorno giallo, notte azzurro, weekend solo in intestazione; volontari scritti in verde, scoperti rossi */
  #view-settimana .griglia thead th { background: #aac6f2 !important; }
  #view-settimana .griglia thead th.weekend { background: #c79cc2 !important; }
  #view-settimana .griglia tr.fascia-giorno .col-turno { background: #ffe9a8 !important; border-left: 4px solid #d99a00; }
  #view-settimana .griglia tr.fascia-notte .col-turno { background: #d3dbf7 !important; border-left: 4px solid #3f4ba8; }
  #view-settimana .griglia tr.fascia-giorno td { background: #fff8de !important; }
  #view-settimana .griglia tr.fascia-notte td { background: #eef1fc !important; }
  #view-settimana .griglia tr.fascia-giorno td.weekend { background: #fff8de !important; }
  #view-settimana .griglia tr.fascia-notte td.weekend { background: #eef1fc !important; }
  #view-settimana .cella-non-richiesta, #view-settimana .cella-non-richiesta.weekend { background: #f3f3f3 !important; }
  #view-settimana .griglia th, #view-settimana .griglia td { border-color: #555; }
  #view-settimana .griglia-titolo { border-left: 0; padding-left: 0; }
  #view-settimana .chip-generato, #view-settimana .chip-manuale, #view-settimana .chip-sostituzione { background: none; border: 0; color: #000; }
  #view-settimana .chip-manuale .chip-nome { text-decoration: none; }
  #view-settimana .chip-tag { display: none; }
  #view-settimana .chip-viol-errore { outline: 0; }
  #view-settimana .eccesso { color: #000; background: none; border-color: #000; }
  #view-settimana .cella-evidenziata { box-shadow: none; }

  /* scritte grandi: nomi al centro e in grassetto, postazione e turno ben visibili */
  #view-settimana .griglia-titolo { font-size: 18pt; font-weight: 800; margin-bottom: 2mm; }
  #view-settimana .griglia thead th { font-size: 11pt; color: #000; }
  #view-settimana .giorno-data { color: #000; }
  /* colonna del turno a filo del testo (diversa per ogni tabella), giorni tutti larghi uguali */
  #view-settimana .griglia { table-layout: auto; }
  #view-settimana .griglia .col-turno { width: 1%; white-space: nowrap; padding: 1mm 2mm; vertical-align: middle; text-align: center; }
  #view-settimana .griglia thead th:not(.col-turno) { width: 14%; }
  #view-settimana .fascia-icona { display: inline; font-size: 13pt; margin-right: 1mm; }
  #view-settimana .fascia-giorno .fascia-icona { color: #b07400 !important; }
  #view-settimana .fascia-notte .fascia-icona { color: #3f4ba8 !important; }
  #view-settimana .griglia .fascia-label { justify-content: center; white-space: nowrap; font-size: 10.5pt; font-weight: 800; color: #000; letter-spacing: 0; }
  #view-settimana .griglia .ruolo-label { font-size: 13pt; font-weight: 800; overflow-wrap: normal; margin-top: .5mm; }
  #view-settimana .griglia .cella { vertical-align: middle; height: 22mm; }  /* nelle tabelle height fa da altezza minima */
  #view-settimana .cella-btn { min-height: 22mm; align-items: center; justify-content: center; text-align: center; gap: 1mm; }
  #view-settimana .chip { align-items: baseline; justify-content: center; text-align: center; font-size: 14pt; padding: .5mm 1mm; border-radius: 3px; }
  #view-settimana .chip-volontario { border: 0; background: none; color: #007a35; }
  #view-settimana .chip-nome { font-weight: 800; }
  #view-settimana .chip-seg { font-size: 10.5pt; opacity: 1; }
  #view-settimana .scoperto { align-self: center; font-size: 10pt; border-width: 1.5px; }
  #view-settimana .eccesso { align-self: center; font-size: 9pt; }
  #view-settimana .griglia-titolo::before { display: inline-block; width: 4mm; height: 4mm; background: #009541; }
  /* stacco netto tra i turni di giorno e quelli di notte */
  #view-settimana .griglia tr.fascia-notte.inizio-fascia > th,
  #view-settimana .griglia tr.fascia-notte.inizio-fascia > td { border-top: 3px solid #000; }
}

/* ---------- Altre stampe: testo grande e nero, colori tenui solo dove distinguono qualcosa ---------- */
@media print {
  :root {
    --st-giorno: #fff4cc; --st-giorno-bordo: #d9a400;   /* giorno: giallo chiaro */
    --st-notte: #e3e8fb;  --st-notte-bordo: #4a5598;    /* notte: azzurro */
    --st-weekend: #fbf3e0;
    --st-testa: #eef1f6;                                /* intestazioni delle tabelle */
    --st-liberi: #e3f2e6; --st-liberi-testo: #1c5a32;
    --st-indisp: #fdf0d5; --st-indisp-testo: #7a4a00;
    --st-ferie: #e3eafa;  --st-ferie-testo: #24408a;
  }

  /* Turni dipendente: nome e settimana in grande, ogni turno su tre righe (orario, postazione, ruolo) */
  #view-dipendente .badge-stato { display: none; }
  #view-dipendente .week-header h1 { font-size: 22pt; }
  #view-dipendente .week-range { color: #000; font-size: 13pt; font-weight: 600; }
  .tabella-turni-orizzontale { font-size: 12pt; margin-top: 4mm; }
  .tabella-turni-orizzontale th, .tabella-turni-orizzontale td { border: 1px solid #555; padding: 2mm; }
  .tabella-turni-orizzontale thead th { background: var(--st-testa); font-size: 11pt; text-align: center; border-bottom: 2px solid #000; }
  .tabella-turni-orizzontale thead th.weekend, .tabella-turni-orizzontale td.weekend { background: var(--st-weekend); }
  .tabella-turni-orizzontale td { height: 45mm; text-align: center; vertical-align: middle; }
  .tabella-turni-orizzontale .turni-persona { gap: 2mm; }
  .tabella-turni-orizzontale .turni-persona li { border-radius: 2mm; padding: 2.5mm 1.5mm; border-left: 3px solid; }
  .tabella-turni-orizzontale .turni-persona li.turno-giorno { background: var(--st-giorno); border-color: var(--st-giorno-bordo); }
  .tabella-turni-orizzontale .turni-persona li.turno-notte { background: var(--st-notte); border-color: var(--st-notte-bordo); }
  .tabella-turni-orizzontale .chip,
  .tabella-turni-orizzontale .turno-giorno .chip, .tabella-turni-orizzontale .turno-notte .chip {
    display: block; background: none; border: 0; padding: 0; color: #000; font-size: inherit; overflow-wrap: normal;
  }
  .tabella-turni-orizzontale .turno-sep { display: none; }
  .tabella-turni-orizzontale .turno-orario { display: block; font-size: 10.5pt; font-weight: 700; text-transform: uppercase; }
  .tabella-turni-orizzontale .turno-giorno .fascia-icona { color: #a86f00; }
  .tabella-turni-orizzontale .turno-notte .fascia-icona { color: var(--st-notte-bordo); }
  .tabella-turni-orizzontale .turno-postazione { display: block; font-size: 13.5pt; font-weight: 800; margin: .5mm 0; overflow-wrap: normal; word-break: normal; }
  .tabella-turni-orizzontale .turno-ruolo { display: block; font-size: 11pt; font-weight: 500; }
  .tabella-turni-orizzontale .muted { color: #444; font-size: 12pt; font-style: italic; }
  .tabella-turni-orizzontale .badge-malattia {
    font-size: 12pt; background: #f6e3f1; color: #6e1d5a; border: 1px solid #6e1d5a;
  }
  .tabella-turni-orizzontale .badge-ferie {
    font-size: 12pt; background: var(--st-ferie); color: var(--st-ferie-testo); border: 1px solid var(--st-ferie-testo);
  }

  /* Stampa liberi: righe con il loro colore, nomi in grassetto uno per riga, avvisi colorati tra parentesi */
  .stampa-liberi h2 { font-size: 15pt; }
  .tabella-liberi { font-size: 11pt; }
  .tabella-liberi th, .tabella-liberi td { border-color: #555; padding: 2mm; }
  .tabella-liberi thead th { background: var(--st-testa); font-size: 11pt; border-bottom: 2px solid #000; }
  .tabella-liberi thead th.weekend, .tabella-liberi td.weekend { background: var(--st-weekend); }
  .tabella-liberi tbody th { width: 24mm; font-size: 11pt; }
  .tabella-liberi .riga-liberi th { background: var(--st-liberi); color: var(--st-liberi-testo); }
  .tabella-liberi .riga-indisponibili th { background: var(--st-indisp); color: var(--st-indisp-testo); }
  .tabella-liberi .riga-smonto th { background: #fde9d6; color: #8a4500; }
  .tabella-liberi .riga-notte th { background: var(--st-notte); color: var(--st-notte-bordo); }
  .tabella-liberi .riga-ferie th { background: var(--st-ferie); color: var(--st-ferie-testo); }
  .tabella-liberi .riga-indisponibili td, .tabella-liberi .riga-ferie td { color: #000; }
  .tabella-liberi .riga-indisponibili > *, .tabella-liberi .riga-ferie > * { border-top: 2px solid #000; }
  .tabella-liberi .lista-liberi { gap: 1.5mm; }
  .tabella-liberi .lista-liberi li { display: block; line-height: 1.25; }
  .tabella-liberi .libero-nome { font-weight: 700; white-space: nowrap; }
  .tabella-liberi .muted { color: #000; }
  .tabella-liberi .badge {
    display: inline; background: none; border: 0; padding: 0;
    font-size: 9.5pt; font-weight: 600; font-style: italic; white-space: normal;
  }
  .tabella-liberi .avviso-smonto_notte { color: #8a5300; }
  .tabella-liberi .avviso-notte { color: var(--st-notte-bordo); }
  .tabella-liberi .badge-ferie { color: var(--st-ferie-testo); }
  .tabella-liberi .badge-malattia { color: #6e1d5a; }
  .tabella-liberi .badge::before { content: " ("; }
  .tabella-liberi .badge::after { content: ")"; }
  .nota-stampa { font-size: 9.5pt; color: #000; }

  /* Statistiche: tutta la tabella dentro il foglio, intestazioni colorate su più righe, righe alterne */
  #view-statistiche .view-header p { font-size: 9pt; color: #000; max-width: none; }
  .tabella-stat, .tabella-indisp-stat { width: 100%; font-size: 9pt; border: 1px solid #555; }
  .tabella-stat th, .tabella-stat td, .tabella-indisp-stat th, .tabella-indisp-stat td {
    padding: 1.3mm 1.2mm; border-bottom: 1px solid #bbb;
  }
  .tabella-stat thead th, .tabella-indisp-stat thead th {
    white-space: normal; text-transform: none; letter-spacing: 0; color: #000; font-size: 8.5pt;
    background: var(--st-testa); border-bottom: 2px solid #000; vertical-align: bottom;
  }
  .tabella-stat tbody th, .tabella-indisp-stat tbody th { white-space: nowrap; }
  .tabella-stat tbody tr:nth-child(even), .tabella-indisp-stat tbody tr:nth-child(even) { background: #f5f6f8; }
  .saldo-pos { color: #8a5300; }
  .saldo-neg { color: #24408a; }
  .cella-rapporto { min-width: 0; }
  .tabella-indisp-stat th.weekend, .tabella-indisp-stat td.weekend.indisp-liv-0 { background: var(--st-weekend); }
  .indisp-num { font-size: 11pt; }
  .indisp-parti { font-size: 7.5pt; opacity: 1; }
}

/* ---------- Statistiche: riepilogo per dipendente (verticale, un giorno per riga) ---------- */
.filtri-riepilogo { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-bottom: 1rem; }
.filtri-riepilogo label { font-weight: 600; }
.riepilogo-testa h2 { margin: .5rem 0 0; font-size: 1.4rem; }
.riepilogo-testa p { margin: .1rem 0 .75rem; color: var(--muted); font-weight: 600; }
.tabella-riepilogo { width: 100%; max-width: 760px; }
.tabella-riepilogo .riep-data { white-space: nowrap; width: 9rem; font-weight: 400; }
.tabella-riepilogo tr.weekend > * { background: var(--weekend); }
.riep-turno {
  display: flex; flex-wrap: wrap; gap: .15rem .6rem; align-items: baseline;
  padding: .3rem .5rem; margin: .15rem 0; border-left: 4px solid var(--giorno); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--giorno) 10%, var(--surface));
}
.riep-turno.turno-notte { border-left-color: var(--notte); background: color-mix(in srgb, var(--notte) 10%, var(--surface)); }
.riep-orario { font-weight: 700; font-variant-numeric: tabular-nums; }
.riep-postazione { font-weight: 750; }
.riep-ruolo { color: var(--muted); }
.riep-festivo { font-size: .85rem; font-weight: 600; color: var(--festivo-testo); }
.riep-indisp { display: inline-block; margin: .15rem .4rem .15rem 0; font-size: .85rem; color: var(--warn); font-weight: 600; }
.riep-totali { margin-top: 1.5rem; max-width: 760px; }
.riep-totali h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
.riep-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; margin: 0 0 1rem; }
.riep-voce { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .7rem; background: var(--surface); }
.riep-voce dt { font-size: .82rem; color: var(--muted); font-weight: 650; }
.riep-voce dd { margin: .15rem 0 0; font-size: 1.3rem; font-weight: 800; }
.riep-nota { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); }
.tabella-riep-postazioni { min-width: 320px; }
.tabella-riep-postazioni caption { text-align: left; font-weight: 700; padding-bottom: .3rem; }

@media print {
  #view-statistiche .filtri-riepilogo { display: none !important; }
  .riepilogo-testa h2 { font-size: 18pt; }
  .riepilogo-testa p { color: #000; font-size: 11pt; }
  .tabella-riepilogo { max-width: none; font-size: 10.5pt; border-collapse: collapse; }
  .tabella-riepilogo th, .tabella-riepilogo td { border: 1px solid #555; padding: 1.2mm 2mm; }
  .tabella-riepilogo tr { break-inside: avoid; }
  .tabella-riepilogo thead th { background: #eef1f6; }
  .tabella-riepilogo tr.weekend > * { background: #fbf3e0; }
  .riep-turno { background: #fff4cc; border-left-color: #d9a400; padding: .8mm 1.5mm; }
  .riep-turno.turno-notte { background: #e3e8fb; border-left-color: #4a5598; }
  .riep-ruolo, .riep-nota, .riep-voce dt, .tabella-riepilogo .muted { color: #000; }
  .riep-totali { max-width: none; break-inside: avoid; }
  .riep-griglia { grid-template-columns: repeat(3, 1fr); gap: 2mm; }
  .riep-voce { border-color: #555; padding: 1.5mm 2mm; }
  .riep-voce dd { font-size: 13pt; }
  .tabella-riep-postazioni { font-size: 10pt; border-collapse: collapse; }
  .tabella-riep-postazioni th, .tabella-riep-postazioni td { border: 1px solid #555; padding: 1mm 2mm; }
}

/* ---------- Festività: intestazione del giorno evidenziata, con il nome (prevale sul weekend) ---------- */
.griglia thead th.festivo, .tabella-liberi thead th.festivo { background: var(--festivo); }
.giorno-festa {
  display: block; margin-top: .1rem; font-size: .74rem; font-weight: 700; line-height: 1.2;
  color: var(--festivo-testo); overflow-wrap: anywhere;
}
.tabella-festivita .col-spunta { text-align: center; }
.tabella-festivita thead th.col-spunta { white-space: normal; min-width: 5.5rem; }
.tabella-festivita input[type="checkbox"] { width: 1.2rem; height: 1.2rem; }
.festa-orario { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; }
.campo-stretto { min-width: 5rem; flex: 0 1 6rem; }

/* ---------- Storico festività ---------- */
.storico-data { display: block; font-weight: 500; font-size: .85rem; }
.tabella-storico .storico-cella { vertical-align: top; min-width: 14rem; }
.storico-chip { list-style: none; margin: 0 0 .4rem; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.storico-chip .chip { display: inline-flex; flex-wrap: nowrap; padding-right: 3px; }
.chip-togli { min-height: 28px; min-width: 28px; padding: 0 .4rem; font-size: 1rem; line-height: 1; }
.storico-vuota { margin: 0 0 .4rem; }
.storico-aggiungi { max-width: 100%; }
.storico-servizio { margin-top: 1.2rem; }
.storico-nota { flex: 1 1 100%; margin: 0; }
.storico-formato .tabella-esempio { width: auto; margin: .4rem 0 .8rem; }
.tabella-esempio caption { text-align: left; font-weight: 650; font-size: .9rem; padding-bottom: .3rem; }
.storico-file-form { margin-top: .8rem; }
.storico-anteprima h3 { margin-top: 1.2rem; }
.storico-conteggi { margin: .4rem 0 .8rem; padding-left: 1.2rem; }
.storico-dettagli { margin: .6rem 0; }
.storico-dettagli summary { cursor: pointer; font-weight: 650; padding: .3rem 0; }
.storico-non-trovati { margin-top: 1rem; }
.storico-scelta {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; margin: .6rem 0;
  display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; align-items: center;
}
.storico-scelta legend { font-weight: 650; padding: 0 .3rem; }
.storico-opzione { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.storico-opzione .check { margin-left: 0; min-height: 36px; }

@media (max-width: 640px) {
  .tabella-storico .storico-cella { min-width: 11rem; }
  .storico-scelta { flex-direction: column; align-items: stretch; }
  .storico-opzione select { flex: 1 1 100%; }
}

@media print {
  #view-settimana .griglia thead th.festivo { background: #f5a9b8 !important; }
  .tabella-liberi thead th.festivo { background: var(--festivo) !important; }
  #view-settimana .giorno-festa { color: var(--festivo-testo) !important; font-size: 9pt; }
}

/* ---------- Statistiche → Equità ---------- */
.periodo-equita label { font-weight: 600; }
.tabella-equita { background: #ffffff; }
.tabella-equita td, .tabella-equita th { vertical-align: middle; }
.eq-riga { cursor: pointer; }
.eq-riga:hover, .eq-riga.aperta { background: #eef5ff; }
.eq-apri {
  display: inline-flex; align-items: center; gap: .4rem; min-height: var(--tap); padding: 0 .3rem;
  border: 0; background: none; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-align: left;
}
.eq-freccia { color: var(--primary); width: 1rem; }
.eq-valore { font-weight: 700; white-space: nowrap; }
.eq-frase { display: block; font-size: .8rem; color: var(--muted); }
.eq-sopra .eq-valore, td.eq-sopra { color: #c2410c; }   /* più della sua parte: arancio */
.eq-sotto .eq-valore, td.eq-sotto { color: #1d4ed8; }   /* meno della sua parte: blu */
.eq-pari { color: var(--ok); font-weight: 650; }
.eq-distanza { font-weight: 700; white-space: nowrap; }
.eq-tend { font-weight: 650; white-space: nowrap; padding: .15rem .5rem; border-radius: 999px; }
.eq-tend-giu { background: #dcfce7; color: #166534; }
.eq-tend-su { background: #ffedd5; color: #9a3412; }
.eq-tend-pari { background: #e0f2fe; color: #075985; }
.eq-grafico { display: block; overflow: visible; }
.eq-grafico .eq-base { stroke: #cbd5e1; stroke-width: 1; }
.eq-grafico .eq-linea { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.eq-linea-giu .eq-linea { stroke: #16a34a; }  .eq-linea-giu .eq-punto { fill: #16a34a; }
.eq-linea-su .eq-linea { stroke: #ea580c; }   .eq-linea-su .eq-punto { fill: #ea580c; }
.eq-linea-pari .eq-linea { stroke: #0284c7; } .eq-linea-pari .eq-punto { fill: #0284c7; }
.eq-dettaglio-riga > td { background: #f8fbff; padding: .6rem 1rem 1rem; }
.tabella-equita-dettaglio { width: auto; min-width: 36rem; background: #ffffff; }
.tabella-equita-dettaglio caption { text-align: left; font-weight: 650; padding: .2rem 0 .4rem; }
.eq-barra { position: relative; display: block; width: 12rem; height: 10px; border-radius: 5px; background: #e2e8f0; }
.eq-barra-centro { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: #64748b; }
.eq-barra-valore { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.eq-barra-sopra { background: #fb923c; }
.eq-barra-sotto { background: #60a5fa; }

@media print {
  .periodo-equita { display: none !important; }
  .eq-riga:hover, .eq-riga.aperta, .eq-dettaglio-riga > td { background: none; }
  .eq-apri { min-height: 0; padding: 0; }
  .eq-freccia { display: none; }
  .tabella-equita, .tabella-equita-dettaglio { font-size: 9pt; border: 1px solid #555; }
  .tabella-equita th, .tabella-equita td { padding: 1.3mm 1.2mm; border-bottom: 1px solid #bbb; }
  .tabella-equita-dettaglio { min-width: 0; page-break-inside: avoid; }
  .eq-tend, .eq-barra, .eq-barra-valore, .eq-grafico { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Stampa "Chi può sostituire": foglio a parte, si vede solo in stampa ---------- */
.stampa-sostituti { display: none; }
.coprire-azioni { margin: 0 0 .75rem; }

@page verticale { size: A4 portrait; margin: 12mm; }
@media print {
  body.stampa-sostituti-attiva > *:not(#stampa-sostituti) { display: none !important; }
  body.stampa-sostituti-attiva .stampa-sostituti { display: block !important; page: verticale; color: #000; }
  .stampa-sostituti h1 { font-size: 16pt; margin: 0 0 5mm; padding-bottom: 2mm; border-bottom: 3px solid #009541; }
  .sost-blocco {
    break-inside: avoid; page-break-inside: avoid; margin: 0 0 5mm; padding: 2.5mm 3.5mm;
    border: 1px solid #9aa3af; border-left: 4px solid #009541; border-radius: 2mm; background: #fff;
  }
  .sost-blocco h2 { font-size: 12.5pt; margin: 0 0 1mm; }
  .sost-assente { margin: 0 0 2mm; font-size: 11pt; }
  .sost-candidati { margin: 0; padding-left: 7mm; font-size: 11pt; }
  .sost-candidati > li { padding: 1mm 1.5mm; margin-bottom: 1mm; border-radius: 1.5mm; }
  .sost-nome { font-size: 12pt; font-weight: 800; }
  .sost-ore { color: #1b2330; }
  .sost-fuori-regola { background: #fff1dc; border-left: 3px solid #e07800; }
  .sost-avvisi { font-size: 10pt; color: #6b3500; margin-top: .5mm; }
  .sost-avvisi ul { margin: .5mm 0 0; padding-left: 5mm; }
  .sost-note { font-size: 9.5pt; color: #4b5563; margin-top: .5mm; }
  .sost-nessuno { margin: 0; font-weight: 700; color: #7a4a00; background: #ffeec2; padding: 1.5mm 2mm; border-radius: 1.5mm; }
  .sost-errore { margin: 0; color: #b3121f; font-weight: 700; }
  .sost-nota { font-size: 10pt; font-weight: 600; margin-top: 4mm; padding: 2mm 3mm; background: #ffe2b8; border-left: 4px solid #e07800; }
}
