/* ============================================================
   Orario Scolastico — Stili principali
   ============================================================ */

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

:root {
    --primary:    #1e3a5f;
    --primary-dk: #152b47;
    --accent:     #3b82f6;
    --accent-lt:  #eff6ff;
    --success:    #16a34a;
    --danger:     #dc2626;
    --warning:    #d97706;
    --text:       #1a1a2e;
    --text-muted: #6b7280;
    --border:     #e5e7eb;
    --bg:         #f8fafc;
    --white:      #ffffff;
    --radius:     6px;
    --shadow:     0 1px 4px rgba(0,0,0,.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,.12);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    position: sticky; top: 0; z-index: 100;
}
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    height: 56px;
}

/* ── Hamburger button ────────────────────────────────────── */
.hamburger-wrapper { position: relative; flex-shrink: 0; }

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 7px 6px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}
.hamburger-btn:hover,
.hamburger-btn[aria-expanded="true"] { background: rgba(255,255,255,.22); }

.hb-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transform-origin: center;
    transition: transform .22s ease, opacity .15s ease;
}
.hamburger-btn[aria-expanded="true"] .hb-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.hamburger-btn[aria-expanded="true"] .hb-bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.hamburger-btn[aria-expanded="true"] .hb-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ── Hamburger dropdown ──────────────────────────────────── */
.hamburger-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 230px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 300;
    overflow: hidden;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}
.hamburger-menu.is-open { display: block; }

.hm-section { padding: .35rem 0; }
.hm-section + .hm-section { border-top: 1px solid var(--border); }

.hm-label {
    display: block;
    padding: .3rem .85rem .1rem;
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}
.hm-link {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .85rem;
    font-size: .875rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    transition: background .1s;
}
.hm-link:hover {
    background: var(--accent-lt);
    color: var(--accent);
    text-decoration: none;
}
.hm-link-dl {
    padding-left: 1.7rem;
    font-size: .8rem;
    color: var(--text-muted);
}
.hm-link-dl:hover { color: var(--accent); }

/* ── School brand ────────────────────────────────────────── */
.school-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.school-brand:hover { text-decoration: none; }
.school-logo { height: 36px; width: auto; object-fit: contain; border-radius: 3px; flex-shrink: 0; }
.school-info { display: flex; flex-direction: column; min-width: 0; }
.school-name {
    color: var(--white);
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.school-link {
    color: rgba(255,255,255,.62);
    font-size: .72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Header right (login / utente) ──────────────────────── */
.header-right {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}
.nav-user   { color: rgba(255,255,255,.75); font-size: .82rem; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.nav-link {
    color: rgba(255,255,255,.9);
    padding: .3rem .7rem;
    border-radius: var(--radius);
    font-size: .85rem;
    white-space: nowrap;
    transition: background .15s;
}
.nav-link:hover { background: rgba(255,255,255,.15); text-decoration: none; color: var(--white); }
.nav-logout { background: rgba(220,38,38,.55); }
.nav-login  { background: rgba(59,130,246,.7); }

/* ── Flash messages ──────────────────────────────────────── */
.flash {
    text-align: center;
    padding: .6rem 1rem;
    font-size: .875rem;
    font-weight: 500;
}
.flash-success { background: #dcfce7; color: #166534; border-bottom: 2px solid #4ade80; }
.flash-error   { background: #fee2e2; color: #991b1b; border-bottom: 2px solid #f87171; }
.flash-info    { background: #dbeafe; color: #1e40af; border-bottom: 2px solid #93c5fd; }

/* ── Main ────────────────────────────────────────────────── */
.site-main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
    background: var(--primary);
    color: rgba(255,255,255,.6);
    font-size: .8rem;
    padding: .75rem 1.25rem;
    text-align: center;
}
.footer-sep { margin: 0 .5rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    background: var(--white);
    color: var(--text);
    transition: background .15s, border-color .15s;
    line-height: 1;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); color: var(--white); }
.btn-danger  { background: var(--danger);  color: var(--white); border-color: var(--danger); }
.btn-danger:hover  { background: #b91c1c; color: var(--white); }
.btn-large  { padding: .75rem 2rem; font-size: 1rem; }
.btn-sm     { padding: .25rem .6rem; font-size: .8rem; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-gray   { background: #f3f4f6; color: var(--text-muted); }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-red    { background: #fee2e2; color: #991b1b; }

/* ── Alerts / info boxes ─────────────────────────────────── */
.alert, .info-box { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }
.alert-error { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.info-box    { background: var(--accent-lt); border: 1px solid #bfdbfe; color: #1e3a8a; }
.info-box ol, .info-box ul { margin: .4rem 0 0 1.25rem; }
.info-box li { margin-bottom: .2rem; }
.info-box code { background: rgba(0,0,0,.06); padding: .1rem .35rem; border-radius: 3px; font-size: .85em; }

/* ── Banners ─────────────────────────────────────────────── */
.banner-archive {
    background: #f3e8ff;
    border: 1px solid #d8b4fe;
    color: #6b21a8;
    padding: .6rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
}
.banner-archive a { color: #7c3aed; }

.banner-next-schedule {
    background: #fef9c3;
    border: 1px solid #fde047;
    color: #713f12;
    padding: .6rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
}
.banner-preview {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #14532d;
    padding: .6rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
}

/* ── Landing / Login ─────────────────────────────────────── */
.landing-page, .login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 55vh;
}
.landing-card, .login-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    text-align: center;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-md);
}
.landing-logo, .login-logo { height: 80px; width: auto; margin-bottom: 1rem; object-fit: contain; }
.landing-card h1, .login-card h1 { font-size: 1.4rem; margin-bottom: .5rem; }
.login-title   { font-size: 1.5rem; font-weight: 700; margin-bottom: .4rem; }
.login-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.5rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow .15s;
    text-decoration: none;
}
.btn-google:hover { box-shadow: var(--shadow-md); text-decoration: none; }

/* ── Orario Index ────────────────────────────────────────── */
.page-header {
    margin-bottom: 1.25rem;
}
.page-header-main h2 { font-size: 1.5rem; }
.valid-from { color: var(--text-muted); font-size: .875rem; margin-top: .2rem; }

.search-box { margin-bottom: 1.25rem; }
.search-box input {
    width: 100%;
    max-width: 400px;
    padding: .5rem .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    outline: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }

.entity-columns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}
.entity-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: .4rem;
    margin-bottom: .75rem;
}
.entity-list { list-style: none; }
.entity-list li { margin-bottom: .25rem; }
.entity-list a {
    display: block;
    padding: .3rem .6rem;
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    transition: background .12s;
}
.entity-list a:hover { background: var(--accent-lt); color: var(--accent); text-decoration: none; }
.entity-list li.hidden { display: none; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; }

/* ── PDF bar ─────────────────────────────────────────────── */
.pdf-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .55rem .85rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
}
.pdf-bar-label { color: #166534; font-weight: 600; margin-right: .25rem; }
.btn-pdf {
    background: var(--white);
    border: 1px solid #86efac;
    color: #15803d;
    padding: .25rem .75rem;
    font-size: .82rem;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background .12s;
}
.btn-pdf:hover { background: #dcfce7; text-decoration: none; }
.btn-pdf-dl { background: #f0fdf4; }

/* ── Admin archive (details/summary) ────────────────────── */
.admin-archive {
    margin-top: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
}
.admin-archive summary {
    padding: .75rem 1rem;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    color: var(--primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.admin-archive summary::-webkit-details-marker { display: none; }
.admin-archive summary::before { content: '▶'; font-size: .7rem; transition: transform .15s; }
.admin-archive[open] summary::before { transform: rotate(90deg); }
.admin-archive .admin-table { border-radius: 0; box-shadow: none; border-top: 1px solid var(--border); }

/* ── Admin schedule table extras ─────────────────────────── */
.row-expired td { opacity: .65; }
.cell-pdf { white-space: nowrap; }
.pdf-badge {
    display: inline-block;
    padding: .15rem .45rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 4px;
    font-size: .75rem;
    color: #15803d;
    text-decoration: none;
    margin-right: .2rem;
}
.pdf-badge:hover { background: #dcfce7; text-decoration: none; }

/* PDF upload area (admin/schedules) */
.pdf-current {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .6rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: var(--radius);
    margin-bottom: .5rem;
    font-size: .85rem;
}
.pdf-icon { font-size: 1.1rem; }
.pdf-filename { color: #15803d; flex: 1; }
.pdf-remove-label { display: flex; align-items: center; gap: .3rem; color: var(--danger); cursor: pointer; font-size: .8rem; }

/* ── Schedule page ───────────────────────────────────────── */
.schedule-page {}
.schedule-header { margin-bottom: 1.25rem; }
.schedule-header h2 { font-size: 1.4rem; margin: .3rem 0; }
.entity-name { color: var(--primary); }

.schedule-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.back-link { color: var(--text-muted); font-size: .875rem; }
.back-link:hover { color: var(--text); }
.nav-prev, .nav-next {
    font-size: .85rem;
    padding: .2rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
}
.nav-prev:hover, .nav-next:hover { background: var(--bg); text-decoration: none; }

/* ── Schedule table ──────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    min-width: 640px;
    background: var(--white);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

.schedule-table thead tr {
    background: var(--primary);
}
.schedule-table thead th {
    color: var(--white);
    padding: .55rem .4rem;
    text-align: center;
    font-weight: 600;
    font-size: .8rem;
    letter-spacing: .04em;
    white-space: nowrap;
}
.schedule-table thead th.time-col { width: 52px; }

.schedule-table tbody tr:nth-child(even) .time-slot { background: #f0f4f8; }
.schedule-table tbody tr:nth-child(odd)  .time-slot { background: #e8edf3; }

.time-slot {
    font-weight: 700;
    text-align: center;
    padding: .4rem .3rem;
    white-space: nowrap;
    border: 1px solid var(--border);
    font-size: .78rem;
    color: var(--primary);
}

.lesson-cell {
    border: 1px solid rgba(0,0,0,.12);
    padding: .35rem .45rem;
    vertical-align: middle;
    text-align: center;
    min-width: 90px;
    transition: filter .1s;
}
.lesson-cell:hover { filter: brightness(.94); }

.empty-cell {
    border: 1px solid var(--border);
    background: #f9fafb;
    min-width: 90px;
}

.lesson-subject {
    font-weight: 700;
    font-size: .78rem;
    line-height: 1.2;
    margin-bottom: 3px;
}
.lesson-class {
    font-weight: 800;
    font-size: .85rem;
    margin-bottom: 2px;
}
.lesson-detail {
    font-size: .72rem;
    line-height: 1.3;
    opacity: .9;
}
.lesson-detail a { color: inherit; }
.lesson-detail a:hover { text-decoration: underline; }

/* Badge per ore a disposizione / ricevimento (vista docente) */
.lesson-type-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 2rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.lesson-badge-disp {
    background: rgba(217, 119, 6, .15);
    color: #92400e;
    border: 1px solid rgba(217, 119, 6, .35);
}
.lesson-badge-ric {
    background: rgba(59, 130, 246, .13);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, .3);
}

/* ── Landing description (HTML dall'editor) ──────────────── */
.landing-description {
    margin-bottom: 1rem;
    font-size: .95rem;
    line-height: 1.65;
    color: var(--text);
    text-align: left;
}
.landing-description h2 { font-size: 1.15rem; font-weight: 700; margin: .6rem 0 .3rem; color: var(--primary); }
.landing-description h3 { font-size: 1rem;    font-weight: 700; margin: .5rem 0 .25rem; color: var(--primary); }
.landing-description p  { margin: 0 0 .5rem; }
.landing-description ul,
.landing-description ol { margin: .3rem 0 .5rem 1.4rem; }
.landing-description li { margin-bottom: .2rem; }
.landing-description a  { color: var(--accent); }
.landing-description a:hover { text-decoration: underline; }

/* ── HTML Editor (admin) ──────────────────────────────────── */
.html-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}
.html-editor:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}
.html-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: .35rem .5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.html-editor-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 5px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
}
.html-editor-toolbar button:hover {
    background: var(--white);
    border-color: var(--border);
}
.html-editor-toolbar button.is-active {
    background: var(--accent-lt);
    border-color: var(--accent);
    color: var(--accent);
}
.html-editor-toolbar button.btn-clear-fmt { color: var(--danger); }
.html-editor-toolbar button.btn-clear-fmt:hover { background: #fee2e2; border-color: #fca5a5; }
.editor-sep {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
    align-self: center;
}
.html-editor-body {
    padding: .65rem .85rem;
    min-height: 130px;
    max-height: 400px;
    overflow-y: auto;
    outline: none;
    font-size: .9rem;
    line-height: 1.65;
    color: var(--text);
}
.html-editor-body:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
    font-style: italic;
}
.html-editor-body h2 { font-size: 1.15rem; font-weight: 700; margin: .4rem 0 .25rem; color: var(--primary); }
.html-editor-body h3 { font-size: 1rem;    font-weight: 700; margin: .35rem 0 .2rem; color: var(--primary); }
.html-editor-body p  { margin: 0 0 .4rem; }
.html-editor-body ul,
.html-editor-body ol { margin: .25rem 0 .4rem 1.4rem; }
.html-editor-body li { margin-bottom: .15rem; }
.html-editor-body a  { color: var(--accent); }

/* ── Admin layout ────────────────────────────────────────── */
.admin-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.admin-sidebar {
    position: sticky;
    top: 74px;
}
.admin-nav {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.admin-nav a {
    display: block;
    padding: .65rem 1rem;
    color: var(--text);
    font-size: .875rem;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.admin-nav a:last-child { border-bottom: none; }
.admin-nav a:hover { background: var(--accent-lt); text-decoration: none; }
.admin-nav a.active { background: var(--accent-lt); color: var(--accent); font-weight: 600; }
.admin-nav hr { border: none; border-top: 2px solid var(--border); }

.admin-content h2 { font-size: 1.4rem; margin-bottom: 1.25rem; }
.admin-content h3 { font-size: 1.05rem; margin: 1.25rem 0 .75rem; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}
.section-header h3 { margin: 0; }

/* ── Stats cards ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-label  { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Admin table ─────────────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    background: var(--white);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}
.admin-table thead tr { background: var(--primary); }
.admin-table thead th { color: var(--white); padding: .55rem .75rem; text-align: left; font-weight: 600; font-size: .82rem; white-space: nowrap; }
.admin-table tbody tr { border-bottom: 1px solid var(--border); }
.admin-table tbody tr:hover { background: var(--bg); }
.admin-table td { padding: .55rem .75rem; vertical-align: middle; }
.admin-table td.actions { white-space: nowrap; }
.admin-table td code { background: #f3f4f6; padding: .15rem .4rem; border-radius: 3px; font-size: .85em; }

/* ── Admin form ──────────────────────────────────────────── */
.admin-form { max-width: 680px; }

.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--text);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    outline: none;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group small { display: block; margin-top: .3rem; color: var(--text-muted); font-size: .78rem; }

.form-checkbox { display: flex; align-items: flex-start; gap: .75rem; }
.form-checkbox label { display: flex; align-items: center; gap: .4rem; font-weight: 500; cursor: pointer; }
.form-checkbox input[type="checkbox"] { width: 16px; height: 16px; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.form-row .form-group { flex: 1; min-width: 160px; }
.form-group-btn { flex: 0 0 auto; display: flex; gap: .5rem; }

.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--white);
}
fieldset legend {
    font-weight: 700;
    font-size: .95rem;
    color: var(--primary);
    padding: 0 .5rem;
}

/* ── Stat card link ──────────────────────────────────────── */
a.stat-card-link {
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, transform .1s;
    display: block;
}
a.stat-card-link:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    text-decoration: none;
}

/* ── Users table ─────────────────────────────────────────── */
.row-self { background: #fafafa; }
.cell-email { font-size: .82rem; color: var(--text-muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-date  { font-size: .82rem; white-space: nowrap; }
.text-muted { color: var(--text-muted); }

.form-inline-role {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-right: .35rem;
}
.select-role {
    padding: .2rem .4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .8rem;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
}
.select-role:focus { border-color: var(--accent); outline: none; }

.table-count {
    margin-top: .6rem;
    font-size: .8rem;
    color: var(--text-muted);
    text-align: right;
}

/* ── Edit card ───────────────────────────────────────────── */
.edit-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.edit-card h3 { margin: 0 0 1rem; font-size: 1rem; }

/* ── Error page ──────────────────────────────────────────── */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 3rem; color: var(--danger); margin-bottom: .5rem; }
.error-page p  { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Course switcher ─────────────────────────────────────── */
.course-switcher {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .75rem 1.5rem .25rem;
    max-width: 1400px;
    margin: 0 auto;
}
.course-tab {
    display: inline-block;
    padding: .35rem .9rem;
    border-radius: 2rem;
    font-size: .85rem;
    font-weight: 500;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    background: var(--white);
    transition: border-color .15s, color .15s, background .15s;
}
.course-tab:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.course-tab.active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}

/* ── Orologio placeholder (nessun orario attivo) ─────────── */
.clock-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem 3rem;
    gap: 1.75rem;
}

.orario-clock {
    position: relative;
    width: 160px;
    height: 160px;
    border: 4px solid var(--primary);
    border-radius: 50%;
    background: var(--white);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

/* Tick marks (ore)
   Ogni tick parte dal top del cerchio e si estende fino al centro (80px = raggio).
   Il transform-origin è bottom center = esatto centro del cerchio.
   Solo i primi 8px in alto vengono colorati (gradient), il resto è trasparente. */
.clock-tick {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 80px;
    background: linear-gradient(to bottom, var(--primary) 8px, transparent 8px);
    transform-origin: bottom center;
    margin-left: -1px;
}

/* Lancette */
.clock-hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    border-radius: 4px 4px 0 0;
    background: var(--primary);
}
.clock-hand-hour {
    width: 5px;
    height: 46px;
    margin-left: -2.5px;
}
.clock-hand-minute {
    width: 3px;
    height: 62px;
    margin-left: -1.5px;
    background: var(--accent);
}
.clock-hand-second {
    width: 2px;
    height: 68px;
    margin-left: -1px;
    background: var(--danger);
}

.clock-center {
    position: absolute;
    top: 50%; left: 50%;
    width: 10px; height: 10px;
    background: var(--primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.clock-message {
    font-size: 1rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 340px;
    line-height: 1.5;
}

/* ── Schedule day navigator (mobile) ────────────────────────── */
.schedule-day-nav {
    display: none;
    gap: .4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .3rem;
    margin-bottom: .75rem;
    scrollbar-width: none;
}
.schedule-day-nav::-webkit-scrollbar { display: none; }

.schedule-day-btn {
    flex-shrink: 0;
    padding: .42rem 1rem;
    border-radius: 2rem;
    border: 1.5px solid var(--border);
    background: var(--white);
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: .04em;
}
.schedule-day-btn:hover { border-color: var(--accent); color: var(--accent); }
.schedule-day-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}
.schedule-day-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Responsive — 768px ─────────────────────────────────────── */
@media (max-width: 768px) {
    /* Spaziatura */
    .site-main { padding: 1rem .75rem; }

    /* ── Admin layout ── */
    .admin-layout { grid-template-columns: 1fr; }

    /* Sidebar: statica, diventa una barra orizzontale sopra il contenuto */
    .admin-sidebar {
        position: static;
        margin-bottom: .75rem;
    }

    /* Admin nav: trasformato in tab-bar a pillole orizzontale */
    .admin-nav {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        /* Reset esplicito di overflow:hidden che nel base blocca lo scroll */
        overflow: visible;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: .3rem .4rem;
        gap: .2rem;
        border-radius: 2rem;
    }
    .admin-nav::-webkit-scrollbar { display: none; }
    .admin-nav hr { display: none; }   /* nasconde i separatori verticali */
    .admin-nav a {
        flex-shrink: 0;
        white-space: nowrap;
        border: none;              /* rimuove tutti i bordi da desktop */
        border-radius: 2rem;
        padding: .4rem .9rem;
        font-size: .82rem;
        color: var(--text-muted);
    }
    .admin-nav a:last-child { border: none; }
    .admin-nav a:hover {
        background: var(--accent-lt);
        color: var(--accent);
    }
    .admin-nav a.active {
        background: var(--primary);
        color: var(--white);
        font-weight: 600;
    }

    /* Admin tabelle: scorrimento orizzontale */
    .admin-table {
        display: block;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;   /* evita clipping visivo anomalo */
        max-width: 100%;
    }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }

    /* Section header: va a capo se titolo + pulsante sono troppo larghi */
    .section-header { flex-wrap: wrap; gap: .5rem; }

    /* Info box: testo lungo (URL, code) va a capo */
    .info-box { word-break: break-word; overflow-wrap: break-word; }
    .info-box code { word-break: break-all; }

    /* Form: evita overflow di input/file */
    .admin-form { max-width: 100%; }
    .form-group input[type="file"] { max-width: 100%; }
    .form-row { flex-direction: column; gap: .6rem; }
    .form-row .form-group { min-width: 0; }
    fieldset { padding: .85rem; }

    /* Header */
    .header-inner { height: 52px; padding: 0 .75rem; gap: .5rem; }
    .school-name  { font-size: .88rem; }
    .school-link  { display: none; }
    .nav-user     { display: none; }

    /* Tipografia pagina */
    .page-header-main h2 { font-size: 1.25rem; }
    .schedule-header h2  { font-size: 1.2rem; }

    /* Navigazione prev/next: target touch piu grandi */
    .schedule-nav { gap: .5rem; }
    .nav-prev, .nav-next {
        padding: .45rem .9rem;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        font-size: .875rem;
    }
    .back-link {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    /* Indice entita */
    .entity-columns  { grid-template-columns: 1fr 1fr; }
    .entity-list a   { padding: .5rem .75rem; min-height: 40px; display: flex; align-items: center; }
    .search-box input { max-width: 100%; }

    /* Course switcher — scorrimento orizzontale se troppi corsi */
    .course-switcher {
        padding: .5rem 1rem .1rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .course-switcher::-webkit-scrollbar { display: none; }
    .course-tab { flex-shrink: 0; }
}

/* ── Responsive — 600px: navigazione giorno per giorno ─────── */
@media (max-width: 600px) {
    /* Mostra i bottoni giorno */
    .schedule-day-nav { display: flex; }

    /* Tabella filtrata per giorno (classe aggiunta da JS) */
    .table-responsive.day-filter-active .schedule-table {
        min-width: 0;
        width: 100%;
    }
    .table-responsive.day-filter-active th[data-day],
    .table-responsive.day-filter-active td[data-day] {
        display: none;
    }
    .table-responsive.day-filter-active th[data-day].day-active,
    .table-responsive.day-filter-active td[data-day].day-active {
        display: table-cell;
    }
    /* Rimuovi min-width nella vista a giorno singolo */
    .table-responsive.day-filter-active .lesson-cell,
    .table-responsive.day-filter-active .empty-cell { min-width: 0; }
    /* Font piu leggibile con una sola colonna */
    .table-responsive.day-filter-active .schedule-table { font-size: .88rem; }
    .table-responsive.day-filter-active .lesson-subject  { font-size: .84rem; }
    .table-responsive.day-filter-active .lesson-class    { font-size: .9rem; }
    .table-responsive.day-filter-active .lesson-detail   { font-size: .76rem; }
    .table-responsive.day-filter-active .time-slot       { font-size: .82rem; padding: .5rem .4rem; }
}

/* ── Responsive — 480px ─────────────────────────────────────── */
@media (max-width: 480px) {
    /* Spaziatura */
    .site-main { padding: .75rem .5rem; }

    /* Indice entita */
    .entity-columns { grid-template-columns: 1fr; }

    /* Tabella orario (fallback senza JS o landscape) */
    .schedule-table { font-size: .72rem; }
    .lesson-subject { font-size: .7rem; }
    .lesson-detail  { font-size: .65rem; }

    /* Orologio placeholder */
    .orario-clock      { width: 120px; height: 120px; }
    .clock-tick        { height: 60px; }
    .clock-hand-hour   { height: 34px; }
    .clock-hand-minute { height: 47px; }
    .clock-hand-second { height: 51px; }

    /* Hamburger menu quasi full-width */
    .hamburger-menu { min-width: calc(100vw - 2rem); }

    /* Card login / landing */
    .login-card, .landing-card { padding: 1.75rem 1.25rem; }

    /* Tipografia */
    .page-header-main h2 { font-size: 1.1rem; }
    .schedule-header h2  { font-size: 1.05rem; }
    .stat-number         { font-size: 1.6rem; }
}
