:root {
    --navy: #0b1d36;
    --navy-mid: #122844;
    --navy-soft: #1b3a5c;
    --teal: #0d9488;
    --teal-bright: #14b8a6;
    --gold: #c9a227;
    --bg: #eef3f8;
    --card: #ffffff;
    --text: #152033;
    --muted: #5b6b7c;
    --line: #d7e0ea;
    --shadow: 0 10px 30px rgba(11, 29, 54, 0.08);
    --radius: 16px;
    --sidebar: 272px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    font-family: "DM Sans", system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 100% -10%, rgba(13, 148, 136, 0.12), transparent 50%),
        radial-gradient(900px 400px at -10% 0%, rgba(201, 162, 39, 0.08), transparent 45%),
        var(--bg);
}

h1, h2, h3, h4, .brand strong, .nav-title h1, .stat-card h3 {
    font-family: Outfit, "DM Sans", sans-serif;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: var(--sidebar);
    background: linear-gradient(180deg, var(--navy) 0%, #081526 100%);
    color: #d7e3f0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    padding: 1.15rem 0.85rem 1rem;
}

.brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.35rem 0.55rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark, .brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--teal), #0f766e);
    color: #fff;
    font-size: 1.2rem;
    object-fit: cover;
}

.brand strong { display: block; color: #fff; font-size: 0.98rem; line-height: 1.2; }
.brand small { color: #8aa0b8; }

.side-nav { flex: 1; overflow: auto; padding: 0.85rem 0.25rem; }
.nav-label {
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #7390ab;
    margin: 0.95rem 0.7rem 0.35rem;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.58rem 0.8rem;
    border-radius: 10px;
    color: #c9d7e6;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 2px;
}

.side-nav a i { width: 1.15rem; text-align: center; color: #8fb0c9; }
.side-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-nav a.active {
    background: linear-gradient(90deg, rgba(13,148,136,0.95), rgba(13,148,136,0.65));
    color: #fff;
    box-shadow: 0 8px 18px rgba(13,148,136,0.25);
}
.side-nav a.active i { color: #fff; }

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #f3c4c4;
    text-decoration: none;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    background: rgba(220, 53, 69, 0.12);
}

.app-navbar, .app-main { margin-left: 0; }

.app-navbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.4rem;
    background: rgba(255,255,255,0.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.nav-title h1 { font-size: 1.25rem; margin: 0; }
.nav-title p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.nav-actions { display: flex; align-items: center; gap: 0.85rem; }

.session-switch {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: #f4f8fb;
    border: 1px solid var(--line);
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
}
.session-switch label { font-size: 0.75rem; color: var(--muted); margin: 0; }
.session-switch select { border: 0; background: transparent; width: auto; box-shadow: none; }

.session-pill, .user-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
}

.user-chip strong, .user-chip small { display: block; line-height: 1.15; }
.user-chip small { color: var(--muted); font-size: 0.75rem; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--navy); color: #fff;
    display: grid; place-items: center; font-weight: 700;
}

.app-main {
    flex: 1;
    padding: 1.25rem 1.4rem 2.2rem;
    width: 100%;
}

.app-shell > .app-sidebar + .sidebar-backdrop + .app-navbar,
.app-shell { /* layout handled below */ }

.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: auto 1fr; }
.app-sidebar { grid-row: 1 / span 2; }
.app-navbar { grid-column: 2; }
.app-main { grid-column: 2; }

.card, .panel {
    background: var(--card);
    border: 1px solid rgba(215, 224, 234, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel { padding: 1.15rem 1.2rem; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 1.1rem 1.15rem;
}

.stat-card .icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center; color: #fff; margin-bottom: 0.7rem;
}
.stat-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.stat-card h3 { margin: 0.15rem 0 0; font-size: 1.55rem; }
.icon.teal { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.icon.navy { background: linear-gradient(135deg, #0b1d36, #1d4e89); }
.icon.gold { background: linear-gradient(135deg, #c9a227, #e0be4b); }
.icon.rose { background: linear-gradient(135deg, #be3a4a, #e05a68); }
.icon.blue { background: linear-gradient(135deg, #0369a1, #38bdf8); }
.icon.violet { background: linear-gradient(135deg, #5b21b6, #8b5cf6); }

.table { margin-bottom: 0; }
.table thead th {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: #f7fafc;
    border-bottom: 1px solid var(--line);
}

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

.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.btn-teal, .btn-primary {
    --bs-btn-bg: var(--teal);
    --bs-btn-border-color: var(--teal);
    --bs-btn-hover-bg: #0f766e;
    --bs-btn-hover-border-color: #0f766e;
    --bs-btn-active-bg: #0f766e;
}

.btn-navy {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}
.btn-navy:hover { background: var(--navy-mid); color: #fff; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.filters .form-control, .filters .form-select { min-width: 180px; flex: 1; }
.table-responsive { border-radius: 12px; }

.profile-hero {
    display: flex;
    gap: 1.2rem;
    align-items: center;
    padding: 1.3rem;
    background: linear-gradient(120deg, var(--navy), #16436d 60%, #0d9488);
    color: #fff;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.profile-hero img {
    width: 92px; height: 92px; border-radius: 20px; object-fit: cover;
    border: 3px solid rgba(255,255,255,0.35);
}
.repeat-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #fff4d6;
    color: #8a6d12;
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-weight: 600;
    font-size: 0.8rem;
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}
.login-art {
    background:
        linear-gradient(160deg, rgba(11,29,54,0.78), rgba(13,148,136,0.55)),
        url('https://images.unsplash.com/photo-1580582932707-520aed937b7b?auto=format&fit=crop&w=1600&q=80') center/cover;
    color: #fff;
    padding: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.login-art h2 { font-size: 2.6rem; max-width: 480px; }
.login-panel {
    display: grid;
    place-items: center;
    padding: 2rem;
    background: #fff;
}
.login-card { width: min(420px, 100%); }
.login-card h1 { font-size: 1.8rem; }

.icon-btn {
    border: 0;
    background: #fff;
    border: 1px solid var(--line);
    width: 40px; height: 40px;
    border-radius: 10px;
}

.sidebar-backdrop { display: none; }

.nav-tabs .nav-link { color: var(--muted); font-weight: 600; }
.nav-tabs .nav-link.active { color: var(--teal); }

.export-doc-header { display: flex; justify-content: space-between; gap: 1rem; }
.export-doc .muted { color: var(--muted); font-size: .875rem; }
.export-doc .center { text-align: center; }
.export-doc .right { text-align: right; }
.export-doc .totals { font-weight: 700; }
.export-doc .pass { color: #0f766e; font-weight: 700; }
.export-doc .fail { color: #b91c1c; font-weight: 700; }
.export-doc .due { color: #b91c1c; font-weight: 700; }
.export-doc .result-card { border: 1px solid #d7e0ea; border-radius: 12px; padding: 1rem; margin-top: 1rem; }
.export-doc .meta { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem 1rem; margin: .75rem 0; }

.result-list-item h5 { font-size: 1.05rem; }
.result-card-print { background: #fff; }

@media print {
    .app-sidebar, .app-navbar, .no-print, .sidebar-backdrop, .nav-tabs, .profile-hero .btn { display: none !important; }
    .app-shell { display: block; }
    .app-main { padding: 0; }
    body { background: #fff; }
    .export-doc .result-card { page-break-inside: avoid; page-break-after: always; }
    .export-doc .result-card:last-child { page-break-after: auto; }
    .result-list-item { page-break-inside: avoid; break-inside: avoid; }
}

@media (max-width: 1199px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991px) {
    .app-shell { display: block; }
    .app-sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-105%);
        transition: transform .25s ease;
    }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(8, 16, 28, 0.45);
        z-index: 30;
    }
    .login-page { grid-template-columns: 1fr; }
    .login-art { min-height: 220px; padding: 1.5rem; }
    .stat-grid { grid-template-columns: 1fr; }
    .nav-actions .user-chip small, .nav-actions .user-chip strong { display: none; }
}
