:root {
  --primary: #066a6a; --primary-dark: #044f4f; --primary-soft: #e3f2f2;
  --surface: #fbfbfb; --card: #ffffff; --text: #0a0a0a; --muted: #505050; --border: #e0e0e0;
  --ok: #1b7f3b; --ok-soft: #e4f5ea; --warn: #8a5a00; --warn-soft: #fff4d6; --bad: #b3261e; --bad-soft: #fdeaea;
  --radius: 12px; --shadow: 0 4px 14px rgba(0,0,0,.08); --max: 76rem;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.55; color: var(--text); background: var(--surface); }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--primary-soft); padding: .1rem .4rem; border-radius: 6px; }

/* Barra superiore */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.topbar-inner { max-width: var(--max); margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.brand { color: var(--primary); font-weight: 700; font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.school-logo { height: 2.4rem; width: 2.4rem; object-fit: contain; border-radius: 8px; }

.container { max-width: var(--max); margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card + .card, .card + section, section + .card { margin-top: 1.25rem; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.2; }
h2 { font-size: 1.25rem; margin-bottom: .75rem; }
.subtitle, .muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Pulsanti */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--card); cursor: pointer; font-weight: 600; transition: background .15s, transform .05s; }
.btn:hover { background: #f1f1f1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--bad); border-color: #e7b9b6; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 36px; padding: .25rem .65rem; font-size: .9rem; }

/* Form */
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin: 1.25rem 0; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field input, .field select, .input { width: 100%; min-height: 46px; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.field input:focus, .field select:focus, .input:focus { outline: 2px solid var(--primary); outline-offset: 1px; background: #fff; }
.code-input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }

/* Messaggi */
.notice { margin-top: 1rem; padding: .9rem 1rem; border-radius: 10px; border: 1px solid; font-weight: 600; }
.notice.ok { background: var(--ok-soft); border-color: #a8dcb8; color: var(--ok); }
.notice.warn { background: var(--warn-soft); border-color: #f0d890; color: var(--warn); }
.notice.err { background: var(--bad-soft); border-color: #efb8b4; color: var(--bad); }
.notice.info { background: var(--primary-soft); border-color: #b5dada; color: var(--primary-dark); }

/* Passaggi (pagina studente) */
.steps { list-style: none; display: grid; gap: .75rem; margin-top: 1rem; }
.steps li { display: flex; gap: .85rem; padding: .85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.step-n { flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.steps h3 { font-size: 1rem; }
.layout-2 { display: grid; gap: 1.25rem; }
@media (min-width: 900px) { .layout-2 { grid-template-columns: 1.1fr .9fr; align-items: start; } .layout-2 > .card { margin-top: 0 !important; } }
