:root {
    --sms-navy: #5c1a24;
    --sms-navy-light: #7a2635;
    --sms-primary: #8b2635;
    --sms-primary-dark: #6b1d29;
    --sms-gold: #c9a961;
    --sms-gold-dark: #a8863f;
    --sms-bg: #f8f5ef;
    --sms-border: #ecdfc7;
    --sms-text-muted: #6b6355;
    --sms-sidebar-start: #12342a;
    --sms-sidebar-end: #1f5c46;
    --sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
    background-color: var(--sms-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    color: #1f2433;
}

/* ---------- App Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sms-sidebar-start) 0%, var(--sms-sidebar-end) 100%);
    color: #cfd6e8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 18px 20px;
    letter-spacing: 0.3px;
    line-height: 1.25;
}
.sidebar-brand i { font-size: 1.5rem; color: var(--sms-gold); }
.sidebar-brand img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1.5px solid var(--sms-gold);
}
.sidebar-brand .brand-text { font-size: 0.92rem; }
.sidebar-brand .brand-text .sub { display: block; font-size: 0.68rem; font-weight: 500; color: var(--sms-gold); letter-spacing: 0.06em; }

.sidebar-nav {
    padding: 8px 12px;
    overflow-y: auto;
}

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6f7996;
    font-weight: 600;
    margin: 18px 12px 6px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #b6bfd9;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, var(--sms-gold) 0%, var(--sms-gold-dark) 100%);
    color: #22160a;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.main-col {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--sms-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 900;
}
.topbar-title { font-weight: 600; font-size: 1.1rem; color: #1f2433; }

.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--sms-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}
.topbar-user a { color: #1f2433; }

.content-area {
    padding: 28px;
    flex: 1;
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--sms-border);
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(92, 26, 36, 0.05);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
    box-shadow: 0 10px 24px rgba(92, 26, 36, 0.10);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px !important;
    position: relative;
    overflow: hidden;
    border-top: 3px solid transparent;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card.stat-blue { border-top-color: var(--sms-primary); }
.stat-card.stat-green { border-top-color: #12946b; }
.stat-card.stat-orange { border-top-color: var(--sms-gold); }
.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}
.stat-card:hover .stat-icon { transform: scale(1.08) rotate(-4deg); }
.stat-card .stat-icon.blue { background: #f1e4e6; color: var(--sms-primary); }
.stat-card .stat-icon.green { background: #e5f8ef; color: #12946b; }
.stat-card .stat-icon.orange { background: #fbf1dd; color: var(--sms-gold-dark); }
.stat-card h2 { font-weight: 700; margin-bottom: 0; font-size: 1.6rem; }
.stat-card .stat-label { color: var(--sms-text-muted); font-size: 0.85rem; font-weight: 500; }

/* ---------- Ribbon corner badge ---------- */
.ribbon-card { position: relative; overflow: hidden; }
.ribbon-corner {
    position: absolute;
    top: 12px;
    right: -34px;
    width: 130px;
    transform: rotate(45deg);
    background: linear-gradient(135deg, var(--sms-primary) 0%, var(--sms-navy) 100%);
    color: #fff;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 4px 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 2;
}
.ribbon-corner.gold { background: linear-gradient(135deg, var(--sms-gold) 0%, var(--sms-gold-dark) 100%); color: #3a2a05; }

/* ---------- Pretty action tiles (used for pickers: attendance, timetable, exams, library) ---------- */
.action-tile {
    display: block;
    text-decoration: none;
    height: 100%;
}
.action-tile .card {
    border-left: 4px solid var(--sms-gold);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.action-tile:hover .card {
    transform: translateY(-4px);
    border-left-color: var(--sms-primary);
    box-shadow: 0 12px 26px rgba(92, 26, 36, 0.14);
}

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-header h3 { font-weight: 700; margin-bottom: 2px; }
.page-header .text-muted { font-size: 0.9rem; }

/* ---------- Dashboard hero banner ---------- */
.dashboard-hero {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    min-height: 220px;
    display: flex;
    align-items: flex-end;
    margin-bottom: 24px;
    background-image: linear-gradient(180deg, rgba(92,26,36,0.15) 0%, rgba(46,13,18,0.88) 100%), url("/static/images/school-hero.jpg");
    background-size: cover;
    background-position: center;
}
.dashboard-hero-content {
    padding: 24px 28px;
    color: #fff;
}
.dashboard-hero-content h3 {
    font-weight: 700;
    font-size: 1.6rem;
    margin-bottom: 4px;
    color: #fff;
}
.dashboard-hero-content .text-muted {
    color: rgba(255,255,255,0.85) !important;
    font-size: 0.95rem;
}

/* ---------- Tables ---------- */
.table-card {
    background: #fff;
    border: 1px solid var(--sms-border);
    border-radius: 12px;
    overflow: hidden;
}
table.table {
    margin-bottom: 0;
}
table.table thead th {
    background: #f8f9fc;
    color: var(--sms-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid var(--sms-border);
    padding: 12px 16px;
}
table.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--sms-border);
}
table.table tbody tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fafbfd; }

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--sms-primary);
    border-color: var(--sms-primary);
    font-weight: 500;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--sms-primary-dark);
    border-color: var(--sms-primary-dark);
}
.btn-outline-primary {
    color: var(--sms-primary);
    border-color: var(--sms-primary);
    font-weight: 500;
}
.btn-outline-primary:hover {
    background: var(--sms-primary);
    border-color: var(--sms-primary);
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: 8px;
    border-color: var(--sms-border);
    font-size: 0.92rem;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--sms-primary);
    box-shadow: 0 0 0 3px rgba(59,91,219,0.12);
}
label.form-label {
    font-weight: 500;
    font-size: 0.86rem;
    color: #3a3f4d;
    margin-bottom: 4px;
}

/* ---------- Badges ---------- */
.badge { font-weight: 500; padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; }

/* ---------- Auth (login) page ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #2a5443 0%, var(--sms-sidebar-start) 45%, #241012 100%);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    padding: 44px 40px;
    width: 100%;
    max-width: 380px;
    border-top: 5px solid var(--sms-gold);
    position: relative;
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 6px;
    color: var(--sms-navy);
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    line-height: 1.35;
}
.auth-brand img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--sms-gold);
    box-shadow: 0 4px 14px rgba(201,169,97,0.35);
}
.auth-brand .sub { display: block; font-size: 0.72rem; font-weight: 600; color: var(--sms-gold-dark); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.auth-subtitle { text-align: center; color: var(--sms-text-muted); font-size: 0.88rem; margin-bottom: 24px; }

/* ---------- Fee Voucher (print) ---------- */
.voucher-sheet {
    max-width: 480px;
    margin: 0 auto;
}
.voucher-copy {
    border: 1.5px solid var(--sms-border);
    border-radius: 12px;
    padding: 24px;
    background: #fff;
}
.voucher-school-name { font-size: 1.2rem; font-weight: 700; color: var(--sms-navy); }
.voucher-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dotted #e1e4ee; font-size: 0.92rem; }
.voucher-row:last-child { border-bottom: none; }
.voucher-row .label { color: var(--sms-text-muted); }
.voucher-row .value { font-weight: 600; text-align: right; }
.voucher-amount-box {
    background: #eef1ff;
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
    margin: 14px 0;
}
.voucher-amount-box .amount { font-size: 1.6rem; font-weight: 700; color: var(--sms-primary); }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-col { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    body { background: #fff !important; }
    .voucher-sheet { break-inside: avoid; }
    .voucher-copy { break-inside: avoid; }
}

/* ---------- Leaving Certificate / Report Card (print) ---------- */
.certificate-sheet {
    max-width: 780px;
    margin: 0 auto;
}
.certificate-border {
    position: relative;
    border: 3px double var(--sms-gold);
    border-radius: 6px;
    padding: 40px 56px;
    background: #fffdf8;
    background-image:
        radial-gradient(circle at top left, rgba(201,169,97,0.08), transparent 40%),
        radial-gradient(circle at bottom right, rgba(139,38,53,0.06), transparent 40%);
}
.certificate-corner {
    position: absolute;
    width: 34px;
    height: 34px;
    border: 3px solid var(--sms-gold);
}
.certificate-corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; }
.certificate-corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; }
.certificate-corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; }
.certificate-corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; }
.certificate-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sms-gold);
}
.certificate-school-name { font-size: 1.35rem; font-weight: 700; color: var(--sms-navy); }
.certificate-ribbon {
    display: inline-block;
    background: linear-gradient(135deg, var(--sms-navy) 0%, var(--sms-primary) 100%);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 9px 32px;
    border-radius: 3px;
    position: relative;
}
.certificate-title {
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sms-primary);
    border-top: 1px solid var(--sms-border);
    border-bottom: 1px solid var(--sms-border);
    padding: 8px 0;
    display: inline-block;
}
.certificate-body {
    font-size: 0.95rem;
    line-height: 1.9;
    text-align: justify;
    margin-bottom: 14px;
}
.certificate-signatures {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 64px;
}
.signature-block { text-align: center; width: 190px; }
.signature-line { border-top: 1px solid #333; margin-bottom: 6px; }
.certificate-seal {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 3px double var(--sms-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.certificate-seal-inner {
    text-align: center;
    color: var(--sms-primary);
}
.certificate-seal-inner i { font-size: 1.3rem; display: block; }
.certificate-seal-inner span { font-size: 0.55rem; font-weight: 700; letter-spacing: 0.05em; color: var(--sms-gold-dark); }

/* ---------- Report Card (print) ---------- */
.report-card-sheet {
    max-width: 780px;
    margin: 0 auto;
}
.report-card-border {
    position: relative;
    border: 2px solid var(--sms-gold);
    border-radius: 6px;
    padding: 32px 40px;
    background: #fffdf8;
}
.report-card-summary-box {
    background: #f6ece0;
    border-radius: 8px;
    padding: 14px 18px;
    text-align: center;
}
.report-card-summary-box .value { font-size: 1.3rem; font-weight: 700; color: var(--sms-primary); }
.report-card-summary-box .label { font-size: 0.75rem; color: var(--sms-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.report-card-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sms-gold);
}

/* ---------- Notice (letterhead with watermark) ---------- */
.notice-sheet {
    max-width: 780px;
    margin: 0 auto;
}
.notice-border {
    position: relative;
    border: 2px solid var(--sms-gold);
    border-radius: 6px;
    padding: 36px 44px;
    background: #fffdf8;
    overflow: hidden;
    min-height: 500px;
}
.notice-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 380px;
    height: 380px;
    transform: translate(-50%, -50%);
    background-image: url("/static/images/school-logo-medium.jpg");
    background-size: cover;
    background-position: center;
    border-radius: 50%;
    opacity: 0.07;
    z-index: 0;
    pointer-events: none;
}
.notice-content { position: relative; z-index: 1; }
.notice-header {
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 2px solid var(--sms-gold);
    padding-bottom: 16px;
    margin-bottom: 24px;
}
.notice-header img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sms-gold);
}
.notice-header .school-name { font-size: 1.15rem; font-weight: 700; color: var(--sms-navy); }
.notice-audience-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--sms-navy) 0%, var(--sms-primary) 100%);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 14px;
    border-radius: 999px;
}
.notice-title { font-size: 1.4rem; font-weight: 700; color: var(--sms-navy); margin: 18px 0 14px; }
.notice-body { font-size: 0.98rem; line-height: 1.85; white-space: pre-line; margin-bottom: 32px; }
.notice-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-top: 1px solid var(--sms-border);
    padding-top: 16px;
    font-size: 0.85rem;
    color: var(--sms-text-muted);
}

@media print {
    .notice-border { border-color: #000 !important; }
    .notice-sheet { break-inside: avoid; }
    .certificate-border, .report-card-border { border-color: #000 !important; }
    .certificate-sheet, .report-card-sheet { break-inside: avoid; }
    @page { size: A4 portrait; margin: 12mm; }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-col { margin-left: 0; }
}
