/* Modulo Evacuazione – mobile-first, alto contrasto per l'uso all'aperto */
:root {
  --bg: #f3f6f3;
  --surface: #ffffff;
  --surface-2: #f6f9f6;
  --border: #d5ded6;
  --text: #15201a;
  --muted: #56645b;
  --primary: #146c34;
  --primary-2: #1b8442;
  --primary-soft: #e3f2e7;
  --on-primary: #ffffff;
  --ok: #1b7a3a;
  --ok-soft: #e2f4e7;
  --warn: #a35a00;
  --warn-soft: #fff1d9;
  --danger: #c0182b;
  --danger-soft: #fde7ea;
  --danger-text: #9b0f20;
  --highlight: #fff27a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 40, 20, .06), 0 4px 18px rgba(10, 40, 20, .07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1612; --surface: #17211b; --surface-2: #1d2922; --border: #2e3d33;
    --text: #eaf2ec; --muted: #9fb1a5; --primary: #3fae66; --primary-2: #52c47a; --primary-soft: #1d3326; --on-primary: #06140b;
    --ok: #52c47a; --ok-soft: #173322; --warn: #f0a640; --warn-soft: #3a2a10; --danger: #ff5a6a; --danger-soft: #3d151b; --danger-text: #ffb3bb;
    --highlight: #5a5410;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 18px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font: 16px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 2px; }

/* ---------- Struttura: menu laterale a sinistra + contenuto ---------- */
.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.main-col { min-width: 0; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--primary); color: var(--on-primary);
  display: flex; flex-direction: column; gap: 10px; padding: calc(16px + env(safe-area-inset-top, 0px)) 12px calc(16px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); z-index: 40; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 6px; }
.side-brand img { width: 44px; height: 44px; border-radius: 10px; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.side-brand .t1, .topbar .t1 { font-weight: 800; font-size: 1rem; line-height: 1.2; }
.side-brand .t2, .topbar .t2 { font-size: .74rem; opacity: .9; line-height: 1.25; }
.sidebar > .net { align-self: flex-start; margin-left: 6px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a { color: var(--on-primary); text-decoration: none; padding: 10px 12px; border-radius: 10px; font-size: .95rem; opacity: .9; }
.side-nav a:hover { background: rgba(255,255,255,.1); opacity: 1; }
.side-nav a.active { background: rgba(255,255,255,.22); opacity: 1; font-weight: 700; }
.nav-sect { margin: 14px 12px 4px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.25); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.side-user { font-size: .82rem; padding: 10px 12px 0; border-top: 1px solid rgba(255,255,255,.25); }
.side-user span { opacity: .8; font-size: .75rem; }
.net { font-size: .75rem; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.net.off { background: #ffd34d; color: #3b2a00; font-weight: 700; }

/* Barra superiore: solo su schermi stretti, con il pulsante che apre il menu */
.topbar { display: none; position: sticky; top: 0; z-index: 20; background: var(--primary); color: var(--on-primary);
  padding: env(safe-area-inset-top, 0) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.topbar-in { display: flex; align-items: center; gap: 10px; min-height: 58px; }
.topbar img { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.topbar .sp { flex: 1; min-width: 0; }
.menu-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: rgba(255,255,255,.15); color: inherit; font-size: 1.4rem; cursor: pointer; flex: none; }
.backdrop { display: none; }
@media (max-width: 899px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .topbar { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 84vw); height: auto; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .sidebar.open { transform: none; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(5, 15, 10, .45); z-index: 30; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

main { max-width: 1100px; margin: 0 auto; padding-block: 18px 60px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main.narrow { max-width: 760px; }

/* ---------- Card e blocchi ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.sect-head { background: var(--primary); color: var(--on-primary); margin: -18px -18px 16px; padding: 12px 18px; border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.sect-head .tag { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 600; font-size: .78rem; background: var(--highlight); color: #2c2700; padding: 2px 8px; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .sect-head .tag { color: #fff7b0; } }
.phase { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary); margin: 6px 2px -4px; font-size: .95rem; }
.phase::after { content: ""; flex: 1; height: 2px; background: var(--border); }

/* ---------- Form ---------- */
label, .lbl { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.req::after { content: " *"; color: var(--danger); }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: 12px 13px; min-height: 48px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 110px; resize: vertical; }
input[type=checkbox] { width: 24px; height: 24px; min-height: 0; accent-color: var(--primary); flex: none; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .grid4 { grid-template-columns: 1fr 1fr; } }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.invalid input, .invalid textarea, .invalid .chips, .invalid .sigwrap { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft); border-radius: 10px; }
.invalid > label, .invalid > .lbl { color: var(--danger-text); }
.error-box { background: var(--danger-soft); color: var(--danger-text); border-radius: 10px; padding: 12px 14px; font-size: .95rem; font-weight: 500; }
.check-panel { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: .92rem; }
.check-panel.ok { background: var(--ok-soft); color: var(--text); border-left: 4px solid var(--ok); }
.check-panel.idle { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.info-box { background: var(--primary-soft); border-radius: 10px; padding: 12px 14px; font-size: .92rem; }
.warn-box { background: var(--warn-soft); color: var(--text); border-left: 4px solid var(--warn); border-radius: 10px; padding: 12px 14px; font-size: .92rem; }

/* Scelte a "chip" (radio) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; border: 1.5px solid transparent; }
.chips label { margin: 0; position: relative; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { display: inline-flex; align-items: center; min-height: 48px; padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface);
  font-weight: 600; font-size: .95rem; cursor: pointer; user-select: none; }
.chips input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chips input:focus-visible + span { outline: 3px solid var(--primary-2); outline-offset: 2px; }
.chips.col { flex-direction: column; }
.chips.col span { width: 100%; }

/* Contatori appello */
.counter { display: flex; align-items: stretch; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.counter button { width: 52px; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.5rem; font-weight: 700; cursor: pointer; flex: none; }
.counter button:active { background: var(--primary-soft); }
.counter input { border: 0; border-radius: 0; text-align: center; font-size: 1.35rem; font-weight: 700; min-width: 0; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.counter input:focus { box-shadow: none; }
.counter:focus-within { border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-soft); }
.invalid .counter { border-color: var(--danger); }
.alarm { display: none; background: var(--danger); color: #fff; border-radius: 12px; padding: 14px 16px; font-weight: 700; font-size: 1rem; margin-top: 14px; }
.alarm.show { display: block; }
.alarm small { display: block; font-weight: 500; opacity: .95; margin-top: 4px; }

/* Firma */
.sigwrap { border: 1.5px dashed var(--border); border-radius: 12px; background: #fff; position: relative; touch-action: none; }
.sigwrap canvas { display: block; width: 100%; height: 170px; border-radius: 12px; cursor: crosshair; }
.sigwrap .sigph { position: absolute; inset: 0; display: grid; place-items: center; color: #8a968e; pointer-events: none; font-size: .95rem; }
.sig-img { background: #fff; border-radius: 8px; max-height: 90px; padding: 4px; }

/* ---------- Pulsanti ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1.5px solid transparent; border-radius: 12px; padding: 10px 18px;
  font: inherit; font-weight: 700; cursor: pointer; background: var(--primary); color: var(--on-primary); text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 1.15rem; border-radius: 16px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--primary); border: 0; min-height: 38px; padding: 6px 10px; }
.btn.ghost:hover { background: var(--primary-soft); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 200px; }
.sticky-bar { position: sticky; bottom: 0; z-index: 10; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); margin-top: 8px; }

/* ---------- Badge e liste ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-danger { background: var(--danger); color: #fff; }
.b-grey { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit; }
.item.alarm-row { border: 2px solid var(--danger); background: var(--danger-soft); }
.item.warn-row { border-left: 5px solid var(--warn); }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 700; }
.item .s { font-size: .85rem; color: var(--muted); }
.nums { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; font-variant-numeric: tabular-nums; }
.nums b { font-size: 1rem; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* ---------- Riepilogo ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, 1fr); } .kpis .k:first-child { grid-column: span 2; } }
.k { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.k .v { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.k .l { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.k.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.k.danger .l { color: #fff; opacity: .9; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
/* L'ultima riga delle tabelle dell'app non ha bordo inferiore; il modulo stampabile (.paper) invece sì */
:not(.paper) > table tr:last-child td, .table-wrap tr:last-child td { border-bottom: 0; }
tr.tot td { font-weight: 800; background: var(--surface-2); }
td.hot { color: var(--danger); font-weight: 800; }
.filters { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 10px; align-items: end; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } }
.filters .field { margin: 0; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.live::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }

/* ---------- Accesso ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background: var(--primary); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 26px 22px; }
.auth-card.wide { max-width: 560px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand img { width: 64px; height: 64px; flex: none; }
.brand .bt { font-weight: 800; font-size: 1.05rem; line-height: 1.25; }
.brand .bs { font-size: .85rem; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); min-height: 44px; }
.tabs button.active { background: var(--primary); color: var(--on-primary); }

/* ---------- Toast e modali ---------- */
#toast-root { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); }
.toast { background: #1d2b22; color: #fff; padding: 13px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.3); font-weight: 600; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.err { background: var(--danger); color: #fff; }
.modal-bg { position: fixed; inset: 0; background: rgba(5, 15, 10, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 700px) { .modal-bg { align-items: center; padding: 20px; } .modal { border-radius: 18px; } }
.sum { width: 100%; border-collapse: collapse; font-size: .92rem; margin-bottom: 14px; }
.sum th { width: 42%; text-transform: none; letter-spacing: 0; font-size: .85rem; background: transparent; white-space: normal; vertical-align: top; }
.sum td { white-space: normal; }

/* Coda invii (offline) */
.outbox { border: 2px solid var(--warn); background: var(--warn-soft); border-radius: 12px; padding: 14px; }

/* ---------- Modulo nel formato cartaceo (vista e stampa) ---------- */
.paper { background: #fff; color: #000; max-width: 820px; margin: 0 auto; padding: 28px 30px; border-radius: 6px; box-shadow: var(--shadow); font-family: Arial, Helvetica, sans-serif; font-size: 13px; }
.paper .ph { display: flex; align-items: center; gap: 12px; font-family: "Times New Roman", Times, serif; font-size: 20px; margin-bottom: 14px; }
.paper .ph img { width: 54px; height: 54px; }
.paper .title { background: #1a7a2e; color: #fff; text-align: center; font-weight: 700; font-size: 18px; padding: 6px; border: 1px solid #000; }
.paper .note { text-align: center; margin: 10px 0; }
.paper .note mark { background: #ffff00; padding: 0 3px; }
.paper table { border-collapse: collapse; width: 100%; margin-bottom: 14px; font-size: 13px; border: 1px solid #000; }
.paper th, .paper td { border: 1px solid #000; padding: 6px 8px; text-align: center; white-space: normal; color: #000; background: #fff; text-transform: none; letter-spacing: 0; font-size: 13px; }
.paper .thh { font-size: 17px; font-weight: 700; padding: 8px; }
.paper td.v { font-family: "Times New Roman", serif; font-size: 14px; font-weight: 700; }
.paper .box { font-family: "Times New Roman", serif; text-align: left; line-height: 1.5; }
.paper .foot { margin-top: 10px; line-height: 2; }
.paper .foot .line { display: inline-block; min-width: 220px; border-bottom: 1px solid #000; font-family: "Times New Roman", serif; font-weight: 700; padding: 0 4px; line-height: 1.4; }
.paper .crit { border-bottom: 1px solid #000; min-height: 70px; white-space: pre-wrap; font-family: "Times New Roman", serif; }
.paper .meta { font-size: 11px; color: #444; margin-top: 12px; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .topbar, .sidebar, .backdrop, .no-print, #toast-root { display: none !important; }
  .layout { display: block; }
  main { padding: 0; max-width: none; }
  .paper { box-shadow: none; padding: 0; max-width: none; }
  .paper .title, .paper .note mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Modulo del docente: sempre in un solo foglio A4. Niente zoom (farebbe saltare le linee delle celle):
     se serve spazio app.js riduce soltanto la dimensione del testo (--fs), i bordi restano pieni a 1 px. */
  .paper.una-pagina { width: 186mm; margin: 0 auto; break-inside: avoid; page-break-inside: avoid; page-break-after: avoid; }
  .paper.una-pagina .crit { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
/* Resa compatta di stampa, usata anche (classe .misura) per misurare l'altezza prima di stampare */
@media print {
  .paper.una-pagina { font-size: var(--fs, 12px); }
  .paper.una-pagina .ph { margin-bottom: .5em; font-size: 1.5em; }
  .paper.una-pagina .ph img { width: 3.3em; height: 3.3em; }
  .paper.una-pagina .title { font-size: 1.35em; padding: .3em; }
  .paper.una-pagina .note { margin: .4em 0; }
  .paper.una-pagina table { margin-bottom: .6em; font-size: 1em; }
  .paper.una-pagina th, .paper.una-pagina td { padding: .25em .5em; font-size: 1em; }
  .paper.una-pagina td.v { font-size: 1.08em; }
  .paper.una-pagina .thh { padding: .3em; font-size: 1.17em; }
  .paper.una-pagina .foot { margin-top: .5em; line-height: 1.7; }
  .paper.una-pagina .meta { margin-top: .5em; font-size: .85em; }
}
.paper.una-pagina.misura { width: 186mm; max-width: none; padding: 0; box-shadow: none; font-size: var(--fs, 12px); }
.paper.una-pagina.misura .ph { margin-bottom: .5em; font-size: 1.5em; }
.paper.una-pagina.misura .ph img { width: 3.3em; height: 3.3em; }
.paper.una-pagina.misura .title { font-size: 1.35em; padding: .3em; }
.paper.una-pagina.misura .note { margin: .4em 0; }
.paper.una-pagina.misura table { margin-bottom: .6em; font-size: 1em; }
.paper.una-pagina.misura th, .paper.una-pagina.misura td { padding: .25em .5em; font-size: 1em; }
.paper.una-pagina.misura td.v { font-size: 1.08em; }
.paper.una-pagina.misura .thh { padding: .3em; font-size: 1.17em; }
.paper.una-pagina.misura .foot { margin-top: .5em; line-height: 1.7; }
.paper.una-pagina.misura .meta { margin-top: .5em; font-size: .85em; }
/* Segnalazione criticità: tre righe tracciate, come nel modulo cartaceo (massimo tre righe di testo) */
.paper .crit { border-bottom: 0; min-height: 5.1em; line-height: 1.7em; white-space: pre-wrap; font-family: "Times New Roman", serif;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.7em - 1px), #000 calc(1.7em - 1px), #000 1.7em); }

/* QR */
.qr { background: #fff; padding: 10px; border-radius: 10px; width: 220px; max-width: 100%; }
.qr svg { display: block; width: 100%; height: auto; }
.guide ol { padding-left: 1.2rem; margin: 0; }
.guide li { margin-bottom: .6rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } }
details > summary { list-style-position: inside; }
.evento-banner { border-radius: 12px; padding: 12px 16px; font-weight: 800; letter-spacing: .04em; text-align: center; }
.evento-banner.reale { background: var(--danger); color: #fff; }
.evento-banner.prova { background: var(--primary-soft); color: var(--primary); border: 1.5px solid var(--primary); }
.filters input:disabled { opacity: .5; }

/* Registro operazioni: tutte le colonne vanno a capo, nessun dato tagliato */
table.log { table-layout: fixed; min-width: 640px; }
table.log th:nth-child(1) { width: 118px; }
table.log td:first-child { white-space: nowrap; }
table.log th:nth-child(2) { width: 26%; }
table.log th:nth-child(3) { width: 22%; }
table.log td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
table.log tr[hidden] { display: none; }
@media (max-width: 700px) {
  table.log { min-width: 0; table-layout: auto; }
  table.log thead { display: none; }
  table.log, table.log tbody, table.log tr, table.log td { display: block; width: auto; }
  table.log tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.log tr[hidden] { display: none; }
  table.log td { border: 0; padding: 2px 0; }
  table.log td:first-child { white-space: normal; font-size: .85rem; }
  table.log td:first-child br { display: none; }
  table.log td:first-child span::before { content: " · "; }
  table.log td:nth-child(3) { font-weight: 700; }
}
.check input[type=radio] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--primary); flex: none; margin-top: 2px; }
/* Pulsante Esci: ultima voce del menu laterale */
.nav-esci { margin-top: 14px; padding: 10px 12px; border: 0; border-top: 1px solid rgba(255,255,255,.25); border-radius: 0; background: transparent;
  color: var(--on-primary); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer; opacity: .95; }
.nav-esci:hover { background: rgba(255,255,255,.1); border-radius: 10px; }
.nav-esci::before { content: "⎋ "; }

/* Moduli ricevuti: tabella per giorno; su telefono diventa un elenco di schede */
table.ric td { white-space: normal; vertical-align: top; }
table.ric tr[hidden], .ric-giorno[hidden] { display: none; }
@media (max-width: 700px) {
  .filters#rf { grid-template-columns: 1fr 1fr !important; }
  table.ric thead { display: none; }
  table.ric, table.ric tbody, table.ric tr, table.ric td { display: block; width: auto; }
  table.ric tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.ric tr[hidden] { display: none; }
  table.ric td { border: 0; padding: 1px 0; }
  table.ric td:nth-child(2)::before { content: "Plesso: "; color: var(--muted); }
  table.ric td:nth-child(3)::before { content: "Classe: "; color: var(--muted); }
  table.ric td:nth-child(4)::before { content: "Ora evacuazione: "; color: var(--muted); }
  table.ric td:nth-child(5)::before { content: "Inviato alle: "; color: var(--muted); }
}

/* Firma: pulsante "Cancella e rifai" ben visibile sotto il riquadro */
.sig-actions { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 8px; }
.sig-actions .btn { flex: none; }
.sig-actions .hint { flex: 1 1 220px; margin: 0; }
@media (max-width: 640px) { .sig-actions .btn { width: 100%; } }

/* Modulo stampabile: griglia affidabile anche in stampa. Ogni cella traccia solo la linea sopra e a sinistra,
   la tabella traccia la linea destra e quella INFERIORE di chiusura: così il bordo finale di ogni sezione
   (Generalità, Nomine, Appello, Emergenza) viene sempre stampato e non ci sono linee doppie. */
.paper table { border-collapse: separate; border-spacing: 0; border: 0; border-right: 1px solid #000; border-bottom: 1px solid #000; }
.paper table th, .paper table td, .paper table tr:last-child td, .paper table tr:last-child th { border: 0; border-top: 1px solid #000; border-left: 1px solid #000; }
@media print {
  .paper table { border-right: 1px solid #000 !important; border-bottom: 1px solid #000 !important; }
  .paper table th, .paper table td { border: 0 !important; border-top: 1px solid #000 !important; border-left: 1px solid #000 !important; }
}

/* Numero dell'evacuazione assegnato automaticamente (non modificabile) */
.num-auto { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; min-height: 48px; padding: 6px 16px;
  border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Riga di campi + pulsante allineati sulla stessa linea di base (es. Numerazione delle evacuazioni) */
.riga-allineata { align-items: end; margin-bottom: 14px; }
.riga-allineata > .field { margin-bottom: 0; }
.riga-allineata .btn { width: 100%; min-height: 48px; }

/* =====================================================================
   Landing page pubblica (presentazione dell'app)
   ===================================================================== */
.lp { background: var(--bg); color: var(--text); min-height: 100vh; }
.lp-wrap { max-width: 1120px; margin: 0 auto; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); }
.lp-top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top, 0px); }
.lp-top-in { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.lp-logo { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.lp-logo img { width: 36px; height: 36px; border-radius: 9px; }
.lp-nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.lp-nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: .92rem; }
.lp-nav a:hover { background: var(--primary-soft); color: var(--primary); }
.lp-top-az { display: flex; gap: 8px; margin-left: auto; }
@media (max-width: 760px) { .lp-nav { display: none; } }
@media (max-width: 420px) { .lp-logo span { display: none; } }

.lp-hero { background: var(--primary); color: #fff; overflow: hidden; position: relative; }
.lp-hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background:
  radial-gradient(circle at 85% 30%, rgba(255,255,255,.14), transparent 45%),
  radial-gradient(circle at 10% 110%, rgba(0,0,0,.18), transparent 50%); }
.lp-hero-in { position: relative; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 40px; align-items: center; padding-block: 56px 64px; }
@media (max-width: 860px) { .lp-hero-in { grid-template-columns: 1fr; padding-block: 36px 44px; } }
.lp-occhiello { font-size: .85rem; font-weight: 700; letter-spacing: .04em; opacity: .9; margin-bottom: 14px; }
.lp-hero h1 { font-size: clamp(1.8rem, 4.2vw, 2.9rem); line-height: 1.12; letter-spacing: -.01em; margin-bottom: 16px; color: #fff; }
.lp-sotto { font-size: 1.1rem; line-height: 1.55; max-width: 60ch; opacity: .95; margin-bottom: 24px; }
.lp-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.lp-hero .btn.big { background: #fff; color: #146c34; }
.lp-hero .btn.big:hover { background: #eef7f0; }
.lp-hero .btn.big.secondary { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.75); }
.lp-hero .btn.big.secondary:hover { background: rgba(255,255,255,.12); }
.lp-nota { font-size: .92rem; opacity: .95; margin: 6px 0 0; }
.lp-hero .lp-nota a { color: #fff; font-weight: 700; }

/* Telefono illustrativo con il modulo inviato */
.lp-telefono { justify-self: center; width: min(290px, 80vw); aspect-ratio: 9 / 17.5; max-width: 100%; border-radius: 34px; background: #0e1a13; padding: 12px; box-shadow: 0 30px 60px rgba(0,0,0,.35); transform: rotate(3deg); }
@media (max-width: 860px) { .lp-telefono { transform: none; width: min(260px, 70vw); } }
.lp-tel-schermo { height: 100%; border-radius: 24px; background: #f3f6f3; color: #15201a; padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.lp-tel-barra { display: flex; align-items: center; gap: 8px; background: #146c34; color: #fff; margin: -12px -12px 2px; padding: 12px; font-weight: 800; font-size: .9rem; }
.lp-tel-barra img { width: 22px; height: 22px; border-radius: 5px; }
.lp-tel-sez { background: #146c34; color: #fff; font-size: .62rem; font-weight: 800; letter-spacing: .06em; padding: 6px 8px; border-radius: 6px; }
.lp-tel-num { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lp-tel-num div { background: #fff; border: 1px solid #d5ded6; border-radius: 8px; padding: 6px; text-align: center; }
.lp-tel-num b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.lp-tel-num span { font-size: .6rem; color: #56645b; text-transform: uppercase; letter-spacing: .04em; }
.lp-tel-firma { border: 1.5px dashed #c3cec6; border-radius: 8px; background: #fff; height: 54px; display: grid; place-items: center; font-family: "Segoe Script", "Brush Script MT", cursive; color: #0b1a3a; font-size: 1rem; }
.lp-tel-ok { margin-top: auto; background: #1b7a3a; color: #fff; border-radius: 10px; padding: 10px; text-align: center; font-weight: 800; font-size: .8rem; }

.lp-sez { padding-block: 64px; }
.lp-sez-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.lp-sez h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 22px; }
.lp-intro { max-width: 70ch; color: var(--muted); margin-bottom: 24px; font-size: 1.02rem; }
.lp-passi { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 860px) { .lp-passi { grid-template-columns: 1fr; } }
.lp-passi li { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.lp-n { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-weight: 800; margin-bottom: 12px; }
.lp-passi p, .lp-ruolo p, .lp-disp-card p { color: var(--muted); margin: 0; line-height: 1.55; }
.lp-ruoli { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 860px) { .lp-ruoli { grid-template-columns: 1fr; } }
.lp-ruolo { border: 1px solid var(--border); border-radius: 16px; padding: 22px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.lp-ruolo a { margin-top: auto; font-weight: 700; color: var(--primary); text-decoration: none; }
.lp-funz { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; }
@media (max-width: 760px) { .lp-funz { grid-template-columns: 1fr; } }
.lp-funz li { padding: 14px 0 14px 36px; border-bottom: 1px solid var(--border); position: relative; line-height: 1.5; }
.lp-funz li::before { content: "✔"; position: absolute; left: 0; top: 13px; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.lp-disp { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 26px; }
@media (max-width: 860px) { .lp-disp { grid-template-columns: 1fr; } }
.lp-disp-card { border: 1px solid var(--border); border-radius: 16px; padding: 22px; background: var(--bg); }
.lp-disp-ic { font-size: 2rem; margin-bottom: 8px; }
.lp-piede { background: #0f2a19; color: #dfeee3; padding-block: 28px calc(28px + env(safe-area-inset-bottom, 0px)); }
.lp-piede-in { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: center; }
.lp-piede-link { display: flex; gap: 18px; flex-wrap: wrap; }
.lp-piede a, .lp-link-btn { color: #fff; font-weight: 600; text-decoration: none; }
.lp-link-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.lp-piede a:hover, .lp-link-btn:hover { text-decoration: underline; }

/* Accesso: separazione docenti / supervisore */
.auth-wrap.admin { background: #0f2a19; }
.auth-wrap.admin .auth-card { border-top: 6px solid #146c34; }
.admin-avviso { background: var(--primary-soft); color: var(--text); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; font-size: .92rem; }
.auth-alt { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; font-size: .92rem; color: var(--muted); }
.auth-alt a { font-weight: 700; }
.auth-piede { margin-top: 14px; }

/* Installazione dell'app */
[data-installa][hidden], [data-installa-box][hidden], [data-installa-ok][hidden] { display: none !important; }
.installa-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1.5px dashed var(--primary); border-radius: 14px; padding: 14px 16px; background: var(--primary-soft); }
.nav-installa { margin-top: 14px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; background: rgba(255,255,255,.08);
  color: var(--on-primary); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer; }
.nav-installa:hover { background: rgba(255,255,255,.16); }
.nav-installa + .nav-esci { margin-top: 6px; }
.ist-blocco { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.ist-titolo { font-weight: 800; margin-bottom: 6px; }
.ist-passi { margin: 0; padding-left: 1.2rem; line-height: 1.55; }
.ist-passi li { margin-bottom: 4px; }
.ist-altri summary { cursor: pointer; font-weight: 700; color: var(--primary); margin: 6px 0 10px; }

/* Informativa sulla privacy */
.privacy { max-width: 72ch; line-height: 1.6; }
.privacy h1 { font-size: 1.6rem; }
.privacy h2 { font-size: 1.1rem; margin-top: 1.6rem; color: var(--primary); }
.privacy ul { padding-left: 1.2rem; margin: 0 0 .75rem; }
.privacy li { margin-bottom: .45rem; }
.side-privacy { color: var(--on-primary); opacity: .85; font-size: .75rem; text-decoration: underline; }

/* ---------------------------------------------------------------- Versione dimostrativa */
.demo-tag { font-size: .62rem; font-weight: 800; letter-spacing: .08em; background: #f5b400; color: #1d1d1d; border-radius: 6px; padding: 2px 6px; vertical-align: middle; margin-left: 4px; }
.demo-badge { display: inline-block; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; padding: 5px 12px; font-size: .8rem; font-weight: 700; margin: 0 0 14px; }
.demo-occhiello { color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; margin: 0 0 6px; }
.demo-ruoli { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 22px; }
@media (max-width: 1040px) { .demo-ruoli { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .demo-ruoli { grid-template-columns: 1fr; } }
.demo-ruoli .lp-ruolo .btn { margin-top: auto; white-space: normal; text-align: center; }
.demo-chi { font-size: .92rem; }
.demo-funz { margin: 0 0 8px; padding-left: 1.1em; color: var(--muted); line-height: 1.5; font-size: .93rem; }
.demo-funz li { margin: 3px 0; }
.demo-banda { background: #fff4cc; color: #4a3b00; border-bottom: 1px solid #ecd78a; padding: 8px 16px; font-size: .86rem; text-align: center; line-height: 1.5; }
.demo-banda-btn { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0 0 0 6px; }
.demo-contatti { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40; background: var(--primary); color: #fff; border: 0; border-radius: 999px; padding: 12px 18px; font: inherit; font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); cursor: pointer; }
.demo-contatti:hover { filter: brightness(1.08); }
.contatto-riga { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.contatto-riga code { font-size: .95rem; word-break: break-all; flex: 1; }
@media print { .demo-banda, .demo-contatti { display: none !important; } }

/* ---------------------------------------------------------------- Telefono: niente scorrimento orizzontale della pagina */
.filters > *, .grid2 > *, .grid4 > * { min-width: 0; }
input, select, textarea { min-width: 0; max-width: 100%; }
.btn { max-width: 100%; white-space: normal; text-align: center; }
@media (max-width: 760px) {
  .filters[style] { grid-template-columns: 1fr 1fr !important; }
  .filters > .field:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
