:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --sidebar-bg: #0c1222;
    --sidebar-text: #94a3b8;
    --sidebar-active: #1a2332;
    --bg: #eef2f7;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 10px;
}

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

body {
    font-family: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

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

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 272px;
    background: var(--sidebar-bg);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #334155;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.sidebar-brand small {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--sidebar-text);
    margin-top: 0.25rem;
}

.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; min-height: 0; }

.nav-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.15rem;
    margin-bottom: 0.15rem;
}

.nav-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.nav-group > summary.nav-section {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.nav-group > summary.nav-section::-webkit-details-marker {
    display: none;
}

.nav-group > summary.nav-section::after {
    content: '';
    display: inline-block;
    width: 0.4rem;
    height: 0.4rem;
    margin-left: auto;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.55;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.nav-group[open] > summary.nav-section::after {
    transform: rotate(-135deg);
    margin-top: 0.15rem;
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    padding-bottom: 0.25rem;
}

.nav-section {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    font-weight: 600;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-active);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--primary-light);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #334155;
    font-size: 0.8rem;
    color: var(--sidebar-text);
}

.sidebar-footer a { color: #cbd5e1; }

.main-content {
    flex: 1;
    margin-left: 272px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 { font-size: 1.25rem; font-weight: 600; }

.topbar-user {
    font-size: 0.875rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem 0.5rem;
    max-width: 100%;
}

.page-body { padding: 1.5rem; flex: 1; }

/* Cards & stats */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

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

.card-header h2 { font-size: 1.1rem; font-weight: 600; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .module-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .card-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .label { color: var(--muted); font-size: 0.875rem; margin-top: 0.25rem; }

/* Tables — horizontal scroll only on desktop; mobile uses card layout (portal-mobile.css) */
.table-wrap { overflow-x: auto; max-width: 100%; }

@media (max-width: 768px) {
    .table-wrap { overflow-x: hidden; }
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table.data-table th,
table.data-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table.data-table tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-whatsapp { background: #25d366; color: #fff; border: none; }
.btn-whatsapp:hover { background: #1da851; color: #fff; text-decoration: none; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; text-decoration: none; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.academic-year-picker-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 0;
    flex-shrink: 0;
}
.academic-year-picker-form--sidebar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    width: 100%;
    margin: 0;
}
.academic-year-picker-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    white-space: nowrap;
}
.academic-year-picker-label--topbar {
    color: var(--muted);
}
.academic-year-picker-form--sidebar .academic-year-picker-label {
    color: #94a3b8;
}
.academic-year-picker {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    max-width: 150px;
    min-width: 120px;
}
.academic-year-picker-form--sidebar .academic-year-picker {
    max-width: none;
    width: 100%;
    font-size: 0.8125rem;
    padding: 0.45rem 0.5rem;
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}
.sidebar-year-picker {
    padding: 0.75rem 1rem;
    border-top: 1px solid #334155;
    border-bottom: 1px solid #334155;
}
.academic-year-picker-static {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.academic-year-picker-current {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e2e8f0;
}
.academic-year-picker-hint {
    margin: 0.15rem 0 0;
    font-size: 0.65rem;
    line-height: 1.4;
    color: #64748b;
}
.academic-year-picker-hint code {
    font-size: 0.6rem;
    color: #94a3b8;
}
.academic-year-preview-banner {
    border-left: 4px solid var(--primary);
}

.attendance-day-banner {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #f8fafc;
}
.attendance-day-banner-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    margin-bottom: 0.35rem;
}
.attendance-day-date {
    color: var(--muted);
    font-size: 0.85rem;
}
.attendance-day-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}
.attendance-day-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.att-badge-muted { background: #e2e8f0; color: #475569; }
.att-badge-warning { background: #fef3c7; color: #92400e; }
.att-badge-info { background: #dbeafe; color: #1e40af; }
.attendance-day-summary,
.attendance-day-note {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
}
.attendance-day-holiday,
.attendance-day-weekend {
    background: #fffbeb;
    border-color: #fcd34d;
}
.attendance-day-exam,
.attendance-day-event,
.attendance-day-staff_meeting {
    background: #eff6ff;
    border-color: #93c5fd;
}
.attendance-closed-note {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.9rem;
}

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; }
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}
.form-control:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* Alerts & messages */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.messages { margin-bottom: 1rem; }

/* Breadcrumb */
.breadcrumb {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--muted); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state p { margin-top: 0.5rem; }

/* Login & account pages (no sidebar) — mobile-first responsive */
html.auth-layout,
body.auth-layout {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}
body.auth-layout {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow-y: auto;
    overflow-x: clip;
    margin: 0;
}
body.auth-layout[class*="auth-body-login"] {
    overflow: hidden;
}
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    padding:
        max(0.75rem, env(safe-area-inset-top))
        max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom))
        max(0.75rem, env(safe-area-inset-left));
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    overflow-x: hidden;
    overflow-y: visible;
}
.auth-page::before,
.auth-page::after {
    content: '';
    flex: 1 1 0;
    width: 0;
    min-height: 0;
    max-width: 100%;
    pointer-events: none;
}
@media (min-width: 640px) {
    .auth-page {
        padding:
            max(1rem, env(safe-area-inset-top))
            max(1rem, env(safe-area-inset-right))
            max(1rem, env(safe-area-inset-bottom))
            max(1rem, env(safe-area-inset-left));
    }
}
.auth-card {
    background: var(--card);
    box-sizing: border-box;
    width: min(580px, 100%);
    max-width: calc(100% - 0.5rem);
    min-width: 0;
    height: fit-content;
    flex: 0 0 auto;
    margin: 0 auto;
    padding: clamp(0.6rem, 1.8vw, 1.2rem);
    border-radius: clamp(8px, 1.5vw, 10px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    overflow-x: hidden;
}
.auth-card-login {
    width: min(620px, 100%);
    max-width: calc(100% - 0.5rem);
}
.auth-card .alert {
    padding: 0.45rem 0.65rem;
    margin-bottom: 0.6rem;
    font-size: 0.82rem;
}
.auth-brand,
.auth-form,
.auth-divider,
.auth-help-grid,
.auth-back-link,
.channel-fieldset,
.channel-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.auth-brand {
    text-align: center;
    margin-bottom: clamp(0.3rem, 1.2vw, 0.6rem);
}
.auth-logo {
    display: block;
    max-width: clamp(56px, 18vw, 96px);
    max-height: clamp(48px, 15vw, 80px);
    width: auto;
    height: auto;
    margin: 0 auto clamp(0.35rem, 1.2vw, 0.65rem);
    object-fit: contain;
}
.auth-brand h2 {
    margin-bottom: 0.15rem;
    font-size: clamp(0.95rem, 3.2vw, 1.25rem);
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.auth-motto {
    color: var(--muted);
    font-size: clamp(0.72rem, 2vw, 0.82rem);
    font-style: italic;
    margin: 0 0 0.15rem;
    line-height: 1.25;
}
.auth-card .subtitle {
    color: var(--muted);
    margin-bottom: clamp(0.6rem, 1.8vw, 0.9rem);
    font-size: clamp(0.78rem, 2vw, 0.88rem);
    text-align: center;
    line-height: 1.3;
}
.auth-form .form-group {
    margin-bottom: clamp(0.5rem, 1.5vw, 0.65rem);
}
.auth-form .form-group label {
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
}
.auth-form .form-control {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 32px;
    padding: 0.35rem 0.55rem;
    font-size: 16px; /* prevents iOS zoom on focus */
}
.auth-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 0.5rem;
    margin-bottom: 0.6rem;
    font-size: clamp(0.75rem, 2vw, 0.82rem);
}
.auth-remember {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--muted);
    cursor: pointer;
    min-height: 32px;
}
.auth-remember input { width: 0.85rem; height: 0.85rem; flex-shrink: 0; }
.auth-forgot-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}
.auth-forgot-link:hover { text-decoration: underline; }
.auth-submit-btn {
    width: 100%;
    margin-top: 0.1rem;
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
}
.password-field-wrap { position: relative; }
.password-field-wrap .form-control { padding-right: 3.5rem; }
.password-toggle {
    position: absolute;
    right: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.45rem;
    min-height: 32px;
    min-width: 32px;
}
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: clamp(0.6rem, 1.8vw, 0.8rem) 0 clamp(0.5rem, 1.5vw, 0.6rem);
    color: var(--muted);
    font-size: clamp(0.7rem, 1.8vw, 0.75rem);
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.auth-help-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
}
@media (min-width: 400px) {
    .auth-help-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
.auth-help-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    min-height: 36px;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    font-size: clamp(0.72rem, 1.8vw, 0.78rem);
    text-align: left;
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: border-color 0.15s, background 0.15s;
}
@media (min-width: 400px) {
    .auth-help-item {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 0.45rem 0.25rem;
        gap: 0.2rem;
    }
}
.auth-help-item:hover { border-color: var(--primary); background: #f0f9ff; }
.auth-help-icon {
    width: clamp(18px, 5vw, 22px);
    height: clamp(18px, 5vw, 22px);
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.55rem, 1.5vw, 0.62rem);
    font-weight: 700;
    flex-shrink: 0;
}
.auth-back-link {
    margin-top: clamp(0.6rem, 1.8vw, 0.8rem);
    text-align: center;
    font-size: clamp(0.78rem, 2vw, 0.82rem);
}
.auth-back-link a {
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0.15rem 0.35rem;
}
.auth-back-link a:hover { text-decoration: underline; }
.auth-dev-note {
    margin-top: 1rem;
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
}
.field-hint {
    font-size: clamp(0.68rem, 1.8vw, 0.72rem);
    color: var(--muted);
    margin-top: 0.2rem;
    line-height: 1.25;
}
.field-error {
    display: block;
    color: #991b1b;
    font-size: 0.72rem;
    margin-top: 0.15rem;
}
.channel-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 0.6rem;
    min-width: 0;
}
.channel-fieldset legend {
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: clamp(0.78rem, 2vw, 0.85rem);
}
.channel-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
}
@media (min-width: 520px) {
    .channel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.channel-card {
    display: block;
    position: relative;
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: clamp(0.4rem, 1.2vw, 0.5rem);
    cursor: pointer;
    min-height: 36px;
    transition: border-color 0.15s, background 0.15s;
}
.channel-card input { position: absolute; opacity: 0; pointer-events: none; }
.channel-card-body {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
@media (min-width: 520px) {
    .channel-card-body {
        flex-direction: column;
        text-align: center;
        gap: 0.3rem;
    }
}
.channel-card-icon {
    width: clamp(22px, 6vw, 26px);
    height: clamp(22px, 6vw, 26px);
    border-radius: 8px;
    background: #e0f2fe;
    color: #0369a1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.channel-card-label {
    font-weight: 500;
    font-size: clamp(0.75rem, 2vw, 0.82rem);
    line-height: 1.25;
}
.channel-card.is-selected { border-color: var(--primary); background: #f0f9ff; }
.channel-card.is-disabled { opacity: 0.55; cursor: not-allowed; }
@media (max-width: 399px) {
    .auth-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .auth-forgot-link { justify-content: center; }
}
@media (min-width: 768px) {
    .auth-card {
        width: min(580px, 100%);
        padding: 1.2rem;
    }
    .auth-card-login { width: min(640px, 100%); }
}
@media (min-width: 1024px) {
    .auth-card-login { width: min(680px, 100%); }
}

/* Module index cards */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.module-card {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    transition: box-shadow 0.2s;
}
.module-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); text-decoration: none; color: inherit; }
.module-card h3 { font-size: 1rem; margin-bottom: 0.35rem; color: var(--primary); }
.module-card p { font-size: 0.85rem; color: var(--muted); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.detail-item label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; display: block; }
.detail-item span { font-weight: 500; }

.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.search-bar input,
.portal-list-search-input { flex: 1; min-width: 180px; max-width: 360px; }
.portal-list-search-meta {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}
.list-search-no-match {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    padding: 0.75rem !important;
}

/* —— System footer —— */
.system-footer {
    flex-shrink: 0;
    margin-top: auto;
    border-top: 3px solid var(--primary);
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 1rem 1.5rem 1.15rem;
}

.system-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1.25rem;
    max-width: 100%;
}

.system-footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.system-footer-name {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.system-footer-motto {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.35;
}

.system-footer-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 1rem;
}

.system-footer-nav a {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.system-footer-nav a:hover {
    color: var(--primary);
    text-decoration: none;
}

.system-footer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.75rem;
    margin: 0;
    width: 100%;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.45;
}

.system-footer-copy,
.system-footer-year,
.system-footer-tag {
    font-size: inherit;
}

.system-footer-school {
    font-weight: 600;
    color: var(--text);
}

.system-footer-year::before,
.system-footer-tag::before {
    content: '·';
    margin-right: 0.75rem;
    color: color-mix(in srgb, var(--muted) 55%, transparent);
}

.system-footer-year {
    font-weight: 500;
    color: var(--text);
}

.system-footer-tag {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary-dark);
}

.system-footer--compact {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    margin-top: 0;
    padding: 0.55rem 1rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--card) 94%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

.system-footer--compact .system-footer-inner {
    justify-content: center;
    text-align: center;
    gap: 0.35rem 0.75rem;
}

.system-footer--compact .system-footer-brand {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.system-footer--compact .system-footer-name {
    font-size: 0.78rem;
}

.system-footer--compact .system-footer-nav {
    display: none;
}

@media (max-width: 920px) {
    body.auth-layout .system-footer--compact .system-footer-nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.35rem 0.85rem;
        margin-bottom: 0.15rem;
    }

    body.auth-layout .system-footer--compact .system-footer-nav a {
        font-size: 0.78rem;
        font-weight: 600;
        padding: 0.35rem 0.65rem;
        border-radius: 999px;
        background: color-mix(in srgb, var(--primary) 8%, transparent);
        border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
    }

    body.auth-layout .auth-page {
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    }
}

.system-footer--compact .system-footer-meta {
    width: auto;
    justify-content: center;
    gap: 0.25rem 0.5rem;
}

.system-footer--compact .system-footer-tag {
    margin-left: 0;
    text-transform: none;
    letter-spacing: 0.02em;
}

.system-footer--compact .system-footer-tag::before {
    margin-right: 0.5rem;
}

body.auth-layout .auth-page {
    padding-bottom: calc(2.75rem + env(safe-area-inset-bottom, 0px));
}

/* —— Scroll to top —— */
.scroll-to-top {
    position: fixed;
    right: 1.25rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(0.5rem);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease, background 0.15s ease;
}

.scroll-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: var(--primary-dark);
}

.scroll-to-top:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.scroll-to-top-icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

body.auth-layout .scroll-to-top {
    bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}

/* —— Re-enrollment prompt (parent & student dashboards) —— */
.re-enrollment-prompt {
    margin-bottom: 1.15rem;
    padding: 0;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
    border-radius: var(--radius-lg, 14px);
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, #fff), #fff 55%);
    box-shadow: 0 4px 18px color-mix(in srgb, var(--primary) 10%, transparent);
}

.re-enrollment-prompt-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem 1.25rem;
    padding: 1.1rem 1.15rem;
    align-items: start;
}

.re-enrollment-prompt-title {
    margin: 0 0 0.35rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.re-enrollment-prompt-text,
.re-enrollment-prompt-note {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
}

.re-enrollment-prompt-note {
    margin-top: 0.45rem;
    color: var(--muted);
}

.re-enrollment-prompt-status {
    margin: 0.55rem 0 0;
    font-size: 0.8125rem;
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    background: #f8fafc;
}

.re-enrollment-prompt-status--yes { background: #dcfce7; color: #166534; }
.re-enrollment-prompt-status--no { background: #fee2e2; color: #991b1b; }

.re-enrollment-prompt-form { min-width: min(100%, 16rem); }

.re-enrollment-prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.re-enrollment-btn {
    width: 100%;
    justify-content: center;
    font-weight: 600;
}

.re-enrollment-note-label {
    display: block;
    margin-top: 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.re-enrollment-note {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    min-height: 2.5rem;
    resize: vertical;
}

@media (max-width: 768px) {
    .re-enrollment-prompt-inner { grid-template-columns: 1fr; }
    .re-enrollment-prompt-form { min-width: 0; }
    .re-enrollment-prompt-actions { flex-direction: row; flex-wrap: wrap; }
    .re-enrollment-btn { flex: 1 1 8rem; width: auto; }
}

@media (max-width: 768px) {
    .scroll-to-top {
        right: 1rem;
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        width: 2.5rem;
        height: 2.5rem;
    }

    body.auth-layout .scroll-to-top {
        bottom: calc(3.25rem + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 767px) {
    .system-footer {
        padding-inline: 1rem;
    }

    .system-footer-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .system-footer-year::before,
    .system-footer-tag::before {
        display: none;
    }

    .system-footer-tag {
        margin-left: 0;
    }
}
