/* ============================================================
   SIMS — Design tokens
   Deep navy authority + academic gold accent. Serif headings
   (institutional/record feel) over a clean sans data layer.
   ============================================================ */
:root {
    --navy: #0F1E3D;
    --navy-light: #16294F;
    --gold: #C9A24B;
    --gold-dark: #A9822F;
    --bg: #F4F5F8;
    --surface: #FFFFFF;
    --text: #1B1F2A;
    --muted: #6B7280;
    --border: #E4E6EC;
    --success: #1F8A5F;
    --success-bg: #E7F5EE;
    --error: #C0392B;
    --error-bg: #FBEAE8;

    --font-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
    --font-sans: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 15px;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: normal; color: var(--navy); }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--gold-dark);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 18px;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.alert-error { background: var(--error-bg); color: var(--error); border-left-color: var(--error); }
.alert-success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }

/* ============================================================
   Auth pages (login / register) — full-bleed split feel
   ============================================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
    background-image: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 60%, #1c3566 100%);
    padding: 24px;
}
.auth-container {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    padding: 40px 36px;
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.auth-container .eyebrow {
    color: var(--gold-dark);
    font-size: 13px;
    margin-bottom: 6px;
}
.auth-container h1 { font-size: 26px; margin: 0 0 24px; }
.auth-container form { display: flex; flex-direction: column; gap: 4px; }
.auth-container label { font-size: 13px; font-weight: 600; margin-top: 12px; color: var(--text); }
.auth-container input,
.auth-container select {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 15px;
    font-family: var(--font-sans);
    background: #FBFBFD;
}
.auth-container input:focus,
.auth-container select:focus {
    border-color: var(--gold-dark);
    background: #fff;
}
.auth-container button {
    margin-top: 24px;
    padding: 13px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.auth-container button:hover { background: var(--navy-light); }
.auth-container p { margin-top: 20px; font-size: 14px; text-align: center; color: var(--muted); }

/* ============================================================
   App shell — sidebar + main content
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--navy);
    color: #E7EAF2;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 20;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
    width: 34px; height: 34px;
    background: var(--gold);
    color: var(--navy);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif);
    font-weight: bold;
    font-size: 18px;
    flex-shrink: 0;
}
.sidebar-brand strong { display: block; font-size: 15px; color: #fff; }
.sidebar-brand small { display: block; font-size: 12px; color: #9BA5BF; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav a {
    display: block;
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: 5px;
    color: #C7CEE0;
    font-size: 14px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.sidebar-nav a.active {
    background: rgba(201,162,75,0.15);
    color: var(--gold);
    font-weight: 600;
    border-left: 3px solid var(--gold);
    padding-left: 11px;
}

.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer a { color: #9BA5BF; font-size: 13px; }
.sidebar-footer a:hover { color: #fff; }

.nav-toggle-state { display: none; }
.nav-burger { display: none; }
.nav-scrim { display: none; }

.main-column {
    margin-left: 240px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.main-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 18px 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.main-header h1 { font-size: 21px; margin: 0; flex: 1; }
.user-chip {
    font-size: 13px;
    color: var(--muted);
    background: var(--bg);
    padding: 7px 14px;
    border-radius: 20px;
    white-space: nowrap;
}

.main-content { padding: 28px; max-width: 1100px; }
.main-content h2 { font-size: 18px; margin: 0 0 4px; }
.main-content h3 { font-size: 16px; margin: 28px 0 12px; color: var(--text); font-family: var(--font-sans); font-weight: 700; }
.main-content .lede { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ============================================================
   Stat cards
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--gold);
    border-radius: 6px;
    padding: 18px 20px;
}
.stat-card h3 {
    font-family: var(--font-serif);
    font-size: 30px;
    color: var(--navy);
    margin: 0;
    font-weight: normal;
}
.stat-card p { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ============================================================
   Dashboard link list (fallback for simple pages)
   ============================================================ */
.dashboard-links { list-style: none; padding: 0; margin: 0; }
.dashboard-links li {
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    border-radius: 6px;
}
.dashboard-links li a { display: block; padding: 14px 18px; color: var(--text); }
.dashboard-links li a:hover { background: var(--bg); text-decoration: none; }

.profile-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 18px 22px;
    border-radius: 6px;
    margin-bottom: 24px;
}
.profile-summary p { margin-bottom: 4px; font-size: 14px; }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
table th, table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table th {
    background: var(--bg);
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--muted);
    font-weight: 600;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #FAFAFC; }

.row-action { background: none; border: none; cursor: pointer; padding: 0; font-size: 14px; font-family: inherit; }
.row-action.delete { color: var(--error); }
.row-action.warn { color: var(--gold-dark); }

/* ============================================================
   Forms (management pages)
   ============================================================ */
.inline-form {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 6px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
        overflow: auto;
    align-items: end;
}
.inline-form label { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 5px; color: var(--text); }
.inline-form input, .inline-form select {
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 14px;
    font-family: var(--font-sans);
    background: #FBFBFD;
}
.inline-form input:focus, .inline-form select:focus { border-color: var(--gold-dark); background: #fff; }
.inline-form button {
    padding: 10px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    height: 40px;
    font-weight: 600;
    font-size: 14px;
}
.inline-form button:hover { background: var(--navy-light); }

code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

/* ============================================================
   Responsive — sidebar collapses under 900px
   ============================================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: 240px;
    }
    .main-column { margin-left: 0; }
    .nav-burger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        width: 32px; height: 32px;
        cursor: pointer;
        flex-shrink: 0;
    }
    .nav-burger span { display: block; height: 2px; background: var(--navy); border-radius: 2px; }

    .nav-scrim {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15,30,61,0.4);
        z-index: 15;
    }

    .nav-toggle-state:checked ~ .app-shell .sidebar {
        transform: translateX(0);
    }
    .nav-toggle-state:checked ~ .app-shell .nav-scrim {
        display: block;
    }

    .main-content { padding: 20px 16px; }
    .main-header { padding: 14px 16px; }
    .inline-form { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .auth-container { padding: 30px 22px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}