/* =====================================================================
   SCIT Result Portal — Design tokens
   Palette: institutional navy + brass/gold accent + warm paper for print
   Type: 'Fraunces' (display/report headers) + 'Inter' (UI)
   ===================================================================== */
:root {
    --navy-950: #0b1220;
    --navy-900: #0f1b30;
    --navy-800: #16294a;
    --navy-700: #1d3763;
    --navy-600: #2a4a86;
    --gold-500: #b8862b;
    --gold-400: #d4a444;
    --gold-100: #f6ecd6;
    --paper: #fbf9f4;
    --paper-line: #e7e1d3;
    --ink: #1c2333;
    --ink-soft: #4a5468;
    --green-ok: #1f7a4d;
    --red-bad: #b3372d;
    --amber: #b8862b;
    --radius: 10px;
    --shadow: 0 10px 30px rgba(11,18,32,0.08);
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--navy-700); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--navy-900); margin: 0 0 .5rem; font-weight: 600; }

/* ---------- Layout shells ---------- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--navy-950);
}
@media (max-width: 860px) { .auth-shell { grid-template-columns: 1fr; } }

.auth-visual {
    background: radial-gradient(circle at 20% 20%, var(--navy-700), var(--navy-950) 70%);
    color: var(--gold-100);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}
.auth-visual::after {
    content: "";
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(45deg, rgba(212,164,68,0.04) 0 2px, transparent 2px 40px);
}
.auth-visual .crest {
    width: 64px; height: 64px; border: 2px solid var(--gold-400); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-size: 1.5rem; color: var(--gold-400); margin-bottom: 2rem;
}
.auth-visual h1 { color: #fff; font-size: 2.4rem; max-width: 420px; position: relative; z-index: 1; }
.auth-visual p { color: rgba(246,236,214,0.75); max-width: 400px; position: relative; z-index: 1; }

.auth-form-wrap {
    display: flex; align-items: center; justify-content: center; padding: 2rem;
    background: var(--paper);
}
.auth-form {
    width: 100%; max-width: 380px;
}
.auth-form h2 { font-size: 1.6rem; }
.auth-form .sub { color: var(--ink-soft); margin-bottom: 2rem; }

/* ---------- Form elements ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--navy-800); margin-bottom: .35rem; }
input, select, textarea {
    width: 100%; padding: .65rem .85rem; border: 1.5px solid #d9d2bd; border-radius: 8px;
    font-family: var(--font-body); font-size: .95rem; background: #fff; color: var(--ink);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-600); }
.field { margin-bottom: 1.1rem; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .7rem 1.4rem; border-radius: 8px; border: none; font-weight: 600; font-size: .92rem;
    cursor: pointer; font-family: var(--font-body); transition: transform .1s, box-shadow .15s;
}
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-gold { background: var(--gold-500); color: #fff; }
.btn-gold:hover { background: var(--gold-400); }
.btn-outline { background: transparent; border: 1.5px solid var(--navy-700); color: var(--navy-800); }
.btn-outline:hover { background: var(--navy-800); color: #fff; }
.btn-danger { background: var(--red-bad); color: #fff; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem; }
.alert-error { background: #fdecea; color: var(--red-bad); border: 1px solid #f3c8c3; }
.alert-success { background: #e9f6ee; color: var(--green-ok); border: 1px solid #bfe3cd; }
.alert-info { background: #eaf1fc; color: var(--navy-700); border: 1px solid #c5d7f2; }

/* ---------- App shell (dashboard layout) ---------- */
:root { --sidebar-w: 240px; }

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

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--navy-950); color: var(--gold-100); padding: 1.5rem 1rem;
    display: flex; flex-direction: column; gap: .2rem;
    z-index: 200; overflow-y: auto;
    transition: transform .25s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: .5rem .5rem 1.5rem; }
.sidebar .brand .mark { width: 34px; height: 34px; border-radius: 8px; background: var(--gold-500); display:flex; align-items:center; justify-content:center; font-family: var(--font-display); font-weight:700; color:#fff; }
.sidebar .brand strong { color: #fff; font-size: .95rem; display:block; }
.sidebar .brand span { color: rgba(246,236,214,0.55); font-size: .72rem; }
.sidebar a.nav-link {
    display: flex; align-items: center; gap: .6rem; padding: .75rem .8rem; border-radius: 8px;
    color: rgba(246,236,214,0.75); font-size: .88rem; font-weight: 500;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.nav-link.active { background: var(--gold-500); color: #fff; }
.sidebar .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(246,236,214,0.4); padding: 1rem .8rem .3rem; }
.sidebar .sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-close-btn { display: none; }

.menu-toggle-btn { display: none; background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: .4rem .6rem; color: var(--navy-900); margin-right: .4rem; }
.sidebar-backdrop { display: none; }

/* Main content is always offset by the fixed sidebar's width on desktop. */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px; max-width: 82vw;
        box-shadow: 8px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-close-btn {
        display: flex; align-items: center; justify-content: center;
        position: absolute; top: 1rem; right: 1rem; width: 32px; height: 32px;
        background: rgba(255,255,255,0.08); border: none; border-radius: 8px;
        color: #fff; font-size: 1.1rem; cursor: pointer;
    }
    .menu-toggle-btn { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar-backdrop.open {
        display: block; position: fixed; inset: 0; background: rgba(11,18,32,0.55); z-index: 150;
    }
}

.topbar {
    display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.6rem;
    background: #fff; border-bottom: 1px solid var(--paper-line); position: sticky; top:0; z-index: 5;
    gap: .6rem;
}
.topbar .topbar-left { display: flex; align-items: center; min-width: 0; }
.topbar h1 { font-size: 1.25rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .user-chip { display:flex; align-items:center; gap:.6rem; font-size:.85rem; flex-shrink: 0; }
.topbar .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-700); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:600; font-size:.8rem; }

.content { padding: 1.6rem; max-width: 1400px; }

@media (max-width: 600px) {
    .content { padding: 1rem; }
    .topbar { padding: .8rem 1rem; }
    .card { padding: 1rem; }
    .topbar .user-chip > div:first-child { display: none; } /* hide name text, keep avatar, saves space */
}

/* ---------- Cards / stats ---------- */
.card { background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1.2rem; }
.card-title { font-size: 1rem; font-weight: 700; color: var(--navy-900); margin-bottom: 1rem; display:flex; align-items:center; justify-content:space-between; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card { background: #fff; border: 1px solid var(--paper-line); border-radius: var(--radius); padding: 1.2rem; border-left: 4px solid var(--gold-500); }
.stat-card .num { font-family: var(--font-display); font-size: 1.9rem; color: var(--navy-900); font-weight: 700; }
.stat-card .label { font-size: .8rem; color: var(--ink-soft); margin-top: .2rem; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data-table th { background: var(--navy-950); color: var(--gold-100); text-align: left; padding: .65rem .8rem; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
table.data-table td { padding: .6rem .8rem; border-bottom: 1px solid var(--paper-line); }
table.data-table tbody tr:hover { background: #faf7ee; }
table.data-table tbody tr:nth-child(even) { background: #fdfcf8; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--paper-line); }

.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 700; }
.badge-a { background:#e9f6ee; color: var(--green-ok); }
.badge-b { background:#eaf1fc; color: var(--navy-700); }
.badge-c { background:#fff6e0; color: var(--amber); }
.badge-f { background:#fdecea; color: var(--red-bad); }
.badge-neutral { background:#f1efe6; color: var(--ink-soft); }

/* ---------- Report card (print-style) ---------- */
.report-card { background:#fff; padding: 0; max-width: 950px; margin: 0 auto; }
.report-border {
    border: 2.5px solid var(--navy-900);
    border-radius: 16px;
    padding: 1.3rem 1.6rem;
    background: #fff;
    box-shadow: 0 12px 32px rgba(11,18,32,0.10);
}
.report-border-inner {
    border: 1px solid var(--gold-500);
    border-radius: 10px;
    padding: 1.1rem 1.3rem;
}
.report-header { display: flex; align-items: center; justify-content: space-between; gap: .8rem; border-bottom: 2.5px double var(--navy-800); padding-bottom: .7rem; margin-bottom: .8rem; }
.report-header .header-logo-box { width: 72px; flex-shrink: 0; text-align: center; }
.report-header .header-logo-box img.logo { width: 60px; height: 60px; object-fit: contain; border-radius: 50%; }
.report-header .header-center { flex: 1; text-align: center; min-width: 0; }
.report-header h2 { font-size: 1.3rem; margin-bottom: .1rem; letter-spacing: .02em; }
.report-header .meta { font-size: .74rem; color: var(--ink-soft); }
.report-header .term-title { font-family: var(--font-display); font-size: 1rem; color: var(--gold-500); margin-top: .35rem; font-weight: 600; }

.passport-box {
    width: 72px; height: 88px;
    flex-shrink: 0;
    border: 2px solid var(--navy-800);
    border-radius: 10px;
    background: #f9f7f0;
    display: flex; align-items: center; justify-content: center;
    font-size: .6rem; color: var(--ink-soft); text-align: center; line-height: 1.2;
    overflow: hidden;
}
.passport-box img { width: 100%; height: 100%; object-fit: cover; }

.student-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem 1.3rem; margin-bottom: .8rem; font-size: .78rem; background: #f9f7f0; border-radius: 10px; padding: .6rem .9rem; }
.student-info-grid div strong { color: var(--navy-900); }

.report-table-wrap { border: 1.5px solid var(--navy-900); border-radius: 10px; overflow-x: auto; margin-bottom: .8rem; -webkit-overflow-scrolling: touch; }
.report-table { width: 100%; border-collapse: collapse; font-size: .72rem; }
.report-table th { background: var(--navy-900); color: #fff; padding: .4rem .35rem; font-size: .62rem; text-transform: uppercase; text-align: center; }
.report-table th.subject-col { text-align: left; }
.report-table td { padding: .3rem .35rem; text-align: center; border-top: 1px solid var(--paper-line); }
.report-table td.subject-col { text-align: left; font-weight: 600; color: var(--navy-900); }
.report-table tfoot td { font-weight: 700; background: var(--gold-100); border-top: 1.5px solid var(--gold-500); }
.report-table .prior-col { background: #f4f1e8; color: var(--ink-soft); }
.report-table .cumulative-col { background: #eef3fb; font-weight: 700; color: var(--navy-800); }

.section-label { font-family: var(--font-display); font-size: .82rem; font-weight: 600; color: var(--navy-900); margin: .7rem 0 .4rem; border-bottom: 1px solid var(--paper-line); padding-bottom: .2rem; }

.psych-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: .7rem; }
.psych-title { font-family: var(--font-display); font-weight: 700; font-size: .76rem; margin-bottom: .3rem; text-transform: uppercase; letter-spacing: .03em; }
.psych-table-wrap { border: 1px solid var(--paper-line); border-radius: 8px; overflow: hidden; }
table.psych-table { width: 100%; border-collapse: collapse; font-size: .72rem; }
.psych-table th { padding: .35rem .5rem; text-align: left; font-size: .66rem; text-transform: uppercase; }
.psych-table th:last-child, .psych-table td:last-child { text-align: center; width: 60px; }
.psych-table td { padding: .3rem .5rem; border-top: 1px solid var(--paper-line); }
.psych-table td:last-child { font-weight: 700; }
.psych-head-gold th { background: var(--gold-400); color: #3a2c05; }
.psych-head-navy th { background: var(--navy-900); color: #fff; }

.remark-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .7rem; }
.remark-grid-4 { grid-template-columns: 1fr 1fr; }
.remark-box { background: #f9f7f0; border: 1px solid var(--paper-line); border-radius: 10px; padding: .5rem .65rem; font-size: .74rem; }
.remark-box .label { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gold-500); font-weight: 700; margin-bottom: .15rem; }

.trait-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; font-size: .72rem; margin-bottom: .7rem; }
.trait-row { display: flex; justify-content: space-between; align-items: center; padding: .18rem 0; border-bottom: 1px dashed var(--paper-line); }
.trait-dots { display: flex; gap: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #e4dfd0; }
.dot.filled { background: var(--gold-500); }

.grading-key { font-size: .66rem; color: var(--ink-soft); display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: .7rem; background: #f9f7f0; border-radius: 8px; padding: .4rem .7rem; }
.sig-row { display: flex; justify-content: space-between; align-items: flex-end; margin-top: .9rem; font-size: .72rem; gap: .5rem; }
.sig-row .box { text-align: center; flex: 1; }
.sig-row .line { width: 140px; border-bottom: 1px solid var(--ink); margin: 0 auto .25rem; height: 22px; }
.sig-row .sig-img { max-width: 140px; max-height: 42px; object-fit: contain; display: block; margin: 0 auto .25rem; }
.sig-row .stamp-box { width: 70px; height: 70px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; margin-bottom: 1.4rem; }
.sig-row .stamp-box img { max-width: 100%; max-height: 100%; object-fit: contain; opacity: .88; }
.sig-row .stamp-placeholder { width: 60px; height: 60px; border: 1px dashed var(--paper-line); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .58rem; color: var(--ink-soft); text-align: center; line-height: 1.1; }

@page { size: A4; margin: 10mm; }
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .report-card { max-width: 100%; }
    .report-border { border: 2px solid var(--navy-900); padding: .9rem 1.1rem; box-shadow: none; }
    .report-border-inner { padding: .8rem 1rem; }
    .app-shell, .content { display: block; padding: 0; margin: 0; }
    .main-content { margin-left: 0 !important; }
    .report-table, .student-info-grid, .remark-grid, .trait-grid { page-break-inside: avoid; }
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--ink-soft); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) {
    .grid-2, .grid-3, .student-info-grid, .remark-grid, .remark-grid-4, .trait-grid, .psych-tables { grid-template-columns: 1fr; }
    .btn { min-height: 42px; }
    table.data-table td, table.data-table th { padding: .55rem .6rem; }
    .flex.gap-1 { flex-wrap: wrap; }
    .report-border { padding: .8rem .9rem; }
    .report-border-inner { padding: .7rem .8rem; }
    .passport-box { width: 56px; height: 68px; }
    .header-logo-box { width: 52px; }
    .header-logo-box img.logo { width: 44px; height: 44px; }
}
@media (max-width: 480px) {
    .report-table { font-size: .6rem; }
    .report-table th, .report-table td { padding: .22rem .25rem; }
    .psych-table { font-size: .64rem; }
    .psych-table th, .psych-table td { padding: .25rem .35rem; }
    .student-info-grid { font-size: .68rem; gap: .25rem .8rem; padding: .5rem .6rem; }
    .grading-key { font-size: .58rem; gap: .5rem; padding: .3rem .5rem; }
    .remark-box { font-size: .66rem; padding: .4rem .5rem; }
    .remark-box .label { font-size: .58rem; }
    .sig-row { font-size: .64rem; }
    .sig-row .line { width: 100px; height: 18px; }
    .sig-row .sig-img { max-width: 100px; max-height: 32px; }
    .sig-row .stamp-box { width: 48px; height: 48px; margin-bottom: 1.1rem; }
    .sig-row .stamp-placeholder { width: 42px; height: 42px; font-size: .5rem; }
    .report-header h2 { font-size: 1.05rem; }
    .report-header .meta { font-size: .66rem; }
    .report-header .term-title { font-size: .85rem; }
    .passport-box { width: 46px; height: 56px; font-size: .5rem; }
    .header-logo-box { width: 42px; }
    .header-logo-box img.logo { width: 36px; height: 36px; }
    .report-border { padding: .5rem .55rem; border-radius: 10px; }
    .report-border-inner { padding: .5rem .55rem; border-radius: 7px; }
    .section-label { font-size: .7rem; }
}
.pill { display:inline-block; padding:.15rem .6rem; border-radius:20px; font-size:.72rem; font-weight:600; background:var(--navy-800); color:#fff; }
.empty-state { text-align:center; padding: 3rem 1rem; color: var(--ink-soft); }
