:root {
    --primary: #0B3D6E;
    --primary-hover: #082C50;
    --primary-light: rgba(11, 61, 110, 0.1);
    --primary-rgb: 11, 61, 110;
    --secondary: #C6A15B;
    --secondary-hover: #b08d49;
    --dark: #0E1B2C;
    --dark-secondary: #16324F;
    --dark-text: #e2e2e2;
    --dark-muted: #8a8a9a;
    --white: #ffffff;
    --light: #f8f9fa;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --text: #212529;
    --sidebar-width: 260px;
    --mobile-nav-height: 70px;
    --mobile-header-height: 56px;
    --font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
    --font: var(--font-family);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --bg: var(--light);
    --line: var(--gray-light);
    --muted: var(--gray);
    --nav-h: var(--mobile-nav-height);
}

* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-family);
    font-weight: 400;
    line-height: 1.5;
    color: var(--text);
    background: var(--light);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.app-wrapper, .app-shell { display: flex; min-height: 100vh; }
.main-content, .workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    margin-left: 0;
    padding-bottom: var(--mobile-nav-height);
}
.page-content, .page { flex: 1; min-width: 0; padding: 1rem; }
@media (min-width: 768px) {
    .page-content, .page { padding: 1.5rem 2rem; }
}
@media (min-width: 992px) {
    .main-content, .workspace { margin-left: var(--sidebar-width); padding-bottom: 0; }
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-secondary) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    color: #fff;
}
.sidebar-header, .sidebar .brand {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-brand, .sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
}
.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    overflow: hidden;
    flex-shrink: 0;
}
.brand-icon img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.2px; }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-nav .nav-link, .sidebar nav > a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: var(--dark-muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    font-weight: 500;
}
.sidebar-nav .nav-link i, .sidebar nav > a i { font-size: 1.2rem; width: 24px; text-align: center; }
.sidebar-nav .nav-link:hover, .sidebar nav > a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.sidebar-nav .nav-link.active, .sidebar nav > a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary);
}
.sidebar-sms-credits { margin: 0 0.75rem 0.75rem; }
.sidebar-sms-credits-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--dark-text);
    text-decoration: none;
}
.sidebar-sms-credits-card:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar-sms-credits.is-low .sidebar-sms-credits-card { background: rgba(255, 193, 7, 0.12); border-color: rgba(255, 193, 7, 0.28); }
.sidebar-sms-credits-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(var(--primary-rgb), 0.35); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-sms-credits-label { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--dark-muted); }
.sidebar-sms-credits-value { font-size: 1.05rem; font-weight: 700; color: #fff; }
.sidebar-sms-credits.is-low .sidebar-sms-credits-value { color: #ffc107; }
.sidebar-footer, .sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 0.75rem; min-width: 0; text-decoration: none; }
.user-avatar, .user-initial {
    width: 40px; height: 40px; background: var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--dark-muted); font-size: 0.75rem; }
.btn-logout {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.1); border: none; border-radius: var(--radius);
    color: var(--dark-muted); text-decoration: none;
}
.btn-logout:hover { background: var(--danger); color: #fff; }

.mobile-header, .mobile-top {
    position: sticky; top: 0; height: var(--mobile-header-height);
    background: #fff; border-bottom: 1px solid var(--gray-light);
    display: none; align-items: center; justify-content: space-between;
    padding: 0 1rem; z-index: 100; color: var(--dark);
}
.mobile-header-left { display: flex; align-items: center; gap: 0.5rem; }
.hamburger-btn, .mobile-top .icon-btn {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--dark); font-size: 1.5rem; border-radius: var(--radius); text-decoration: none;
}
.hamburger-btn:hover { background: var(--gray-light); }
.brand-logo-img { max-height: 28px; max-width: 80px; object-fit: contain; }
.mobile-brand, .mobile-top > a {
    display: flex; align-items: center; gap: 0.5rem;
    text-decoration: none; color: var(--primary); font-weight: 700; font-size: 1.05rem;
}
.mobile-user-btn {
    width: 36px; height: 36px; background: var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; text-decoration: none; color: #fff;
}

.mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--mobile-nav-height);
    background: #fff; border-top: 1px solid var(--gray-light);
    display: none; align-items: center; justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom); z-index: 1000;
}
.mobile-nav-item, .mobile-nav > a, .mobile-nav > button {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.2rem; padding: 0.5rem; color: var(--gray); text-decoration: none;
    font-size: 0.65rem; font-weight: 600; flex: 1; background: none; border: 0;
}
.mobile-nav-item i, .mobile-nav > a i, .mobile-nav > button i { font-size: 1.25rem; }
.mobile-nav-item.active, .mobile-nav > a.active { color: var(--primary); }
.mobile-nav-add {
    width: 52px; height: 52px; background: var(--primary); border-radius: 50%;
    color: #fff !important; margin-top: -20px; flex: none;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}
.mobile-nav-add i { font-size: 1.5rem; }

.offcanvas-header-dark { background: linear-gradient(180deg, var(--dark) 0%, var(--dark-secondary) 100%); }
.offcanvas-nav-link, .more-menu a {
    display: flex; align-items: center; gap: 0.875rem;
    padding: 0.875rem 1.25rem; color: var(--dark); text-decoration: none; font-weight: 500;
    border-left: 3px solid transparent; border-bottom: 0;
}
.offcanvas-nav-link:hover, .more-menu a:hover { background: var(--primary-light); color: var(--primary); }
.offcanvas-nav-link.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--secondary); }
.offcanvas-nav-link i, .more-menu a i { font-size: 1.2rem; width: 24px; text-align: center; }
.offcanvas-nav-divider { height: 1px; background: var(--gray-light); margin: 0.5rem 1.25rem; }
.offcanvas-user-footer {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1rem 1.25rem; border-top: 1px solid var(--gray-light); background: var(--light); margin-top: auto;
}
.offcanvas-user-footer .user-name { color: var(--dark); }
.offcanvas-body-nav { display: flex; flex-direction: column; }

.page-header, .page-head {
    display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem;
}
.page-header h1, .page-head h1, .page-title {
    font-size: 1.5rem; font-weight: 700; color: var(--dark); margin: 0; letter-spacing: -0.02em;
}
.page-head p, .page-header p { margin: 0.25rem 0 0; color: var(--gray); }
@media (min-width: 576px) {
    .page-header, .page-head { flex-direction: row; align-items: center; justify-content: space-between; }
}

.card, .panel {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: #fff;
}
.panel { padding: 1.15rem 1.25rem; }
.card { padding: 0; overflow: hidden; }
.panel.p-0, .card .card-body.p-0 { padding: 0; }
.card-header { background: transparent; border-bottom: 1px solid var(--gray-light); font-weight: 600; }
.panel > .h6, .panel > h2.h6 {
    border-bottom: 1px solid var(--gray-light);
    padding-bottom: 0.75rem;
    margin-bottom: 0.9rem;
    font-weight: 600;
}
.panel > .h6, .panel > h2.h6 { font-size: 1rem; }

.stat-card { position: relative; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }
.stat-grid .stat-card {
    position: relative;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.15rem;
    text-decoration: none;
    color: inherit;
    display: block;
    border: none;
    overflow: hidden;
}
.stat-grid .stat-card span, .stat-label { color: var(--gray); font-size: 0.875rem; font-weight: 500; display: block; }
.stat-grid .stat-card strong, .stat-value { font-size: 1.15rem; font-weight: 650; color: var(--dark); display: block; margin-top: 0.15rem; }
.stat-card .stat-icon {
    position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
    width: 52px; height: 52px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.stat-card .card-body { padding-right: 4.2rem; }
.bg-primary-subtle { background: var(--primary-light) !important; color: var(--primary) !important; }
.bg-success-subtle { background: rgba(40, 167, 69, 0.15) !important; color: var(--success) !important; }
.bg-warning-subtle { background: rgba(255, 193, 7, 0.22) !important; color: #b58a00 !important; }
.bg-info-subtle { background: rgba(23, 162, 184, 0.15) !important; color: var(--info) !important; }
.bg-danger-subtle { background: rgba(220, 53, 69, 0.12) !important; color: var(--danger) !important; }

.settings-card { transition: transform 0.2s ease, box-shadow 0.2s ease; color: inherit; }
.settings-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); color: inherit; }
.settings-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 60px; height: 60px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 1.4rem;
}

.btn { font-weight: 600; border-radius: var(--radius); min-height: 42px; }
.btn-sm { min-height: 34px; padding: 0.35rem 0.75rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); background: #fff; }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-secondary, .btn-gold { background: var(--secondary); border-color: var(--secondary); color: var(--dark); }
.form-label { font-weight: 600; color: var(--dark); font-size: 0.875rem; }
.form-control, .form-select {
    min-height: 44px; border-radius: var(--radius); border-color: var(--gray-light); background: #fff;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control-sm, .form-select-sm { min-height: 36px; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.filters {
    display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end;
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    padding: 0.85rem 1rem; margin-bottom: 1rem;
}
.filters .form-control, .filters .form-select { width: auto; min-width: 150px; }
.date-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.date-chip {
    border: 1px solid var(--gray-light); background: #fff; color: var(--text);
    text-decoration: none; border-radius: var(--radius); padding: 0.35rem 0.7rem; font-size: 0.84rem; font-weight: 600;
}
.date-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.table { margin-bottom: 0; font-size: 0.92rem; }
.table th {
    white-space: nowrap; font-size: 0.75rem; letter-spacing: 0.03em; text-transform: uppercase;
    color: var(--gray); font-weight: 700; background: var(--light); border-bottom-color: var(--gray-light);
}
.table td, .table th { padding: 0.8rem 0.9rem; vertical-align: middle; }
.table tbody tr:hover { background: #fafbfc; }
.sort-link { color: inherit; text-decoration: none; }
.desktop-table { overflow-x: auto; }
.record-cards { display: none; }
.record-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 0.9rem; margin-bottom: 0.6rem; }
.record-card summary { cursor: pointer; font-weight: 650; }
.badge { font-weight: 600; }

.empty-state { text-align: center; padding: 2.5rem 1rem; background: transparent; border: 0; color: var(--gray); }
.empty-state-icon, .empty-state > i { font-size: 2.6rem; color: #ced4da; margin-bottom: 0.6rem; display: block; }
.empty-state-text, .empty-state p { margin: 0; color: var(--gray); }
.panel > .empty-state { padding: 1.5rem 0.5rem; }

.role-link {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.85rem 1rem; color: var(--dark); text-decoration: none;
    border-bottom: 1px solid var(--gray-light);
}
.role-link:last-child { border-bottom: 0; }
.role-link small { display: block; color: var(--gray); font-weight: 400; margin-top: 0.15rem; }
.role-link.active, .role-link:hover { background: var(--primary-light); color: var(--primary); }
.permission-panel {
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    background: #fff;
}
.permission-panel-title {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    font-weight: 700; margin-bottom: 0.7rem;
}
.permission-panel .form-check { margin-bottom: 0.4rem; }

.impersonation-banner {
    background: #fff8e8; border: 1px solid #f3e0b5; border-radius: var(--radius);
    padding: 0.75rem 0.9rem; margin-bottom: 1rem;
}
.medical-alert { background: #fff8f3; border: 1px solid #f3d7c4; color: #7a2e0e; border-radius: var(--radius); padding: 0.75rem 0.9rem; margin-bottom: 1rem; }
.password-wrap { position: relative; }
.password-wrap .toggle-password { position: absolute; right: 0.15rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; }
.icon-btn {
    width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: inherit; text-decoration: none; border-radius: var(--radius);
}
.bulk-bar {
    position: sticky; bottom: 1rem; z-index: 12;
    display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end;
    box-shadow: var(--shadow);
}
.charge-row { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; padding: 0.45rem 0; border-bottom: 1px solid var(--gray-light); }

.nav-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 35%;
    background: var(--secondary); z-index: 2000; animation: navslide 1s ease infinite;
}
.nav-progress[hidden] { display: none; }
@keyframes navslide { 0% { transform: translateX(-120%); } 100% { transform: translateX(280%); } }
.spinner {
    width: 0.9rem; height: 0.9rem; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 0.35rem; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-stack {
    position: fixed; top: 1rem; right: 1rem; z-index: 2100;
    display: flex; flex-direction: column; gap: 0.5rem; width: min(360px, calc(100vw - 2rem));
}
.toast-item {
    display: flex; gap: 0.65rem; align-items: flex-start; background: #fff;
    border-radius: var(--radius); padding: 0.85rem 0.9rem; box-shadow: var(--shadow-lg);
    border-left: 3px solid var(--primary);
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: #b58a00; }
.toast-item span { flex: 1; }
.toast-item button { border: 0; background: transparent; color: var(--gray); padding: 0; }

.dialog {
    position: fixed; inset: 0; background: rgba(14, 27, 44, 0.45); z-index: 2200;
    display: grid; place-items: center; padding: 1rem;
}
.dialog[hidden] { display: none; }
.dialog-card { width: min(440px, 100%); background: #fff; border-radius: var(--radius-lg); padding: 1.35rem; box-shadow: var(--shadow-lg); }
.dialog-card h2 { font-size: 1.1rem; margin: 0 0 0.35rem; }
.dialog-card p { color: var(--gray); margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.progress-track { height: 8px; background: var(--gray-light); border-radius: 99px; overflow: hidden; margin: 0.9rem 0 0.45rem; }
.progress-track > div { height: 100%; width: 0; background: var(--primary); transition: width 0.2s ease; }
.progress-percent { font-variant-numeric: tabular-nums; }

.form-meter { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.9rem; }
.form-meter-track { flex: 1; height: 6px; background: var(--gray-light); border-radius: 99px; overflow: hidden; }
.form-meter-track > div { height: 100%; width: 0; background: var(--secondary); }
.form-meter span { font-size: 0.78rem; color: var(--gray); font-weight: 600; white-space: nowrap; }
.date-field { position: relative; }
.date-field .date-display { background: #fff; padding-right: 2.4rem; }
.date-field .date-native { position: absolute; left: 0; right: 0; bottom: 0; height: 44px; opacity: 0; cursor: pointer; width: 100%; }
.date-field-icon { position: absolute; right: 0.8rem; bottom: 0.7rem; color: var(--gray); pointer-events: none; }
.student-picker { position: relative; }
.picker-results {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
    background: #fff; border: 1px solid var(--gray-light); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto;
}
.picker-option, .picker-empty { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 0.7rem 0.85rem; }
.picker-option:hover { background: var(--primary-light); }
.picker-empty { color: var(--gray); }

.login-page, .auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-secondary) 100%);
    padding: 1rem;
}
.login-card, .auth-card {
    width: 100%; max-width: 420px; background: #fff; border-radius: var(--radius-xl);
    overflow: hidden; box-shadow: var(--shadow-lg); border: 0; padding: 0;
}
.login-header { background: var(--primary); padding: 2rem; text-align: center; }
.login-logo {
    width: 60px; height: 60px; background: #fff; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem;
    font-size: 1.7rem; color: var(--primary);
}
.login-title { color: #fff; font-size: 1.4rem; font-weight: 700; margin: 0 0 0.25rem; }
.login-subtitle { color: rgba(255, 255, 255, 0.85); margin: 0; font-size: 0.9rem; }
.login-body, .auth-card { padding: 1.6rem 1.7rem 1.7rem; }
.login-card .login-body { padding: 1.6rem 1.7rem 1.7rem; }
.gold-rule { height: 3px; width: 48px; background: var(--secondary); border-radius: 3px; margin: 0.2rem 0 1rem; }

.receipt { width: min(720px, 100%); margin: 0 auto; background: #fff; padding: 1.25rem; }
.receipt-compact { max-width: 320px; font-size: 0.85rem; }
.qr-box { width: 140px; height: 140px; }

@media (max-width: 991.98px) {
    .mobile-header, .mobile-top { display: flex; }
    .mobile-nav { display: flex; }
    .desktop-table { display: none; }
    .record-cards { display: block; }
    .toast-stack { top: auto; bottom: calc(var(--mobile-nav-height) + 0.6rem); left: 0.7rem; right: 0.7rem; width: auto; }
    .bulk-bar { bottom: calc(var(--mobile-nav-height) + 0.45rem); }
}
@media print {
    .sidebar, .mobile-header, .mobile-top, .mobile-nav, .no-print, .toast-stack, .dialog, .nav-progress { display: none !important; }
    .main-content, .workspace { margin: 0; padding: 0; }
    body { background: #fff; }
}
