:root {
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --accent: #0ea5e9;
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #1d4ed8;
    --surface: #f1f5f9;
    --surface-elevated: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    --radius: 12px;
    --radius-lg: 16px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--surface);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── App shell ─── */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-tagline { font-size: 0.7rem; color: #94a3b8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }

.sidebar-user {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 999px;
    margin-top: 4px;
}
.role-student { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.role-teacher { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.role-admin { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }

.nav-section { padding: 16px 12px; flex: 1; }
.nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0 12px 10px;
}

.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #cbd5e1;
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.nav-links a svg { width: 18px; height: 18px; opacity: 0.75; flex-shrink: 0; }
.nav-links a:hover { background: var(--sidebar-hover); color: #fff; }
.nav-links a:hover svg { opacity: 1; }
.nav-links a.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.35);
}
.nav-links a.active svg { opacity: 1; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: #64748b;
}

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.top-nav {
    background: var(--surface-elevated);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.page-heading h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-heading p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.live-clock {
    display: flex;
    align-items: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    background: var(--surface);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.live-clock::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--danger);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: var(--danger-bg);
    transition: background 0.15s;
}

.btn-logout:hover { background: #fee2e2; }

.content-area { flex: 1; }

.dashboard-grid {
    padding: 28px 32px;
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
}

.page-content { padding: 28px 32px; }

/* ─── Cards ─── */
.card {
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    transition: box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-md); }

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.card-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon-blue { background: #eff6ff; color: var(--primary); }
.card-icon-green { background: var(--success-bg); color: var(--success); }
.card-icon-purple { background: #f5f3ff; color: #7c3aed; }

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.card-header-row h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }

/* ─── Hero banner ─── */
.page-banner {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #2563eb 100%);
    color: #fff;
    padding: 28px 32px;
    margin: 0;
}

.page-banner h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-banner p {
    margin-top: 6px;
    opacity: 0.88;
    font-size: 0.95rem;
    max-width: 560px;
}

/* ─── Stats ─── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-card-icon.green { background: var(--success-bg); }
.stat-card-icon.red { background: var(--danger-bg); }
.stat-card-icon.blue { background: #eff6ff; }

.stat-card-body strong {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-present { color: var(--success); }
.stat-late { color: var(--danger); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

/* ─── Clock controls ─── */
.panel-note { color: var(--text-muted); margin-bottom: 16px; font-size: 0.9rem; line-height: 1.6; }

.clock-container, .clock-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.clock-form label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.clock-form select,
.form-input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.clock-form select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-clock-in {
    background: linear-gradient(135deg, var(--success), #047857);
    color: #fff;
    border: none;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    width: 100%;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.btn-clock-in:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4);
}

.btn-clock-out {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
    color: #fff;
    border: none;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s;
    width: 100%;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}

.btn-clock-out:hover { transform: translateY(-1px); }

.active-session {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.active-session strong { color: var(--primary-dark); }

/* ─── Lists ─── */
.class-list { display: flex; flex-direction: column; }

.class-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.class-item:last-child { border: none; padding-bottom: 0; }
.class-item-stacked { align-items: flex-start; }

.subject-code {
    display: inline-block;
    background: #eff6ff;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 6px;
}

.teacher-line {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-badge {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.badge-present { color: var(--success); background: var(--success-bg); border-color: #a7f3d0; }
.badge-late { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }

/* ─── Status pills ─── */
.status-pill-box { display: flex; gap: 12px; margin-bottom: 20px; }

.status-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.875rem;
    transition: 0.2s;
    border: 2px solid transparent;
}

.pill-present { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.pill-late { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.pill-inactive { opacity: 0.45; filter: grayscale(0.3); }
.pill-active { opacity: 1; box-shadow: var(--shadow-md); }

/* ─── Tables ─── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

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

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

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

/* ─── Tags & buttons ─── */
.status-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-present { background: var(--success-bg); color: #047857; }
.status-late { background: var(--danger-bg); color: #b91c1c; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border: none;
    padding: 13px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(29, 78, 216, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(29, 78, 216, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: var(--text);
    padding: 9px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--border);
    transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: #cbd5e1;
}

/* ─── Flash messages ─── */
.flash {
    margin: 16px 32px 0;
    padding: 14px 18px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash-success {
    background: var(--success-bg);
    color: #047857;
    border: 1px solid #a7f3d0;
}

.flash-error {
    background: var(--danger-bg);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* ─── Site footer ─── */
.site-footer {
    background: var(--surface-elevated);
    border-top: 1px solid var(--border);
    padding: 24px 32px;
    margin-top: auto;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.footer-logo { font-weight: 800; color: var(--text); font-size: 0.95rem; }
.footer-brand p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.footer-links a:hover { color: var(--primary); }

.footer-copy {
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

/* ─── Public site header & pages ─── */
.public-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.public-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 72px;
    display: flex;
    align-items: center;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow-sm);
}

.public-header .brand-link { text-decoration: none; color: inherit; flex-shrink: 0; }
.public-header .brand-name { color: var(--text); font-size: 1.1rem; }
.public-header .brand-tagline { color: var(--text-muted); font-size: 0.65rem; }

.public-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.public-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}

.public-nav a:hover {
    color: var(--primary);
    background: #eff6ff;
}

.public-nav a.active {
    color: var(--primary);
    background: #eff6ff;
}

.public-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-nav {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: 0.15s;
}

.btn-nav-outline {
    color: var(--text);
    border: 1px solid var(--border);
    background: #fff;
}

.btn-nav-outline:hover,
.btn-nav-outline.active {
    border-color: var(--primary-light);
    color: var(--primary);
    background: #eff6ff;
}

.btn-nav-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 2px 8px rgba(29, 78, 216, 0.3);
}

.btn-nav-primary:hover,
.btn-nav-primary.active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.4);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: auto;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: 0.2s;
}

.public-main {
    flex: 1;
    padding: 48px 32px;
}

.public-content {
    max-width: 960px;
    margin: 0 auto;
}

.public-content-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.page-eyebrow,
.hero-eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    background: #eff6ff;
    padding: 6px 12px;
    border-radius: 999px;
    margin-bottom: 16px;
}

.public-content h1,
.public-hero-inner h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 16px;
}

.lead {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 32px;
}

.public-hero {
    flex: 1;
    background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
    color: #fff;
    padding: 64px 32px;
}

.public-hero-inner {
    max-width: 640px;
    margin: 0 auto 48px;
    text-align: center;
}

.public-hero-inner h1 { color: #fff; font-size: 2.5rem; }
.public-hero-inner p { color: #cbd5e1; font-size: 1.1rem; line-height: 1.7; margin-bottom: 28px; }

.hero-cta {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-cta .btn-primary { width: auto; padding: 14px 28px; text-decoration: none; display: inline-block; }

.hero-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 960px;
    margin: 0 auto;
}

.hero-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(4px);
}

.hero-card strong { display: block; font-size: 1rem; margin-bottom: 8px; }
.hero-card p { font-size: 0.875rem; color: #cbd5e1; line-height: 1.5; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.info-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.info-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }

.activity-list { display: flex; flex-direction: column; gap: 16px; }

.activity-item {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.activity-icon {
    width: 48px;
    height: 48px;
    background: #eff6ff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.activity-item h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.activity-item p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }

.contact-info {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.contact-info strong { color: var(--text); }

.contact-form-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.contact-form-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.contact-form-card textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.public-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 32px;
    margin-top: auto;
}

.public-footer-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.public-footer .footer-copy {
    width: 100%;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 8px;
}

/* ─── Login / public pages ─── */
.public-page .login-page {
    flex: 1;
    min-height: calc(100vh - 72px);
}

.login-page {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-hero {
    background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 45%, #1d4ed8 100%);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.login-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 150%;
    background: radial-gradient(circle, rgba(59,130,246,0.25) 0%, transparent 65%);
    pointer-events: none;
}

.login-hero-content { position: relative; z-index: 1; }

.login-hero .brand-link { margin-bottom: 48px; }
.login-hero .brand-name { font-size: 1.5rem; }
.login-hero .brand-tagline { color: #94a3b8; }

.hero-title {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    max-width: 420px;
}

.hero-desc {
    margin-top: 16px;
    font-size: 1.05rem;
    color: #cbd5e1;
    line-height: 1.7;
    max-width: 440px;
}

.hero-features {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-feature {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.95rem;
    color: #e2e8f0;
}

.hero-feature-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.hero-footer {
    position: relative;
    z-index: 1;
    font-size: 0.8rem;
    color: #64748b;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: var(--surface);
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.login-card-wide { max-width: 520px; }

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 0.9rem;
}

.login-form { display: flex; flex-direction: column; gap: 6px; }

.login-form label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 12px;
    color: var(--text);
}

.login-form input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-form .btn-primary { margin-top: 20px; }

.auth-switch {
    margin-top: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover { text-decoration: underline; }

.subject-select-label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 16px;
    display: block;
}

.subject-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 180px;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 4px;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    line-height: 1.4;
}

.checkbox-row input {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.checkbox-row small {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.demo-credentials {
    margin-top: 28px;
    padding: 16px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.demo-credentials strong { color: var(--text); }
.demo-credentials code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.account-list {
    margin: 8px 0 12px 18px;
    line-height: 1.7;
}

.login-card .flash { margin: 0 0 16px; }

.teacher-class-card { margin-bottom: 24px; }

.hidden { display: none !important; }

.role-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

.role-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.role-option input { display: none; }

.role-option.selected {
    border-color: var(--primary-light);
    background: #eff6ff;
}

.role-option-icon { font-size: 1.25rem; }

.role-option-text strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
}

.role-option-text small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.home-activities-section {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 48px 32px;
}

.home-activity-folders {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.home-activity-folders.compact {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.home-folder-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.home-folder-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.home-folder-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.home-folder-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Activity studio (embedded previews) */
.activity-studio-page .public-main.activity-drive-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 12px 4px;
    min-height: 0;
}

.activity-studio-page .activity-drive-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-width: min(1900px, 99vw);
    width: 100%;
    margin: 0 auto;
}

.activity-studio-page .activity-drive-intro {
    flex-shrink: 0;
    margin-bottom: 8px;
}

.activity-studio-page .activity-drive-intro h1 {
    font-size: 1.35rem;
    margin-bottom: 0;
}

.activity-studio-page .activity-drive-intro .page-eyebrow {
    margin-bottom: 6px;
}

.activity-studio-page .activity-drive-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 14px;
    align-items: stretch;
    min-height: calc(100vh - 118px);
    height: calc(100vh - 118px);
}

.activity-studio-page .activity-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 14px;
}

.activity-studio-page .activity-folder-list {
    flex: 1;
    margin-bottom: 0;
}

.activity-studio-page .activity-main {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    min-width: 0;
}

.activity-studio-page .activity-main-header {
    margin-bottom: 6px;
    flex-shrink: 0;
}

.activity-studio-page .activity-main-title h2 {
    font-size: 1.4rem;
}

.activity-studio-page .activity-runner-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 7px 12px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.activity-studio-page .activity-runner-bar code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.78rem;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    color: #334155;
}

.activity-studio-page .btn-runner {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.activity-studio-page .activity-viewer-panel {
    flex: 1;
    position: relative;
    min-height: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.activity-studio-page .activity-viewer-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.activity-studio-page .public-footer {
    display: none;
}

/* Activity File Drive (legacy helpers) */
.activity-drive-page.public-main {
    padding: 28px 16px 40px;
}

.activity-drive-page .public-content {
    max-width: min(1680px, 98vw);
}

.activity-drive-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    align-items: start;
}

.activity-sidebar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.activity-sidebar-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.activity-folder-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.activity-folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background 0.15s;
}

.activity-folder-item:hover {
    background: var(--surface);
}

.activity-folder-item.active {
    background: #eff6ff;
    border-left-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
}

.folder-icon { font-size: 1rem; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 999px;
}

.activity-add-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.activity-main {
    min-width: 0;
}

.activity-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.activity-main-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.activity-main-title h2 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
}

.activity-viewer-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.activity-viewer-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    min-height: calc(100vh - 200px);
}

.activity-viewer-frame {
    display: block;
    width: 100%;
    height: calc(100vh - 200px);
    min-height: 720px;
    border: none;
    background: #fff;
}

.activity-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.folder-icon-lg { font-size: 1.75rem; }

.activity-upload-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.activity-upload-bar.view-only {
    justify-content: flex-end;
}

.activity-file-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.activity-content-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.activity-content-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.file-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    margin-bottom: 20px;
    transition: border-color 0.15s, background 0.15s;
}

.file-dropzone.dragover {
    border-color: var(--primary-light);
    background: #eff6ff;
}

.file-dropzone strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 6px;
}

.file-dropzone span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.dropzone-link {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    text-decoration: underline;
}

.file-dropzone small {
    display: block;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.activity-no-files {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 0.9rem;
}

.activity-file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activity-file-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.file-row-icon { font-size: 1.25rem; flex-shrink: 0; }

.file-row-info { flex: 1; min-width: 0; }

.file-row-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-row-name:hover { text-decoration: underline; }

.file-row-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.activity-empty-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 24px;
    text-align: center;
}

.activity-empty-icon { font-size: 3rem; margin-bottom: 16px; }
.activity-empty-panel h2 { font-size: 1.25rem; margin-bottom: 8px; }
.activity-empty-panel p { color: var(--text-muted); }

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.section-header-row h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 8px 0;
}

.school-activities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.school-activities-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.school-activity-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.school-activity-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.activity-image {
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: #eff6ff;
}

.activity-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
}

.activity-body {
    padding: 20px;
}

.activity-date {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin-bottom: 8px;
}

.activity-body h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
}

.activity-body p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.admin-upload-card {
    margin-bottom: 32px;
    padding: 28px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.activity-upload-form .btn-primary { margin-top: 8px; }

.btn-danger-sm {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-danger-sm:hover { background: #fee2e2; }

/* ─── Utilities ─── */
.empty-state {
    color: var(--text-muted);
    padding: 24px;
    text-align: center;
    font-size: 0.9rem;
}

.text-muted { color: var(--text-light); font-size: 0.875rem; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-row { grid-template-columns: 1fr; }
}

.subject-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

.subject-form-grid .form-action-cell {
    grid-column: 1 / -1;
}

.enroll-list {
    max-height: none;
}

@media (max-width: 768px) {
    .subject-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .public-header {
        flex-wrap: wrap;
        height: auto;
        padding: 16px 20px;
        gap: 12px;
    }

    .nav-toggle { display: flex; }

    .public-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        order: 4;
        padding: 8px 0;
    }

    .public-nav.open { display: flex; }
    .public-nav a { width: 100%; text-align: center; }

    .public-actions {
        width: 100%;
        order: 3;
        justify-content: center;
    }

    .public-content-split { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .hero-cards { grid-template-columns: 1fr; }
    .public-hero-inner h1 { font-size: 1.75rem; }

    .activity-drive-layout { grid-template-columns: 1fr; }
    .activity-sidebar { order: 2; }
    .activity-main { order: 1; }

    .activity-studio-page .activity-drive-layout {
        height: auto;
        min-height: auto;
    }

    .activity-studio-page .activity-viewer-panel {
        min-height: 72vh;
    }

    .login-page { grid-template-columns: 1fr; }
    .login-hero { padding: 32px 24px; min-height: auto; }
    .hero-title { font-size: 1.75rem; }
    .hero-features { display: none; }
    .login-panel { padding: 24px; }

    .app-container { flex-direction: column; }
    .sidebar { width: 100%; }
    .sidebar-brand, .sidebar-user { padding: 16px; }
    .nav-section { padding: 12px; }
    .nav-links { flex-direction: row; flex-wrap: wrap; }
    .nav-label { display: none; }
    .sidebar-footer { display: none; }

    .top-nav, .dashboard-grid, .page-content, .page-banner { padding-left: 20px; padding-right: 20px; }
    .flash { margin-left: 20px; margin-right: 20px; }
    .status-pill-box { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }

    .footer-inner { flex-direction: column; text-align: center; }
    .footer-links { flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .user-profile { width: 100%; justify-content: space-between; }
}
