/* ============================================================
   SSMlab — Stylesheet principale
   Design: dark tech, gradiente teal → indigo
   ============================================================ */

:root {
    --bg:            #0b1120;
    --bg-soft:       #0f172a;
    --card:          #131c31;
    --card-border:   #1e2a44;
    --text:          #e2e8f0;
    --text-muted:    #94a3b8;
    --teal:          #14b8a6;
    --indigo:        #6366f1;
    --gradient:      linear-gradient(135deg, #14b8a6 0%, #6366f1 100%);
    --danger:        #f87171;
    --success:       #34d399;
    --radius:        14px;
    --shadow:        0 10px 40px rgba(0, 0, 0, .35);
    --font-display:  'Sora', sans-serif;
    --font-body:     'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; }

a { color: inherit; text-decoration: none; }

.container {
    width: min(1200px, 92%);
    margin-inline: auto;
}

/* ---------- NAVBAR ---------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 17, 32, .8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    transition: box-shadow .3s;
}
.navbar.scrolled { box-shadow: var(--shadow); }

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; }
.brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: -.5px;
}
.brand-accent {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a {
    font-size: .95rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: 14px;
    position: relative;
}

.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 6px; z-index: 310; }
.hamburger span {
    display: block;
    width: 24px; height: 2px;
    background: var(--text);
    margin: 5px 0;
    transition: transform .3s ease, opacity .3s ease;
    border-radius: 2px;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- BOTTONI ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 28px;
    border-radius: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .95rem;
    border: none;
    cursor: pointer;
    transition: transform .15s, box-shadow .2s, opacity .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--gradient);
    color: #fff !important;
    box-shadow: 0 4px 20px rgba(20, 184, 166, .35);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(99, 102, 241, .45); }

.btn-outline {
    background: transparent;
    color: var(--text) !important;
    border: 1px solid var(--card-border);
}
.btn-outline:hover { border-color: var(--teal); }

.btn-sm { padding: 9px 18px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 36px; font-size: 1.05rem; }

/* ---------- FLASH ---------- */
.flash {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 14px 44px 14px 20px;
    border-radius: 10px;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: slideDown .4s ease;
    max-width: 90%;
}
@keyframes slideDown {
    from { opacity: 0; transform: translate(-50%, -16px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
.flash-success { background: #064e3b; color: #a7f3d0; border: 1px solid #10b981; }
.flash-error   { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
.flash-info    { background: #1e3a5f; color: #bfdbfe; border: 1px solid #3b82f6; }
.flash-close {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ---------- HERO ---------- */
.hero {
    position: relative;
    padding: 120px 0 100px;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -200px; right: -150px;
    width: 700px; height: 700px;
    background: radial-gradient(circle, rgba(99, 102, 241, .28), transparent 65%);
    pointer-events: none;
}
.hero::after {
    content: '';
    position: absolute;
    bottom: -250px; left: -150px;
    width: 700px; height: 700px;
    background: radial-gradient(circle, rgba(20, 184, 166, .22), transparent 65%);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 60px;
    align-items: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 184, 166, .14);
    border: 1px solid rgba(20, 184, 166, .4);
    color: var(--teal);
    font-size: .88rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 999px;
    margin-bottom: 24px;
}

.hero h1 {
    font-size: clamp(2.6rem, 5.2vw, 4.2rem);
    font-weight: 800;
    letter-spacing: -1.5px;
    margin-bottom: 24px;
    line-height: 1.15;
}
.hero h1 .grad {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero p.lead {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 580px;
    margin-bottom: 38px;
    line-height: 1.65;
}

.hero-cta { display: flex; gap: 18px; flex-wrap: wrap; }

.hero-visual { position: relative; display: flex; justify-content: center; align-items: center; }
.hero-visual img {
    width: min(520px, 100%);
    max-width: 100%;
    filter: drop-shadow(0 0 70px rgba(99, 102, 241, .5));
    animation: float 5s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-16px); }
}

/* ---------- STATS ---------- */
.stats {
    border-block: 1px solid var(--card-border);
    background: var(--bg-soft);
    padding: 40px 0;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    text-align: center;
}
.stat-num {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.stat-label { color: var(--text-muted); font-size: .9rem; }

/* ---------- SEZIONI ---------- */
.section { padding: 90px 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 56px; }
.section-head h2 {
    font-size: clamp(1.7rem, 3.5vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -.5px;
    margin-bottom: 14px;
}
.section-head p { color: var(--text-muted); }

/* ---------- FEATURES ---------- */
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.feature-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 32px 28px;
    transition: transform .25s, border-color .25s;
}
.feature-card:hover {
    transform: translateY(-6px);
    border-color: rgba(20, 184, 166, .5);
}
.feature-icon {
    width: 52px; height: 52px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    border-radius: 12px;
    background: rgba(20, 184, 166, .12);
    margin-bottom: 20px;
}
.feature-card h3 { font-size: 1.15rem; margin-bottom: 10px; }
.feature-card p { color: var(--text-muted); font-size: .95rem; }

.badge-soon {
    display: inline-block;
    margin-left: 8px;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--indigo);
    background: rgba(99, 102, 241, .15);
    border: 1px solid rgba(99, 102, 241, .4);
    padding: 2px 9px;
    border-radius: 999px;
    vertical-align: middle;
}

/* ---------- ARCHIVIO ANNI ---------- */
.years-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 14px;
}
.year-chip {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 18px 8px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    transition: .25s;
    cursor: pointer;
}
.year-chip:hover {
    background: var(--gradient);
    border-color: transparent;
    transform: translateY(-4px);
    color: #fff;
}

/* ---------- CTA FINALE ---------- */
.cta-final {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 64px 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.cta-final::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top, rgba(99, 102, 241, .18), transparent 60%);
    pointer-events: none;
}
.cta-final h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 14px; }
.cta-final p { color: var(--text-muted); margin-bottom: 30px; }

/* ---------- AUTH (login / register) ---------- */
.auth-wrap {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 70px 0;
    position: relative;
    width: 100%;
}
.auth-wrap::before {
    content: '';
    position: absolute;
    top: 10%; left: 50%;
    transform: translateX(-50%);
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(20, 184, 166, .12), transparent 65%);
    pointer-events: none;
}
.auth-card {
    position: relative;
    width: min(540px, 92vw);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 44px 40px;
    box-shadow: var(--shadow);
}
.auth-card .auth-logo {
    width: 56px;
    display: block;
    margin: 0 auto 18px;
    border-radius: 14px;
}
.auth-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 8px;
}
.auth-card .auth-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: .92rem;
    margin-bottom: 30px;
}

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 7px;
    color: var(--text-muted);
}

input, select {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 13px 15px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: .95rem;
    transition: border-color .2s, box-shadow .2s;
}
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2314b8a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}
select option {
    background: var(--card, #1e293b);
    color: var(--text, #f8fafc);
    padding: 10px;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, .15);
}
input.input-error { border-color: var(--danger); }

.field-error {
    color: var(--danger);
    font-size: .8rem;
    margin-top: 5px;
}

.auth-alt {
    text-align: center;
    margin-top: 24px;
    font-size: .9rem;
    color: var(--text-muted);
}
.auth-alt a { color: var(--teal); font-weight: 600; }
.auth-alt a:hover { text-decoration: underline; }

.pw-wrap { position: relative; }
.pw-toggle {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

.pw-meter {
    height: 5px;
    border-radius: 3px;
    background: var(--card-border);
    margin-top: 8px;
    overflow: hidden;
}
.pw-meter-bar {
    height: 100%;
    width: 0;
    border-radius: 3px;
    transition: width .3s, background .3s;
}
.pw-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }

/* ---------- DASHBOARD ---------- */
.dash { flex: 1; padding: 50px 0 80px; }

.dash-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
}
.dash-head h1 { font-size: 1.8rem; letter-spacing: -.5px; }
.dash-head .sub { color: var(--text-muted); margin-top: 4px; }

.avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--gradient);
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 36px;
}
.dash-stat {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 24px;
}
.dash-stat .icon { font-size: 1.4rem; margin-bottom: 10px; }
.dash-stat .num {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 800;
}
.dash-stat .lbl { color: var(--text-muted); font-size: .85rem; }

.dash-cols {
    display: grid;
    grid-template-columns: 1.4fr .6fr;
    gap: 24px;
    align-items: start;
}

.panel {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 28px;
}
.panel h2 {
    font-size: 1.1rem;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .big { font-size: 2.6rem; margin-bottom: 12px; }
.empty-state p { font-size: .95rem; margin-bottom: 20px; }

.profile-list { list-style: none; }
.profile-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--card-border);
    font-size: .92rem;
}
.profile-list li:last-child { border-bottom: none; }
.profile-list .k { color: var(--text-muted); }
.profile-list .v { font-weight: 600; text-align: right; }

table.sim-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.sim-table th, .sim-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--card-border);
}
.sim-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ---------- FOOTER ---------- */
.footer {
    margin-top: auto;
    background: var(--bg-soft);
    border-top: 1px solid var(--card-border);
    padding-top: 50px;
    width: 100%;
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    flex-wrap: wrap;
    padding-bottom: 40px;
}
.footer-brand { display: flex; gap: 16px; max-width: 340px; }
.footer-logo { width: 46px; height: 46px; border-radius: 12px; }
.footer-brand strong { font-family: var(--font-display); font-size: 1.15rem; }
.footer-brand p { color: var(--text-muted); font-size: .88rem; margin-top: 6px; }

.footer-links { display: flex; gap: 60px; }
.footer-links h4 { font-size: .95rem; margin-bottom: 14px; }
.footer-links a {
    display: block;
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 9px;
    transition: color .2s;
}
.footer-links a:hover { color: var(--teal); }

.footer-bottom {
    border-top: 1px solid var(--card-border);
    padding: 18px 0;
    font-size: .82rem;
    color: var(--text-muted);
}

/* ---------- ANIMAZIONI SCROLL ---------- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity .6s ease, transform .6s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- TABLE RESPONSIVE WRAPPER ---------- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}
.table-responsive table {
    min-width: 600px;
}

/* ============================================================
   ADMIN DASHBOARD & MODULO AI IMPORTAZIONE
   ============================================================ */

.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 6px;
    margin-bottom: 30px;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.admin-tabs::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}
.admin-tabs::-webkit-scrollbar-thumb {
    display: none !important;
}
.admin-tabs::-webkit-scrollbar-track {
    display: none !important;
}

.admin-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.admin-tab-btn.active {
    color: #fff;
    background: var(--teal);
    box-shadow: 0 4px 14px rgba(20, 184, 166, 0.35);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Zone di drag and drop e caricamento PDF */
.dropzone {
    border: 2px dashed var(--card-border);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    background: var(--card);
    transition: all 0.25s ease;
    cursor: pointer;
    position: relative;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--teal);
    background: rgba(20, 184, 166, 0.05);
    transform: translateY(-2px);
}

.dropzone-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
}

.dropzone-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.dropzone-sub {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 16px;
}

/* Barra di avanzamento AI */
.progress-wrap {
    background: var(--bg-soft);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--card-border);
    margin-top: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.progress-bar-bg {
    height: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient);
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* Tag categoria e badge */
.cat-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Tabella domande estratti */
.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--card);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    background: var(--bg-soft);
    padding: 14px 16px;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--card-border);
}

.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
    vertical-align: top;
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.015);
}

.editable-textarea {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--card-border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.88rem;
    resize: vertical;
    min-height: 60px;
}

.editable-textarea:focus, .editable-select:focus, .editable-input:focus {
    border-color: var(--teal);
    outline: none;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.editable-select, .editable-input {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--card-border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.88rem;
}

/* Modale Admin */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 32, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.modal-backdrop.open {
    display: flex;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    width: min(780px, 95%);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    padding: 28px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: var(--bg-soft);
    color: var(--text);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--teal);
    color: var(--teal);
}

.page-btn.active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}

/* ---------- MENU PROFILO NAVBAR (POPOVER) ---------- */
.user-profile-menu {
    position: relative;
    display: inline-block;
}

.profile-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 99px;
    cursor: pointer;
    color: var(--text);
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

.profile-pill-btn:hover {
    border-color: var(--teal);
    background: rgba(20, 184, 166, 0.08);
}

.online-dot {
    width: 9px;
    height: 9px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    display: inline-block;
}

.profile-pill-name {
    font-weight: 600;
    font-size: 0.88rem;
}

.profile-pill-avatar {
    width: 28px;
    height: 28px;
    background: var(--gradient);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 800;
    font-family: var(--font-display);
}

.profile-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 48px;
    width: 290px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    z-index: 250;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.profile-dropdown-menu.open {
    display: block;
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--card-border);
}

.avatar-large {
    width: 44px;
    height: 44px;
    background: var(--gradient);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    font-family: var(--font-display);
}

.profile-dropdown-body {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}
.info-row strong {
    color: var(--text);
    font-weight: 600;
}

.profile-dropdown-footer {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--card-border);
}

.dropdown-item.logout-link {
    color: var(--danger);
}
.dropdown-item.logout-link:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* ============================================================
   SISTEMA RESPONSIVE COMPLETO & MOBILE OPTIMIZATION
   ============================================================ */

/* QUIZ LAYOUT CLASSES */
.quiz-grid-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}
.quiz-grid-wrap.has-sidebar {
    grid-template-columns: 300px 1fr;
}
.quiz-sidebar-panel {
    position: sticky;
    top: 90px;
    padding: 20px;
    order: 1;
}
#questionCardPanel {
    order: 2;
}
.quiz-sidebar-header .grid-toggle-icon {
    display: none;
}
.question-grid-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}
.quiz-nav-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--card-border);
    padding-top: 20px;
    gap: 12px;
}
.quiz-nav-right {
    display: flex;
    gap: 12px;
}

/* MEDIA QUERIES: TABLET (< 992px) */
@media (max-width: 992px) {
    .container {
        width: 100%;
        padding-inline: 20px;
    }
    .hero {
        padding: 80px 0 60px;
    }
    .hero-inner {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 36px;
    }
    .hero p.lead {
        margin-inline: auto;
    }
    .hero-cta {
        justify-content: center;
    }
    .hero-visual {
        order: -1;
    }
    .hero-visual img {
        width: min(380px, 90%);
        max-width: 100%;
    }
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    .dash-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .dash-cols {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .quiz-grid-wrap.has-sidebar {
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }
    .quiz-sidebar-panel {
        order: 1 !important;
        position: relative;
        top: 0;
        width: 100%;
        box-sizing: border-box;
        padding: 18px 20px;
        margin: 0;
    }
    #questionCardPanel {
        order: 2 !important;
        width: 100%;
        box-sizing: border-box;
        padding: 20px;
        margin: 0;
    }
    .quiz-sidebar-header {
        cursor: pointer;
        user-select: none;
    }
    .quiz-sidebar-header .grid-toggle-icon {
        display: inline-block !important;
        transition: transform 0.25s ease;
    }
    .quiz-sidebar-panel:not(.is-open) .quiz-sidebar-body {
        display: none !important;
    }
    .quiz-sidebar-panel:not(.is-open) .grid-toggle-icon {
        transform: rotate(-90deg);
    }
    .question-grid-nav {
        grid-template-columns: repeat(8, 1fr);
        max-height: 260px;
        gap: 6px;
    }
}

/* MEDIA QUERIES: SMARTPHONE & IPHONE 14 PRO MAX (< 768px) */
@media (max-width: 768px) {
    .navbar {
        padding-block: 8px;
    }
    .nav-inner {
        padding-block: 8px;
    }
    .brand-logo {
        width: 34px;
        height: 34px;
    }
    .brand-name {
        font-size: 1.15rem;
    }
    .hamburger {
        display: block;
    }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background: var(--card);
        border-bottom: 1px solid var(--card-border);
        flex-direction: column;
        padding: 20px;
        gap: 16px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        z-index: 300;
    }
    .nav-links.open {
        display: flex;
    }
    .profile-dropdown-menu {
        position: fixed;
        top: 70px;
        right: 15px;
        left: 15px;
        width: auto;
    }
    .hero {
        padding: 50px 0 40px;
    }
    .hero h1 {
        font-size: clamp(2.1rem, 7vw, 2.8rem);
    }
    .hero p.lead {
        font-size: 1.05rem;
    }
    .hero-visual img {
        width: min(300px, 85%);
    }
    .hero-cta {
        flex-direction: column;
        width: 100%;
    }
    .hero-cta .btn {
        width: 100%;
    }
    .features-grid {
        grid-template-columns: 1fr;
    }
    .auth-card {
        padding: 32px 20px;
    }
    .footer-inner {
        flex-direction: column;
        gap: 30px;
    }
    .footer-links {
        flex-direction: column;
        gap: 24px;
    }
    .dash-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
}

/* MEDIA QUERIES: PICCOLI SMARTPHONE & DEVICE COMPATTI (< 540px) */
@media (max-width: 540px) {
    .container {
        padding-inline: 16px;
    }
    .dash-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .quiz-nav-footer {
        flex-direction: column-reverse;
        width: 100%;
    }
    .quiz-nav-footer .btn,
    .quiz-nav-right,
    .quiz-nav-right .btn {
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    table.sim-table {
        font-size: 0.82rem;
    }
    .sim-table th, .sim-table td {
        padding: 8px 6px;
    }
    .question-grid-nav {
        grid-template-columns: repeat(7, 1fr);
        gap: 5px;
    }
    .quiz-sidebar-panel, #questionCardPanel {
        padding: 16px 18px;
    }
}

/* PAGINA PROFILO RESPONSIVE */
.profile-page-container {
    padding-top: 40px;
    padding-bottom: 60px;
    max-width: 960px;
}
.profile-header-card {
    margin-bottom: 24px;
    background: radial-gradient(circle at top right, rgba(20, 184, 166, 0.1), transparent 70%), var(--card);
    border: 1px solid rgba(20, 184, 166, 0.3);
}
.profile-header-main {
    display: flex;
    align-items: center;
    gap: 20px;
}
.profile-avatar-xl {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(20, 184, 166, 0.35);
}
.profile-header-info h1 {
    font-size: 1.5rem;
    margin: 0 0 4px 0;
}
.profile-email {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 10px 0;
}
.profile-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.profile-joined-tag {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.profile-card-title {
    font-size: 1.1rem;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 12px;
}

@media (max-width: 850px) {
    .profile-page-container {
        padding-top: 24px;
        padding-bottom: 40px;
    }
    .profile-header-main {
        flex-direction: column;
        text-align: center;
        gap: 14px;
    }
    .profile-badges {
        justify-content: center;
    }
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* CUSTOM COMBOBOX RICERCA UNIVERSITÀ */
.custom-combobox-wrap {
    position: relative;
    width: 100%;
}
.combobox-input {
    width: 100%;
    padding-right: 36px !important;
}
.combobox-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--teal);
    font-size: 0.75rem;
    cursor: pointer;
    user-select: none;
}
.combobox-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    max-height: 280px;
    display: flex;
    flex-direction: column;
}
.combobox-options-list {
    overflow-y: auto;
    max-height: 220px;
    padding: 6px;
}
.combobox-item {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.combobox-item:hover, .combobox-item.selected {
    background: rgba(20, 184, 166, 0.15);
    color: var(--teal);
    font-weight: 600;
}
.combobox-no-results {
    padding: 12px 14px;
    font-size: 0.84rem;
    color: var(--text-muted);
    text-align: center;
}
.combobox-custom-option {
    border-top: 1px solid var(--card-border);
    padding: 11px 14px;
    font-size: 0.82rem;
    color: var(--teal);
    font-weight: 600;
    background: rgba(20, 184, 166, 0.08);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease;
}
.combobox-custom-option:hover {
    background: rgba(20, 184, 166, 0.18);
}
