/* ============================================================
   Premium Global Styles & Variables
   ============================================================ */

/* Accessibility: visible keyboard focus indicator on all interactive
   elements (mouse clicks are unaffected — :focus-visible only triggers
   for keyboard navigation) */
:focus-visible {
    outline: 3px solid var(--c-c9a84c, #c9a84c);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Accessibility: respect users who turn off animations system-wide */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

:root {
    --primary: var(--c-1b4332, #1b4332);
    /* Deep Forest Green - authoritative, academic, trustworthy */
    --primary-dark: #0F2E22;
    --primary-light: var(--c-2d6a4f, #2d6a4f);
    /* Active nav item - Medium Green */
    --sidebar-bg: var(--c-1b4332, #1b4332);
    --sidebar-hover: var(--c-2d6a4f, #2d6a4f);
    --secondary: #5D5D5B;
    /* Clean Warm Muted Grey */
    --accent: #EAEAE0;
    /* Soft Ivory/Warm Beige Accent */
    --accent-gold: var(--c-c9a84c, #c9a84c);
    /* Accent / Gold line - Warm Gold for prestige & school pride */
    --success: var(--c-2d6a4f, #2d6a4f);
    --danger: #be123c;
    --warning: var(--c-c9a84c, #c9a84c);
    --background: #FAFAF5;
    /* Warm Ivory - clean but not cold */
    --card-bg: #ffffff;
    --text-main: #1C1C1E;
    /* Deep Charcoal - enhanced readability */
    --text-muted: var(--c-64748b, #64748b);
    --border: #E5E5DB;
    /* Soft warm ivory border */
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgba(27, 67, 50, 0.06), 0 2px 4px -2px rgba(27, 67, 50, 0.03);
    --shadow-lg: 0 20px 25px -5px rgba(27, 67, 50, 0.04), 0 8px 10px -6px rgba(27, 67, 50, 0.03);

    /* Mobile header height — used consistently */
    --mobile-header-h: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.011em;
    /* Tighter, professional kerning */
}

html {
    height: -webkit-fill-available;
    font-size: 16px;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    /* Optimized line height for Inter */
    display: flex;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--c-1b4332, #1b4332) 0%, #0D2518 100%);
    color: white;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 1.75rem 1.1rem;
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 3rem;
    width: calc(100% - 280px);
    min-width: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Branding */
.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-bottom: 1.4rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-logo {
    width: 78px;
    height: 78px;
    object-fit: contain;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 2px 8px rgba(201, 168, 76, 0.3));
    border-radius: 50%;
    background: var(--card-bg, white);
    padding: 4px;
}

.sidebar-title {
    font-size: 0.67rem;
    font-weight: 800;
    line-height: 1.55;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.6);
}

.security-badge {
    margin-top: 0.85rem;
    background: rgba(52, 211, 153, 0.08);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.2);
    padding: 0.32rem 0.8rem;
    border-radius: 99px;
    font-size: 0.58rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    animation: fadeIn 0.8s ease-out;
}

.security-badge::before {
    content: '🔒';
    font-size: 0.7rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Nav section label */
.nav-section-label {
    font-size: 0.57rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.25);
    padding: 0 0.65rem;
    margin: 0.25rem 0 0.5rem;
}

/* Thin divider */
.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.07);
    margin: 0.5rem 0;
}

/* Rothana branding card at sidebar bottom */
.sidebar-rothana {
    position: relative;
    overflow: hidden;
    margin: 0.85rem 0.5rem 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #071c0f 0%, #102b1d 55%, #060f08 100%);
    border: 1px solid rgba(201, 168, 76, 0.22);
    padding: 0.85rem 1rem 0.9rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 4px 18px rgba(0,0,0,0.35);
    cursor: default;
}
.sidebar-rothana:hover {
    border-color: rgba(201, 168, 76, 0.5);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 4px 18px rgba(0,0,0,0.35), 0 0 0 1px rgba(201,168,76,0.14);
}
/* Large watermark logo floated to the right */
.sidebar-rothana-bg {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 96px;
    height: 96px;
    object-fit: contain;
    opacity: 0.13;
    pointer-events: none;
    user-select: none;
}
/* Text block */
.sidebar-rothana-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.sidebar-rothana-name {
    font-size: 0.92rem;
    font-weight: 900;
    letter-spacing: 0.22em;
    color: #ffffff;
    text-transform: uppercase;
    line-height: 1;
}
.sidebar-rothana-sub {
    font-size: 0.47rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: rgba(201, 168, 76, 0.88);
    text-transform: uppercase;
    line-height: 1;
}
/* Small icon shown only in collapsed mode */
.sidebar-rothana-icon {
    display: none;
    width: 26px;
    height: 26px;
    object-fit: contain;
    opacity: 0.55;
}
/* Collapsed: strip back to a minimal centered icon row */
body.sidebar-collapsed .sidebar-rothana {
    margin: 0.65rem 0 0;
    border-radius: 0;
    background: transparent;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.6rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}
body.sidebar-collapsed .sidebar-rothana:hover {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}
body.sidebar-collapsed .sidebar-rothana-bg { display: none; }
body.sidebar-collapsed .sidebar-rothana-content { display: none; }
body.sidebar-collapsed .sidebar-rothana-icon { display: block; }

/* --- Avatar Styling --- */
.avatar-container {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    border: 2px solid white;
}

.avatar-container:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.3);
}

.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(37, 99, 235, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
}

.avatar-container:hover .avatar-overlay {
    opacity: 1;
}

.avatar-overlay svg {
    width: 24px;
    height: 24px;
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Sidebar Navigation */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.78rem 0.9rem;
    color: rgba(255, 255, 255, 0.48);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.18s ease;
    font-size: 0.855rem;
    border-left: 2.5px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.92);
    border-left-color: rgba(255, 255, 255, 0.18);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left: 2.5px solid var(--accent-gold);
    font-weight: 700;
}

.nav-link svg {
    width: 17px;
    height: 17px;
    stroke-width: 1.75;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-link.active svg,
.nav-link:hover svg {
    opacity: 1;
}

/* Mobile header — hidden on desktop */
.mobile-header {
    display: none;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
    padding: 0.4rem;
    line-height: 1;
}

/* Sidebar overlay backdrop — hidden on desktop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
}

/* ============================================================
   Sidebar Collapse Toggle Button
   ============================================================ */
.sidebar-collapse-btn {
    position: fixed;
    left: 280px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 56px;
    background: linear-gradient(180deg, var(--c-1b4332, #1b4332), #0D2518);
    border: 1px solid rgba(201, 168, 76, 0.35);
    border-left: none;
    border-radius: 0 10px 10px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
    box-shadow: 3px 0 12px rgba(0, 0, 0, 0.35);
    color: rgba(201, 168, 76, 0.75);
    padding: 0;
}
.sidebar-collapse-btn:hover {
    background: linear-gradient(180deg, var(--c-2d6a4f, #2d6a4f), var(--c-1b4332, #1b4332));
    color: var(--c-c9a84c, #c9a84c);
}
.sidebar-collapse-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Collapsed Sidebar State
   ============================================================ */
body.sidebar-collapsed .sidebar {
    width: 72px;
    padding: 1.75rem 0.5rem;
}
body.sidebar-collapsed .main-content {
    margin-left: 72px;
    width: calc(100% - 72px);
}
body.sidebar-collapsed .sidebar-collapse-btn {
    left: 72px;
}
body.sidebar-collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}
body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .nav-section-label,
body.sidebar-collapsed .nav-divider,
body.sidebar-collapsed .security-badge {
    display: none !important;
}
body.sidebar-collapsed .sidebar-brand {
    border-bottom: none;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}
body.sidebar-collapsed .sidebar-logo {
    width: 46px;
    height: 46px;
    margin-bottom: 0;
}
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .sp-nav-link span {
    display: none !important;
}
body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .sp-nav-link {
    justify-content: center;
    padding: 0.85rem 0.5rem;
    border-left-color: transparent !important;
}
body.sidebar-collapsed .nav-link.active,
body.sidebar-collapsed .sp-nav-link.active {
    border-left-color: transparent !important;
    border-bottom: 2px solid var(--accent-gold);
}
/* Tooltip on collapsed nav items */
body.sidebar-collapsed .nav-link[title],
body.sidebar-collapsed .sp-nav-link[title] {
    position: relative;
}
body.sidebar-collapsed .nav-link[title]:hover::after,
body.sidebar-collapsed .sp-nav-link[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--c-1e293b, #1e293b);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    pointer-events: none;
}
/* Badge in collapsed sidebar (Messages) */
body.sidebar-collapsed #msg-unread-badge,
body.sidebar-collapsed #sp-msg-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.5rem;
    padding: 0 4px;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
}
/* Hide collapse button on tablet/mobile (they have their own responsive behavior) */
@media (max-width: 1024px) {
    .sidebar-collapse-btn { display: none !important; }
}
/* On mobile, the sidebar is a slide-in drawer — collapsed state must not shrink it */
@media (max-width: 768px) {
    body.sidebar-collapsed .sidebar { width: 280px !important; }
    body.sidebar-collapsed .main-content { margin-left: 0 !important; width: 100% !important; }
    body.sidebar-collapsed .sidebar-title { display: block !important; }
    body.sidebar-collapsed .nav-section-label { display: block !important; }
    body.sidebar-collapsed .nav-divider { display: block !important; }
    body.sidebar-collapsed .sidebar-brand { border-bottom: 1px solid rgba(255,255,255,0.07) !important; padding-bottom: 1.4rem !important; margin-bottom: 1.1rem !important; }
    body.sidebar-collapsed .nav-link span,
    body.sidebar-collapsed .sp-nav-link span { display: inline !important; }
    body.sidebar-collapsed .nav-link,
    body.sidebar-collapsed .sp-nav-link { justify-content: flex-start !important; padding: 0.9rem 1.2rem !important; }
    body.sidebar-collapsed .sidebar-logo { width: 80px !important; height: 80px !important; }
}

/* ============================================================
   Page Header
   ============================================================ */
header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.header-title h1 {
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -0.05em;
    line-height: 1;
    margin-bottom: 0.25rem;
    text-transform: capitalize;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

/* Rothana branded header card (replaces plain title on index.html) */
.rothana-header-card {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background: linear-gradient(135deg, #071c0f 0%, #102b1d 55%, #060f08 100%);
    border: 1px solid rgba(201, 168, 76, 0.22);
    padding: 1.3rem 2rem 1.3rem 1.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.16);
    display: inline-flex;
    align-items: center;
    min-width: 260px;
}
.rothana-header-bg {
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    height: 160px;
    object-fit: contain;
    opacity: 0.1;
    pointer-events: none;
    user-select: none;
}
.rothana-header-text {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
}
.rothana-header-name {
    font-size: 1.9rem;
    font-weight: 900;
    letter-spacing: 0.26em;
    color: #ffffff;
    text-transform: uppercase;
    line-height: 1;
}
.rothana-header-sub {
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: rgba(201, 168, 76, 0.92);
    text-transform: uppercase;
}

/* ============================================================
   Cards & Grid
   ============================================================ */
.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent-gold);
    /* Warm Gold Top Border */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-gold);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2.5rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(27, 67, 50, 0.2);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 16px rgba(27, 67, 50, 0.35);
}

.btn-secondary {
    background: var(--card-bg, white);
    border: 1.5px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 10px;
}

/* ============================================================
   Utility helpers
   ============================================================ */
.flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-danger {
    background: var(--c-fee2e2, #fee2e2);
    color: var(--danger);
}

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

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: border-color 0.2s;
    background: var(--card-bg, white);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================================
   Tables
   ============================================================ */
.table-container {
    background: var(--card-bg, white);
    padding: 0;
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 2rem;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #EAEAE0;
    padding: 1.2rem 1.5rem;
    font-weight: 800;
    color: var(--primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: left;
    border-bottom: 2px solid var(--accent-gold);
}

td {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #FAFAF0;
}

/* ============================================================
   Modals
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg, white);
    padding: 2.5rem;
    border-radius: 28px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 40px 60px -20px rgba(0, 0, 0, 0.4);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
}

.modal-close {
    background: #f3f4f6;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--border);
    color: var(--danger);
}

/* ============================================================
   Subject Item (Class Detail Sidebar)
   ============================================================ */
.subject-item {
    padding: 1rem 1.25rem;
    border-radius: 14px;
    background: var(--accent);
    border: 1.5px solid transparent;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subject-item:hover {
    background: var(--card-bg, white);
    border-color: var(--primary);
    transform: scale(1.02) translateX(4px);
    box-shadow: var(--shadow);
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
    background: var(--card-bg, white);
    padding: 1.75rem 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent-gold);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card[onclick]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-top-color: var(--primary);
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.3;
    z-index: 0;
}

.stat-icon-wrapper {
    width: 70px;
    height: 70px;
    background: var(--accent);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
    z-index: 1;
}

.stat-icon-wrapper svg {
    width: 32px;
    height: 32px;
}

.stat-content {
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.stat-value {
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-main);
    line-height: 1;
    letter-spacing: -0.05em;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

/* Progress Bar for Class Cards */
.progress-container {
    margin-top: 1.5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--c-f1f5f9, #f1f5f9);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Grade Pills
   ============================================================ */
.grade-pill {
    padding: 0.5rem 0.4rem;
    border-radius: 10px;
    font-weight: 800;
    text-align: center;
    font-size: 0.95rem;
}

.pill-green {
    background: var(--c-dcfce7, #dcfce7);
    color: var(--c-166534, #166534);
}

.pill-yellow {
    background: #fef9c3;
    color: var(--c-854d0e, #854d0e);
}

.pill-red {
    background: var(--c-fee2e2, #fee2e2);
    color: var(--c-991b1b, #991b1b);
}

/* ============================================================
   Student Avatar (student.html)
   ============================================================ */
.avatar-circle {
    width: 110px;
    height: 110px;
    border-radius: 30%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 900;
    box-shadow: 0 15px 25px -5px rgba(27, 67, 50, 0.25);
    margin-right: 2rem;
    border: 4px solid white;
    flex-shrink: 0;
}

/* ============================================================
   Class Detail Layout  (class.html)
   ============================================================ */

/* Two-column: subjects sidebar | roster */
.class-detail-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    align-items: start;
    gap: 2rem;
}

.subjects-panel {
    position: sticky;
    top: 1rem;
}

.roster-panel {
    padding: 0;
    overflow: hidden;
    min-width: 0;
}

/* Toolbar inside the roster card */
.roster-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.roster-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.roster-top-row h3 {
    font-size: 1.1rem;
    font-weight: 800;
    flex-shrink: 0;
}

/* Search box */
.search-wrap {
    position: relative;
    flex: 1;
    max-width: 260px;
}

.search-wrap input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.4rem;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    font-size: 0.88rem;
    background: var(--card-bg, white);
    color: var(--text-main);
    transition: border-color 0.2s;
}

.search-wrap input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Action buttons row */
.roster-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Scrollable table (no card shadow — already inside card) */
.table-scroller {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroller table {
    min-width: 460px;
    border-collapse: collapse;
    width: 100%;
}

.table-scroller th,
.table-scroller td {
    white-space: nowrap;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ============================================================
   BREAKPOINT: Tablet — 1024px
   Collapse sidebar to icon-only strip
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 1.5rem 0.5rem;
    }

    .sidebar-brand {
        margin-bottom: 2rem;
        border-bottom: none;
        padding-bottom: 0;
    }

    .sidebar-logo {
        width: 52px;
        height: 52px;
        margin-bottom: 0;
    }

    .sidebar-title { display: none; }
    .nav-section-label { display: none; }
    .nav-divider { display: none; }
    .security-badge { display: none; }

    .nav-link span {
        display: none;
    }

    .nav-link {
        justify-content: center;
        padding: 0.85rem;
        border-radius: 10px;
        border-left: none;
    }

    .nav-link:hover {
        transform: none;
        border-left: none;
    }

    .nav-link.active {
        border-left: none;
        border-bottom: 2px solid var(--accent-gold);
    }

    .main-content {
        margin-left: 80px;
        width: calc(100% - 80px);
        padding: 2rem;
    }

    .header-title h1 {
        font-size: 2rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

/* ============================================================
   BREAKPOINT: Mobile — 768px
   Full slide-in drawer sidebar, stacked layout
   ============================================================ */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    /* — Sidebar becomes hidden drawer — */
    .sidebar {
        width: 280px;
        left: -280px;
        top: 0;
        height: 100%;
        padding: 2rem 1.25rem;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.active {
        left: 0;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.35);
    }

    .sidebar .nav-link span {
        display: inline;
    }

    .sidebar .nav-link {
        justify-content: flex-start;
        padding: 0.9rem 1.2rem;
    }

    .sidebar-logo {
        width: 80px;
        height: 80px;
    }

    .sidebar-title {
        display: block;
    }

    .sidebar-brand {
        margin-bottom: 2.5rem;
    }

    /* — Mobile top bar — */
    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: var(--mobile-header-h);
        background: var(--sidebar-bg);
        color: white;
        align-items: center;
        padding: 0 1.25rem;
        z-index: 900;
        box-shadow: var(--shadow);
        gap: 0.5rem;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* — Main content reflow — */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.25rem;
        margin-top: var(--mobile-header-h);
    }

    /* — Page header — */
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .header-title h1 {
        font-size: 1.6rem;
    }

    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.6rem;
        width: 100%;
    }

    .header-actions .btn {
        flex: 1 1 calc(50% - 0.3rem);
        min-width: 130px;
        font-size: 0.78rem;
        padding: 0.7rem 0.5rem;
        border-radius: 10px;
    }

    /* — Cards — */
    .card {
        padding: 1.25rem;
    }

    .card:hover {
        transform: none;
    }

    /* Disable lift on touch */

    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* — Stats section — */
    #stats.grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
        border-radius: 14px;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.7rem;
        letter-spacing: 0;
    }

    /* — Class detail: stack columns vertically — */
    .class-detail-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .subjects-panel {
        position: static;
        /* stop sticking on mobile */
    }

    /* Roster toolbar: search full width, buttons wrap */
    .roster-header {
        padding: 1rem 1.25rem;
    }

    .search-wrap {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .roster-top-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .roster-btn-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .roster-btn-row .btn {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.6rem 0.4rem;
    }

    /* — Toolbar inside class.html roster card — */
    .roster-toolbar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .roster-toolbar .btn-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .roster-toolbar .btn-group .btn {
        width: 100%;
        font-size: 0.75rem;
        padding: 0.6rem 0.4rem;
    }

    /* search inputs full width */
    #class-search,
    #student-search {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* — Tables — */
    .table-container {
        border-radius: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Allow tables to scroll horizontally naturally */
    table {
        min-width: 480px;
    }

    th,
    td {
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }

    /* — Modals — */
    .modal {
        padding: 0;
        align-items: flex-end;
        /* slide up from bottom */
    }

    .modal-content {
        padding: 1.5rem 1.25rem;
        border-radius: 24px 24px 0 0;
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        margin: 0;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    /* — Form grids inside modals collapse to 1-col — */
    .modal-content .grid,
    form .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* — Grade pills — */
    .grade-pill {
        font-size: 0.8rem;
        padding: 0.35rem 0.25rem;
        border-radius: 8px;
    }

    /* — Student page avatar + name row — */
    #student-avatar {
        width: 56px !important;
        height: 56px !important;
        font-size: 1.2rem !important;
        margin-right: 1rem !important;
        border-radius: 16px !important;
    }

    #student-name {
        font-size: 1.4rem !important;
    }

    #student-meta {
        font-size: 0.72rem !important;
    }

    /* Performance table gets proper scroll wrapper */
    .performance-table-scroller {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
    }

    /* Academic year selector row */
    #academic-year-select {
        max-width: 130px;
    }

    /* Teacher dashboard panel grid → single col */
    #teacher-dashboard-panel .grid {
        grid-template-columns: 1fr !important;
    }

    /* Pending approvals table */
    #approvals-section .table-container table {
        min-width: 560px;
    }

    /* User management form grids */
    #form-user .grid {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    /* Subject assignment checkbox list */
    #assign-subject-list {
        max-height: 240px;
    }

    /* Division header spacing */
    .division-header {
        margin-top: 0.5rem !important;
    }

    /* flex justify-between utilities — stack on phone */
    .flex.justify-between {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* — Financials Modal Responsive Overrides —
       The console is a full-screen modal: dark header bar, then a body
       with a 250px dark sidebar (nav + class list) and the content pane.
       On phones the sidebar becomes a compact horizontal toolbar on top. */

    /* Top header bar: tighter padding; totals wrap under the title */
    #modal-financials .modal-content > div:first-child {
        padding: 0.6rem 1rem !important;
        gap: 0.5rem !important;
    }

    /* Body: stack toolbar above content; content pane scrolls internally */
    #modal-financials .modal-content > div:nth-child(2) {
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* Sidebar → full-width compact toolbar */
    #modal-financials .modal-content > div:nth-child(2) > div:first-child {
        width: 100% !important;
        flex-shrink: 0 !important;
    }

    /* Class search row */
    #modal-financials .modal-content > div:nth-child(2) > div:first-child > div:first-child {
        padding: 0.6rem 0.75rem !important;
        border-bottom: none !important;
    }

    /* Nav (School Dashboard / Debtors): horizontal chips, labels hidden */
    #modal-financials .modal-content > div:nth-child(2) > div:first-child > div:nth-child(2) {
        display: flex !important;
        align-items: center;
        gap: 0.4rem;
        padding: 0 0.75rem !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #modal-financials .modal-content > div:nth-child(2) > div:first-child > div:nth-child(2) > div:not(.fin-nav-item) {
        display: none !important;
        /* hides the "OVERVIEW" / "CLASSES" section labels */
    }

    #modal-financials .fin-nav-item {
        flex-shrink: 0;
        white-space: nowrap;
        border-left: none;
        border-radius: 8px;
        padding: 0.45rem 0.8rem;
        background: rgba(255, 255, 255, 0.06);
        font-size: 0.76rem;
    }

    #modal-financials .fin-nav-item.active {
        background: rgba(255, 255, 255, 0.18);
    }

    /* Class list: horizontally scrolling chips */
    #financial-class-list {
        display: flex !important;
        flex-direction: row !important;
        flex: 0 0 auto !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: 0.4rem;
        padding: 0.5rem 0.75rem !important;
        -webkit-overflow-scrolling: touch;
    }

    #modal-financials .fin-class-item {
        flex-shrink: 0;
        white-space: nowrap;
        border-left: none;
        border-radius: 8px;
        padding: 0.45rem 0.7rem;
        background: rgba(255, 255, 255, 0.06);
        font-size: 0.74rem;
    }

    #modal-financials .fin-class-item.active {
        background: rgba(255, 255, 255, 0.18);
    }

    /* Bottom actions (Transaction History / Fee Settings): two columns */
    #modal-financials .modal-content > div:nth-child(2) > div:first-child > div:last-child {
        padding: 0.5rem 0.75rem 0.75rem !important;
        border-top: none !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }

    #modal-financials .modal-content > div:nth-child(2) > div:first-child > div:last-child button {
        font-size: 0.72rem !important;
        padding: 0.5rem !important;
        text-align: center !important;
    }

    /* Content pane fills the remaining height; its own area scrolls */
    #modal-financials .modal-content > div:nth-child(2) > div:last-child {
        flex: 1 !important;
        min-height: 0 !important;
    }

    /* Sub-header: wrap; the student filter takes its own full row */
    #modal-financials .modal-content > div:nth-child(2) > div:last-child > div:first-child {
        flex-wrap: wrap !important;
        padding: 0.7rem 1rem !important;
        gap: 0.5rem !important;
    }

    #fin-student-search-container,
    #fin-student-search-container > div,
    #financial-student-filter {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    /* Main view container padding */
    #financial-main-content {
        padding: 0.85rem !important;
    }

    /* Overview: "Collection by Class" / "Recent Transactions" stack */
    .fin-two-col {
        grid-template-columns: 1fr !important;
    }

    /* Wide finance tables (ledger, history, debtors) keep their column
       widths and scroll sideways inside their card instead of crushing */
    .fin-table-card table {
        min-width: 640px;
    }

    /* Fee settings: exchange-rate row and grade-select row stack */
    #financial-settings-view div[style*="gap:1.25rem"] {
        flex-wrap: wrap !important;
    }

    #financial-settings-view .card>div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    #financial-settings-view .card>div>p {
        margin-top: 0 !important;
    }

    /* Fee category rows: name on its own line, amounts + delete below */
    .fee-row {
        flex-wrap: wrap !important;
    }

    .fee-row > div:first-child {
        flex: 1 1 100% !important;
    }

    /* ---- Restore sidebar drawer elements at 768px ---- */
    .nav-section-label { display: block; }
    .nav-divider { display: block; }
    .security-badge { display: inline-flex; }
    .sidebar-brand {
        padding-bottom: 1.4rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    }
    .nav-link { border-left: 2.5px solid transparent; }
    .nav-link.active { border-bottom: none; border-left: 2.5px solid var(--accent-gold); }

    /* ---- Redesigned full-screen modal headers (dark green bars) ---- */
    /* Users list & user form — reduce padding, stack inner content */
    #modal-users .modal-content > div:first-child,
    #modal-user-form .modal-content > div:first-child {
        padding: 0.85rem 1rem !important;
        flex-wrap: wrap !important;
        gap: 0.65rem !important;
    }
    #modal-user-form .modal-content > div:first-child > div:first-child {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Subjects & Classes list modal headers */
    #modal-list-subjects .modal-content > div:first-child,
    #modal-list-classes .modal-content > div:first-child {
        padding: 0.85rem 1rem !important;
    }
    #modal-list-subjects .modal-content > div:first-child > div:last-child {
        flex-shrink: 0;
    }

    /* ---- Class page: roster panel dark header stack ---- */
    .roster-panel > div:first-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.65rem !important;
        padding: 0.85rem 1rem !important;
        border-radius: 20px 20px 0 0 !important;
    }
    .roster-panel > div:first-child > div:last-child {
        max-width: 100% !important;
        width: 100% !important;
    }
    #student-search {
        background: rgba(255, 255, 255, 0.14) !important;
        max-width: 100% !important;
    }

    /* Roster action button toolbar → 2-column grid */
    .roster-panel > div:nth-child(2) {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.45rem !important;
        padding: 0.75rem !important;
    }
    .roster-panel > div:nth-child(2) > button {
        margin-left: 0 !important;
        font-size: 0.7rem !important;
        padding: 0.5rem 0.3rem !important;
        justify-content: center !important;
        gap: 0.3rem !important;
    }

    /* Subjects panel dark header corner fix */
    .subjects-panel > div:first-child {
        border-radius: 20px 20px 0 0 !important;
    }

    /* ---- Student page: long student ID wraps ---- */
    #student-meta {
        word-break: break-all !important;
        line-height: 1.5 !important;
    }

    /* ---- Performance panel header ---- */
    main > section.card > div:first-child {
        padding: 0.85rem 1rem !important;
        border-radius: 20px 20px 0 0 !important;
    }

    /* ---- Superadmin platform header stack ---- */
    .platform-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1.25rem !important;
        padding: 1.5rem !important;
    }
    .platform-header > div:last-child {
        width: 100% !important;
        justify-content: space-between !important;
    }
}

/* ============================================================
   BREAKPOINT: Small phones — 480px
   Extra tightening for 360-480px screens
   ============================================================ */
@media (max-width: 480px) {

    .main-content {
        padding: 1rem;
    }

    /* Title sizes */
    .header-title h1 {
        font-size: 1.3rem;
    }

    /* Hide the square icon badge in page headers to save space */
    .header-title > div > div[style*="border-radius:14px"],
    .header-title > div > div[style*="border-radius: 14px"] {
        display: none !important;
    }

    /* 3-stat row keeps working but values shrink more */
    #stats.grid {
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 0.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-card {
        padding: 0.75rem 0.6rem;
        border-left-width: 4px;
    }

    /* Class cards minimal padding */
    .card {
        padding: 1rem;
        border-radius: 14px;
    }

    /* Buttons in header: full width single column on very small screens */
    .header-actions {
        display: flex;
        flex-direction: column;
    }

    .header-actions .btn {
        font-size: 0.82rem;
        padding: 0.75rem 1rem;
        width: 100%;
    }

    /* Roster action buttons: single column on very small phones */
    .roster-panel > div:nth-child(2) {
        grid-template-columns: 1fr !important;
    }

    /* Modal full-height-ish drawer */
    .modal-content {
        max-height: 95vh;
        padding: 1.25rem 1rem;
    }

    .modal-header h3 {
        font-size: 1rem;
    }

    /* New dark modal headers — tighter */
    #modal-users .modal-content > div:first-child,
    #modal-user-form .modal-content > div:first-child,
    #modal-list-subjects .modal-content > div:first-child,
    .roster-panel > div:first-child,
    main > section.card > div:first-child {
        padding: 0.75rem 0.85rem !important;
    }

    /* th/td tighter */
    th,
    td {
        padding: 0.7rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Avatar even smaller */
    #student-avatar {
        width: 46px !important;
        height: 46px !important;
        font-size: 1rem !important;
        border-radius: 14px !important;
    }

    #student-name {
        font-size: 1.1rem !important;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    /* Grade pill input */
    .grade-pill {
        font-size: 0.75rem;
    }

    input[type="number"].grade-pill {
        width: 58px !important;
    }

    /* search bars */
    #student-search {
        width: 100% !important;
    }

    /* Superadmin platform header: tighter on tiny screens */
    .platform-header {
        padding: 1.25rem !important;
    }
    .platform-header > div:first-child > div:first-child {
        display: none !important;
    }
    .platform-header h1 {
        font-size: 1.35rem !important;
    }

    /* Academic year selector row wraps */
    section>div>div[style*="display: flex"] {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* ============================================================
   Animations & Spinners
   ============================================================ */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(27, 67, 50, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Student Management Utility --- */
.grid {
    display: grid;
    gap: 1.5rem;
}

.student-class-group {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1.5px solid var(--border);
    transition: all 0.3s ease;
}

.student-class-group:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--c-e2e8f0, #e2e8f0);
}

/* --- Make Financial Management Modal Truly Full Screen globally --- */
#modal-financials {
    padding: 0 !important;
}

#modal-financials .modal-content {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
}

/* ============================================================
   Academic Reports Console
   ============================================================ */
#modal-reports {
    padding: 0 !important;
}

#modal-reports .modal-content {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
}

.reports-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.reports-nav-panel {
    width: 220px;
    background: var(--c-1b4332, #1b4332);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    overflow-y: auto;
    flex-shrink: 0;
}

.reports-nav-section {
    padding: 0 1rem 0.4rem;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 1.25rem;
}

.reports-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    user-select: none;
}

.reports-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.reports-nav-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-left-color: var(--c-c9a84c, #c9a84c);
}

.reports-nav-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.8;
}

.reports-content {
    flex: 1;
    overflow-y: auto;
    background: var(--c-f8fafc, #f8fafc);
    padding: 2rem;
}

/* Metric Cards */
.report-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.report-metric-card {
    background: var(--card-bg, white);
    border-radius: 14px;
    padding: 1.25rem;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.report-metric-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.report-metric-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-main);
    line-height: 1;
}

/* Rank Badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: 900;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.rank-1 {
    background: linear-gradient(135deg, #F59E0B, #FCD34D);
    color: #78350F;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.rank-2 {
    background: linear-gradient(135deg, var(--c-94a3b8, #94a3b8), #CBD5E1);
    color: var(--c-1e293b, #1e293b);
    box-shadow: 0 2px 8px rgba(148, 163, 184, 0.4);
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #E8A95E);
    color: #431407;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.3);
}

.rank-other {
    background: var(--c-f1f5f9, #f1f5f9);
    color: var(--text-muted);
}

/* Report Table */
.report-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg, white);
}

.report-table th {
    background: var(--c-f8fafc, #f8fafc);
    padding: 0.8rem 1rem;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1.5px solid var(--border);
}

.report-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--c-f1f5f9, #f1f5f9);
    font-size: 0.875rem;
    vertical-align: middle;
}

.report-table tr:last-child td {
    border-bottom: none;
}

.report-table tr.top-rank-row {
    background: linear-gradient(90deg, var(--c-fffbeb, #fffbeb) 0%, white 100%);
}

/* CSS Progress Bar */
.report-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.report-bar-track {
    flex: 1;
    height: 8px;
    background: var(--c-f1f5f9, #f1f5f9);
    border-radius: 999px;
    overflow: hidden;
}

.report-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}

.report-bar-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    min-width: 36px;
    text-align: right;
}

/* Section Headers */
.report-section-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.report-section-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Risk Badges */
.risk-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.risk-high { background: var(--c-fee2e2, #fee2e2); color: var(--c-991b1b, #991b1b); }
.risk-med  { background: #fef9c3; color: var(--c-854d0e, #854d0e); }
.risk-ok   { background: var(--c-dcfce7, #dcfce7); color: var(--c-166534, #166534); }

/* Gender Comparison Rows */
.gender-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.gender-label {
    width: 70px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    flex-shrink: 0;
}

/* ============================================================
   BREAKPOINT: Reports console — mobile
   ============================================================ */
@media (max-width: 768px) {
    .reports-layout {
        flex-direction: column;
        overflow: auto;
    }

    .reports-nav-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0.75rem;
        gap: 0.25rem;
        flex-shrink: 0;
        max-height: none;
    }

    .reports-nav-section { display: none; }

    .reports-nav-item {
        white-space: nowrap;
        flex-shrink: 0;
        border-left: none;
        border-bottom: 2.5px solid transparent;
        padding: 0.55rem 0.85rem;
        border-radius: 8px;
        font-size: 0.75rem;
    }

    .reports-nav-item.active {
        border-left: none;
        border-bottom: 2.5px solid var(--accent-gold);
    }

    .reports-content {
        padding: 1.25rem;
    }

    .reports-header-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .reports-header-bar > div:last-child {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .report-metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

/* ============================================================
   New Features — Shared Styles
   ============================================================ */

/* Announcements section */
#announcements-section {
    margin-bottom: 2.5rem;
}

/* Timetable cells hover */
.tt-cell:hover {
    border-color: var(--primary) !important;
    background: rgba(27, 67, 50, 0.06) !important;
}

/* Feature panel section cards (student.html) */
.feature-panel {
    background: var(--card-bg, white);
    border-radius: 20px;
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent-gold);
    overflow: hidden;
    margin-top: 2rem;
}

.feature-panel-header {
    background: var(--primary);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.feature-panel-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.feature-panel-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-panel-title {
    font-weight: 800;
    color: white;
    font-size: 0.9rem;
}

.feature-panel-sub {
    font-size: 0.63rem;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 600;
}

.feature-panel-body {
    padding: 1.5rem;
}

/* Responsive: feature panels on mobile */
@media (max-width: 768px) {
    .feature-panel-header {
        padding: 0.85rem 1rem;
        flex-wrap: wrap;
    }
    .feature-panel-body {
        padding: 1rem;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .mobile-header,
    .modal:not(#modal-reports),
    .reports-nav-panel,
    .reports-header-bar {
        display: none !important;
    }

    #modal-reports {
        position: static !important;
        background: none !important;
    }

    #modal-reports .modal-content {
        position: static !important;
        height: auto !important;
        overflow: visible !important;
    }

    .reports-layout {
        display: block !important;
    }

    .reports-content {
        overflow: visible !important;
        background: var(--card-bg, white) !important;
        padding: 1rem !important;
    }

    .report-table {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .report-metric-card {
        border: 1px solid #ccc;
        box-shadow: none;
    }

    @page {
        margin: 1.5cm;
    }
}
}

/* ============================================================
   Financial Management Console
   ============================================================ */
.fin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    user-select: none;
}

.fin-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.fin-nav-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-left-color: var(--c-c9a84c, #c9a84c);
}

.fin-class-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1.25rem;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    user-select: none;
}

.fin-class-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.fin-class-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-left-color: var(--c-c9a84c, #c9a84c);
}

/* Stat cards */
.fin-stat-card {
    background: var(--card-bg, white);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.fin-stat-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.fin-stat-value {
    font-size: 1.75rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.fin-stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Payment status pills */
.pay-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.6rem;
    border-radius: 99px;
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.pay-status-full    { background: var(--c-dcfce7, #dcfce7); color: #15803d; }
.pay-status-partial { background: #fef9c3; color: var(--c-854d0e, #854d0e); }
.pay-status-unpaid  { background: var(--c-fee2e2, #fee2e2); color: var(--c-991b1b, #991b1b); }

/* Payment progress bar */
.pay-progress-track {
    width: 100%;
    height: 6px;
    background: var(--c-f1f5f9, #f1f5f9);
    border-radius: 999px;
    overflow: hidden;
}

.pay-progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* Student financial card */
.fin-student-card {
    background: var(--card-bg, white);
    border-radius: 14px;
    padding: 1.25rem;
    border: 1.5px solid var(--border);
    transition: all 0.2s ease;
}

.fin-student-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 16px rgba(27, 67, 50, 0.1);
    transform: translateY(-2px);
}

/* Card wrappers around wide finance tables (ledger, transaction history,
   debtors). The JS sets overflow:hidden inline for the rounded corners;
   !important lets the table scroll sideways on narrow screens instead
   of overflowing the card. */
.fin-table-card {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Workspace pages (class.html, student.html) — full-screen like
   the management consoles: no sidebar, content takes the whole
   viewport. Navigation happens through the Back buttons.
   ============================================================ */
body.workspace-page .sidebar,
body.workspace-page .mobile-header,
body.workspace-page .sidebar-overlay {
    display: none !important;
}

body.workspace-page .main-content {
    margin-top: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    max-width: 1500px;
    padding: 2rem 2.5rem !important;
}

@media (max-width: 768px) {
    body.workspace-page .main-content {
        padding: 1rem !important;
    }
}

/* Sidebar class search */
#fin-class-search {
    color: white;
}

#fin-class-search::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#fin-class-search:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
}

/* ============================================================
   ENHANCED MOBILE RESPONSIVE FIXES
   These rules use !important to override inline styles that
   are injected by JS or set directly on HTML elements.
   ============================================================ */

/* ---- 768px: tablet / phone landscape / large phone ---- */
@media (max-width: 768px) {

    /* Stats section: override the JS-injected 3-col and 4-col inner grids */
    #stats > div {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 0.75rem !important;
    }

    /* Class list cards: always single column on mobile */
    #class-list {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Academic year pill: expand to full width so it never overflows */
    #academic-year-display > div {
        width: 100% !important;
        box-sizing: border-box !important;
        flex-wrap: wrap !important;
    }

    /* Approval section heading: stack label + badge on mobile */
    #approvals-section > .flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Teacher grade-completion and performance-overview: collapse grids */
    #grade-completion-section div[style*="minmax"],
    #teacher-performance-overview div[style*="minmax"] {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Teacher dashboard bio panel: collapse any 2-col inner grids */
    #teacher-dashboard-panel div[style*="1fr 1fr"],
    #teacher-dashboard-panel div[style*="1fr  1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Any stat-icon inside JS-injected stat cards: slightly smaller */
    .stat-icon-wrapper {
        width: 52px !important;
        height: 52px !important;
    }
    .stat-icon-wrapper svg {
        width: 24px !important;
        height: 24px !important;
    }

    /* Messaging modal: full-screen on mobile, stacked two-pane layout */
    #modal-messaging {
        padding: 0 !important;
        align-items: flex-start !important;
    }
    #modal-messaging .modal-content {
        border-radius: 0 !important;
        max-width: 100vw !important;
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
    }
    /* Stack contact list above chat (column instead of row) */
    #modal-messaging .modal-content > div:nth-child(2) {
        flex-direction: column !important;
        overflow: hidden !important;
    }
    /* Contact list pane: full width, capped height, scrollable */
    #modal-messaging .modal-content > div:nth-child(2) > div:first-child {
        width: 100% !important;
        min-width: 0 !important;
        border-right: none !important;
        border-bottom: 1.5px solid var(--border) !important;
        max-height: 190px !important;
        flex-shrink: 0 !important;
    }
    /* Contact list items: compact on mobile */
    .msg-contact-row {
        padding: 0.55rem 0.75rem !important;
    }
    /* Search bar: full width */
    #msg-search {
        max-width: 100% !important;
    }
    /* Right pane (profile + chat): flex-1 so it fills remaining height */
    #modal-messaging #msg-right-pane {
        flex: 1 !important;
        min-height: 0 !important;
    }
    /* Profile header in chat pane: compact on mobile */
    #modal-messaging #msg-right-pane > div:first-child {
        padding: 0.75rem 1rem !important;
        flex-wrap: wrap !important;
    }
    /* Compose area: adjust spacing */
    #modal-messaging #msg-body {
        font-size: 0.9rem !important;
    }

    /* — Enrollment form: 3-column field rows become 2 columns — */
    #form-enrollment div[style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }
    #form-enrollment > div {
        padding: 1.25rem 1rem 6rem !important;
    }
}

/* ---- 480px: small phones (360–480px) ---- */
@media (max-width: 480px) {

    /* Stats inner rows: tighter minimum so 2+ cards fit per row */
    #stats > div {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
        gap: 0.5rem !important;
    }

    /* Stat card: stack icon + value vertically so nothing overflows */
    .stat-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
        padding: 0.8rem 0.75rem !important;
    }
    .stat-card::after {
        display: none !important;
    }
    .stat-icon-wrapper {
        width: 34px !important;
        height: 34px !important;
        border-radius: 9px !important;
    }
    .stat-icon-wrapper svg {
        width: 17px !important;
        height: 17px !important;
    }
    .stat-value {
        font-size: 1.55rem !important;
    }
    .stat-subtext {
        display: none !important;
    }

    /* Academic year section: even tighter */
    #academic-year-display > div {
        padding: 0.6rem 1rem !important;
        gap: 0.5rem !important;
    }
    #academic-year-display span:first-child {
        font-size: 0.78rem !important;
    }
    #academic-year-display #active-academic-year {
        font-size: 0.9rem !important;
    }

    /* Class list: minimum padding on cards */
    #class-list .card,
    #class-list > div {
        padding: 1rem !important;
    }

    /* Messaging modal contact list: shorter on tiny phones */
    #modal-messaging .modal-content > div:nth-child(2) > div:first-child {
        max-height: 155px !important;
    }

    /* Grade completion and performance overview: compact cards */
    #grade-completion-section .card,
    #teacher-performance-overview .card {
        padding: 0.9rem !important;
    }

    /* Pending approvals table: scroll works, reduce font */
    #approvals-section .table-container table {
        min-width: 480px;
        font-size: 0.78rem;
    }
    #approvals-section th,
    #approvals-section td {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.78rem !important;
    }

    /* Teacher dashboard panel: inner flex wraps */
    #teacher-dashboard-panel > div {
        flex-wrap: wrap !important;
    }

    /* Announcement cards: no hover lift on touch */
    #announcements-section .card:hover {
        transform: none !important;
    }

    /* — Financial console: small phones — */

    /* Overview + ledger stat cards: two per row, compact */
    #financial-dashboard-default div[style*="minmax(190px"],
    #financial-student-ledger > div[style*="minmax(180px"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }
    #modal-financials .fin-stat-card {
        padding: 0.85rem 0.9rem;
    }
    #modal-financials .fin-stat-value {
        font-size: 1.3rem;
    }

    /* One student card per row */
    #financial-students-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    /* Today's Collections banner: totals close up under the heading */
    #financial-dashboard-default div[style*="gap:1.75rem"] {
        gap: 1rem !important;
    }

    /* Transaction history filter bar: search takes the full row */
    #financial-history-view > div:first-child > div:first-child {
        flex: 1 1 100% !important;
    }

    /* Record Payment / Scholarship modals: comfortable on 360px screens */
    #modal-record-payment .modal-content,
    #modal-scholarship .modal-content {
        padding: 1.25rem !important;
        border-radius: 18px !important;
    }

    /* Field pairs (currency/method, reference/remarks, payer/date) stack */
    #modal-record-payment .modal-content div[style*="1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Fee breakdown rows: amount input + "Pay All" wrap under the label */
    #pay-fee-rows > div {
        flex-wrap: wrap !important;
    }

    /* Ledger header card: student info and action buttons stack */
    #financial-student-ledger > div:first-child > div:last-child {
        width: 100%;
        flex-wrap: wrap;
    }

    /* — Enrollment form: every field row single-column on small phones — */
    #form-enrollment div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}
/* ============================================================
   Theme palette — every var below is referenced as
   var(--c-<hex>, #<hex>) throughout the app, so light mode is
   pixel-identical to the original design. The dark block remaps
   each color for [data-theme="dark"], set by the toggle in
   shared.js (persisted in localStorage).
   ============================================================ */
:root {
    --c-1b4332: #1b4332; --c-dc2626: #dc2626; --c-f8fafc: #f8fafc;
    --c-f1f5f9: #f1f5f9; --c-94a3b8: #94a3b8; --c-e2e8f0: #e2e8f0;
    --c-64748b: #64748b; --c-059669: #059669; --c-f0fdf4: #f0fdf4;
    --c-166534: #166534; --c-dcfce7: #dcfce7; --c-d97706: #d97706;
    --c-fee2e2: #fee2e2; --c-991b1b: #991b1b; --c-c9a84c: #c9a84c;
    --c-2d6a4f: #2d6a4f; --c-1e293b: #1e293b; --c-d1fae5: #d1fae5;
    --c-2563eb: #2563eb; --c-1d4ed8: #1d4ed8; --c-fffbeb: #fffbeb;
    --c-92400e: #92400e; --c-bbf7d0: #bbf7d0; --c-0f5132: #0f5132;
    --c-eff6ff: #eff6ff; --c-6366f1: #6366f1; --c-854d0e: #854d0e;
    --c-fde68a: #fde68a; --c-dbeafe: #dbeafe;
    /* Extended text-color palette (added 2026-06-14 for dark-mode legibility).
       Light values are identity; the dark block remaps each to a light tint so
       badge/label text stays readable on dark backgrounds. */
    --c-374151: #374151; --c-b91c1c: #b91c1c; --c-6d28d9: #6d28d9;
    --c-15803d: #15803d; --c-be185d: #be185d; --c-475569: #475569;
    --c-1e40af: #1e40af; --c-0369a1: #0369a1; --c-7f1d1d: #7f1d1d;
    --c-7c3aed: #7c3aed; --c-4c1d95: #4c1d95; --c-0f172a: #0f172a;
    --c-065f46: #065f46; --c-c2410c: #c2410c; --c-7e22ce: #7e22ce;
    --c-78350f: #78350f; --c-16a34a: #16a34a; --c-6b7280: #6b7280;
    --c-1c1c1e: #1c1c1e;
    /* Light pastel/near-white surfaces (badge & card backgrounds). Identity in
       light mode; remapped to dark tints in the dark block so paired text stays
       legible. */
    --c-f3f4f6: #f3f4f6; --c-fafbfc: #fafbfc; --c-fef9c3: #fef9c3;
    --c-fef2f2: #fef2f2; --c-fdf2f2: #fdf2f2; --c-fafafa: #fafafa;
    --c-f7f9fc: #f7f9fc; --c-e0f2fe: #e0f2fe; --c-fdf8f6: #fdf8f6;
    --c-fce7f3: #fce7f3; --c-faf5ff: #faf5ff; --c-efeae2: #efeae2;
    --c-eaeae0: #eaeae0; --c-fffcfc: #fffcfc; --c-fff7ed: #fff7ed;
    --c-fff5f5: #fff5f5; --c-fff1f2: #fff1f2; --c-fef3c7: #fef3c7;
    --c-f9fafb: #f9fafb; --c-eef2ff: #eef2ff;
}

[data-theme="dark"] {
    /* core design-system variables */
    --background: #0f172a;
    --card-bg: #182234;
    --text-main: #e6eaf0;
    --text-muted: #9aa7ba;
    --border: #2c3a52;
    --accent: #1f2937;
    --secondary: #a8a8a4;

    /* remapped palette */
    --c-1b4332: #3d8a64; --c-dc2626: #f87171; --c-f8fafc: #1e293b;
    --c-f1f5f9: #253349; --c-94a3b8: #7e8ba1; --c-e2e8f0: #334155;
    --c-64748b: #9aa7ba; --c-059669: #34d399; --c-f0fdf4: #13291b;
    --c-166534: #4ade80; --c-dcfce7: #1d3a29; --c-d97706: #fbbf24;
    --c-fee2e2: #3d1a1a; --c-991b1b: #fca5a5; --c-c9a84c: #d4b65f;
    --c-2d6a4f: #3b8f6a; --c-1e293b: #dfe5ee; --c-d1fae5: #1c3a2b;
    --c-2563eb: #60a5fa; --c-1d4ed8: #82aef8; --c-fffbeb: #2d2510;
    --c-92400e: #f0b35c; --c-bbf7d0: #265138; --c-0f5132: #66d9a3;
    --c-eff6ff: #1c2a42; --c-6366f1: #8a8ef5; --c-854d0e: #dba24e;
    --c-fde68a: #4b3d12; --c-dbeafe: #1e3252;
    /* Extended text-color remaps → light tints readable on dark surfaces.
       Pairs with the raw badge backgrounds (e.g. dark-green bg + #4ade80 text). */
    --c-374151: #c7d2e0; --c-b91c1c: #fca5a5; --c-6d28d9: #c4b5fd;
    --c-15803d: #4ade80; --c-be185d: #f9a8d4; --c-475569: #aab6c8;
    --c-1e40af: #93c5fd; --c-0369a1: #7dd3fc; --c-7f1d1d: #fca5a5;
    --c-7c3aed: #c4b5fd; --c-4c1d95: #c4b5fd; --c-0f172a: #e6eaf0;
    --c-065f46: #6ee7b7; --c-c2410c: #fdba74; --c-7e22ce: #d8b4fe;
    --c-78350f: #fcd34d; --c-16a34a: #4ade80; --c-6b7280: #aab6c8;
    --c-1c1c1e: #e6eaf0;
    /* Pastel surfaces → dark tints (pair with the light text remaps above). */
    --c-f3f4f6: #1f2937; --c-fafbfc: #182234; --c-fef9c3: #2e2a12;
    --c-fef2f2: #2d1717; --c-fdf2f2: #2d1717; --c-fafafa: #1b2536;
    --c-f7f9fc: #182234; --c-e0f2fe: #0e2a3f; --c-fdf8f6: #241c18;
    --c-fce7f3: #3a1f2d; --c-faf5ff: #241b33; --c-efeae2: #1f2937;
    --c-eaeae0: #1f2937; --c-fffcfc: #241c18; --c-fff7ed: #2d2110;
    --c-fff5f5: #2d1717; --c-fff1f2: #2d1820; --c-fef3c7: #2d2510;
    --c-f9fafb: #182234; --c-eef2ff: #1c2a42;
}

[data-theme="dark"] body { background: var(--background); color: var(--text-main); }

/* Form controls: dark mode is driven entirely by the variable remap and has no
   component rules, so any inline-styled <select>/<input>/<textarea> that sets a
   background but NO color falls back to the browser default (black) — invisible
   on a dark surface (e.g. the directory/finance filter dropdowns). These rules
   only set the text color, so any control with an explicit inline color still
   wins; backgrounds are left to each control's own var-based styling. */
[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] textarea {
    color: var(--text-main);
}
/* Native dropdown list items render with system colors on some platforms —
   pin them to the themed surface so the open menu is readable too. */
[data-theme="dark"] select option,
[data-theme="dark"] select optgroup {
    background: var(--card-bg);
    color: var(--text-main);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-muted);
}
