/* Aula UF 22 — foglio di stile unico */
:root {
  --carta: #f4f3ef;
  --superficie: #ffffff;
  --inchiostro: #1d2a2a;
  --tenue: #5b6b6a;
  --bordo: #dde2df;
  --bordo-forte: #c4ccc8;
  --primario: #0e6f6b;
  --primario-scuro: #0a5552;
  --primario-chiaro: #e3f1ef;
  --verde: #3d8b3d;
  --verde-chiaro: #e7f3e2;
  --ambra: #9a6b00;
  --ambra-chiaro: #fbf1d9;
  --rosso: #b3261e;
  --rosso-chiaro: #fbe9e7;
  --raggio: 10px;
  --ombra: 0 1px 2px rgba(29, 42, 42, .06), 0 2px 8px rgba(29, 42, 42, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--carta); color: var(--inchiostro); font: 16px/1.5 var(--font); }
a { color: var(--primario); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
code { font-family: var(--mono); font-size: .9em; background: #eef1ef; padding: .1em .35em; border-radius: 4px; }
small, .muto { color: var(--tenue); font-size: .875rem; }
hr { border: 0; border-top: 1px solid var(--bordo); margin: 1.2rem 0; }

/* ---------- Barra superiore ---------- */
.topbar { background: var(--superficie); border-bottom: 1px solid var(--bordo); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--inchiostro); font-weight: 700; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primario); color: #fff; font-weight: 800; font-size: 15px; flex: none; }
.brand-mark.grande { width: 52px; height: 52px; border-radius: 14px; font-size: 26px; margin-bottom: 12px; }
.topbar-user { display: flex; align-items: center; gap: 12px; flex: none; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primario-chiaro); color: var(--primario-scuro); font-size: 13px; font-weight: 700; }
.logout { font-size: .9rem; color: var(--tenue); text-decoration: none; }
.mainnav { max-width: 1180px; margin: 0 auto; padding: 0 8px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { padding: 8px 10px 10px; color: var(--tenue); text-decoration: none; font-size: .95rem; white-space: nowrap; border-bottom: 2px solid transparent; }
.mainnav a:hover { color: var(--inchiostro); }
.mainnav a.attiva { color: var(--primario); border-bottom-color: var(--primario); font-weight: 600; }
.pill { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--rosso); color: #fff; font-size: .75rem; text-align: center; line-height: 1.4em; font-weight: 700; }

/* ---------- Contenuto ---------- */
.contenuto { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.testata { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.testata h1 { margin: 0; }
.testata .sotto { color: var(--tenue); margin: 4px 0 0; }
.azioni { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.briciole { font-size: .875rem; margin-bottom: 6px; }
.briciole a { text-decoration: none; }

.card { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 18px; box-shadow: var(--ombra); margin-bottom: 16px; }
.card > :last-child { margin-bottom: 0; }
.card-stretta { max-width: 520px; margin: 40px auto; }
.card h2 { margin-bottom: 12px; }
.card-titolo { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-titolo h2 { margin: 0; }

.griglia { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.griglia > .card { margin-bottom: 0; }
.colonne { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .colonne { grid-template-columns: 2fr 1fr; } .colonne.meta { grid-template-columns: 1fr 1fr; } }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--tenue); font-size: .85rem; margin-top: 4px; }

/* ---------- Avvisi ---------- */
.avviso { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid; font-size: .95rem; }
.avviso-successo { background: var(--verde-chiaro); border-color: #bfdcb6; color: #24572a; }
.avviso-errore { background: var(--rosso-chiaro); border-color: #f0c2bd; color: #8c1d17; }
.avviso-info { background: var(--primario-chiaro); border-color: #bcdcd8; color: var(--primario-scuro); }
.avviso-attenzione { background: var(--ambra-chiaro); border-color: #ecd59b; color: #6d4c00; }

/* ---------- Pulsanti ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--bordo-forte); background: var(--superficie); color: var(--inchiostro); font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; line-height: 1.2; min-height: 40px; }
.btn:hover { border-color: var(--tenue); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--primario); border-color: var(--primario); color: #fff; }
.btn-primario:hover { background: var(--primario-scuro); border-color: var(--primario-scuro); }
.btn-verde { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn-pericolo { color: var(--rosso); border-color: #e6b3ae; }
.btn-pericolo:hover { background: var(--rosso-chiaro); border-color: var(--rosso); }
.btn-piccolo { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn-pieno { width: 100%; }
.btn-link { background: none; border: 0; color: var(--primario); padding: 0; min-height: 0; font-weight: 500; cursor: pointer; font: inherit; text-decoration: underline; }
form.inline { display: inline; }

/* ---------- Form ---------- */
.form { display: grid; gap: 14px; }
.form label, label.campo { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.form label small { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input:not([type]), select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--inchiostro); background: #fff; border: 1px solid var(--bordo-forte); border-radius: 8px; padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primario); outline-offset: 0; border-color: var(--primario); }
.riga2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .riga2 { grid-template-columns: 1fr 1fr; } .riga3 { grid-template-columns: 1fr 1fr 1fr; } }
.riga3 { display: grid; gap: 14px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; }
.maiuscolo { text-transform: uppercase; letter-spacing: .08em; }
.link-sotto { text-align: center; margin-top: 14px; font-size: .92rem; }

/* ---------- Accesso ---------- */
.pagina-accesso .contenuto { max-width: 460px; padding-top: 6vh; }
.accesso-intro { text-align: center; margin-bottom: 18px; }
.accesso-intro p { color: var(--tenue); }
.codice-grande { font-family: var(--mono); font-size: 1.6rem; letter-spacing: .15em; }

/* ---------- Tabelle ---------- */
.tabella-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.tab { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.tab th { text-align: left; font-weight: 600; color: var(--tenue); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--bordo-forte); white-space: nowrap; }
table.tab td { padding: 10px; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
table.tab tr:last-child td { border-bottom: 0; }
table.tab td.num, table.tab th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tab a.riga-link { color: var(--inchiostro); font-weight: 600; text-decoration: none; }
table.tab a.riga-link:hover { color: var(--primario); }
table.tab tr.evidenza td { background: #fafbf9; }
th a { color: inherit; text-decoration: none; }

/* ---------- Badge e barre ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-base { background: var(--rosso-chiaro); color: var(--rosso); }
.badge-medio { background: var(--ambra-chiaro); color: var(--ambra); }
.badge-alto { background: var(--verde-chiaro); color: var(--verde); }
.badge-neutro { background: #eef1ef; color: var(--tenue); }
.badge-primario { background: var(--primario-chiaro); color: var(--primario-scuro); }
.barra { display: inline-block; width: 100%; max-width: 160px; height: 8px; border-radius: 999px; background: #e7ebe9; overflow: hidden; vertical-align: middle; }
.barra > span { display: block; height: 100%; background: var(--primario); border-radius: 999px; }
.barra.verde > span { background: var(--verde); }
.barra.ambra > span { background: #c99a1a; }
.barra.rossa > span { background: var(--rosso); }
.barra-stack { display: flex; width: 100%; height: 12px; border-radius: 999px; overflow: hidden; background: #e7ebe9; }
.barra-stack span { height: 100%; }
.barra-stack .ok { background: var(--verde); }
.barra-stack .ko { background: var(--rosso); }
.barra-stack .ns { background: #c9cfcc; }
.legenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--tenue); margin: 6px 0 12px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { padding: 10px 0; border-bottom: 1px solid var(--bordo); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.lista li:last-child { border-bottom: 0; }
.lista .t { font-weight: 600; }
.non-letto .t::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rosso); margin-right: 8px; vertical-align: 1px; }
.vuoto { color: var(--tenue); text-align: center; padding: 20px 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .95rem; }
.dl dt { color: var(--tenue); }
.dl dd { margin: 0; }

/* ---------- Presenza studente ---------- */
.presenza-box { text-align: center; padding: 24px 18px; }
.presenza-box .stato { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.codice-input { font-family: var(--mono); font-size: 1.8rem !important; letter-spacing: .3em; text-align: center; max-width: 260px; margin: 0 auto; }
.spunta { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--verde-chiaro); color: var(--verde); font-size: 30px; margin-bottom: 10px; }

/* ---------- Proiezione QR ---------- */
body.proiezione { background: #0b2f2d; color: #fff; }
.proiezione .contenuto { max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.proj { display: grid; gap: 16px; justify-items: center; text-align: center; }
.proj-titolo { font-size: clamp(1.2rem, 3.5vh, 2.2rem); font-weight: 700; margin: 0 0 8px; }
.proj-tipo { display: inline-block; padding: 6px 16px; border-radius: 999px; background: #fff; color: #0b2f2d; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.proj-tipo.uscita { background: #f2c14e; }
.proj-qr { background: #fff; padding: 18px; border-radius: 18px; line-height: 0; }
.proj-qr img, .proj-qr svg { width: min(52vh, 80vw); height: auto; display: block; }
.proj-codice { font-family: var(--mono); font-size: clamp(2rem, 6vh, 4.2rem); line-height: 1.1; letter-spacing: .25em; font-weight: 700; }
.proj-sotto { opacity: .8; font-size: 1.1rem; }
.proj-barra { width: min(52vh, 80vw); height: 6px; border-radius: 999px; background: rgba(255,255,255,.2); overflow: hidden; }
.proj-barra span { display: block; height: 100%; background: #fff; transition: width 1s linear; }
.proj-comandi { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.proj-comandi .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.3); }

/* ---------- Quiz ---------- */
.quiz-testa { position: sticky; top: 0; z-index: 15; background: var(--carta); padding: 10px 0; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--bordo); }
.timer { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; padding: 4px 10px; border-radius: 8px; background: var(--superficie); border: 1px solid var(--bordo); }
.timer.poco { color: var(--rosso); border-color: var(--rosso); }
.salvataggio { font-size: .85rem; color: var(--tenue); }
.salvataggio.errore { color: var(--rosso); font-weight: 600; }
.sezione-quiz { margin: 22px 0 10px; font-size: 1rem; color: var(--primario); text-transform: uppercase; letter-spacing: .05em; }
.domanda { background: var(--superficie); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 16px; margin-bottom: 12px; }
.domanda.bloccata { background: #fafbf9; }
.domanda-testo { font-weight: 600; margin-bottom: 12px; display: flex; gap: 10px; }
.domanda-num { flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 7px; background: var(--primario-chiaro); color: var(--primario-scuro); font-size: .85rem; }
.opzioni { display: grid; gap: 8px; }
.opzione { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--bordo); border-radius: 8px; cursor: pointer; font-weight: 400; }
.opzione:hover { border-color: var(--bordo-forte); }
.opzione input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--primario); }
.opzione:has(input:checked) { border-color: var(--primario); background: var(--primario-chiaro); }
.opzione.nonso { border-style: dashed; color: var(--tenue); }
.opzione .lettera { font-weight: 700; color: var(--tenue); min-width: 1.2em; }
.domanda input:disabled + .lettera, .domanda.bloccata .opzione { cursor: default; }
.corr-riga { display: grid; gap: 6px; grid-template-columns: 1fr; padding: 8px 0; border-bottom: 1px dashed var(--bordo); }
@media (min-width: 640px) { .corr-riga { grid-template-columns: 1fr 1fr; align-items: center; } }
.domanda-azioni { margin-top: 12px; display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.confermata { color: var(--verde); font-weight: 600; font-size: .9rem; }
.invio-box { text-align: center; padding: 24px 16px; }

/* ---------- Risultati e schede ---------- */
.area-riga { display: grid; grid-template-columns: minmax(140px, 1.3fr) 2fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--bordo); font-size: .93rem; }
.area-riga:last-child { border-bottom: 0; }
.area-riga .pct { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.5em; text-align: right; }
.esito-corretta { color: var(--verde); font-weight: 600; }
.esito-errata { color: var(--rosso); font-weight: 600; }
.esito-nonso, .esito-vuota, .esito-nv { color: var(--tenue); }
.risposta-data { white-space: pre-line; background: #f6f7f6; border-left: 3px solid var(--primario); padding: 6px 10px; border-radius: 0 6px 6px 0; margin: 6px 0; }
.scelte-dist { font-size: .85rem; color: var(--tenue); margin-top: 6px; }

.gruppo-card h3 { display: flex; justify-content: space-between; gap: 10px; }
.membri { list-style: none; padding: 0; margin: 0; }
.membri li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bordo); font-size: .93rem; align-items: center; }
.membri li:last-child { border-bottom: 0; }
.membri select { width: auto; min-height: 32px; padding: 3px 8px; font-size: .85rem; }

.log { font-size: .85rem; }
.log td { padding: 6px 10px !important; }

.editor-opzione { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.editor-opzione input[type=radio] { width: 18px; height: 18px; }

@media print {
  .topbar, .azioni, .btn, .mainnav { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
