:root {
    --color-primary: #3b82f6;
    --color-primary-dark: #2563eb;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-info: #06b6d4;
    --color-danger: #ef4444;
    --color-dark: #1f2937;
    --color-darker: #111827;
    --color-sidebar: #1f2937;
    --color-sidebar-hover: #374151;
    --color-text: #f3f4f6;
    --color-muted: #9ca3af;
    --color-bg: #f3f4f6;
    --color-card: #ffffff;
    --color-border: #e5e7eb;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

/* The [hidden] attribute must always win over classes like .form-row / .alert
   that set their own `display` — otherwise toggling `el.hidden` via JS has no
   visible effect on elements whose class already sets a `display` value. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: var(--font-main);
    background: var(--color-bg);
    color: #111827;
    line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.2s ease;
}

.brand {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--color-sidebar-hover);
}

.logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 10px;
    flex-shrink: 0;
}

.brand-text {
    flex: 1;
}

.brand-title {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.2;
}

.brand-version {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    font-size: 1.4rem;
    cursor: pointer;
}

.nav {
    padding: 10px 0;
    flex: 1;
}

.nav-group {
    margin-bottom: 14px;
}

.nav-heading {
    display: block;
    padding: 8px 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-primary);
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 18px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active,
.nav-item.open {
    background: var(--color-sidebar-hover);
    border-left-color: var(--color-primary);
}

.nav-item.has-submenu {
    cursor: pointer;
    justify-content: space-between;
}

.submenu-caret {
    font-size: 0.75rem;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.nav-item.open .submenu-caret {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    flex-direction: column;
    background: #111827;
    padding-left: 16px;
}

.submenu.open {
    display: flex;
}

.submenu-item {
    display: block;
    padding: 8px 18px;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.submenu-item:hover,
.submenu-item.active {
    background: var(--color-sidebar-hover);
    border-left-color: var(--color-primary);
    color: var(--color-text);
}

.submenu-item.sub2 {
    padding-left: 28px;
}

.submenu-heading {
    display: block;
    padding: 6px 18px 3px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-primary);
    opacity: 0.7;
}

.nav-icon {
    width: 24px;
    display: inline-block;
    text-align: center;
    margin-right: 10px;
    color: var(--color-muted);
}

/* Main area */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main.full {
    margin-left: 0;
    justify-content: center;
}

.main.full .content {
    padding: 0;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-height);
    background: linear-gradient(90deg, #1e3a5f 0%, #2563eb 100%);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.25);
}

.topbar-left .page-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu {
    position: relative;
}

.user-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s, box-shadow 0.2s;
}

.user-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.user-name {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-caret {
    font-size: 0.75rem;
    opacity: 0.8;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 190px;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--color-border);
    padding: 8px 0;
    z-index: 100;
}

.user-dropdown[hidden] {
    display: none;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--color-dark);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.user-dropdown-item:hover {
    background: #eff6ff;
}

.user-dropdown-icon {
    width: 20px;
    text-align: center;
}

.user-dropdown-logout {
    color: #dc2626;
}

.user-dropdown-logout:hover {
    background: #fef2f2;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 6px 0;
}

.content {
    padding: 24px;
    flex: 1;
}

/* Login */
.login-split {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.login-promo {
    flex: 1;
    min-width: 0;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 55%, #2a9d8f 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 48px;
    overflow: hidden;
}

.login-promo-brand {
    text-align: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.login-promo-brand h1 {
    margin: 12px 0 6px;
    font-size: 1.8rem;
}

.login-promo-tagline {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.login-live-clock {
    display: inline-block;
    margin-top: 14px;
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.login-promo-section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.75;
    margin: 0 0 16px;
    flex-shrink: 0;
}

.login-promo-scroll {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
}

.login-promo-track {
    display: flex;
    flex-direction: column;
    animation: promoScroll 30s linear infinite;
}

.login-promo-scroll:hover .login-promo-track {
    animation-play-state: paused;
}

@keyframes promoScroll {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-50%);
    }
}

.promo-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    backdrop-filter: blur(4px);
    transition: background 0.15s;
    flex-shrink: 0;
}

.promo-card:hover {
    background: rgba(255, 255, 255, 0.18);
}

.promo-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.promo-card h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 600;
}

.promo-card p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.92;
    line-height: 1.5;
}

.login-geo-status {
    flex-shrink: 0;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.geo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    flex-shrink: 0;
    animation: geoPulse 1.4s ease-in-out infinite;
}

.geo-dot-live {
    background: #22c55e;
}

@keyframes geoPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.login-form-side {
    flex: 1;
    min-width: 0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.login-card {
    background: var(--color-card);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.logo-large {
    width: 56px;
    height: 56px;
    font-size: 1.6rem;
    margin: 0 auto 14px;
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.login-sub {
    color: var(--color-muted);
    margin: 0;
}

.login-note {
    text-align: center;
    color: var(--color-muted);
    font-size: 0.8rem;
    margin-top: 18px;
}

.login-note a {
    color: var(--color-primary);
    text-decoration: none;
}

.login-note a:hover {
    text-decoration: underline;
}

.login-form-links {
    display: flex;
    justify-content: flex-end;
    margin: -8px 0 18px;
}

.login-form-links a {
    color: var(--color-primary);
    font-size: 0.85rem;
    text-decoration: none;
}

.login-form-links a:hover {
    text-decoration: underline;
}

@media (max-width: 860px) {
    .login-split {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .login-promo {
        padding: 24px;
        height: 42vh;
        min-height: 300px;
        flex: none;
    }

    .login-form-side {
        flex: none;
        overflow: visible;
    }

    .login-live-clock {
        margin-top: 10px;
        font-size: 0.8rem;
    }

    .login-form-side {
        padding: 24px 16px 40px;
    }

    .login-card {
        padding: 28px 22px;
    }
}

@media (max-width: 480px) {
    .login-promo-brand h1 {
        font-size: 1.4rem;
    }

    .login-promo-tagline {
        font-size: 0.85rem;
    }

    .promo-card h3 {
        font-size: 0.95rem;
    }

    .promo-card p {
        font-size: 0.82rem;
    }

    .login-geo-status {
        font-size: 0.72rem;
    }
}

/* Forms */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.05s;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-secondary:hover {
    background: #d1d5db;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.data-table td .btn {
    margin-right: 6px;
}

.data-table td .btn:last-child {
    margin-right: 0;
}

.btn-block {
    width: 100%;
    padding: 12px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Alerts */
.alert {
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.9rem;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Dashboard */
.welcome {
    margin-bottom: 20px;
}

.welcome h2 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

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

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.card {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
}

.stat-primary .stat-value { color: var(--color-primary); }
.stat-success .stat-value { color: var(--color-success); }
.stat-warning .stat-value { color: var(--color-warning); }
.stat-info .stat-value { color: var(--color-info); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}

.dashboard-card h3 {
    margin: 0 0 14px;
    font-size: 1.1rem;
}

.quick-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quick-links li {
    margin-bottom: 10px;
}

.quick-links a {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.95rem;
}

.quick-links a:hover {
    text-decoration: underline;
}

/* Page header */
.page-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.page-header .page-title {
    margin: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

/* School select */
.school-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

.school-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.school-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.school-meta {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.empty-state {
    color: var(--color-muted);
}

/* Search form */
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    max-width: 600px;
}

.search-form input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.search-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.95rem;
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table .empty {
    text-align: center;
    color: var(--color-muted);
    padding: 24px;
}

/* Stats */
.stat-danger .stat-value { color: var(--color-danger); }

/* Finance gradient KPI cards */
.finance-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.stat-gradient-purple { background: linear-gradient(135deg, #764ba2, #667eea); color: #fff; }
.stat-gradient-pink   { background: linear-gradient(135deg, #f093fb, #f5576c); color: #fff; }
.stat-gradient-cyan   { background: linear-gradient(135deg, #4facfe, #00f2fe); color: #fff; }
.stat-gradient-green  { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #fff; }

.stat-gradient-purple .stat-label,
.stat-gradient-pink .stat-label,
.stat-gradient-cyan .stat-label,
.stat-gradient-green .stat-label { color: rgba(255,255,255,0.85); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; }

.stat-gradient-purple .stat-value,
.stat-gradient-pink .stat-value,
.stat-gradient-cyan .stat-value,
.stat-gradient-green .stat-value { color: #fff; font-size: 1.5rem; margin: 4px 0; }

.stat-gradient-purple .stat-sub,
.stat-gradient-pink .stat-sub,
.stat-gradient-cyan .stat-sub,
.stat-gradient-green .stat-sub { color: rgba(255,255,255,0.7); font-size: 0.75rem; }

/* Finance charts row */
.finance-charts-row { display: flex; gap: 16px; margin-top: 20px; }
@media (max-width: 768px) { .finance-charts-row { flex-direction: column; } }

/* Finance controls */
.finance-controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.finance-controls .form-group { flex: 1; min-width: 160px; margin-bottom: 0; }

/* Finance export buttons */
.finance-export-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.finance-export-btns .btn { flex: 1; min-width: 180px; text-align: center; }

/* Tab bar */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid #dee2e6; }
.tab-btn { background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 20px; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: #6c757d; margin-bottom: -2px; }
.tab-btn.active { border-bottom-color: var(--color-primary); color: var(--color-primary); }
.tab-btn:hover { color: var(--color-primary); }

/* Progress bar */
.progress-bar-wrap { display: flex; align-items: center; gap: 8px; }
.progress-bar-fill { height: 10px; background: var(--color-primary); border-radius: 5px; transition: width 0.4s; }
.progress-bar-wrap span { font-size: 0.78rem; white-space: nowrap; color: #555; }

/* Row danger highlight */
.row-danger { background: #fff5f5; }

/* Badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.72rem; font-weight: 600; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info    { background: #d1ecf1; color: #0c5460; }

/* Module quick links */
.module-index {
    max-width: 1200px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.quick-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 600;
    min-height: 80px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.quick-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 8px;
}

.tab {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--color-muted);
    font-weight: 500;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}

.tab:hover,
.tab.active {
    background: var(--color-primary);
    color: #fff;
}

/* Form controls */
.form-control,
select.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
}

.form-control:focus,
select.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Alert info */
.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Persistent info panel that looks like .alert-info but is NOT a dismissible
   flash message, so app.js's auto-hide-after-5s logic (which targets .alert)
   doesn't remove it from the page. */
.online-payment-note {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.9rem;
}

/* Form layout helpers */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.crud-form h3 {
    margin-top: 28px;
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: #374151;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
}

.field-error {
    color: #b91c1c;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Searchable select (student picker) */
.searchable-select {
    position: relative;
}

.searchable-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 60;
}

.searchable-select-options[hidden] {
    display: none;
}

.searchable-select-option {
    padding: 9px 12px;
    font-size: 0.9rem;
    cursor: pointer;
}

.searchable-select-option:hover {
    background: #eff6ff;
}

.searchable-select-option[hidden] {
    display: none;
}

.form-control[readonly],
.form-control:disabled {
    background: #f3f4f6;
    color: #374151;
    cursor: not-allowed;
    opacity: 1;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Pagination */
.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination .btn.active {
    cursor: default;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .cards {
        grid-template-columns: 1fr;
    }

    .topbar-left .page-title {
        font-size: 1.05rem;
    }

    .tenant-name {
        display: none;
    }
}

/* Global responsive helpers */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, canvas, video, svg {
    max-width: 100%;
    height: auto;
}

.main, .content {
    min-width: 0;
}

.dash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-row canvas {
    max-width: 100% !important;
    display: block;
}

@media (max-width: 991px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .chart-row {
        grid-template-columns: 1fr;
    }

    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 640px) {
    .dash-cards {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 16px;
    }
}

/* Parent Portal Theme */
body.parent-theme {
    --parent-primary: #2a9d8f;
    --parent-secondary: #1e3a5f;
    --parent-accent: #e9c46a;
}

body.parent-theme .main {
    background: #f4f7fb;
}

body.parent-theme .sidebar {
    background: linear-gradient(180deg, #1e3a5f 0%, #142744 100%);
    border-right: 4px solid #2a9d8f;
}

body.parent-theme .nav-item {
    color: rgba(255,255,255,0.9);
    border-radius: 8px;
    margin: 2px 12px;
    transition: all 0.2s;
}

body.parent-theme .nav-item:hover,
body.parent-theme .nav-item.active {
    background: rgba(42, 157, 143, 0.18);
    color: #fff;
}

body.parent-theme .nav-item.active .nav-icon {
    color: #2a9d8f;
}

body.parent-theme .submenu {
    background: rgba(0,0,0,0.12);
    border-radius: 8px;
    margin: 0 12px 8px;
}

body.parent-theme .submenu-item.active,
body.parent-theme .submenu-item:hover {
    color: #2a9d8f;
    background: rgba(42, 157, 143, 0.1);
}

body.parent-theme .submenu-heading {
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    padding: 10px 14px 4px;
}

body.parent-theme .page-header h2 {
    color: #1e3a5f;
}

body.parent-theme .welcome p {
    color: #64748b;
}

body.parent-theme .cards .stat-card {
    border-radius: 14px;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    border: none;
}

body.parent-theme .cards .stat-card .stat-label {
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

body.parent-theme .cards .stat-card:nth-child(1) { background: linear-gradient(135deg, #1e3a5f, #2c5282); }
body.parent-theme .cards .stat-card:nth-child(2) { background: linear-gradient(135deg, #2a9d8f, #21867a); }
body.parent-theme .cards .stat-card:nth-child(3) { background: linear-gradient(135deg, #e76f51, #d45a3d); }
body.parent-theme .cards .stat-card:nth-child(4) { background: linear-gradient(135deg, #f4a261, #e89548); }
body.parent-theme .cards .stat-card:nth-child(5) { background: linear-gradient(135deg, #6a4c93, #553c7a); }

.ward-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.ward-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border-radius: 14px;
    text-decoration: none;
    color: #1e293b;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: transform 0.15s, box-shadow 0.15s;
}

.ward-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(0,0,0,0.1);
}

.ward-avatar {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a9d8f, #1e3a5f);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3rem;
    overflow: hidden;
}

.ward-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ward-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ward-info strong {
    font-size: 1.05rem;
    color: #1e3a5f;
}

.ward-info small {
    color: #64748b;
    font-size: 0.82rem;
}

.ward-class {
    color: #2a9d8f;
    font-weight: 600;
}

body.parent-theme .chart-card,
body.parent-theme .card {
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

body.parent-theme .section-title {
    color: #1e3a5f;
    font-weight: 600;
    margin-bottom: 14px;
}

body.parent-theme .btn-primary {
    background: linear-gradient(135deg, #2a9d8f, #21867a);
    border: none;
}

body.parent-theme .btn-primary:hover {
    background: linear-gradient(135deg, #21867a, #1a6b61);
}

body.parent-theme .form-group label {
    color: #475569;
    font-weight: 600;
    font-size: 0.88rem;
}

body.parent-theme input:disabled {
    background: #f1f5f9;
    color: #334155;
}
