:root {
    color-scheme: dark;
    --bg: #0a0e17;
    --card-bg: #121826;
    --border: #1f2a3d;
    --accent: #3ec6e0;
    --accent-ink: #05131a;
    --text: #e5e7eb;
    --text-muted: #8b95a7;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
}

h1, h2, h3 {
    color: #ffffff;
}

/* Nav */
.site-navbar {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
    background: rgba(10, 14, 23, 0.9);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.5rem;
}

.site-navbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-brand-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
}

.site-logo {
    height: 40px;
    width: auto;
    display: block;
    background: linear-gradient(160deg, #ffffff 0%, #eef4f8 100%);
    padding: 0.2rem 0.35rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(62, 198, 224, 0.25);
}

.site-brand {
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 1.05rem;
}

.site-nav-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1.15rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.site-nav-link i {
    color: var(--accent);
    transition: color 0.15s ease;
}

.site-nav-link:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #7fe0f0, var(--accent));
    border-color: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 8px 22px rgba(62, 198, 224, 0.3);
}

.site-nav-link:hover i {
    color: var(--accent-ink);
}

/* Footer */
.site-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2.5rem 1rem 3rem;
}

.site-footer p {
    margin-bottom: 0.85rem;
}

.footer-whatsapp i { color: #25d366; transition: color 0.15s ease; }
.footer-whatsapp:hover { border-color: #25d366; color: #25d366; }

/* Messages */
.site-messages {
    max-width: 640px;
    margin: 1.25rem auto 0;
    padding: 0 1.5rem;
}

.alert {
    border-radius: 0.85rem;
    border: 1px solid transparent;
}

.alert-success { background: rgba(34, 197, 94, 0.12); border-color: #22c55e; color: #bbf7d0; }
.alert-danger, .alert-error { background: rgba(239, 68, 68, 0.12); border-color: #ef4444; color: #fecaca; }
.alert-warning { background: rgba(245, 158, 11, 0.12); border-color: #f59e0b; color: #fde68a; }
.alert-info { background: rgba(62, 198, 224, 0.1); border-color: var(--accent); color: var(--text); }

.alert-dismissible .btn-close {
    filter: invert(1);
    opacity: 0.6;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* Buttons */
.btn-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.btn-pill:hover { transform: translateY(-2px); }
.btn-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-pill-block { width: 100%; }
.btn-pill:disabled { opacity: 0.65; cursor: wait; transform: none; }
.btn-pill-sm { padding: 0.5rem 1.1rem; font-size: 0.85rem; }

.btn-pill-solid {
    background: linear-gradient(135deg, #7fe0f0, var(--accent));
    color: var(--accent-ink);
    box-shadow: 0 10px 30px rgba(62, 198, 224, 0.28);
}
.btn-pill-solid:hover { box-shadow: 0 14px 36px rgba(62, 198, 224, 0.4); }

.btn-pill-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-pill-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-pill-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}
.btn-pill-danger:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

/* Kicker */
.page-kicker {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

/* Auth split layout */
.auth-shell {
    min-height: calc(100vh - 170px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: radial-gradient(circle at 50% 0%, rgba(62, 198, 224, 0.12), transparent 60%);
}

.auth-grid {
    width: 100%;
    max-width: 980px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
}

.auth-grid > * { min-width: 0; }

@media (max-width: 860px) {
    .auth-grid { grid-template-columns: 1fr; }
}

.auth-brand {
    background: #0d131f;
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-brand-crest {
    height: 170px;
    width: auto;
    align-self: center;
    margin-bottom: 2rem;
    display: block;
    background: linear-gradient(160deg, #ffffff 0%, #eef4f8 100%);
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(62, 198, 224, 0.25);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.35),
        0 0 0 6px rgba(62, 198, 224, 0.06);
}

.auth-title {
    font-size: 1.9rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.25;
    margin-bottom: 1rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 1.75rem;
}

.auth-points {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.auth-points li {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    color: var(--text);
    font-size: 0.9rem;
}

.auth-points i { color: var(--accent); margin-top: 0.15rem; }

.auth-brand .page-kicker { text-align: left; }

.auth-form-panel {
    background: var(--card-bg);
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-form-panel h2 { font-size: 1.4rem; font-weight: 700; color: #fff; margin-bottom: 0.4rem; }
.auth-form-title { text-align: center; }
.auth-form-lead { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.75rem; text-align: center; }

/* Form fields */
.field { margin-bottom: 1.1rem; }
.field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.field input, .field select {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 0.85rem;
    border: 1px solid var(--border);
    background-color: #0e1522;
    color: var(--text);
    font-size: 0.95rem;
}

.field select option {
    background-color: #121826;
    color: var(--text);
}

.field select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(62, 198, 224, 0.15);
}

.field input::placeholder { color: var(--text-muted); }

.field-input-wrap { position: relative; }
.field-input-wrap input { padding-left: 2.75rem; }
.field-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.field-error { color: #fca5a5; font-size: 0.8rem; margin-top: 0.35rem; }

/* OTP boxes */
.otp-boxes {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    width: 100%;
}
.otp-box {
    flex: 1 1 0;
    min-width: 0;
    max-width: 3.25rem;
    height: 3.5rem;
    padding: 0;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: 0.85rem;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}
.otp-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(62, 198, 224, 0.15); }
.otp-boxes.has-error .otp-box { border-color: rgba(239, 68, 68, 0.6); }

.otp-note {
    color: #b4bdcc;
    font-size: 0.85rem;
    text-align: center;
    margin: 1rem 0 0;
}

@media (max-width: 400px) {
    .otp-boxes { gap: 0.4rem; }
    .otp-box { height: 3rem; font-size: 1.25rem; border-radius: 0.7rem; }
}

/* Compact brand panel for short steps (e.g. OTP) so the form is reachable on phones */
@media (max-width: 860px) {
    .auth-brand-compact { padding: 2rem 1.5rem; text-align: center; }
    .auth-brand-compact .page-kicker { text-align: center; }
    .auth-brand-compact .auth-brand-crest { height: 84px; padding: 0.6rem 0.8rem; margin-bottom: 1.25rem; }
    .auth-brand-compact .auth-title { font-size: 1.5rem; margin-bottom: 0.6rem; }
    .auth-brand-compact .auth-subtitle { margin-bottom: 1rem; }
    .auth-brand-compact .auth-points { align-items: center; gap: 0.5rem; }
    .auth-brand-compact .auth-points li { font-size: 0.85rem; }
}

/* Success page */
.success-card {
    max-width: 560px;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    padding: 3rem 2.5rem;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.success-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7fe0f0, var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--accent-ink);
    margin: 0 auto 1.25rem;
    box-shadow: 0 10px 30px rgba(62, 198, 224, 0.35);
}

.success-card .auth-subtitle { margin-bottom: 1.75rem; }
.success-actions { display: flex; justify-content: center; }

@media (max-width: 576px) {
    .success-card { padding: 2.25rem 1.5rem; border-radius: 1.25rem; }
    .success-icon { width: 60px; height: 60px; font-size: 1.7rem; }
    .success-actions .btn-pill { width: 100%; }
}

/* Directory */
.directory-header { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.5rem 1rem; }
.directory-header .page-kicker { text-align: left; }
.directory-title { font-size: 2rem; font-weight: 800; color: #fff; margin-bottom: 0.5rem; }
.directory-lead {
    color: #b4bdcc;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
    max-width: 60ch;
}

.directory-toolbar-wrap { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.toolbar-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto auto;
    gap: 0.75rem;
    align-items: end;
}

.toolbar-card .field { margin-bottom: 0; min-width: 0; }

@media (max-width: 860px) {
    .toolbar-card { grid-template-columns: 1fr 1fr; }
    .toolbar-card .toolbar-search { grid-column: 1 / -1; }
}

@media (max-width: 576px) {
    .toolbar-card { grid-template-columns: 1fr; padding: 1.1rem; }
    .toolbar-card .btn-pill { width: 100%; }
}

.filter-indicator {
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.filter-indicator .badge {
    background-color: var(--accent) !important;
    color: var(--accent-ink) !important;
    margin-left: 0.35rem;
    border-radius: 999px;
}

.directory-results-wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem; }

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.student-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1.1rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.student-card > .btn-pill,
.student-card > .flagged-badge { flex-shrink: 0; }

.student-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(62, 198, 224, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.student-info { flex: 1; min-width: 0; }
.student-name {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.3rem;
    font-size: 1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.student-class-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(62, 198, 224, 0.12);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.flagged-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

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

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Modal (flag dialog) */
.modal-content { background-color: var(--card-bg); border: 1px solid var(--border); color: var(--text); border-radius: 1.1rem; }
.modal-header, .modal-footer { border-color: var(--border); }
.btn-close { filter: invert(1); }
.modal .form-control {
    background-color: #0e1522;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 0.75rem;
}
.modal .form-control:focus {
    background-color: #0e1522;
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 0.2rem rgba(62, 198, 224, 0.15);
}
.modal .form-control::placeholder { color: var(--text-muted); }
.modal .form-label { color: var(--text); }

@media (max-width: 576px) {
    .auth-brand, .auth-form-panel { padding: 2rem 1.5rem; }
    .auth-title { font-size: 1.5rem; }
    .directory-title { font-size: 1.5rem; }
    .student-card { padding: 1rem; gap: 0.75rem; }
    .student-avatar { width: 40px; height: 40px; font-size: 1rem; }
    .student-name { font-size: 0.88rem; }
    .student-class-badge { font-size: 0.68rem; }
    .auth-brand-crest { height: 140px; }
    .site-navbar { padding: 0.7rem 1rem; }
    .site-nav-link { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
    .btn-pill, .site-nav-link { transition: none; }
    .btn-pill:hover, .site-nav-link:hover { transform: none; }
}

/* Auth pages on phones: less outer padding so the card and OTP boxes fit */
@media (max-width: 576px) {
    .auth-shell {
        min-height: 0;
        align-items: flex-start;
        padding: 1.25rem 0.85rem 2rem;
    }
    .auth-grid { border-radius: 1.25rem; }
    .auth-form-panel { padding: 1.75rem 1.1rem; }
    .auth-form-panel h2 { font-size: 1.25rem; }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 23, 0.9);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-box {
    text-align: center;
    color: var(--text);
}

.loading-box p {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}