:root {
    --cba-navy: #0f4c81;
    --cba-navy-dark: #0b3559;
    --cba-navy-light: #1c6fb0;
    --cba-accent: #f59e0b;
    --cba-sidebar: #0d2b45;
    --cba-bg: #f5f7fb;
    --cba-border: #e4e9f2;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body { background: var(--cba-bg); color: #1f2937; font-size: .925rem; }
a { text-decoration: none; }

/* ---------------------------------------------------------------- Branding */
.brand-badge,
.brand-badge-sm {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--cba-navy), var(--cba-navy-light));
    color: #fff; border-radius: 14px;
}
.brand-badge { width: 64px; height: 64px; font-size: 1.8rem; }
.brand-badge-sm { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 10px; }

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

.app-sidebar {
    width: 258px; flex: 0 0 258px; background: var(--cba-sidebar); color: #cbd5e1;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .55rem; }
.sidebar-group { font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; color: #64748b; padding: .85rem .6rem .35rem; font-weight: 700; }
.sidebar-link {
    display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 9px;
    color: #cbd5e1; font-size: .855rem; transition: background .15s ease, color .15s ease;
}
.sidebar-link i { width: 1.05rem; font-size: .95rem; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active { background: linear-gradient(90deg, var(--cba-navy-light), rgba(28,111,176,.35)); color: #fff; font-weight: 600; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding: .6rem .55rem .9rem; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem;
    padding: .7rem 1.15rem; background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--cba-border);
}
.app-content { padding: 1.15rem; flex: 1; }
.app-footer {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: .8rem 1.15rem; border-top: 1px solid var(--cba-border); color: #64748b; font-size: .78rem;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 1045; transform: translateX(-100%);
        transition: transform .2s ease; height: 100vh;
    }
    .app-sidebar.show { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1040; }
    .app-content { padding: .9rem; }
}

/* --------------------------------------------------------------- Components */
.card { border: 1px solid var(--cba-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--cba-border); font-weight: 600; }
.stat-card { border-radius: 12px; border: 1px solid var(--cba-border); background: #fff; padding: 1rem; height: 100%; }
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; }

.avatar-sm {
    width: 32px; height: 32px; border-radius: 50%; background: var(--cba-navy); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 600;
}
.avatar-lg {
    width: 64px; height: 64px; border-radius: 50%; background: var(--cba-navy); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; font-weight: 600;
}

.table > :not(caption) > * > * { padding: .6rem .65rem; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: #475569; font-weight: 700; background: #f8fafc; }
.table-hover > tbody > tr:hover > * { background: #f8fbff; }

.btn-primary { --bs-btn-bg: var(--cba-navy); --bs-btn-border-color: var(--cba-navy); --bs-btn-hover-bg: var(--cba-navy-dark); --bs-btn-hover-border-color: var(--cba-navy-dark); }
.btn-outline-primary { --bs-btn-color: var(--cba-navy); --bs-btn-border-color: var(--cba-navy); --bs-btn-hover-bg: var(--cba-navy); --bs-btn-hover-border-color: var(--cba-navy); }
.text-primary { color: var(--cba-navy) !important; }
.bg-primary-soft { background: rgba(15,76,129,.08); }
.bg-success-soft { background: rgba(22,163,74,.1); }
.bg-warning-soft { background: rgba(245,158,11,.14); }
.bg-danger-soft { background: rgba(220,38,38,.1); }
.bg-info-soft { background: rgba(14,165,233,.12); }

.form-label { font-weight: 600; font-size: .82rem; color: #334155; margin-bottom: .3rem; }
.form-text { font-size: .78rem; }
.required::after { content: " *"; color: #dc2626; }

.select2-container--bootstrap-5 .select2-selection { min-height: 38px; }
.note-editor.note-frame { border-radius: 10px; border-color: var(--cba-border); }

.nav-tabs .nav-link { color: #475569; font-weight: 600; font-size: .88rem; }
.nav-tabs .nav-link.active { color: var(--cba-navy); }

.mini-chart { position: relative; height: 260px; }
.mini-chart-sm { position: relative; height: 200px; }
.hero-card {
    background: linear-gradient(135deg, var(--cba-navy) 0%, #1c6fb0 65%, #2c8ac9 100%);
    color: #fff; border-radius: 14px; padding: 1.5rem;
}
.hero-card .display-6 { font-weight: 700; }

.question-preview { border: 1px dashed var(--cba-border); border-radius: 10px; padding: 1rem; background: #fff; }
.qb-rich img { max-width: 100%; height: auto; }
.qb-rich table { width: 100%; border-collapse: collapse; }
.qb-rich table td, .qb-rich table th { border: 1px solid #cbd5e1; padding: .35rem .5rem; }
.katex { font-size: 1.03em; }

.stepper { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stepper .step { display: flex; align-items: center; gap: .45rem; font-size: .82rem; color: #64748b; }
.stepper .step .dot { width: 24px; height: 24px; border-radius: 50%; background: #e2e8f0; color: #475569; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; }
.stepper .step.active { color: var(--cba-navy); font-weight: 600; }
.stepper .step.active .dot { background: var(--cba-navy); color: #fff; }
.stepper .step.done .dot { background: #16a34a; color: #fff; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: #64748b; }
.empty-state i { font-size: 2.2rem; color: #cbd5e1; }

.notification-menu .dropdown-item { white-space: normal; }
.notif-unread { background: rgba(15,76,129,.05); }

.guest-body { background: linear-gradient(135deg, #0d2b45 0%, #164e77 55%, #1c6fb0 100%); min-height: 100vh; }
.guest-body .card { border-radius: 16px; }

@media print {
    .app-sidebar, .app-topbar, .app-footer, .print-toolbar, .no-print { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
}
