:root {
    --navy: #07345b;
    --navy-2: #0a426e;
    --gold: #e8b442;
    --ink: #172235;
    --muted: #65758a;
    --line: #dfe5ec;
    --bg: #e6e6e6;
    --panel: #ffffff;
    --good: #0f8b64;
    --warn: #b7791f;
    --bad: #b42318;
    --info: #2563eb;
    --radius: 8px;
    --shadow: 0 10px 24px rgba(12, 34, 58, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--navy);
    color: #fff;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: #fff;
    padding: 8px 8px 18px;
    border-bottom: 1px solid rgba(255,255,255,.16);
}

.brand:hover { text-decoration: none; }
.brand img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
}
.brand strong { display: block; font-size: 18px; letter-spacing: 0; }
.brand small { color: rgba(255,255,255,.72); }

.nav { display: grid; gap: 4px; margin-top: 16px; }
.nav a {
    color: rgba(255,255,255,.82);
    padding: 10px 12px;
    border-radius: var(--radius);
}
.nav a.active,
.nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.12);
    text-decoration: none;
}

.main {
    min-width: 0;
    min-height: 100vh;
    padding: 22px;
    display: flex;
    flex-direction: column;
}

.app-footer {
    margin-top: auto;
    padding: 28px 6px 2px;
    color: var(--navy);
    font-size: 14px;
    text-align: center;
    font-weight: 700;
}

.app-footer span {
    display: inline-block;
    color: var(--navy);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.topbar h1 { margin: 0; font-size: 26px; letter-spacing: 0; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 13px; text-transform: uppercase; font-weight: 700; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 10px;
    box-shadow: 0 3px 12px rgba(12,34,58,.05);
}
.user-chip span { font-weight: 700; }
.user-chip small { color: var(--muted); }

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

.grid {
    display: grid;
    gap: 14px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid {
    column-gap: 30px;
    row-gap: 18px;
    margin-bottom: 18px;
}
.dashboard-period {
    margin: -4px 0 14px;
    color: #486076;
}
.dashboard-period strong {
    color: #071223;
}

.panel,
.metric,
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel { padding: 16px; margin-bottom: 16px; }
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.panel-header h2 { margin: 0; font-size: 18px; }

.metric {
    min-height: 86px;
    padding: 15px 14px;
    border: 0;
    box-shadow: none;
}
.metric span {
    display: inline-block;
    color: #0b8175;
    font-size: 13px;
    text-transform: none;
    font-weight: 700;
    position: relative;
    padding-bottom: 7px;
}
.metric span::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 34px;
    height: 2px;
    background: var(--gold);
    border-radius: 2px;
}
.metric strong {
    display: block;
    margin-top: 4px;
    color: #071223;
    font-size: 27px;
    line-height: 1.1;
}
.metric small {
    color: #486076;
    display: block;
    margin-top: 6px;
}
.metric.gold,
.metric.green,
.metric.blue,
.metric.red { border-top: 0; }

form.compact-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

label { display: grid; gap: 5px; font-weight: 700; color: #26364a; }
label span { font-size: 13px; }

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 9px 10px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 86px; resize: vertical; }

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: var(--navy);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.btn:hover { text-decoration: none; background: var(--navy-2); }
.btn.secondary { background: #fff; color: var(--navy); border-color: #b8c4d2; }
.btn.secondary:hover { background: #eef4f9; }
.btn.danger { background: var(--bad); }
.btn.gold { background: var(--gold); color: #182235; }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th,
td {
    padding: 11px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
th {
    background: #eef3f8;
    color: #26364a;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}
tr:last-child td { border-bottom: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 700;
    background: #edf2f7;
    color: #334155;
    white-space: nowrap;
}
.badge-cleared,
.badge-checked-in,
.badge-active,
.badge-available,
.badge-fixed { background: #dff8ee; color: #08734f; }
.badge-checked-out { background: #e9eff6; color: #26364a; }
.badge-full { background: #e9eff6; color: #26364a; }
.badge-partly-taken { background: #fff4d6; color: #8a5a00; }
.badge-reserved,
.badge-not-fixed,
.badge-under-construction { background: #fff4d6; color: #8a5a00; }
.badge-replaced,
.badge-cancelled,
.badge-non-revenue { background: #eef2f7; color: #475569; }

.alert {
    padding: 11px 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid transparent;
}
.alert-success { background: #e8f8f1; border-color: #bdebd9; color: #075e44; }
.alert-error { background: #fff0ee; border-color: #ffc4bd; color: #922018; }
.alert-info { background: #eef5ff; border-color: #c7dcff; color: #1e4e93; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(145deg, #07345b 0%, #09263e 100%);
}
.login-card {
    width: min(430px, 100%);
    padding: 24px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
.login-brand img {
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    object-fit: cover;
}
.login-brand h1 { margin: 0; font-size: 24px; }
.login-brand p { margin: 2px 0 0; color: var(--muted); }

.receipt {
    max-width: 760px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    padding: 28px;
}

.student-profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.student-profile-head h2 {
    margin: 0 0 4px;
    font-size: 24px;
}
.student-profile-head p {
    margin: 4px 0;
}
.profile-photo {
    width: 92px;
    height: 92px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--navy);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 28px;
    font-weight: 800;
    flex: 0 0 auto;
}
.profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 18px;
}
.profile-details p {
    margin: 0;
}

.occupancy-cell {
    display: grid;
    gap: 5px;
    min-width: 150px;
}
.occupancy-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.occupancy-top strong {
    white-space: nowrap;
}
.occupancy-bar {
    height: 7px;
    background: #e6edf4;
    border-radius: 999px;
    overflow: hidden;
}
.occupancy-bar span {
    display: block;
    height: 100%;
    background: var(--gold);
    border-radius: inherit;
}
.occupancy-cell small {
    color: var(--muted);
}
.receipt-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 2px solid var(--navy);
    padding-bottom: 14px;
    margin-bottom: 18px;
}
.receipt-head img { width: 82px; height: 82px; object-fit: cover; border-radius: var(--radius); }
.receipt h2 { margin: 0 0 3px; }
.receipt p { margin: 4px 0; }
.receipt-contact {
    display: grid;
    gap: 2px;
    margin-bottom: 5px;
}
.receipt-contact strong {
    font-size: 14px;
    color: #071223;
}
.receipt-contact span {
    font-size: 12px;
    color: #30465d;
}
.bank-line {
    font-size: 12px;
    color: #30465d;
    font-weight: 700;
}
.print-only { display: none; }

@media print {
    @page { size: A4; margin: 12mm; }
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    body {
        background: #fff;
        color: #000;
        font-size: 12px;
    }
    .sidebar, .topbar, .no-print { display: none !important; }
    .app-shell { display: block; }
    .main { padding: 0; }
    .panel,
    .metric,
    .receipt,
    .student-profile-head {
        box-shadow: none;
        break-inside: avoid;
    }
    .panel {
        border: 1px solid #dfe5ec;
        margin-bottom: 10px;
        padding: 12px;
    }
    .metric-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
    }
    .receipt {
        max-width: 100%;
        border: 1px solid #dfe5ec;
        padding: 18px;
    }
    .student-profile-head {
        border: 1px solid #dfe5ec;
        padding: 12px;
        margin-bottom: 10px;
    }
    .profile-photo {
        width: 72px;
        height: 72px;
        font-size: 22px;
    }
    .profile-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .receipt-head {
        border-bottom-color: var(--navy);
    }
    .print-only { display: block; }
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .grid-3, .grid-4, .form-grid, form.compact-form { grid-template-columns: 1fr; }
    .topbar { align-items: stretch; flex-direction: column; }
}
