/* RUI Tracker — design system (SPEC §11). Mobile first: ≤640 mobile, 641–1024 tablet, >1024 desktop.
   Nessuno stile inline nell'HTML: la CSP consente solo questo file. */

/* ---------------------------------------------------------------- Token */
:root {
    --c-primary: #1B3A6B;
    --c-accent: #2563EB;
    --c-accent-hover: #1D4ED8;
    --c-text: #111827;
    --c-muted: #6B7280;
    --c-bg: #F3F4F6;
    --c-surface: #FFFFFF;
    --c-border: #E5E7EB;
    --c-success: #059669;
    --c-warning: #D97706;
    --c-danger: #DC2626;

    /* Varianti più scure per il testo colorato: i token sopra, su sfondo bianco, non raggiungono
       il contrasto AA per il testo normale (vedi docs/DECISIONI.md). */
    --c-success-text: #047857;
    --c-warning-text: #B45309;
    --c-muted-strong: #4B5563;

    --radius: 8px;
    --shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
    --header-h: 56px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }

a { color: var(--c-accent); }
a:hover { color: var(--c-accent-hover); }

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

img, svg { max-width: 100%; }
code, pre { font-family: var(--font-mono); }

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dot { width: 10px; height: 10px; flex-shrink: 0; }

/* ---------------------------------------------------------------- Utilità */
.visually-hidden {
    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: -9999px;
    top: 8px;
    z-index: 100;
    padding: 8px 12px;
    background: var(--c-surface);
    color: var(--c-accent);
    border-radius: 6px;
}
.skip-link:focus { left: 16px; }

[hidden] { display: none !important; }

.muted { color: var(--c-muted); }
.inline-form { display: inline; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > * { margin: 0; }

.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* minmax(0, …): le colonne non si allargano sul contenuto (es. tabelle), che scorre nel proprio riquadro */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }

.is-ok { color: var(--c-success-text); }
.is-near { color: var(--c-warning-text); }
.is-low { color: var(--c-danger); }

/* ---------------------------------------------------------------- Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--c-primary);
    color: #FFFFFF;
}

.app-header__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--header-h);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}
.layout-admin .app-header__inner { max-width: none; }

.brand {
    color: #FFFFFF;
    font-size: 1.125rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.brand:hover { color: #FFFFFF; }

.nav-toggle { flex-shrink: 0; }

.brand__role {
    display: none; /* su mobile non c'è spazio: visibile da tablet in su */
    margin-left: 6px;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
}

.top-nav { display: none; }

.app-header__user { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    min-width: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #FFFFFF;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.header-link:hover { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }
.header-link[aria-current="page"] { background: rgba(255, 255, 255, 0.18); }

.header-link__text {
    max-width: 12ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- Area studente */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    color: var(--c-muted-strong);
    font-size: 0.75rem;
    text-decoration: none;
}
.bottom-nav__item:hover { color: var(--c-accent); }
.bottom-nav__item[aria-current="page"] { color: var(--c-accent); font-weight: 700; }

.bottom-nav__icon { display: flex; align-items: center; justify-content: center; }

.bottom-nav__item--primary .bottom-nav__icon {
    width: 52px;
    height: 52px;
    margin-top: -32px; /* 52 − 32 = 20 px, come le altre icone: le etichette restano allineate */
    border-radius: 50%;
    background: var(--c-accent);
    color: #FFFFFF;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}
.bottom-nav__item--primary .icon { width: 26px; height: 26px; }
.bottom-nav__item--primary { color: var(--c-accent); font-weight: 600; }

/* ---------------------------------------------------------------- Pannello docente */
.admin-main { padding: 16px; min-width: 0; }

.sidebar { background: var(--c-primary); }

.js .sidebar { display: none; }
.js .sidebar.is-open { display: block; }

.sidebar__list { list-style: none; margin: 0; padding: 8px; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
}
.sidebar__link:hover { background: rgba(255, 255, 255, 0.1); color: #FFFFFF; }
.sidebar__link[aria-current="page"] { background: rgba(255, 255, 255, 0.18); color: #FFFFFF; font-weight: 600; }

/* ---------------------------------------------------------------- Pagine pubbliche */
.guest-header {
    display: flex;
    align-items: center;
    min-height: var(--header-h);
    padding: 0 16px;
    background: var(--c-primary);
}

.guest-main { max-width: 440px; margin: 32px auto; padding: 0 16px; }

.site-footer { padding: 24px 16px; text-align: center; font-size: 0.875rem; }

/* ---------------------------------------------------------------- Card e pagina */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.page-head h1, .page-head p { margin: 0; }
.page-head__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.card {
    padding: 16px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card__title { font-size: 1.125rem; margin: 0 0 12px; }

/* ---------------------------------------------------------------- Indicatori */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.kpi { padding: 14px; }
.kpi__label { margin: 0 0 4px; color: var(--c-muted); font-size: 0.8125rem; font-weight: 600; }
.kpi__value { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi__note { margin: 4px 0 0; color: var(--c-muted); font-size: 0.8125rem; }

.week-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}
.week-strip__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2px 0;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 0.6875rem;
    line-height: 1.3;
}
.week-strip__day.is-active { background: var(--c-success-text); border-color: var(--c-success-text); color: #FFFFFF; }

/* ---------------------------------------------------------------- Pulsanti */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--c-accent); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--c-accent-hover); color: #FFFFFF; }

.btn-secondary { background: var(--c-surface); border-color: var(--c-muted); color: var(--c-text); }
.btn-secondary:hover:not(:disabled) { background: var(--c-bg); color: var(--c-text); }

.btn-danger { background: var(--c-danger); color: #FFFFFF; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; color: #FFFFFF; }

.btn-ghost { background: transparent; color: var(--c-accent); }
.btn-ghost:hover:not(:disabled) { background: #EFF6FF; }

.btn-block { width: 100%; }

/* ---------------------------------------------------------------- Moduli */
.field { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }

.field__label { display: block; margin-bottom: 6px; padding: 0; font-weight: 600; }
.field__help { margin: 6px 0 0; color: var(--c-muted); font-size: 0.875rem; }
.field__error { margin: 6px 0 0; color: var(--c-danger); font-size: 0.875rem; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--c-muted);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: 1rem; /* 16px: evita lo zoom automatico su iOS */
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--c-accent); }
[aria-invalid="true"] { border-color: var(--c-danger); }

.select-inline { width: auto; }

.checkbox { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding-top: 10px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--c-accent); flex-shrink: 0; }

.form-errors {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--c-danger);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: #FEF2F2;
}

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* Mostra/nascondi password (D-15): il pulsante compare solo con JavaScript attivo */
.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 44px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--c-muted-strong);
    cursor: pointer;
}
.password-toggle:hover { color: var(--c-accent); }
.password-toggle span { display: flex; }
.password-toggle[aria-pressed="true"] .password-toggle__show,
.password-toggle[aria-pressed="false"] .password-toggle__hide { display: none; }

/* Elenco di verifiche con esito (installer, manutenzione) */
.check-list { margin: 0; padding: 0; list-style: none; }
.check-list li { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.check-list__detail { display: block; color: var(--c-text); font-size: 0.875rem; }

/* Colonna stretta per moduli e schede singole dentro le aree con menu */
.narrow { max-width: 560px; }

/* Elenco etichetta → valore (profilo, dettagli) */
.data-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.data-list dt { color: var(--c-muted); font-weight: 600; }
.data-list dd { margin: 0; }

/* Testi lunghi (informativa) */
.prose h2 { margin-top: 8px; font-size: 1.125rem; }

.code-display { margin: 0; font-family: var(--font-mono); font-size: 1.75rem; font-weight: 700; letter-spacing: 0.08em; }

/* Scelte a pulsanti (giorno, tipo di test): radio nascosti ma raggiungibili da tastiera */
.choice-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.choice-input:focus-visible + label { outline: 3px solid var(--c-accent); outline-offset: 2px; }

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--c-muted);
    border-radius: var(--radius);
    overflow: hidden;
}
.segmented label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    background: var(--c-surface);
    font-weight: 600;
    cursor: pointer;
}
.segmented label + input + label { border-left: 1px solid var(--c-muted); }
.segmented .choice-input:checked + label { background: var(--c-accent); color: #FFFFFF; }

.day-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day-picker__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--c-muted);
    border-radius: var(--radius);
    background: var(--c-surface);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}
.choice-input:checked + .day-picker__btn { background: var(--c-accent); border-color: var(--c-accent); color: #FFFFFF; }
.choice-input:disabled + .day-picker__btn { background: var(--c-bg); border-color: var(--c-border); color: #9CA3AF; cursor: not-allowed; }

.score-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.score-row input { width: 5.5rem; text-align: center; }
.score-preview { margin: 8px 0 0; font-weight: 700; }
.score-preview:empty { display: none; }

/* ---------------------------------------------------------------- Modulo report (§6.3) */
/* Passi numerati con un contatore CSS: la materia nascosta per Omnia non conta */
.report-form { counter-reset: step; }
.report-step:not([hidden]) .report-step__num::before { counter-increment: step; content: counter(step); }
.report-step__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--c-primary);
    color: #FFFFFF;
    font-size: 0.8125rem;
    vertical-align: 1px;
}
.report-step { margin-bottom: 20px; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.week-nav__label { color: var(--c-muted-strong); font-size: 0.9375rem; font-weight: 600; text-align: center; }
.week-nav__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
}
.week-nav__arrow.is-disabled { color: #9CA3AF; background: var(--c-bg); }

.day-picker__btn { flex-direction: column; gap: 2px; min-height: 52px; line-height: 1.1; }
.day-picker__num { font-size: 1rem; }
.day-label { margin: 8px 0 0; color: var(--c-muted-strong); font-weight: 600; }

.subject-select { display: none; }
.subject-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.subject-grid__btn {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 6px 10px;
    border: 1px solid var(--c-muted);
    border-radius: var(--radius);
    background: var(--c-surface);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}
.choice-input:checked + .subject-grid__btn {
    border-color: var(--c-accent);
    background: #EFF6FF;
    box-shadow: inset 0 0 0 1px var(--c-accent);
}

.report-actions .btn { flex: 1 1 auto; }
.danger-zone { margin-top: 16px; text-align: center; }
.btn-danger-text { color: var(--c-danger); }
.btn-danger-text:hover:not(:disabled) { background: #FEF2F2; color: #B91C1C; }
.btn-small { padding: 0 10px; font-size: 0.875rem; }

/* ---------------------------------------------------------------- Storico (§6.4) */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}
.filters .field { margin: 0; }
.filters__actions { display: flex; gap: 8px; }

.empty-state { text-align: center; }

.week { margin-bottom: 16px; }
.week__title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 1.0625rem; }

.week-check {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.week-check__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    color: var(--c-muted-strong);
    font-size: 0.75rem;
    line-height: 1.3;
}
.week-check__mark { font-size: 0.875rem; font-weight: 700; }
.week-check__day.is-done { background: var(--c-success-text); border-color: var(--c-success-text); color: #FFFFFF; }

.report-list { margin: 12px 0 0; padding: 0; list-style: none; }
.report-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px 0;
    border-top: 1px solid var(--c-border);
}
.report-item__what { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.report-item__date { color: var(--c-muted); font-size: 0.875rem; }
.report-item__name { font-weight: 600; overflow-wrap: anywhere; }
.badge-subject { white-space: normal; }
.report-item__score { text-align: right; font-variant-numeric: tabular-nums; }
.report-item__percent { display: block; font-size: 1.125rem; font-weight: 700; white-space: nowrap; }
.report-item__raw { color: var(--c-muted); font-size: 0.875rem; }
.report-item__actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 4px; }
.report-item__note { grid-column: 1 / -1; margin: 0; color: var(--c-muted-strong); font-size: 0.875rem; white-space: pre-line; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

/* ---------------------------------------------------------------- Dashboard (§6.5) */
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.dashboard > .card { margin: 0; }
.dashboard__kpi .kpi-grid { margin: 0; }

.exam-countdown {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--c-primary);
    border-color: var(--c-primary);
    color: #FFFFFF;
}
.exam-countdown p { margin: 0; }
.exam-countdown__number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.exam-countdown__number .icon { width: 40px; height: 40px; }
.exam-countdown__title { font-size: 1.125rem; font-weight: 700; }
.exam-countdown__date { color: rgba(255, 255, 255, 0.85); }

.card__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }

.period-filter {
    display: grid;
    grid-template-columns: repeat(4, auto);
    border: 1px solid var(--c-muted);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--c-surface);
}
.period-filter a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 12px;
    color: var(--c-text);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}
.period-filter a + a { border-left: 1px solid var(--c-muted); }
.period-filter a[aria-current="true"] { background: var(--c-accent); color: #FFFFFF; }

.chart-hint { margin: 0 0 8px; font-size: 0.8125rem; }
.chart-box { position: relative; height: 300px; }
/* Rete di sicurezza: il grafico non esce mai dal riquadro, anche prima che Chart.js lo ridimensioni */
.chart-box canvas { max-width: 100%; }
.chart-box--bars { height: 220px; margin-top: 16px; }
.chart-box--error { height: auto; }
.chart-data { margin-top: 12px; }
.chart-data summary { min-height: 44px; display: flex; align-items: center; color: var(--c-accent); font-weight: 600; cursor: pointer; }

.subject-name { display: inline-flex; align-items: center; gap: 8px; }
.trend { font-size: 1.125rem; font-weight: 700; }
.trend--su { color: var(--c-success-text); }
.trend--giu { color: var(--c-danger); }
.trend--stabile { color: var(--c-muted-strong); }

.summary-row { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0 0 12px; }
.summary-row dt { color: var(--c-muted); font-size: 0.8125rem; font-weight: 600; }
.summary-row dd { margin: 0; font-size: 1.125rem; font-weight: 700; }

.strengths { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.strengths__title { font-size: 1rem; }
.strengths__list { margin: 0; padding: 0; list-style: none; }
.strengths__list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--c-border); }
.strengths__list strong { margin-left: auto; }

/* ---------------------------------------------------------------- Obiettivi (§6.6, D-35) */
.objective-group { margin: 16px 0 8px; color: var(--c-muted-strong); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.04em; }
.objective-count { margin: 0 0 12px; }

.objective {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-accent);
    border-radius: var(--radius);
    background: var(--c-surface);
}
.objective--settimana { border-left-color: var(--c-primary); }
.objective--weekend { border-left-color: #7C3AED; }
.objective.is-done { background: #F0FDF4; border-color: #BBF7D0; border-left-color: var(--c-success-text); }

.objective__body { flex: 1; min-width: 0; }
.objective__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 4px; color: var(--c-muted); font-size: 0.8125rem; }
.objective__period { color: var(--c-muted-strong); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.objective__title { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.objective.is-done .objective__title { color: var(--c-muted-strong); }
.objective__target { margin: 4px 0 0; font-size: 0.9375rem; }
.objective__text { margin: 6px 0 0; color: var(--c-muted-strong); font-size: 0.9375rem; overflow-wrap: anywhere; }
.objective__details summary { min-height: 44px; display: flex; align-items: center; color: var(--c-accent); font-size: 0.9375rem; font-weight: 600; cursor: pointer; }
.objective__details .objective__text { margin-top: 0; }

.objective__form { flex-shrink: 0; margin: 0; }
.objective__check {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 56px;
    min-height: 56px;
    padding: 4px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--c-muted-strong);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}
.objective__check:hover { background: var(--c-bg); }
.objective__box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 2px solid var(--c-muted);
    border-radius: 6px;
    background: var(--c-surface);
}
.objective__box .icon { width: 18px; height: 18px; stroke-width: 3; visibility: hidden; }
.objective__check[aria-pressed="true"] { color: var(--c-success-text); }
.objective__check[aria-pressed="true"] .objective__box { border-color: var(--c-success-text); background: var(--c-success-text); color: #FFFFFF; }
.objective__check[aria-pressed="true"] .objective__box .icon { visibility: visible; }

/* Profilo: area di eliminazione dell'account */
.danger-card { border-color: #FECACA; }
.danger-card h2 { color: var(--c-danger); }

/* ---------------------------------------------------------------- Pannello docente: pagine */
.breadcrumb { margin: 0 0 8px; font-size: 0.9375rem; }
.breadcrumb a { text-decoration: none; }
.section-title { margin: 24px 0 12px; font-size: 1.25rem; }
.table-hint { margin: 0 0 8px; font-size: 0.8125rem; }
.table-sub { display: block; color: var(--c-muted); font-size: 0.8125rem; overflow-wrap: anywhere; }
.code-inline { padding: 2px 6px; border-radius: 4px; background: var(--c-bg); }
.badge-warning { background: #FFFBEB; border-color: var(--c-warning); color: var(--c-warning-text); }
.badge-success { background: #ECFDF5; border-color: var(--c-success); color: var(--c-success-text); }

/* Intestazioni ordinabili: il pulsante occupa tutta la cella */
.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.sort-btn::after { content: "↕"; opacity: 0.5; font-size: 0.8125rem; }
[aria-sort="ascending"] .sort-btn::after { content: "↑"; opacity: 1; }
[aria-sort="descending"] .sort-btn::after { content: "↓"; opacity: 1; }

/* Elenchi a schede del pannello (aule, materie, obiettivi) */
.admin-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
.admin-item__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.admin-item__title { margin: 0; font-size: 1.0625rem; overflow-wrap: anywhere; }
.admin-item__meta { margin: 4px 0 0; color: var(--c-muted-strong); font-size: 0.9375rem; }
.admin-item__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.admin-item.is-archived { background: var(--c-bg); }

.check-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
.inline-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.inline-fields--3 { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.section-gap { margin-top: 24px; }
.pdf-details { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--c-border); }
.pdf-details summary { min-height: 44px; display: flex; align-items: center; color: var(--c-accent); font-weight: 600; cursor: pointer; }
.danger-details { margin-top: 12px; padding-top: 8px; border-top: 1px solid #FECACA; }
.danger-details summary { min-height: 44px; display: flex; align-items: center; color: var(--c-danger); font-weight: 600; cursor: pointer; }
input[type="color"] { width: 64px; min-height: 44px; padding: 4px; border: 1px solid var(--c-muted); border-radius: var(--radius); background: var(--c-surface); }

/* Obiettivi nel pannello: stesso colore di bordo per periodo della scheda studente */
.admin-item.objective--giorno { border-left: 4px solid var(--c-accent); }
.admin-item.objective--settimana { border-left: 4px solid var(--c-primary); }
.admin-item.objective--weekend { border-left: 4px solid #7C3AED; }
.completion-list { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.9375rem; }
.duplicate-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--c-border); }
.duplicate-form .field__label { font-size: 0.875rem; }

/* Confronto aule (§7.4): celle colorate con simbolo */
.matrix td.is-ok, .matrix td.is-near, .matrix td.is-low { font-weight: 700; }
.matrix th[scope="row"] { background: var(--c-surface); color: var(--c-text); white-space: normal; }

.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--c-border); overflow-wrap: anywhere; }
.plain-list li:last-child { border-bottom: 0; }
.alert-card { margin-bottom: 16px; border-color: var(--c-warning); border-left-width: 4px; }

/* Registro attività */
.audit-detail { margin: 0; font-family: var(--font-mono); font-size: 0.8125rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Tabelle */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th {
    padding: 10px 12px;
    background: var(--c-primary);
    color: #FFFFFF;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr:nth-child(even) { background: var(--c-bg); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------------------------------------- Etichette e messaggi */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    background: var(--c-surface);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-omnia { background: var(--c-primary); border-color: var(--c-primary); color: #FFFFFF; }

.alert {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid;
    border-left-width: 4px;
    border-radius: var(--radius);
}
.alert-info { background: #EFF6FF; border-color: var(--c-accent); }
.alert-success { background: #ECFDF5; border-color: var(--c-success); }
.alert-warning { background: #FFFBEB; border-color: var(--c-warning); }
.alert-danger { background: #FEF2F2; border-color: var(--c-danger); }
.alert-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------------------------------------------------------------- Pagine d'errore */
.error-card { text-align: center; }
.error-card__code { margin: 0; color: var(--c-primary); font-size: 3rem; font-weight: 800; line-height: 1; }
.error-card__id { padding: 4px 8px; border-radius: 6px; background: var(--c-bg); font-size: 1.125rem; }

.debug-box {
    max-height: 60vh;
    overflow: auto;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--c-text);
    color: #F9FAFB;
    font-size: 0.75rem;
    text-align: left;
    white-space: pre-wrap;
}

/* ---------------------------------------------------------------- Tablet e oltre */
@media (min-width: 641px) {
    h1 { font-size: 1.75rem; }

    .brand__role { display: inline; }

    .top-nav { display: flex; gap: 4px; margin-left: 24px; }
    .top-nav a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding: 0 12px;
        border-radius: 6px;
        color: rgba(255, 255, 255, 0.92);
        text-decoration: none;
    }
    .top-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }
    .top-nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.18); color: #FFFFFF; font-weight: 600; }

    .bottom-nav { display: none; }
    .app-main { padding: 24px; }
    .admin-main { padding: 24px; }
    .card { padding: 20px; }
    .kpi { padding: 16px; }

    .subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .strengths { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-box { height: 340px; }
    .admin-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-item__what { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
    .report-item__date { min-width: 7.5rem; }
}

/* ---------------------------------------------------------------- Desktop */
@media (min-width: 1025px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard__wide { grid-column: 1 / -1; }
    .dashboard__kpi .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

    /* Materia: select su desktop, griglia di pulsanti su mobile e tablet (§6.3) */
    .subject-select { display: block; }
    .subject-grid { display: none; }

    .nav-toggle { display: none; }
    .admin-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
    .sidebar,
    .js .sidebar {
        display: block;
        position: sticky;
        top: var(--header-h);
        height: calc(100vh - var(--header-h));
        overflow-y: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
