/* ============================================================
   SCUOLA GUIDA — Design System
   Stile coerente, ispirato alla pagina di svolgimento del quiz.
   ============================================================ */

:root {
    /* ── Shell: sidebar, navbar, intestazioni scure ─────────────────────────
       --sg-shell-text su --sg-shell-bg: #e6ebf0 su #1e2a38 → 10.88:1 ✓ WCAG AA */
    --sg-shell-bg:          #1e2a38;
    --sg-shadow-sm:         0 1px 4px rgba(0, 0, 0, .06);
    --sg-shell-bg-elevated: #25323f;
    --sg-shell-text:        #e6ebf0;
    --sg-shell-text-muted:  #9fb0c0;

    /* ── Accent di brand (costante, non più configurabile dall'admin) ────────
       --sg-accent-text (#fff) su --sg-accent (#3c8dbc) → 3.37:1.
       Adatto a testo grande/grassetto (pulsanti, CTA ≥ 14pt bold) ≥ 3:1 ✓ WCAG AA large text. */
    --sg-accent:       #3c8dbc;
    --sg-accent-hover: #347aa3;
    --sg-accent-text:  #ffffff;

    /* ── Superfici chiare (contenuto) ───────────────────────────────────────  */
    --sg-surface:       #ffffff;
    --sg-surface-muted: #f4f6f8;
    --sg-border:        #e3e8ee;
    --sg-text:          #1f2933;
    --sg-text-muted:    #6b7785;

    /* ── Stati semantici (desaturati rispetto ai bootstrap puri) ────────────  */
    --sg-success: #2f9e6f;
    --sg-warning: #d9a420;
    --sg-danger:  #c0392b;
    --sg-info:    #3c8dbc;

    /* ── Colori di ruolo (badge + accento sidebar lotto 15.1) ───────────────
       Contrasto *-text su *: verificato per badge (WCAG AA normal text ≥ 4.5:1) */
    --sg-role-admin:           #c0392b;  /* #fff su #c0392b → 5.06:1 ✓ */
    --sg-role-admin-text:      #ffffff;
    --sg-role-editor:          #2f6f9e;  /* #fff su #2f6f9e → 4.92:1 ✓ */
    --sg-role-editor-text:     #ffffff;
    --sg-role-viewer:          #d9a420;  /* #1f2933 su #d9a420 → 6.00:1 ✓ */
    --sg-role-viewer-text:     #1f2933;
    --sg-role-instructor:      #267348;  /* #fff su #267348 → 5.81:1 ✓ */
    --sg-role-instructor-text: #ffffff;

    /* ── Tipografia: Inter, scala condivisa tra area admin e guest ──────────  */
    --sg-font:        'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --sg-fs-xs:       .75rem;
    --sg-fs-sm:       .875rem;
    --sg-fs-base:     1rem;
    --sg-fs-lg:       1.125rem;
    --sg-fs-xl:       1.5rem;
    --sg-fs-2xl:      2rem;
    --sg-fs-3xl:      2.5rem;
    --sg-fw-normal:   400;
    --sg-fw-medium:   500;
    --sg-fw-semibold: 600;
    --sg-fw-bold:     700;

    /* ── Arrotondamento bordi (costante, non più configurabile dall'admin) ── */
    --sg-radius:      .5rem;
    --sg-radius-sm:   .375rem;
    --sg-radius-pill: 20px;

    /* ── Transizione micro-interazioni ──────────────────────────────────────  */
    --sg-transition: all .2s ease;

    /* ── Token legacy — usati dalle classi esistenti; non rimuovere ─────────  */
    --sg-dark-1:           #1a1a2e;
    --sg-dark-2:           #16213e;
    --sg-dark-3:           #343a40;
    --sg-primary:          #4361ee;
    --sg-success-2:        #20c997;
    --sg-text-soft:        #adb5bd;
    --sg-border-light:     #f1f3f5;
    --sg-bg-soft:          #f8f9fb;
    --sg-shadow-card:      0 4px 20px rgba(0, 0, 0, .08);
    --sg-shadow-hover:     0 6px 16px rgba(0, 0, 0, .18);
    --sg-gradient-dark:    linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --sg-gradient-success: linear-gradient(90deg, #28a745, #20c997);
    --sg-gradient-blue:    linear-gradient(135deg, #4361ee, #4cc9f0);
    --sg-gradient-orange:  linear-gradient(135deg, #ff7e00, #ffc107);
    --sg-gradient-red:     linear-gradient(135deg, #dc3545, #e83e8c);
    --sg-navbar-height:    56px;
}

/* Tipografia globale: Inter applicata a tutte le aree (admin e guest). */
body {
    font-family: var(--sg-font);
}

/* ── Layout container ─────────────────────────────────────── */
.sg-wrapper {
    max-width: 1100px;
    margin: 0 auto;
}
.sg-wrapper-fluid {
    max-width: none;
    margin: 0;
}
.sg-wrapper-sm { max-width: 720px; margin: 0 auto; }

/* ── Page header compatto (15.1) ─────────────────────────── */
.sg-header {
    background: var(--sg-surface-muted);
    border-radius: var(--sg-radius) var(--sg-radius) 0 0;
    padding: 14px 24px 16px;
    margin-bottom: 0;
    color: var(--sg-text);
    box-shadow: none;
    border-bottom: 2px solid var(--sg-border);
}
.sg-header.compact { padding: 10px 20px 12px; }
.sg-header-title {
    font-size: var(--sg-fs-2xl);
    font-weight: var(--sg-fw-semibold);
    letter-spacing: -.2px;
    margin: 0;
    color: var(--sg-text);
}
.sg-header-subtitle,
.sg-header .sg-subtle {
    font-size: var(--sg-fs-sm);
    color: var(--sg-text-muted);
    margin-bottom: 4px;
    letter-spacing: .2px;
}
.sg-header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Card morbida ─────────────────────────────────────────── */
.sg-card {
    border: none;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
    background: #fff;
    overflow: hidden;
}
.sg-card-body { padding: 1.75rem; }
.sg-card-body-tight { padding: 1.25rem; }
.sg-card-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--sg-border-light);
}
.sg-card-section:last-child { border-bottom: none; }
.sg-card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--sg-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.sg-card-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sg-text);
    margin: 0;
    letter-spacing: .2px;
}
.sg-card-danger { border-top: 4px solid var(--sg-danger); }

/* ── Etichette e badge ───────────────────────────────────── */
.sg-label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--sg-text-soft);
    margin-bottom: 6px;
}
.sg-badge {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--sg-radius-pill);
    letter-spacing: .5px;
    text-transform: uppercase;
}
.sg-badge-success { background: #d4edda; color: #155724; }
.sg-badge-danger  { background: #f8d7da; color: #721c24; }
.sg-badge-warning { background: #fff3cd; color: #856404; }
.sg-badge-info    { background: #d1ecf1; color: #0c5460; }

/* ── Page title ─────────────────────────────────────────── */
.sg-page-title {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--sg-text);
    margin: 0 0 18px;
    letter-spacing: -.3px;
}

/* ── Bottoni ─────────────────────────────────────────────── */
.sg-btn {
    padding: 11px 22px;
    font-weight: 700;
    letter-spacing: .5px;
    border-radius: var(--sg-radius-sm);
    border: 2px solid transparent;
    transition: transform .12s ease, box-shadow .12s ease, opacity .15s, background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: .92rem;
    text-decoration: none !important;
    cursor: pointer;
    line-height: 1.2;
}
.sg-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--sg-shadow-hover);
}
.sg-btn:active:not(:disabled) { transform: translateY(0); }
.sg-btn:disabled { opacity: .55; cursor: not-allowed; }
.sg-btn-block { width: 100%; }
.sg-btn-sm { padding: 7px 14px; font-size: .8rem; letter-spacing: .3px; }

.sg-btn-primary {
    background: var(--sg-dark-1);
    color: #fff;
    border-color: var(--sg-dark-1);
}
.sg-btn-primary:hover { color: #fff; background: #0e0e1f; border-color: #0e0e1f; }

.sg-btn-success {
    background: var(--sg-success);
    color: #fff;
    border-color: var(--sg-success);
}
.sg-btn-success:hover { color: #fff; }

.sg-btn-danger {
    background: var(--sg-danger);
    color: #fff;
    border-color: var(--sg-danger);
}
.sg-btn-danger:hover { color: #fff; }

.sg-btn-outline {
    background: transparent;
    color: var(--sg-dark-1);
    border-color: var(--sg-dark-1);
}
.sg-btn-outline:hover { background: var(--sg-dark-1); color: #fff; }

.sg-btn-light {
    background: #fff;
    color: var(--sg-text);
    border-color: var(--sg-border);
}
.sg-btn-light:hover { background: #f8f9fa; color: var(--sg-text); }

/* ── Form controls ───────────────────────────────────────── */
.sg-form-group { margin-bottom: 1.1rem; }
.sg-form-label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
    letter-spacing: .2px;
}
.sg-form-control {
    width: 100%;
    height: auto;
    padding: 10px 14px 14px;
    font-size: .95rem;
    line-height: 1.6;
    color: var(--sg-text);
    background-color: #fff;
    border: 1.5px solid #e0e3e7;
    border-radius: var(--sg-radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.sg-form-control:focus {
    outline: none;
    border-color: var(--sg-dark-1);
    box-shadow: 0 0 0 3px rgba(26, 26, 46, .1);
}
.sg-form-control.is-invalid {
    border-color: var(--sg-danger);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, .08);
}
.sg-form-error {
    color: var(--sg-danger);
    font-size: .82rem;
    margin-top: 5px;
    font-weight: 500;
}
.sg-form-hint {
    color: var(--sg-text-muted);
    font-size: .82rem;
    margin-top: 5px;
}
.sg-form-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    color: var(--sg-text-muted);
    cursor: pointer;
}
.sg-form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--sg-dark-1);
}

/* ── Link ────────────────────────────────────────────────── */
.sg-link {
    color: var(--sg-dark-1);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 500;
    transition: color .15s;
}
.sg-link:hover { color: var(--sg-primary); text-decoration: underline; }
.sg-link-muted { color: var(--sg-text-muted); }
.sg-link-muted:hover { color: var(--sg-text); }

/* ── Tabelle ─────────────────────────────────────────────── */
.sg-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}
.sg-table thead th {
    background: var(--sg-bg-soft);
    color: var(--sg-text-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 14px 18px;
    border: none;
    text-align: left;
}
.sg-table tbody td {
    padding: 14px 18px;
    border-top: 1px solid var(--sg-border-light);
    vertical-align: middle;
    color: var(--sg-text);
    font-size: .92rem;
}
.sg-table tbody tr:hover { background: var(--sg-bg-soft); }
.sg-table-empty {
    padding: 32px 22px;
    text-align: center;
    color: var(--sg-text-muted);
}

/* ── KPI / Stat cards ────────────────────────────────────── */
.sg-stat-card {
    background: #fff;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform .15s, box-shadow .15s;
    text-decoration: none !important;
    color: var(--sg-text);
}
.sg-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--sg-shadow-hover);
    color: var(--sg-text);
}
.sg-stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    color: #fff;
    flex-shrink: 0;
}
.sg-stat-icon.grad-blue   { background: var(--sg-gradient-blue); }
.sg-stat-icon.grad-green  { background: var(--sg-gradient-success); }
.sg-stat-icon.grad-orange { background: var(--sg-gradient-orange); }
.sg-stat-icon.grad-red    { background: var(--sg-gradient-red); }
.sg-stat-icon.grad-dark   { background: var(--sg-gradient-dark); }
.sg-stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    color: var(--sg-text);
    font-variant-numeric: tabular-nums;
}
.sg-stat-label {
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--sg-text-muted);
    margin-top: 6px;
}

/* ── Progress bar ────────────────────────────────────────── */
.sg-progress {
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .15);
    overflow: hidden;
}
.sg-progress .bar {
    height: 100%;
    border-radius: 4px;
    background: var(--sg-gradient-success);
    transition: width .4s ease;
}

/* ── Override su Bootstrap card / table / form usate da AdminLTE
       per allineare le viste già esistenti. ──────────────── */
.content-wrapper .card {
    border: none;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
}
.content-wrapper .card > .card-header {
    border-bottom: 1px solid var(--sg-border-light);
    background: #fff;
    border-radius: var(--sg-radius) var(--sg-radius) 0 0;
}
.content-wrapper .small-box {
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
    overflow: hidden;
}
.content-wrapper .small-box > .inner { padding: 18px; }
.content-wrapper .small-box h3 {
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -.5px;
}
.content-wrapper .table {
    margin-bottom: 0;
}
.content-wrapper .table thead th {
    background: var(--sg-bg-soft);
    color: var(--sg-text-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    border: none;
}
.content-wrapper .table tbody td {
    border-top: 1px solid var(--sg-border-light);
    vertical-align: middle;
}
.content-wrapper .form-control {
    border: 1.5px solid #e0e3e7;
    border-radius: var(--sg-radius-sm);
    padding: 10px 14px;
}
.content-wrapper .form-control:focus {
    border-color: var(--sg-dark-1);
    box-shadow: 0 0 0 3px rgba(26, 26, 46, .1);
}
.content-wrapper .btn {
    border-radius: var(--sg-radius-sm);
    font-weight: 600;
    letter-spacing: .2px;
}
.content-wrapper .btn-primary {
    background: var(--sg-dark-1);
    border-color: var(--sg-dark-1);
}
.content-wrapper .btn-primary:hover,
.content-wrapper .btn-primary:focus {
    background: #0e0e1f;
    border-color: #0e0e1f;
}
.content-wrapper .alert {
    border-radius: var(--sg-radius-sm);
    border: none;
}
.content-wrapper .badge {
    border-radius: var(--sg-radius-pill);
    padding: 5px 10px;
    font-weight: 700;
    letter-spacing: .3px;
}

/* ============================================================
   COMPONENTI QUIZ (estratti da quiz/play)
   ============================================================ */

.quiz-wrapper { max-width: 1100px; margin: 0 auto; }

.quiz-header {
    background: var(--sg-gradient-dark);
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
    color: #fff;
}
.quiz-title {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: .3px;
    margin: 0;
}
.progress-label {
    font-size: .8rem;
    color: rgba(255, 255, 255, .65);
    margin-bottom: 4px;
}
.quiz-progress {
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .15);
    overflow: hidden;
}
.quiz-progress .bar {
    height: 100%;
    border-radius: 4px;
    background: var(--sg-gradient-success);
    transition: width .4s ease;
}

.question-card {
    border: none;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
}
.question-badge {
    display: inline-block;
    background: var(--sg-border);
    color: #495057;
    font-size: .75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--sg-radius-pill);
    margin-bottom: 16px;
    letter-spacing: .5px;
    text-transform: uppercase;
}
#question-text {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--sg-text);
    min-height: 80px;
}

.answer-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 28px;
}
.btn-answer {
    padding: 18px 12px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    border-radius: var(--sg-radius-sm);
    border: 2px solid transparent;
    transition: transform .12s ease, box-shadow .12s ease, opacity .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-answer[data-value="1"] {
    background: var(--sg-success);
    color: #fff;
    border-color: var(--sg-success);
}
.btn-answer[data-value="0"] {
    background: var(--sg-danger);
    color: #fff;
    border-color: var(--sg-danger);
}
.btn-answer:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--sg-shadow-hover);
}
.btn-answer:active:not(:disabled) { transform: translateY(0); }
.btn-answer:disabled { opacity: .55; cursor: not-allowed; }

#feedback {
    font-size: 1rem;
    font-weight: 600;
    min-height: 28px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.feedback-correct { color: var(--sg-success); }
.feedback-wrong   { color: var(--sg-danger); }

.sidebar-card {
    border: none;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
    overflow: hidden;
}
.sidebar-section {
    padding: 14px 18px;
    border-bottom: 1px solid var(--sg-border-light);
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--sg-text-soft);
    margin-bottom: 6px;
}

#timer {
    font-size: 2.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    line-height: 1;
    color: var(--sg-dark-3);
}
#timer.danger { color: var(--sg-danger); }

.error-dots {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.error-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #dee2e6;
    background: transparent;
    transition: background .2s, border-color .2s;
}
.error-dot.filled {
    background: var(--sg-danger);
    border-color: var(--sg-danger);
}

#navigator {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.nav-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    background: #fff;
    color: #495057;
    transition: transform .1s;
}
.nav-btn:hover { transform: scale(1.1); }
.nav-btn.answered-ok { background: var(--sg-success); border-color: var(--sg-success); color: #fff; }
.nav-btn.answered-ko { background: var(--sg-danger); border-color: var(--sg-danger); color: #fff; }
.nav-btn.current     { border-color: var(--sg-dark-3) !important; box-shadow: 0 0 0 2px rgba(52, 58, 64, .25); }

#finish-quiz {
    width: 100%;
    padding: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    border-radius: var(--sg-radius-sm);
    font-size: .95rem;
}

/* ============================================================
   ROLES / USERS / PERMISSIONS — componenti shared admin
   ============================================================ */

/* ── Avatar utente (lettera iniziale) ── */
.sg-user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c757d, #495057);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 10px;
    flex-shrink: 0;
}

/* ── Badge ruolo ── */
.sg-badge-role {
    display: inline-block;
    font-size: .65rem;
    padding: 4px 10px;
    border-radius: var(--sg-radius-pill);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 700;
}
.sg-badge-role.role-admin  { background: #6f42c1; color: #fff; }      /* contrasto #fff su #6f42c1: 7.27:1 ✓ */
.sg-badge-role.role-editor { background: #fd7e14; color: #212529; }   /* contrasto #212529 su #fd7e14: 4.96:1 ✓ (era #fff: 2.82:1 ✗) */
.sg-badge-role.role-viewer { background: #20c997; color: #212529; }   /* contrasto #212529 su #20c997: 7.79:1 ✓ (era #fff: 2.47:1 ✗) */

/* ── Sezione card form admin (header grigio soft) ── */
.sg-form-section {
    border: none;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
    overflow: hidden;
    background: #fff;
    margin-bottom: 22px;
}
.sg-form-section-header {
    background: #f8f9fa;
    padding: 14px 22px;
    border-bottom: 1px solid #ecedef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.sg-form-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sg-text);
    text-transform: uppercase;
    letter-spacing: .8px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.sg-form-section-title i { color: var(--sg-text-muted); }
.sg-form-section-hint {
    font-size: .8rem;
    color: #6f42c1;
    font-weight: 600;
}
.sg-form-section-body { padding: 1.5rem; }

/* ── Card permessi per entità (usato in users/form) ── */
.sg-perm-entity-card {
    border: 1px solid #ecedef;
    border-radius: var(--sg-radius-sm);
    overflow: hidden;
    background: #fff;
    height: 100%;
}
.sg-perm-entity-head {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 10px 14px;
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sg-perm-entity-head i { color: var(--sg-text-muted); }
.sg-perm-entity-body {
    padding: 8px 14px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

/* ── Toggle permesso individuale (users/form) ── */
.sg-perm-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    margin: 0;
    cursor: pointer;
    transition: background .15s;
}
.sg-perm-toggle:hover { background: #f8f9fa; }
.sg-perm-toggle input { display: none; }
.sg-perm-toggle .dot {
    width: 18px; height: 18px;
    border-radius: 5px;
    border: 2px solid #dee2e6;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    flex-shrink: 0;
}
.sg-perm-toggle .dot::after {
    content: '';
    width: 5px; height: 9px;
    border: solid transparent;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
    transition: border-color .15s;
}
.sg-perm-toggle input:checked + .dot {
    background: var(--sg-gradient-success);
    border-color: var(--sg-success);
}
.sg-perm-toggle input:checked + .dot::after {
    border-color: #fff;
}
.sg-perm-toggle .lbl {
    font-size: .85rem;
    color: #495057;
    font-weight: 500;
}

/* ── Checkbox a quadrato grosso (roles matrix) ── */
.sg-perm-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}
.sg-perm-check input { display: none; }
.sg-perm-check .box {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
    color: transparent;
}
.sg-perm-check:hover .box {
    border-color: #adb5bd;
    transform: scale(1.08);
}
.sg-perm-check input:checked + .box {
    background: var(--sg-gradient-success);
    border-color: var(--sg-success);
    color: #fff;
    box-shadow: 0 4px 10px rgba(40, 167, 69, .3);
}
.sg-perm-check.disabled {
    cursor: not-allowed;
    opacity: .6;
}
.sg-perm-check.disabled input:checked + .box {
    background: linear-gradient(135deg, #6f42c1, #5a32a3);
    border-color: #6f42c1;
    box-shadow: 0 4px 10px rgba(111, 66, 193, .3);
}

/* ── Modal stile sg ── */
.sg-modal-content {
    border: none;
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-card);
    overflow: hidden;
}
.sg-modal-header-dark {
    background: var(--sg-gradient-dark);
    color: #fff;
    border: none;
}
.sg-modal-header-dark .close { color: #fff; opacity: .8; }
.sg-modal-header-dark .close:hover { opacity: 1; }

/* ── Save bar sticky in fondo ── */
.sg-save-bar {
    position: sticky;
    bottom: 20px;
    background: #fff;
    border-radius: var(--sg-radius);
    box-shadow: 0 -2px 20px rgba(0, 0, 0, .1);
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #ecedef;
    z-index: 10;
    gap: 12px;
    flex-wrap: wrap;
}
.sg-save-bar .hint {
    color: var(--sg-text-muted);
    font-size: .85rem;
}

/* ── Legend in header (roles index) ── */
.sg-legend {
    display: flex;
    gap: 18px;
    margin-top: 10px;
    flex-wrap: wrap;
    font-size: .8rem;
    color: rgba(255, 255, 255, .85);
}
.sg-legend-item { display: flex; align-items: center; gap: 6px; }
.sg-legend-dot {
    width: 14px; height: 14px; border-radius: 4px;
}
.sg-legend-dot--granted { background: linear-gradient(135deg, #28a745, #20c997); }
.sg-legend-dot--admin   { background: linear-gradient(135deg, #6f42c1, #5a32a3); }
.sg-legend-dot--denied  { background: #fff; border: 2px solid #dee2e6; }

/* ── Action cell allineata a destra ── */
.sg-actions-cell {
    text-align: right;
    white-space: nowrap;
}
.sg-actions-cell > * { margin-left: 4px; }

/* ── Pulsanti azione tabella (icone) ── */
.sg-btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1.5px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: .85rem;
    transition: transform .12s, background .15s, color .15s;
    text-decoration: none;
}
.sg-btn-icon:hover { transform: translateY(-1px); }
.sg-btn-icon.edit   { background: #fff3cd; color: #856404; }
.sg-btn-icon.edit:hover   { background: #ffe69c; color: #533f03; }
.sg-btn-icon.delete { background: #f8d7da; color: #721c24; }
.sg-btn-icon.delete:hover { background: #f5c2c7; color: #5b181e; }
.sg-btn-icon.info   { background: #d1ecf1; color: #0c5460; }
.sg-btn-icon.info:hover   { background: #b8dde5; color: #062c33; }
.sg-btn-icon--disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   AUTH / GUEST LAYOUT
   ============================================================ */

.sg-auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    background: var(--sg-gradient-dark);
    position: relative;
    overflow: hidden;
}
.sg-auth-shell::before,
.sg-auth-shell::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .04);
    pointer-events: none;
}
.sg-auth-shell::before {
    width: 480px; height: 480px;
    top: -180px; right: -120px;
}
.sg-auth-shell::after {
    width: 380px; height: 380px;
    bottom: -160px; left: -120px;
}
.sg-auth-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    background: var(--sg-surface);
    border-radius: calc(var(--sg-radius) * 2.25);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
    padding: 38px 36px;
    z-index: 1;
}
.sg-auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
}
.sg-auth-brand .sg-auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--sg-gradient-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 8px 22px rgba(26, 26, 46, .35);
}
.sg-auth-brand .sg-auth-app-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--sg-text);
    letter-spacing: .3px;
}
.sg-auth-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--sg-text);
    margin: 0 0 6px;
    letter-spacing: -.2px;
}
.sg-auth-subtitle {
    font-size: .9rem;
    color: var(--sg-text-muted);
    margin: 0 0 26px;
}
.sg-auth-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--sg-border-light);
    text-align: center;
    font-size: .88rem;
    color: var(--sg-text-muted);
}

/* ============================================================
   HOMEPAGE / WELCOME
   ============================================================ */

.sg-home {
    min-height: 100vh;
    background: var(--sg-gradient-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
}
.sg-home-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 5%;
}
.sg-home-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .3px;
    color: #fff;
    text-decoration: none;
}
.sg-home-brand-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.sg-home-actions { display: flex; gap: 10px; }
.sg-home-actions .sg-btn-ghost {
    background: transparent;
    color: rgba(255, 255, 255, .85);
    border-color: rgba(255, 255, 255, .25);
}
.sg-home-actions .sg-btn-ghost:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-color: rgba(255, 255, 255, .4);
}
.sg-home-actions .sg-btn-cta {
    background: #fff;
    color: var(--sg-dark-1);
    border-color: #fff;
}
.sg-home-actions .sg-btn-cta:hover {
    background: #f1f3f5;
    color: var(--sg-dark-1);
}

.sg-home-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 5% 32px;
}
.sg-home-eyebrow {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: rgba(255, 255, 255, .7);
    background: rgba(255, 255, 255, .08);
    padding: 6px 14px;
    border-radius: var(--sg-radius-pill);
    margin-bottom: 22px;
}
.sg-home-title {
    font-size: clamp(2rem, 4.5vw, 3.4rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -1px;
    margin: 0 0 18px;
    max-width: 820px;
}
.sg-home-lead {
    font-size: 1.05rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, .8);
    max-width: 640px;
    margin: 0 0 30px;
}
.sg-home-cta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.sg-home-features {
    padding: 36px 5% 64px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .03) 0%, rgba(255, 255, 255, 0) 100%);
}
.sg-feature-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}
.sg-feature-card {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--sg-radius);
    padding: 22px 24px;
    transition: transform .18s, background .18s, border-color .18s;
}
.sg-feature-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, .09);
    border-color: rgba(255, 255, 255, .18);
}
.sg-feature-icon {
    width: 44px; height: 44px;
    border-radius: 11px;
    background: var(--sg-gradient-success);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1.05rem;
    margin-bottom: 14px;
}
.sg-feature-icon.alt-blue   { background: var(--sg-gradient-blue); }
.sg-feature-icon.alt-orange { background: var(--sg-gradient-orange); }
.sg-feature-card h3 {
    font-size: 1.02rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 6px;
    letter-spacing: .2px;
}
.sg-feature-card p {
    font-size: .88rem;
    color: rgba(255, 255, 255, .7);
    margin: 0;
    line-height: 1.55;
}

.sg-home-footer {
    padding: 18px 5%;
    text-align: center;
    font-size: .8rem;
    color: rgba(255, 255, 255, .45);
    border-top: 1px solid rgba(255, 255, 255, .06);
}

/* ============================================================
   UTILITIES
   ============================================================ */

.sg-mt-0 { margin-top: 0 !important; }
.sg-mt-1 { margin-top: .5rem !important; }
.sg-mt-2 { margin-top: 1rem !important; }
.sg-mt-3 { margin-top: 1.5rem !important; }
.sg-mt-4 { margin-top: 2rem !important; }
.sg-mt-5 { margin-top: 2.5rem !important; }
.sg-mb-0 { margin-bottom: 0 !important; }
.sg-mb-1 { margin-bottom: .5rem !important; }
.sg-mb-2 { margin-bottom: 1rem !important; }
.sg-mb-3 { margin-bottom: 1.5rem !important; }
.sg-mb-4 { margin-bottom: 2rem !important; }
.sg-mb-5 { margin-bottom: 2.5rem !important; }
.sg-text-muted { color: var(--sg-text-muted) !important; }
.sg-text-success { color: var(--sg-success) !important; }
.sg-text-danger { color: var(--sg-danger) !important; }
.sg-text-primary { color: var(--sg-primary) !important; }
.sg-text-center { text-align: center; }
.sg-d-flex { display: flex; }
.sg-flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sg-flex-wrap { flex-wrap: wrap; }
.sg-gap-2 { gap: .5rem; }
.sg-gap-3 { gap: 1rem; }
.sg-btn-reset { background: none; border: none; padding: 0; cursor: pointer; }
.sg-disabled { opacity: .5; pointer-events: none; }
.sg-form-label-note { font-weight: 400; text-transform: none; letter-spacing: 0; }
/* Colonna griglia con spaziatura standard (padding laterale + gap inferiore) */
.sg-grid-row { margin: 0 -8px; }
.sg-grid-col { padding: 0 8px; margin-bottom: 16px; }

/* ── Section title (usato nelle card admin) ──────────────── */
.sg-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sg-text);
    margin: 0 0 6px;
    letter-spacing: .2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Bottone secondary (outline grigio) ─────────────────── */
.sg-btn-secondary {
    background: #fff;
    color: #495057;
    border-color: #ced4da;
}
.sg-btn-secondary:hover:not(:disabled) {
    background: #f8f9fa;
    color: #343a40;
    border-color: #adb5bd;
}

/* ── Media Manager specifici ────────────────────────────── */
.sg-upload-box {
    flex: 1 1 260px;
    min-width: 0;
    padding: 1rem;
    background: #f9fafb;
    border-radius: var(--sg-radius-sm);
    border: 1px solid #e5e7eb;
    transition: background .15s, border-color .15s;
}

.sg-img-preview {
    aspect-ratio: 1;
    background: #f4f6f8;
    border-radius: var(--sg-radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    transition: background .15s;
}
.sg-img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sg-img-thumb { border-radius: var(--sg-radius-sm); box-shadow: var(--sg-shadow-card); }
.sg-media-filename { font-size: .95rem; word-break: break-all; line-height: 1.3; }

/* ============================================================
   DARK MODE — AdminLTE aggiunge `dark-mode` al body
   ============================================================ */

body.dark-mode .sg-card {
    background: #2d3436;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .3);
}

body.dark-mode .sg-auth-card {
    background: #3d4349;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

body.dark-mode .sg-auth-card .sg-auth-title,
body.dark-mode .sg-auth-card .sg-auth-subtitle,
body.dark-mode .sg-auth-card .sg-auth-app-name {
    color: #f8f9fa;
}

body.dark-mode .sg-card-header-title,
body.dark-mode .sg-section-title,
body.dark-mode .sg-page-title {
    color: #f8f9fa;
}

body.dark-mode .sg-card-header {
    border-color: #495057;
}

body.dark-mode .sg-card-section {
    border-color: #495057;
}

body.dark-mode .sg-upload-box {
    background: #3d4349;
    border-color: #495057;
}

body.dark-mode .sg-img-preview {
    background: #3d4349;
}

body.dark-mode .sg-form-control {
    background: #3d4349;
    border-color: #6c757d;
    color: #f8f9fa;
}

body.dark-mode .sg-form-control:focus {
    border-color: #748ffc;
    box-shadow: 0 0 0 3px rgba(116, 143, 252, .15);
}

body.dark-mode .sg-form-label {
    color: #adb5bd;
}

body.dark-mode .sg-form-hint {
    color: #6c757d;
}

body.dark-mode .sg-stat-card {
    background: #2d3436;
    color: #f8f9fa;
}

body.dark-mode .sg-stat-card:hover { color: #f8f9fa; }

body.dark-mode .sg-stat-value { color: #f8f9fa; }

body.dark-mode .sg-table thead th {
    background: #3d4349;
    color: #adb5bd;
}

body.dark-mode .sg-table tbody td {
    color: #f8f9fa;
    border-color: #495057;
}

body.dark-mode .sg-table tbody tr:hover { background: #3d4349; }

body.dark-mode .sg-form-section {
    background: #2d3436;
}

body.dark-mode .sg-form-section-header {
    background: #3d4349;
    border-color: #495057;
}

body.dark-mode .sg-form-section-title { color: #f8f9fa; }

body.dark-mode .sg-save-bar {
    background: #2d3436;
    border-color: #495057;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, .3);
}

body.dark-mode .sg-save-bar .hint { color: #adb5bd; }

body.dark-mode .sg-perm-entity-card {
    background: #2d3436;
    border-color: #495057;
}

body.dark-mode .sg-perm-entity-head {
    background: linear-gradient(135deg, #3d4349 0%, #495057 100%);
    color: #f8f9fa;
}

body.dark-mode .sg-perm-entity-head i { color: #adb5bd; }

body.dark-mode .sg-perm-toggle .lbl { color: #adb5bd; }

body.dark-mode .sg-perm-toggle:hover { background: #3d4349; }

body.dark-mode .sg-perm-check .box {
    background: #3d4349;
    border-color: #6c757d;
}

body.dark-mode .sg-btn-light {
    background: #3d4349;
    color: #f8f9fa;
    border-color: #495057;
}

body.dark-mode .sg-btn-secondary {
    background: #3d4349;
    color: #f8f9fa;
    border-color: #495057;
}

body.dark-mode .sg-btn-secondary:hover:not(:disabled) {
    background: #495057;
    color: #fff;
}

body.dark-mode .sg-btn-icon.edit   { background: #3d3000; color: #ffc107; }
body.dark-mode .sg-btn-icon.edit:hover { background: #553d00; color: #ffd454; }
body.dark-mode .sg-btn-icon.delete { background: #3d0a0f; color: #f88; }
body.dark-mode .sg-btn-icon.delete:hover { background: #5b1018; color: #ffaaaa; }
body.dark-mode .sg-btn-icon.info   { background: #002f37; color: #5dd; }
body.dark-mode .sg-btn-icon.info:hover { background: #004455; color: #7ee; }

body.dark-mode .sg-badge { background: #3d4349; color: #adb5bd; }
body.dark-mode .sg-badge-success { background: #1a3d25; color: #5dd678; }
body.dark-mode .sg-badge-danger  { background: #3d1418; color: #f88; }
body.dark-mode .sg-badge-warning { background: #3d2e00; color: #ffc107; }
body.dark-mode .sg-badge-info    { background: #002f37; color: #5dd; }

/* Override su classi Bootstrap/AdminLTE usate inline nelle viste */
body.dark-mode .content-wrapper .card {
    background: #2d3436;
}

body.dark-mode .content-wrapper .card > .card-header {
    background: #3d4349;
    border-color: #495057;
    color: #f8f9fa;
}

body.dark-mode .content-wrapper .table thead th {
    background: #3d4349;
    color: #adb5bd;
}

body.dark-mode .content-wrapper .table tbody td {
    border-color: #495057;
    color: #f8f9fa;
}

body.dark-mode .content-wrapper .form-control {
    background: #3d4349;
    border-color: #6c757d;
    color: #f8f9fa;
}

body.dark-mode .content-wrapper .form-control:focus {
    border-color: #748ffc;
    box-shadow: 0 0 0 3px rgba(116, 143, 252, .15);
}

body.dark-mode .modal-content {
    background: #2d3436;
    color: #f8f9fa;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    border-color: #495057;
}

body.dark-mode .modal-title { color: #f8f9fa; }

body.dark-mode code {
    background: #3d4349;
    color: #f8c6d6;
    border-radius: 4px;
    padding: 1px 6px;
}

body.dark-mode .text-muted { color: #adb5bd !important; }

body.dark-mode .nav-btn {
    background: #3d4349;
    border-color: #6c757d;
    color: #f8f9fa;
}

body.dark-mode .sidebar-card { background: #2d3436; }

body.dark-mode .sidebar-section { border-color: #495057; }

/* ── Bootstrap classes usate nelle viste admin (non coperte da AdminLTE dark) ── */

body.dark-mode .sg-card .btn-outline-secondary {
    color: #adb5bd;
    border-color: #6c757d;
    background: transparent;
}
body.dark-mode .sg-card .btn-outline-secondary:hover {
    color: #f8f9fa;
    background: #495057;
    border-color: #6c757d;
}
body.dark-mode .sg-card .btn-outline-danger {
    color: #f88;
    border-color: #dc3545;
    background: transparent;
}
body.dark-mode .sg-card .btn-outline-danger:hover {
    color: #fff;
    background: #a71d2a;
    border-color: #a71d2a;
}
body.dark-mode .sg-card .btn-secondary {
    background: #495057;
    border-color: #495057;
    color: #f8f9fa;
}
body.dark-mode .sg-card .btn-secondary:hover {
    background: #5a6268;
    border-color: #5a6268;
}

body.dark-mode .badge-light {
    background: #3d4349;
    color: #f8f9fa;
}
body.dark-mode .badge-secondary {
    background: #495057;
    color: #f8f9fa;
}
body.dark-mode .badge-info {
    background: #0c5460;
    color: #d1ecf1;
}

body.dark-mode .modal .close {
    color: #adb5bd;
    text-shadow: none;
    opacity: 1;
}
body.dark-mode .modal .close:hover {
    color: #f8f9fa;
}

body.dark-mode .alert-warning {
    background: #332d00;
    border-color: #6b5900;
    color: #ffc107;
}
body.dark-mode .alert-success {
    background: #0d2b1a;
    border-color: #155724;
    color: #5dd678;
}
body.dark-mode .alert-danger {
    background: #2c0a0e;
    border-color: #721c24;
    color: #f88;
}
body.dark-mode .alert-info {
    background: #001e26;
    border-color: #0c5460;
    color: #5dd;
}

/* ============================================================
   DARK MODE — estensioni: contrasto e copertura totale
   ============================================================ */

/* Testi & link */
body.dark-mode .sg-text-muted { color: #adb5bd !important; }
body.dark-mode .sg-card-body { color: #e9ecef; }
body.dark-mode .sg-card-body p,
body.dark-mode .sg-card-body span:not([class*="badge"]):not([class*="sg-badge"]),
body.dark-mode .sg-card-body li,
body.dark-mode .sg-card-body strong { color: inherit; }

body.dark-mode .sg-link {
    color: #8aa9ff;
}
body.dark-mode .sg-link:hover { color: #b0c4ff; }
body.dark-mode .sg-link-muted { color: #adb5bd; }
body.dark-mode .sg-link-muted:hover { color: #f8f9fa; }

/* Quiz play — testo domanda, badge, timer, dots, navigatore */
body.dark-mode .question-card { background: #2d3436; }
body.dark-mode #question-text { color: #f8f9fa; }
body.dark-mode .question-badge {
    background: #495057;
    color: #e9ecef;
}
body.dark-mode #timer { color: #e9ecef; }
body.dark-mode #timer.danger { color: #ff7a85; }
body.dark-mode .sidebar-label { color: #adb5bd; }
body.dark-mode .error-dot {
    border-color: #6c757d;
    background: transparent;
}
body.dark-mode .nav-btn.current {
    border-color: #adb5bd !important;
    box-shadow: 0 0 0 2px rgba(173, 181, 189, .25);
}
body.dark-mode .feedback-correct { color: #5dd678; }
body.dark-mode .feedback-wrong   { color: #ff7a85; }

/* Search highlight */
body.dark-mode mark {
    background: #ffd54f;
    color: #1a1a2e;
    padding: 0 2px;
    border-radius: 3px;
}

/* Sortable questions (quizzes/questions.blade.php) */
body.dark-mode #sortable-questions li {
    background: #2d3436;
    border-color: #495057 !important;
    color: #f8f9fa;
}
body.dark-mode #sortable-questions li:hover {
    background: #3d4349;
}

/* DataTables — riga evidenziata table-success (Bootstrap) */
body.dark-mode .content-wrapper table tbody tr.table-success,
body.dark-mode .sg-table tbody tr.table-success {
    background-color: rgba(40, 167, 69, .18) !important;
}
body.dark-mode .content-wrapper table tbody tr.table-success > td,
body.dark-mode .sg-table tbody tr.table-success > td {
    background-color: transparent !important;
    color: #f8f9fa !important;
}

/* DataTables controls (info/length/filter/paginate) */
body.dark-mode .dataTables_wrapper,
body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_length,
body.dark-mode .dataTables_wrapper .dataTables_filter,
body.dark-mode .dataTables_wrapper .dataTables_paginate {
    color: #adb5bd !important;
}
body.dark-mode .dataTables_wrapper .dataTables_filter input,
body.dark-mode .dataTables_wrapper .dataTables_length select {
    background: #3d4349;
    border: 1px solid #6c757d;
    color: #f8f9fa;
    border-radius: 6px;
    padding: 4px 8px;
}
body.dark-mode .dataTables_wrapper .paginate_button {
    color: #adb5bd !important;
    background: transparent !important;
    border-color: #495057 !important;
}
body.dark-mode .dataTables_wrapper .paginate_button.current,
body.dark-mode .dataTables_wrapper .paginate_button.current:hover {
    background: #495057 !important;
    border-color: #6c757d !important;
    color: #fff !important;
}
body.dark-mode .dataTables_wrapper .paginate_button:hover {
    background: #3d4349 !important;
    border-color: #6c757d !important;
    color: #f8f9fa !important;
}
body.dark-mode .dataTables_wrapper .paginate_button.disabled,
body.dark-mode .dataTables_wrapper .paginate_button.disabled:hover {
    color: #6c757d !important;
    background: transparent !important;
}

/* Paginazione Laravel (Bootstrap) */
body.dark-mode .pagination .page-link {
    background: #3d4349;
    border-color: #495057;
    color: #adb5bd;
}
body.dark-mode .pagination .page-link:hover {
    background: #495057;
    color: #f8f9fa;
}
body.dark-mode .pagination .page-item.active .page-link {
    background: #495057;
    border-color: #6c757d;
    color: #fff;
}
body.dark-mode .pagination .page-item.disabled .page-link {
    background: #2d3436;
    color: #6c757d;
    border-color: #495057;
}

/* Toggle permesso (users/form) — stato non checked */
body.dark-mode .sg-perm-toggle .dot {
    background: #3d4349;
    border-color: #6c757d;
}

/* Hint speciale (es. perms-hint) */
body.dark-mode .sg-form-section-hint { color: #b794f4; }

/* Bootstrap-switch (form domande Vero/Falso) — wrapper */
body.dark-mode .bootstrap-switch {
    border-color: #495057;
    background: #3d4349;
}
body.dark-mode .bootstrap-switch .bootstrap-switch-label {
    background: #495057;
    color: #f8f9fa;
}

/* Score display (quiz/attempt) */
.sg-score-display {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    color: var(--sg-text);
    font-variant-numeric: tabular-nums;
}
body.dark-mode .sg-score-display { color: #f8f9fa; }

/* Pre/code blocks (audit log) */
.sg-pre {
    margin: 0;
    font-size: .75rem;
    max-width: 280px;
    overflow: auto;
    background: var(--sg-bg-soft);
    color: var(--sg-text);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--sg-border-light);
}
body.dark-mode .sg-pre {
    background: #1f2426;
    color: #e9ecef;
    border-color: #495057;
}

/* Toastr notifiche */
body.dark-mode #toast-container > .toast-success { background-color: #1a3d25 !important; }
body.dark-mode #toast-container > .toast-error   { background-color: #3d1418 !important; }
body.dark-mode #toast-container > .toast-warning { background-color: #3d2e00 !important; color: #ffd454 !important; }
body.dark-mode #toast-container > .toast-info    { background-color: #002f37 !important; }

/* Modal close button generico (oltre alla regola .modal .close) */
body.dark-mode .modal-content .close {
    color: #f8f9fa;
    text-shadow: none;
    opacity: .85;
}
body.dark-mode .modal-content .close:hover { opacity: 1; color: #fff; }

/* Welcome / sg-home: già scuro, ma garantisce contrasto se forzato in dark-mode */
body.dark-mode .sg-home,
body.dark-mode .sg-auth-shell { color: #fff; }

/* sg-badge "neutro" (es. Bozza) */
body.dark-mode .sg-badge:not([class*="sg-badge-"]) {
    background: #495057;
    color: #e9ecef;
}

/* Card-section / card-header che restano scuri ma con testo leggibile */
body.dark-mode .sg-card-section { color: inherit; }

/* Spinners / loading text dentro card scuri */
body.dark-mode .text-danger { color: #ff7a85 !important; }
body.dark-mode .text-warning { color: #ffd454 !important; }
body.dark-mode .text-success { color: #5dd678 !important; }
body.dark-mode .text-info { color: #5ddde9 !important; }

/* ============================================================
   RESPONSIVE — mobile first overrides
   Tutto il CSS sopra è desktop; qui adattiamo i blocchi rigidi
   (header, card, quiz, tabelle, form, home, auth, sidebar) alle
   viewport <= 991px (tablet) e <= 575px (mobile vero).
   ============================================================ */

/* ── Tablet e sotto ───────────────────────────────────────── */
@media (max-width: 991.98px) {
    /* Wrapper: niente più padding inutile sui lati di AdminLTE */
    .sg-wrapper,
    .sg-wrapper-sm { padding-left: 4px; padding-right: 4px; }

    /* Header con titolo + azioni: vanno in colonna */
    .sg-header { padding: 18px 18px; }
    .sg-header.sg-flex-between {
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .sg-header-title { font-size: 1.2rem; }
    .sg-header-actions {
        flex-wrap: wrap;
        margin-top: 10px;
        width: 100%;
    }
    .sg-header-actions .sg-btn,
    .sg-header-actions form { flex: 0 1 auto; }

    /* Card padding più contenuto */
    .sg-card-body { padding: 1.25rem; }
    .sg-card-body-tight { padding: 1rem; }
    .sg-card-header { padding: 12px 16px; flex-wrap: wrap; }
    .sg-card-section { padding: 14px 16px; }

    /* sg-flex-between fa wrap di default sui dispositivi piccoli */
    .sg-flex-between { flex-wrap: wrap; }

    /* Stat card: leggermente più compatto */
    .sg-stat-card { padding: 16px 18px; gap: 12px; }
    .sg-stat-value { font-size: 1.5rem; }
    .sg-stat-icon { width: 46px; height: 46px; font-size: 1.2rem; }

    /* Tabella custom: scroll orizzontale già fornito da .table-responsive,
       ma riduciamo padding celle e font per più contenuto a vista */
    .sg-table thead th { padding: 10px 12px; font-size: .68rem; }
    .sg-table tbody td { padding: 10px 12px; font-size: .88rem; }

    /* Quiz player: la sidebar passa sotto la domanda */
    .quiz-header { padding: 14px 18px; }
    .quiz-title { font-size: 1.05rem; }
    .quiz-header.d-flex {
        flex-wrap: wrap;
        gap: 10px;
    }
    /* Container progresso a tutta larghezza sotto al titolo */
    .quiz-header-progress,
    .quiz-header > div:last-child {
        width: 100%;
        min-width: 0 !important;
    }

    #question-text { font-size: 1.1rem; min-height: auto; }
    .question-card .card-body { padding: 1.25rem !important; }
    .answer-area { gap: 10px; margin-top: 20px; }
    .btn-answer { padding: 14px 8px; font-size: .95rem; letter-spacing: 1px; }

    /* Sidebar quiz player più compatta */
    #timer { font-size: 1.8rem; letter-spacing: 1px; }
    .sidebar-section { padding: 12px 14px; }

    /* Form admin sezioni: header in colonna */
    .sg-form-section-header { padding: 12px 16px; }
    .sg-form-section-body { padding: 1rem; }

    /* Permessi: una colonna sola su tablet */
    .sg-perm-entity-body { grid-template-columns: 1fr; }

    /* Welcome */
    .sg-home-nav { padding: 16px 5%; }
    .sg-home-hero { padding: 32px 5% 24px; }
    .sg-home-features { padding: 24px 5% 48px; }
    .sg-home-cta { width: 100%; }
    .sg-home-cta .sg-btn { flex: 1 1 200px; justify-content: center; }
}

/* ── Mobile (< 576px) ─────────────────────────────────────── */
@media (max-width: 575.98px) {
    /* Header: titolo più piccolo, padding minimo */
    .sg-header { padding: 16px 16px; border-radius: 10px; margin-bottom: 14px; }
    .sg-header-title { font-size: 1.05rem; }
    .sg-header-subtitle { font-size: .72rem; }
    .sg-page-title { font-size: 1.25rem; }

    /* Bottoni: leggermente più grandi per essere "touch friendly" */
    .sg-btn { padding: 10px 16px; font-size: .88rem; }
    .sg-btn-sm { padding: 8px 12px; font-size: .78rem; }

    /* Bottoni nelle azioni header non più allineati a destra: vanno full-width
       quando da soli, altrimenti restano in fila e fanno wrap */
    .sg-header-actions { gap: 6px; }
    .sg-header-actions form { width: auto; }
    .sg-header-actions .sg-btn { padding: 8px 14px; font-size: .8rem; }

    /* Card */
    .sg-card { border-radius: 10px; }
    .sg-card-body { padding: 1rem; }
    .sg-card-body-tight { padding: .85rem; }

    /* Stat cards: full-width per migliore leggibilità sui telefoni */
    .sg-stat-card { padding: 14px 16px; }
    .sg-stat-value { font-size: 1.4rem; }
    .sg-stat-label { font-size: .68rem; }
    .sg-stat-icon { width: 42px; height: 42px; font-size: 1.05rem; }

    /* Quiz player: layout ulteriormente compatto */
    .quiz-header { padding: 12px 14px; }
    .quiz-title { font-size: .98rem; }
    .quiz-progress { height: 6px; }

    #question-text { font-size: 1rem; line-height: 1.5; }
    .question-card .card-body { padding: 1rem !important; }
    .question-badge { font-size: .68rem; padding: 3px 9px; margin-bottom: 12px; }
    .answer-area { gap: 8px; margin-top: 16px; }
    .btn-answer {
        padding: 14px 6px;
        font-size: .9rem;
        letter-spacing: .8px;
    }
    .btn-answer i { font-size: .95rem; }

    /* Sidebar quiz player */
    #timer { font-size: 1.55rem; }
    #navigator { gap: 4px; justify-content: center; }
    .nav-btn { width: 28px; height: 28px; font-size: .7rem; }
    #finish-quiz { padding: 10px; font-size: .88rem; }
    .error-dot { width: 12px; height: 12px; }

    /* sg-table: padding ulteriormente ridotto */
    .sg-table thead th { padding: 8px 10px; font-size: .65rem; }
    .sg-table tbody td { padding: 8px 10px; font-size: .82rem; }

    /* Form */
    .sg-form-control { padding: 8px 12px 12px; font-size: .9rem; line-height: 1.6; }
    .sg-form-label { font-size: .8rem; }
    .sg-form-group { margin-bottom: .85rem; }

    /* Auth card: niente padding eccessivo né shadow pesante su schermi piccoli */
    .sg-auth-shell { padding: 12px; }
    .sg-auth-card {
        padding: 26px 22px;
        border-radius: 14px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    }
    .sg-auth-title { font-size: 1.2rem; }
    .sg-auth-subtitle { font-size: .82rem; margin-bottom: 18px; }

    /* Home / welcome: hero più contenuta */
    .sg-home-nav {
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 5%;
    }
    .sg-home-brand { font-size: 1rem; }
    .sg-home-brand-icon { width: 36px; height: 36px; font-size: 1rem; }
    .sg-home-actions {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .sg-home-hero { padding: 26px 5% 18px; }
    .sg-home-eyebrow { font-size: .68rem; margin-bottom: 16px; }
    .sg-home-lead { font-size: .95rem; margin-bottom: 22px; }
    .sg-home-cta { flex-direction: column; width: 100%; }
    .sg-home-cta .sg-btn { width: 100%; }
    .sg-feature-grid { grid-template-columns: 1fr; gap: 12px; }
    .sg-feature-card { padding: 18px 18px; }

    /* AdminLTE: la navbar mostra pulsante hamburger; assicuriamoci che il
       dropdown notifiche non superi lo schermo */
    .navbar-nav .dropdown-menu.dropdown-menu-lg {
        width: calc(100vw - 24px);
        max-width: 360px;
    }
    .navbar-nav .dropdown-menu .dropdown-item .float-right { float: none !important; display: block; }
}

/* ── Force AdminLTE small-box numeri leggibili su tutto < md ── */
@media (max-width: 767.98px) {
    .content-wrapper .small-box h3 { font-size: 1.5rem; }
    .content-wrapper .small-box .icon { display: none; }
}

/* ── Modal scrollabile su schermi piccoli ─────────────────── */
@media (max-width: 575.98px) {
    .modal-dialog { margin: .5rem; }
}

/* ── Study nav footer ─────────────────────────────────────
   Desktop: 3 gruppi (prev | azioni | next) su una riga.
   Mobile: tutto in colonna, ogni bottone a tutta larghezza. */
.sg-study-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.sg-study-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
@media (max-width: 575.98px) {
    .sg-study-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .sg-study-nav-prev,
    .sg-study-nav-next,
    .sg-study-nav-actions {
        width: 100%;
    }
    /* prev / next: bottone unico full-width */
    .sg-study-nav-prev > .sg-btn,
    .sg-study-nav-next > .sg-btn {
        width: 100%;
    }
    /* azioni: i due bottoni vanno in colonna */
    .sg-study-nav-actions {
        flex-direction: column;
        order: 3; /* azioni in fondo */
    }
    .sg-study-nav-actions > .sg-btn { width: 100%; }
    .sg-study-nav-next { order: 2; }
    .sg-study-nav-prev { order: 1; }
}

/* ============================================================
   Mobile responsive overrides — aggiunti nella revisione
   responsive globale del progetto.
   ============================================================ */

/* ── Save bar sticky: su mobile diventa colonna ─────────────── */
@media (max-width: 575.98px) {
    .sg-save-bar {
        flex-direction: column;
        align-items: stretch;
        bottom: 0;
        border-radius: var(--sg-radius) var(--sg-radius) 0 0;
    }
    .sg-save-bar .hint { font-size: .78rem; }
    .sg-save-bar .sg-btn { width: 100%; }
}

/* ── Cmd tile comandi artisan: pre con wrap su mobile ────────── */
@media (max-width: 575.98px) {
    .sg-cmd-tile { padding: .85rem !important; }
}

/* ── Tabella audit: celle pre non sforano ────────────────────── */
@media (max-width: 767.98px) {
    .sg-pre { max-width: 160px; }
}

/* ── Roles matrix: su mobile la tabella è scrollabile;
   la colonna Ruolo non si stringe troppo ─────────────────────── */
@media (max-width: 575.98px) {
    .sg-form-section .sg-table thead th,
    .sg-form-section .sg-table tbody td { padding: 8px 10px; }
}

/* ── Quiz player: sidebar quiz viene SOTTO la domanda su mobile── */
@media (max-width: 991.98px) {
    .quiz-wrapper .col-lg-4 { margin-top: 1.25rem; }
}

/* ── Stat-card "Ultimo tentativo": testo lungo non sforano ────── */
@media (max-width: 575.98px) {
    .sg-stat-value { word-break: break-word; }
}

/* ── Study/index: bottone submit full-width su xs ─────────────── */
@media (max-width: 575.98px) {
    .sg-card .d-grid > .sg-btn { width: 100%; }
}

/* ── Sortable quiz questions: altezza ridotta su mobile ─────────── */
@media (max-width: 767.98px) {
    .sg-sortable-scroll { max-height: 360px; }
}

/* ============================================================
   CENTRALIZZAZIONE CSS — Feature 14.3
   Stili estratti dalle view inline e portati qui.
   ============================================================ */

/* ── Alpine: nasconde elementi prima dell'inizializzazione ── */
[x-cloak] { display: none !important; }

/* ── Logo scuola nella navbar di AdminLTE ── */
.navbar-brand img.school-logo { max-height: 40px; width: auto; }

/* ── Auth center: contenitore centrato sotto la navbar ── */
.sg-auth-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 3rem;
    padding-bottom: 3rem;
    min-height: calc(100vh - var(--sg-navbar-height) - 80px);
}

/* ── Immagine domanda in quiz e simulatore ── */
.sg-question-img { max-height: 220px; cursor: pointer; }

/* ── Status dot ricerca (search/results) ── */
.sg-status-dot-xs { font-size: .55rem; vertical-align: middle; margin-right: 8px; }

/* ── Classi hero legacy (rimosse in 15.3, tenute per eventuali dipendenze esterne) ── */
/* sg-hero-overlay-* sostituite da .sg-hero / .sg-hero-overlay in 15.3 */

/* ── Sortable lista domande quiz (admin/quizzes/questions) ── */
#sortable-questions li {
    font-size: 13px;
    padding: 10px 12px;
    border: 1px solid var(--sg-border-light);
    border-radius: var(--sg-radius-sm);
    margin-bottom: 6px;
    background: #fff;
    transition: background .15s, box-shadow .15s;
}
#sortable-questions li:hover {
    background: var(--sg-bg-soft);
    box-shadow: var(--sg-shadow-card);
}
.index-badge {
    min-width: 28px;
    text-align: center;
    font-size: .7rem;
    padding: 4px 8px;
    background: var(--sg-gradient-dark) !important;
    color: #fff;
    border-radius: var(--sg-radius-pill);
    font-weight: 700;
}
.quiz-q-progress {
    height: 10px;
    border-radius: 5px;
    background: var(--sg-border);
    overflow: hidden;
}
.quiz-q-progress .bar {
    height: 100%;
    border-radius: 5px;
    transition: width .35s ease, background .15s;
    background: var(--sg-gradient-success);
}
.quiz-q-progress .bar.warn   { background: linear-gradient(90deg, #ffc107, #fd7e14); }
.quiz-q-progress .bar.danger { background: linear-gradient(90deg, #dc3545, #e83e8c); }
.sg-sortable-scroll { max-height: 800px; overflow-y: auto; padding: 14px; }
.sg-q-text { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#questions-table th:last-child,
#questions-table td:last-child { padding-right: 16px; }

/* ============================================================
   SHELL 15.1 — sidebar e navbar uniformi, accento di ruolo localizzato.
   Il middleware RoleTheme aggiunge al <body> la classe
   role-admin | role-editor | role-viewer | role-instructor.
   Il colore di ruolo non vernicia più le superfici: compare solo
   come striscia laterale, bordo voce attiva e badge pill.
   ============================================================ */

/* Navbar uniforme navy per tutti i ruoli */
.sg-navbar,
.main-header.navbar {
    background-color: var(--sg-shell-bg) !important;
    border-bottom: 1px solid rgba(255,255,255,.06) !important;
}

/* Sidebar uniforme navy per tutti i ruoli */
.main-sidebar {
    background-color: var(--sg-shell-bg) !important;
}
.brand-link {
    background-color: var(--sg-shell-bg-elevated) !important;
    border-bottom-color: rgba(255,255,255,.08) !important;
    color: var(--sg-shell-text) !important;
}
.brand-link:hover {
    background-color: var(--sg-shell-bg-elevated) !important;
    color: var(--sg-shell-text) !important;
}

/* Striscia verticale colore ruolo sul bordo destro della sidebar */
body.role-admin      .main-sidebar { border-right: 3px solid var(--sg-role-admin)      !important; }
body.role-editor     .main-sidebar { border-right: 3px solid var(--sg-role-editor)     !important; }
body.role-viewer     .main-sidebar { border-right: 3px solid var(--sg-role-viewer)     !important; }
body.role-instructor .main-sidebar { border-right: 3px solid var(--sg-role-instructor) !important; }

/* Badge ruolo: pill con icona e label (sidebar + navbar) */
.sg-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--sg-radius-pill);
    font-size: var(--sg-fs-xs);
    font-weight: var(--sg-fw-semibold);
    letter-spacing: .4px;
    text-transform: uppercase;
    line-height: 1.5;
    white-space: nowrap;
}
.sg-role-badge.role-admin      { background-color: var(--sg-role-admin);      color: var(--sg-role-admin-text); }
.sg-role-badge.role-editor     { background-color: var(--sg-role-editor);     color: var(--sg-role-editor-text); }
.sg-role-badge.role-viewer     { background-color: var(--sg-role-viewer);     color: var(--sg-role-viewer-text); }
.sg-role-badge.role-instructor { background-color: var(--sg-role-instructor); color: var(--sg-role-instructor-text); }

/* Contenitore badge sotto il brand nella sidebar */
.sg-sidebar-role-area {
    padding: 8px 16px 10px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

/* Navbar: link e icone in shell-text */
.main-header.navbar .nav-link,
.main-header.navbar .nav-link * {
    color: var(--sg-shell-text) !important;
}
.main-header.navbar .nav-link:hover,
.main-header.navbar .nav-link:hover * {
    color: var(--sg-accent) !important;
}

/* Dropdown dentro navbar: testo scuro su sfondo bianco */
.main-header .dropdown-menu { color: #212529 !important; }
.main-header .dropdown-menu .dropdown-item,
.main-header .dropdown-menu a:not(.btn) { color: #212529 !important; }
.main-header .dropdown-menu .dropdown-item:hover { color: #000 !important; }

/* Footer del menu utente */
.main-header .user-footer {
    background-color: var(--sg-shell-bg-elevated) !important;
}
.main-header .user-footer .btn {
    color: var(--sg-shell-text) !important;
    border-color: rgba(255,255,255,.25) !important;
    background-color: rgba(255,255,255,.08) !important;
}
.main-header .user-footer .btn:hover {
    background-color: rgba(255,255,255,.18) !important;
}

/* Badge numerini nella topnav */
.navbar-badge {
    background-color: transparent !important;
    border: 1px solid var(--sg-accent) !important;
    color: var(--sg-accent) !important;
}

/* Badge generici nella topnav (esclusi sg-role-badge e navbar-badge) */
.main-header .badge:not(.navbar-badge):not(.sg-role-badge) {
    background-color: rgba(255,255,255,.15) !important;
    color: var(--sg-shell-text) !important;
}

/* Footer applicazione */
.main-footer {
    background-color: var(--sg-shell-bg-elevated) !important;
    border-top-color: rgba(255,255,255,.06) !important;
    color: var(--sg-shell-text-muted) !important;
}
.main-footer a { color: var(--sg-accent) !important; }
.main-footer a:hover { color: var(--sg-accent-hover) !important; }

/* Sidebar nav: testo link e icone */
.sidebar .nav-sidebar .nav-link {
    color: var(--sg-shell-text) !important;
}
.sidebar .nav-sidebar .nav-link .nav-icon {
    color: var(--sg-shell-text-muted) !important;
}

/* Hover su voci non attive */
.sidebar .nav-sidebar .nav-item > .nav-link:not(.active):hover {
    background-color: var(--sg-shell-bg-elevated) !important;
    color: var(--sg-shell-text) !important;
}
.sidebar .nav-sidebar .nav-item > .nav-link:not(.active):hover .nav-icon {
    color: var(--sg-shell-text) !important;
}

/* Voce attiva: bordo sinistro colore ruolo + sfondo tenue navy */
.sidebar .nav-sidebar .nav-item > .nav-link.active {
    background-color: rgba(255,255,255,.07) !important;
    box-shadow: none !important;
    color: var(--sg-shell-text) !important;
    border-left: 3px solid transparent;
    border-radius: 0;
}
body.role-admin      .sidebar .nav-sidebar .nav-item > .nav-link.active { border-left-color: var(--sg-role-admin)      !important; }
body.role-editor     .sidebar .nav-sidebar .nav-item > .nav-link.active { border-left-color: var(--sg-role-editor)     !important; }
body.role-viewer     .sidebar .nav-sidebar .nav-item > .nav-link.active { border-left-color: var(--sg-role-viewer)     !important; }
body.role-instructor .sidebar .nav-sidebar .nav-item > .nav-link.active { border-left-color: var(--sg-role-instructor) !important; }

/* Icona voce attiva: colore ruolo */
body.role-admin      .sidebar .nav-sidebar .nav-item > .nav-link.active .nav-icon { color: var(--sg-role-admin)      !important; }
body.role-editor     .sidebar .nav-sidebar .nav-item > .nav-link.active .nav-icon { color: var(--sg-role-editor)     !important; }
body.role-viewer     .sidebar .nav-sidebar .nav-item > .nav-link.active .nav-icon { color: var(--sg-role-viewer)     !important; }
body.role-instructor .sidebar .nav-sidebar .nav-item > .nav-link.active .nav-icon { color: var(--sg-role-instructor) !important; }

/* Badge contatori nella sidebar */
.sidebar .badge {
    background-color: rgba(255,255,255,.15) !important;
    color: var(--sg-shell-text) !important;
}
body.role-admin      .sidebar .badge { background-color: var(--sg-role-admin)      !important; color: var(--sg-role-admin-text)      !important; }
body.role-editor     .sidebar .badge { background-color: var(--sg-role-editor)     !important; color: var(--sg-role-editor-text)     !important; }
body.role-viewer     .sidebar .badge { background-color: var(--sg-role-viewer)     !important; color: var(--sg-role-viewer-text)     !important; }
body.role-instructor .sidebar .badge { background-color: var(--sg-role-instructor) !important; color: var(--sg-role-instructor-text) !important; }

/* Etichette sezione ("AREA PERSONALE", "ESAMI" …) nella sidebar */
.sidebar .nav-header {
    color: var(--sg-shell-text-muted) !important;
    font-weight: var(--sg-fw-medium) !important;
    letter-spacing: .06em !important;
}

/* Scrollbar sidebar */
.sidebar .os-scrollbar-track  { background: rgba(255,255,255,.05) !important; }
.sidebar .os-scrollbar-handle { background: rgba(255,255,255,.20) !important; }

/* AdminLTE .content-header compatto */
.content-header {
    padding: 8px 0 !important;
    background: transparent !important;
}
.content-header h1 {
    font-size: var(--sg-fs-xl) !important;
    font-weight: var(--sg-fw-semibold) !important;
    color: var(--sg-text) !important;
    margin: 0 !important;
    line-height: 1.3 !important;
}

/* ============================================================
   COMPONENTI REDESIGN 15.2
   Card, stat icon, status box, badge semantici, stile tabelle.
   Tutti i token sono da 15.0; nessuno ridefinito qui.
   ============================================================ */

/* ── Icone stat card: chip tondo tenuito (accento <12% opacità) ── */

/* Override classi grad-* esistenti: da gradiente saturo a chip tenuito */
.sg-stat-icon.grad-blue   { background: rgba(60, 141, 188, .12); color: var(--sg-accent); }
.sg-stat-icon.grad-green  { background: rgba(47, 158, 111, .12); color: var(--sg-success); }
.sg-stat-icon.grad-orange { background: rgba(217, 164, 32, .12); color: var(--sg-warning); }
.sg-stat-icon.grad-red    { background: rgba(192, 57, 43, .12);  color: var(--sg-danger); }
.sg-stat-icon.grad-dark   { background: rgba(30, 42, 56, .10);   color: var(--sg-text); }

/* Varianti semantiche (preferire queste nelle nuove view) */
.sg-stat-icon--accent  { background: rgba(60, 141, 188, .12); color: var(--sg-accent);    }
.sg-stat-icon--success { background: rgba(47, 158, 111, .12); color: var(--sg-success);   }
.sg-stat-icon--warning { background: rgba(217, 164, 32, .12); color: var(--sg-warning);   }
.sg-stat-icon--danger  { background: rgba(192, 57, 43, .12);  color: var(--sg-danger);    }
.sg-stat-icon--muted   { background: rgba(107, 119, 133, .10); color: var(--sg-text-muted); }

/* ── Status box (sostituisce small-box AdminLTE nelle pagine KPI) ── */
.sg-status-box {
    background: var(--sg-surface);
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-sm);
    padding: 20px 22px;
    border: 1px solid var(--sg-border);
    border-left: 4px solid var(--sg-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
}
.sg-status-box-value {
    font-size: var(--sg-fs-3xl);
    font-weight: var(--sg-fw-bold);
    line-height: 1;
    color: var(--sg-text);
    font-variant-numeric: tabular-nums;
}
.sg-status-box-label {
    font-size: var(--sg-fs-sm);
    color: var(--sg-text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: var(--sg-fw-medium);
    margin-top: 4px;
}
.sg-status-box-action {
    margin-top: 14px;
}
.sg-status-box--warning { border-left-color: var(--sg-warning); }
.sg-status-box--success { border-left-color: var(--sg-success); }
.sg-status-box--danger  { border-left-color: var(--sg-danger);  }
.sg-status-box--muted   { border-left-color: var(--sg-text-muted); }

/* ── Badge semantici stato (convenzione unica: sfondo tenuito + testo scuro) ──
   Contrasto verificato WCAG AA (≥ 4.5:1 per testo normale):
   #856404 su #fff3cd → 5.23:1 ✓   #155724 su #d4edda → 5.74:1 ✓
   #495057 su #e9ecef → 7.37:1 ✓   #0c5460 su #d1ecf1 → 5.89:1 ✓  */
.sg-badge--draft     { background: #e9ecef; color: #495057; }
.sg-badge--published { background: #d4edda; color: #155724; }
.sg-badge--confirmed { background: #d1ecf1; color: #0c5460; }
.sg-badge--pending   { background: #fff3cd; color: #856404; }
.sg-badge--accepted  { background: #d4edda; color: #155724; }
.sg-badge--rejected  { background: #e9ecef; color: #6c757d; }

/* ── Card footer (sezione in fondo alla sg-card) ── */
.sg-card-footer {
    padding: 12px 22px;
    border-top: 1px solid var(--sg-border-light);
    background: var(--sg-surface);
}

/* ── Righe tabella segnalazioni: lo stato si legge dal badge, non dal fondo riga ── */
.content-wrapper .table tbody tr.table-warning,
.sg-table tbody tr.table-warning {
    background-color: transparent !important;
}
.content-wrapper .table tbody tr.table-warning > td,
.sg-table tbody tr.table-warning > td {
    background-color: transparent !important;
}

/* ── Header tabella uniforme su token ── */
.sg-table thead th {
    background: var(--sg-surface-muted);
    border-bottom: 1px solid var(--sg-border);
}

/* ── Dark mode: nuove classi 15.2 ── */
body.dark-mode .sg-status-box {
    background: #2d3436;
    border-color: #495057;
}
body.dark-mode .sg-status-box-value { color: #f8f9fa; }
body.dark-mode .sg-status-box-label { color: #adb5bd; }

body.dark-mode .sg-stat-icon.grad-blue,
body.dark-mode .sg-stat-icon--accent  { background: rgba(60, 141, 188, .20); color: #5dd; }
body.dark-mode .sg-stat-icon.grad-green,
body.dark-mode .sg-stat-icon--success { background: rgba(47, 158, 111, .20); color: #5dd678; }
body.dark-mode .sg-stat-icon.grad-orange,
body.dark-mode .sg-stat-icon--warning { background: rgba(217, 164, 32, .20); color: #ffc107; }
body.dark-mode .sg-stat-icon.grad-red,
body.dark-mode .sg-stat-icon--danger  { background: rgba(192, 57, 43, .20);  color: #ff7a85; }
body.dark-mode .sg-stat-icon.grad-dark,
body.dark-mode .sg-stat-icon--muted   { background: rgba(255,255,255, .08);  color: #adb5bd; }

body.dark-mode .sg-badge--draft     { background: #3d4349; color: #adb5bd; }
body.dark-mode .sg-badge--published { background: #1a3d25; color: #5dd678; }
body.dark-mode .sg-badge--confirmed { background: #002f37; color: #5dd; }
body.dark-mode .sg-badge--pending   { background: #3d2e00; color: #ffc107; }
body.dark-mode .sg-badge--accepted  { background: #1a3d25; color: #5dd678; }
body.dark-mode .sg-badge--rejected  { background: #3d4349; color: #adb5bd; }

body.dark-mode .sg-card-footer {
    background: #2d3436;
    border-color: #495057;
}

body.dark-mode .content-wrapper .table tbody tr.table-warning > td,
body.dark-mode .sg-table tbody tr.table-warning > td {
    color: #f8f9fa !important;
}

/* ============================================================
   GUEST REDESIGN 15.3 — Hero, feature card, badge patente, CTA
   Prefisso sg-, su token. Classi guest-only.
   ============================================================ */

/* ── Hero homepage ─────────────────────────────────────────── */
.sg-hero {
    position: relative;
    overflow: hidden;
    min-height: 58vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--sg-shell-bg);
}
.sg-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.sg-hero-bg .carousel,
.sg-hero-bg .carousel-inner,
.sg-hero-bg .carousel-item { height: 100%; }
.sg-hero-bg img { width: 100%; height: 100%; object-fit: cover; }
.sg-hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(160deg, rgba(30,42,56,.72) 0%, rgba(30,42,56,.55) 100%);
}
.sg-hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 5rem 1.5rem;
    max-width: 700px;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.sg-hero-logo {
    max-height: 76px;
    width: auto;
    filter: drop-shadow(0 2px 10px rgba(0,0,0,.35));
}
.sg-hero-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255,255,255,.14);
    border: 1.5px solid rgba(255,255,255,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    backdrop-filter: blur(4px);
}
.sg-hero-title {
    font-size: var(--sg-fs-3xl);
    font-weight: var(--sg-fw-bold);
    color: #fff;
    margin: 0;
    line-height: 1.15;
    letter-spacing: -.5px;
    text-shadow: 0 2px 16px rgba(0,0,0,.28);
}
.sg-hero-tagline {
    font-size: var(--sg-fs-lg);
    color: rgba(255,255,255,.82);
    margin: 0;
    line-height: 1.55;
}
.sg-hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .75rem;
    margin-top: .25rem;
}
.sg-btn-hero-primary {
    display: inline-flex;
    align-items: center;
    background: var(--sg-accent);
    color: var(--sg-accent-text);
    font-weight: var(--sg-fw-semibold);
    font-size: var(--sg-fs-base);
    padding: .7rem 1.75rem;
    border-radius: var(--sg-radius);
    border: none;
    text-decoration: none;
    transition: var(--sg-transition);
    box-shadow: 0 4px 18px rgba(60,141,188,.45);
}
.sg-btn-hero-primary:hover {
    background: var(--sg-accent-hover);
    color: var(--sg-accent-text);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(60,141,188,.55);
    text-decoration: none;
}
.sg-btn-hero-secondary {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: #fff;
    font-weight: var(--sg-fw-medium);
    font-size: var(--sg-fs-base);
    padding: .7rem 1.75rem;
    border-radius: var(--sg-radius);
    border: 1.5px solid rgba(255,255,255,.55);
    text-decoration: none;
    transition: var(--sg-transition);
    backdrop-filter: blur(4px);
}
.sg-btn-hero-secondary:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.9);
    color: #fff;
    transform: translateY(-2px);
    text-decoration: none;
}

/* ── Stat card guest ───────────────────────────────────────── */
.sg-guest-stat-card {
    background: var(--sg-surface);
    border: 1px solid var(--sg-border);
    border-top: 3px solid var(--sg-accent);
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-sm);
    padding: 1.75rem 1.25rem;
}
.sg-guest-stat-value {
    font-size: var(--sg-fs-2xl);
    font-weight: var(--sg-fw-bold);
    color: var(--sg-text);
    line-height: 1.1;
    margin-bottom: .25rem;
}
.sg-guest-stat-label {
    font-size: var(--sg-fs-sm);
    color: var(--sg-text-muted);
}

/* ── Feature card ──────────────────────────────────────────── */
.sg-features-section { background: var(--sg-surface-muted); }
.sg-section-heading {
    font-size: var(--sg-fs-2xl);
    font-weight: var(--sg-fw-semibold);
    color: var(--sg-text);
    letter-spacing: -.2px;
}
.sg-feature-card {
    background: var(--sg-surface);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    box-shadow: var(--sg-shadow-sm);
    padding: 1.75rem 1.5rem;
    text-align: center;
    height: 100%;
    transition: var(--sg-transition);
}
.sg-feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--sg-shadow-card);
}
.sg-feature-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--sg-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.25rem;
}
.sg-feature-icon--blue  { background: rgba(60,141,188,.12); color: var(--sg-accent); }
.sg-feature-icon--red   { background: rgba(192,57,43,.12);  color: var(--sg-danger); }
.sg-feature-icon--green { background: rgba(47,158,111,.12); color: var(--sg-success); }
.sg-feature-icon--teal  { background: rgba(60,141,188,.10); color: var(--sg-info); }
.sg-feature-title {
    font-size: var(--sg-fs-lg);
    font-weight: var(--sg-fw-semibold);
    color: var(--sg-text);
    margin: 0 0 .5rem;
}
.sg-feature-text {
    font-size: var(--sg-fs-sm);
    color: var(--sg-text-muted);
    margin: 0;
    line-height: 1.6;
}

/* ── Badge tipi patente ────────────────────────────────────── */
.sg-badge-license {
    display: inline-block;
    background: rgba(60,141,188,.10);
    color: var(--sg-accent);
    border: 1px solid rgba(60,141,188,.22);
    border-radius: var(--sg-radius-pill);
    font-size: var(--sg-fs-base);
    font-weight: var(--sg-fw-semibold);
    padding: .35rem 1.1rem;
    margin: .25rem;
    transition: var(--sg-transition);
    cursor: default;
}
.sg-badge-license:hover {
    background: var(--sg-accent);
    color: var(--sg-accent-text);
    border-color: var(--sg-accent);
}

/* ── CTA finale ────────────────────────────────────────────── */
.sg-cta-section {
    background: var(--sg-accent);
    padding: 4.5rem 1.5rem;
    text-align: center;
}
.sg-cta-title {
    font-size: var(--sg-fs-2xl);
    font-weight: var(--sg-fw-bold);
    color: var(--sg-accent-text);
    margin: 0 0 .75rem;
}
.sg-cta-subtitle {
    font-size: var(--sg-fs-lg);
    color: rgba(255,255,255,.88);
    margin: 0 0 2rem;
}
.sg-btn-cta {
    display: inline-flex;
    align-items: center;
    background: #fff;
    color: var(--sg-accent);
    font-weight: var(--sg-fw-semibold);
    font-size: var(--sg-fs-base);
    padding: .75rem 2.25rem;
    border-radius: var(--sg-radius);
    text-decoration: none;
    transition: var(--sg-transition);
    box-shadow: 0 4px 16px rgba(0,0,0,.16);
}
.sg-btn-cta:hover {
    background: rgba(255,255,255,.92);
    color: var(--sg-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(0,0,0,.22);
    text-decoration: none;
}

/* ── Dark mode guest (data-bs-theme su <html> via Alpine) ──── */
[data-bs-theme='dark'] .sg-auth-card {
    background: var(--sg-shell-bg-elevated);
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
[data-bs-theme='dark'] .sg-auth-card .sg-auth-title,
[data-bs-theme='dark'] .sg-auth-card .sg-auth-subtitle,
[data-bs-theme='dark'] .sg-auth-card .sg-auth-app-name {
    color: var(--sg-shell-text);
}
[data-bs-theme='dark'] .sg-auth-footer {
    color: var(--sg-shell-text-muted);
    border-color: rgba(255,255,255,.1);
}
[data-bs-theme='dark'] .sg-guest-stat-card {
    background: var(--sg-shell-bg-elevated);
    border-color: rgba(255,255,255,.08);
}
[data-bs-theme='dark'] .sg-guest-stat-value { color: var(--sg-shell-text); }
[data-bs-theme='dark'] .sg-guest-stat-label { color: var(--sg-shell-text-muted); }
[data-bs-theme='dark'] .sg-features-section { background: var(--sg-shell-bg); }
[data-bs-theme='dark'] .sg-section-heading  { color: var(--sg-shell-text); }
[data-bs-theme='dark'] .sg-feature-card {
    background: var(--sg-shell-bg-elevated);
    border-color: rgba(255,255,255,.08);
}
[data-bs-theme='dark'] .sg-feature-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.35); }
[data-bs-theme='dark'] .sg-feature-title { color: var(--sg-shell-text); }
[data-bs-theme='dark'] .sg-feature-text  { color: var(--sg-shell-text-muted); }
[data-bs-theme='dark'] .sg-badge-license {
    background: rgba(60,141,188,.18);
    border-color: rgba(60,141,188,.32);
}

/* ============================================================
   ACCESSIBILITÀ — Feature 19.0 (deroga controllata)
   ------------------------------------------------------------
   DEROGA al vincolo "zero CSS custom" di CLAUDE.md:
   ammesso SOLO il CSS strettamente necessario qui di seguito:
     · @font-face OpenDyslexic (self-hosted, licenza SIL OFL)
     · classi utility a11y-* scoped su html element
   Vietato aggiungere altro CSS custom fuori da questo foglio.
   Non estendere questa deroga ad altri file o componenti.
   ============================================================ */

/* Font OpenDyslexic — self-hosted in public/fonts/opendyslexic/ */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('/fonts/opendyslexic/OpenDyslexic-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'OpenDyslexic';
    src: url('/fonts/opendyslexic/OpenDyslexic-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'OpenDyslexic';
    src: url('/fonts/opendyslexic/OpenDyslexic-Italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

/* ── Font DSA: sostituisce l'intera family quando attivo ─── */
html.a11y-dyslexic,
html.a11y-dyslexic body {
    font-family: 'OpenDyslexic', var(--sg-font) !important;
}

/* ── Scala testo: agisce su font-size radice → tutto in rem scala ── */
/* Default scale = 1 (fallback quando nessuna classe è presente)     */
html {
    font-size: calc(100% * var(--sg-a11y-text-scale, 1));
}
html.a11y-text-large  { --sg-a11y-text-scale: 1.15; }
html.a11y-text-xlarge { --sg-a11y-text-scale: 1.3; }

/* ── Correzioni layout con xlarge: sidebar AdminLTE e navbar ─── */
html.a11y-text-xlarge .main-sidebar { font-size: .9rem; }
html.a11y-text-xlarge .navbar       { font-size: .9rem; }
html.a11y-text-xlarge .main-header .navbar { min-height: 57px; }

/* ── Lettura vocale: stato attivo del bottone (Feature 19.1) ── */
html.a11y-voice .voice-read-btn.is-reading {
    color: var(--sg-accent, #4361ee);
    border-color: var(--sg-accent, #4361ee);
}
html.a11y-voice .voice-read-btn.is-reading .fa-volume-up::before {
    content: "\f028"; /* fa-volume-up solid — sostituisce l'icona durante la lettura */
}

/* ── Dark mode: le classi a11y non toccano i colori ─────────── */
