/* ═══════════════════════════════════════════════════
   OMOA Pay — Design System v2
   Primary: #6B4FBB · Modern glassmorphism
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Avenir Next LT — fallback to Inter if not installed locally */
@font-face { font-family: 'Avenir Next LT'; src: local('Avenir Next LT Pro'), local('AvenirNextLTPro-Regular'), local('Avenir Next'); font-weight: 400; }
@font-face { font-family: 'Avenir Next LT'; src: local('Avenir Next LT Pro Medium'), local('AvenirNextLTPro-Medium'); font-weight: 500; }
@font-face { font-family: 'Avenir Next LT'; src: local('Avenir Next LT Pro Demi'), local('AvenirNextLTPro-Demi'), local('Avenir Next Demi Bold'); font-weight: 600; }
@font-face { font-family: 'Avenir Next LT'; src: local('Avenir Next LT Pro Bold'), local('AvenirNextLTPro-Bold'), local('Avenir Next Bold'); font-weight: 700; }
@font-face { font-family: 'Avenir Next LT'; src: local('Avenir Next LT Pro Heavy'), local('AvenirNextLTPro-Heavy'); font-weight: 800; }

:root, [data-theme="light"] {
    --primary: #6B4FBB;
    --primary-light: #8B6FDB;
    --primary-dark: #4B2F9B;
    --primary-50: #f3f0ff;
    --primary-100: #e8e0ff;
    --primary-200: #d4c8ff;
    --accent: #B99FFF;
    --surface: #f8f9fc;
    --surface-card: #ffffff;
    --text: #1a1d2e;
    --text-secondary: #6b7194;
    --text-muted: #9da3be;
    --border: #e8eaf0;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(107,79,187,0.06);
    --shadow: 0 4px 12px rgba(107,79,187,0.08);
    --shadow-lg: 0 8px 32px rgba(107,79,187,0.12);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══ DARK THEME ═══ */
/* ═══ DARK THEME — Exhaustive overrides ═══ */
[data-theme="dark"] {
    --surface: #0f1117;
    --surface-card: #1a1d2e;
    --text: #e2e4eb;
    --text-secondary: #9da3be;
    --text-muted: #6b7194;
    --border: #2a2d3e;
    --primary-50: rgba(107,79,187,0.12);
    --primary-100: rgba(107,79,187,0.22);
    --primary-200: rgba(107,79,187,0.35);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    color-scheme: dark;
}

/* Body & surfaces */
[data-theme="dark"] body { background: var(--surface); color: var(--text); }

/* Topbar */
[data-theme="dark"] .topbar { background: var(--surface-card); border-color: var(--border); }
[data-theme="dark"] .topbar-link { color: var(--text-secondary); border-color: var(--border); }
[data-theme="dark"] .topbar-link:hover { color: var(--primary-light); border-color: var(--primary-light); }
[data-theme="dark"] .topbar-time { color: var(--text-muted); }
[data-theme="dark"] .status-pill { background: rgba(34,197,94,0.12); }

/* Cards */
[data-theme="dark"] .card { background: var(--surface-card); border-color: var(--border); }
[data-theme="dark"] .card.border-0 { border-color: var(--border); }
[data-theme="dark"] .card-header { border-color: var(--border); }
[data-theme="dark"] .card-header.bg-white { background: var(--surface-card) !important; }
[data-theme="dark"] .card-footer { background: var(--surface); border-color: var(--border); }

/* Tables — THE KEY FIX */
[data-theme="dark"] .table { color: var(--text); }
[data-theme="dark"] .table th { background: #2d2355; color: rgba(255,255,255,0.85); border-color: var(--border); }
[data-theme="dark"] .table td { color: var(--text); border-color: var(--border); }
[data-theme="dark"] .table-hover > tbody > tr:hover { background: var(--primary-50); color: var(--text); }
[data-theme="dark"] .table-hover > tbody > tr:hover > td { color: var(--text); }
[data-theme="dark"] .table-light { background: var(--surface) !important; }
[data-theme="dark"] .table > :not(caption) > * > * { color: var(--text); background-color: transparent; border-color: var(--border); }
[data-theme="dark"] .table-sm > :not(caption) > * > * { color: var(--text); }
[data-theme="dark"] thead { color: var(--text-muted); }
[data-theme="dark"] tbody { color: var(--text); }
[data-theme="dark"] td.fw-semibold, [data-theme="dark"] td.fw-bold { color: var(--text); }
[data-theme="dark"] td.small { color: var(--text-secondary); }
[data-theme="dark"] .font-monospace { color: var(--text-secondary); }

/* KPI Cards */
[data-theme="dark"] .kpi-card { background: var(--surface-card); border-color: var(--border); }
[data-theme="dark"] .kpi-card::before { background: radial-gradient(circle at top right, var(--primary-50) 0%, transparent 70%); }
[data-theme="dark"] .kpi-label { color: var(--text-muted); }

/* Filters & Forms */
[data-theme="dark"] .filter-panel { background: var(--surface-card); border-color: var(--border); }
[data-theme="dark"] .filter-label { color: var(--text-muted); }
[data-theme="dark"] .form-select, [data-theme="dark"] select,
[data-theme="dark"] .tenant-select,
[data-theme="dark"] .form-control, [data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="search"], [data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="email"], [data-theme="dark"] input[type="password"] {
    background: var(--surface); border-color: var(--border); color: var(--text);
}
[data-theme="dark"] .form-select:focus, [data-theme="dark"] select:focus,
[data-theme="dark"] .form-control:focus, [data-theme="dark"] input:focus {
    border-color: var(--primary-light); box-shadow: 0 0 0 3px var(--primary-100);
}
[data-theme="dark"] .form-select option { background: var(--surface-card); color: var(--text); }
[data-theme="dark"] select option { background: var(--surface-card); color: var(--text); }
[data-theme="dark"] .btn-filter { background: var(--primary); }
[data-theme="dark"] .btn-filter-reset { background: var(--surface); border-color: var(--border); color: var(--text-secondary); }

/* Pager */
[data-theme="dark"] .pager { background: var(--surface-card); border-color: var(--border); }
[data-theme="dark"] .pager-info { color: var(--text-muted); }
[data-theme="dark"] .pager-btn { background: var(--surface); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .pager-btn:hover:not(:disabled) { background: var(--primary-50); color: var(--primary-light); border-color: var(--primary-light); }
[data-theme="dark"] .pager-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
[data-theme="dark"] .pager-size { background: var(--surface); border-color: var(--border); color: var(--text-secondary); }

/* Tabs */
[data-theme="dark"] .nav-tabs-modern { border-color: var(--border); }
[data-theme="dark"] .tab-btn { color: var(--text-muted); }
[data-theme="dark"] .tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }
[data-theme="dark"] .tab-count { background: var(--primary-100); color: var(--primary-light); }
[data-theme="dark"] .tab-btn.active .tab-count { background: var(--primary); color: white; }

/* Drawer */
[data-theme="dark"] .drawer { background: var(--surface-card); }
[data-theme="dark"] .drawer-overlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] .drawer-header { border-color: var(--border); }
[data-theme="dark"] .drawer-title { color: var(--text); }
[data-theme="dark"] .drawer-subtitle { color: var(--text-muted); }
[data-theme="dark"] .drawer-footer { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .drawer-close { background: var(--surface); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .detail-label { color: var(--text-muted); }
[data-theme="dark"] .detail-value { color: var(--text); }
[data-theme="dark"] .detail-section { color: var(--primary-light); border-color: var(--primary-100); }
[data-theme="dark"] .scenario-card { border-color: var(--border); background: var(--surface); }
[data-theme="dark"] .scenario-card:hover { background: var(--primary-50); border-color: var(--primary-light); }
[data-theme="dark"] .scenario-card.selected { background: var(--primary-50); border-color: var(--primary-light); }
[data-theme="dark"] .scenario-title { color: var(--text); }
[data-theme="dark"] .scenario-desc { color: var(--text-muted); }
[data-theme="dark"] .timeline::before { background: var(--border); }
[data-theme="dark"] .timeline-text { color: var(--text); }
[data-theme="dark"] .timeline-time { color: var(--text-muted); }

/* Buttons */
[data-theme="dark"] .btn-action { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .btn-action:hover { background: var(--primary-50); border-color: var(--primary-light); color: var(--primary-light); }
[data-theme="dark"] .btn-view { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .btn-view:hover { background: var(--primary-50); border-color: var(--primary-light); color: var(--primary-light); }
[data-theme="dark"] .btn-outline-primary { color: var(--primary-light); border-color: var(--border); }
[data-theme="dark"] .btn-outline-secondary { border-color: var(--border); color: var(--text-secondary); }

/* Alerts */
[data-theme="dark"] .alert-info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-light); }
[data-theme="dark"] .alert-secondary { background: var(--surface); border-color: var(--border); color: var(--text-secondary); }

/* Reserve gauge */
[data-theme="dark"] .reserve-gauge { background: var(--border); }

/* Badges — keep their colors, they work on both themes */
[data-theme="dark"] .badge.bg-dark { background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border); }

/* Login */
[data-theme="dark"] .login-right { background: var(--surface); }
[data-theme="dark"] .login-card h2 { color: var(--text); }
[data-theme="dark"] .login-card p { color: var(--text-muted); }
[data-theme="dark"] .login-hint { background: var(--primary-50); color: var(--text-secondary); }
[data-theme="dark"] .login-hint code { background: var(--surface-card); color: var(--primary-light); }
[data-theme="dark"] .alert-error { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: #fca5a5; }

/* Misc */
[data-theme="dark"] .empty-state { color: var(--text-muted); }
[data-theme="dark"] code { background: var(--primary-50); color: var(--primary-light); }
[data-theme="dark"] hr { border-color: var(--border); }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] p.text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] h1 { color: var(--text); }
[data-theme="dark"] h2 { color: var(--text); }
[data-theme="dark"] .text-danger { color: #fca5a5 !important; }
[data-theme="dark"] .text-success { color: #86efac !important; }
[data-theme="dark"] .fw-semibold { color: var(--text); }

/* Theme toggle button */
.theme-toggle {
    width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px;
    background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition); font-size: 1rem;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Avenir Next LT', 'Inter', -apple-system, sans-serif; background: var(--surface); color: var(--text); -webkit-font-smoothing: antialiased; }

/* ═══ LOGIN ═══ */
.login-container {
    display: flex; min-height: 100vh;
}
.login-left {
    flex: 1; background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    color: white; display: flex; flex-direction: column; justify-content: center; padding: 4rem;
    position: relative; overflow: hidden;
}
.login-left::before {
    content: ''; position: absolute; top: -50%; right: -30%; width: 80%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
}
.login-brand { position: relative; z-index: 1; }
.brand-icon { margin-bottom: 1.5rem; opacity: 0.9; }
.login-brand h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.02em; }
.tagline { font-size: 1.1rem; opacity: 0.7; margin-top: 0.25rem; font-weight: 300; }
.login-features { margin-top: 3rem; position: relative; z-index: 1; }
.feature { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; font-size: 0.95rem; opacity: 0.85; }
.feature i { font-size: 1.1rem; opacity: 0.7; }
.login-footer-left { position: relative; z-index: 1; margin-top: 3rem; font-size: 0.8rem; opacity: 0.5; display: flex; align-items: center; gap: 0.75rem; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.login-right { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--surface); }
.login-card { width: 100%; max-width: 420px; padding: 2rem; }
.login-header h2 { font-size: 1.75rem; font-weight: 700; color: var(--text); margin-bottom: 0.25rem; }
.login-header p { color: var(--text-muted); margin-bottom: 2rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.04em; }
.input-wrapper { position: relative; }
.input-wrapper i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1rem; }
.input-wrapper input {
    width: 100%; padding: 0.8rem 0.8rem 0.8rem 2.75rem; border: 2px solid var(--border); border-radius: var(--radius);
    font-size: 0.95rem; font-family: inherit; transition: var(--transition); background: white;
}
.input-wrapper input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-100); }
.btn-login {
    width: 100%; padding: 0.85rem; border: none; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white; font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    margin-top: 0.5rem;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: 0.88rem; display: flex; align-items: center; gap: 0.5rem; }
.login-hint { margin-top: 1.5rem; padding: 0.75rem; background: var(--primary-50); border-radius: var(--radius); font-size: 0.8rem; color: var(--text-secondary); text-align: center; }
.login-hint code { background: white; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.78rem; font-weight: 600; color: var(--primary); }

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

/* ═══ SIDEBAR ═══ */
.sidebar {
    width: 260px; background: linear-gradient(180deg, #1e1540 0%, #2d1f6b 40%, var(--primary-dark) 100%);
    color: white; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}
.sidebar-brand { display: flex; align-items: center; gap: 0.75rem; padding: 1.25rem 1.25rem; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.25rem; background: linear-gradient(135deg, var(--accent), var(--primary-light));
    color: white; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.7rem; opacity: 0.5; font-weight: 400; }
.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 0.5rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15); border-radius: 10px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.sidebar-nav::-webkit-scrollbar-button { display: none; }
.nav-section { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em; opacity: 0.35; padding: 1rem 0.75rem 0.4rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.75rem; border-radius: 8px;
    color: rgba(255,255,255,0.65); text-decoration: none; font-size: 0.87rem; font-weight: 500;
    transition: var(--transition); margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: rgba(255,255,255,0.12); color: white; font-weight: 600; }
.nav-item i { font-size: 1rem; width: 20px; text-align: center; opacity: 0.7; }
.nav-item.active i { opacity: 1; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: space-between; }
.user-card { display: flex; align-items: center; gap: 0.6rem; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--primary-light));
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}
.user-name { font-size: 0.82rem; font-weight: 600; }
.user-role { font-size: 0.65rem; opacity: 0.45; }
.btn-logout { color: rgba(255,255,255,0.4); font-size: 1.1rem; text-decoration: none; padding: 0.4rem; border-radius: 6px; transition: var(--transition); }
.btn-logout:hover { color: white; background: rgba(255,255,255,0.1); }

/* ═══ MAIN AREA ═══ */
.main-area { flex: 1; margin-left: 260px; display: flex; flex-direction: column; }
.topbar {
    height: 56px; background: white; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem;
    position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.status-pill {
    display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--success);
    font-weight: 500; background: #f0fdf4; padding: 0.3rem 0.75rem; border-radius: 20px;
}
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-link { font-size: 0.82rem; color: var(--text-secondary); text-decoration: none; padding: 0.3rem 0.7rem; border-radius: 6px; border: 1px solid var(--border); transition: var(--transition); }
.topbar-link:hover { border-color: var(--primary); color: var(--primary); }
.topbar-time { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.content { padding: 1.5rem; flex: 1; }

/* ═══ PAGE TITLES ═══ */
h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; margin-bottom: 0.1rem; outline: none; }
h1 i { color: var(--primary); }
h2 { font-size: 0.95rem; font-weight: 600; color: var(--text); }

/* ═══ KPI CARDS ═══ */
.kpi-card {
    background: white; border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.25rem !important; transition: var(--transition); position: relative; overflow: hidden;
}
.kpi-card::before {
    content: ''; position: absolute; top: 0; right: 0; width: 80px; height: 80px;
    background: radial-gradient(circle at top right, var(--primary-50) 0%, transparent 70%);
    border-radius: 0 var(--radius-lg) 0 0;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary-200); }
.kpi-card .text-muted { font-size: 0.75rem !important; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted) !important; }
.kpi-card .fs-3 { font-size: 1.75rem !important; font-weight: 800; letter-spacing: -0.02em; position: relative; }

/* ═══ CARDS ═══ */
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card.border-0 { border: 1px solid var(--border); }
.card.shadow-sm { box-shadow: var(--shadow-sm); }
.card-header { padding: 1rem 1.25rem; font-weight: 600; }
.card-header.bg-white { background: white !important; border-bottom: 1px solid var(--border); }

/* ═══ TABLES ═══ */
.table { margin: 0; border-collapse: separate; border-spacing: 0; }
.table th {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em;
    color: white; font-weight: 600; padding: 0.7rem 1rem;
    background: #7c65c0;
    border-bottom: none; position: sticky; top: 0; z-index: 2;
}
.table th:first-child { border-radius: 0; }
.table th:last-child { border-radius: 0; }
.table td {
    padding: 0.65rem 1rem; vertical-align: middle; font-size: 0.85rem; color: var(--text);
    border-bottom: 1px solid rgba(107,79,187,0.06);
}
.table tbody tr:nth-child(even) { background: rgba(107,79,187,0.02); }
.table-hover tbody tr:hover { background: rgba(107,79,187,0.07); }
.table-light { background: var(--surface) !important; }
.table-sm td { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
.table-sm th { padding: 0.5rem 0.75rem; }

/* ═══ BADGES ═══ */
.badge {
    font-weight: 600; font-size: 0.68rem; padding: 0.3em 0.65em; border-radius: 6px;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-approved, .badge-active, .badge-validated, .badge-clean { background: #dcfce7; color: #166534; }
.badge-declined, .badge-critical, .badge-failed { background: #fef2f2; color: #b91c1c; }
.badge-pending, .badge-medium, .badge-suspended, .badge-pendingvalidation, .badge-pendingapproval { background: #fef3c7; color: #92400e; }
.badge-processing, .badge-instructed, .badge-underanalysis { background: #dbeafe; color: #1e40af; }
.badge-disputed, .badge-high, .badge-awaitingpartner { background: #fff7ed; color: #c2410c; }
.badge-settled, .badge-executed, .badge-reconciled { background: #ede9fe; color: #5b21b6; }
.badge-resolved { background: #d1fae5; color: #065f46; }
.badge-closed { background: #e5e7eb; color: #374151; }
.badge-reversed { background: #fae8ff; color: #86198f; }
.badge-escalated { background: #fef2f2; color: #991b1b; }
.badge-open { background: #fee2e2; color: #991b1b; }
.badge-draft { background: #f3f4f6; color: #4b5563; }
.badge-mno { background: var(--primary-100); color: var(--primary-dark); }
.badge-fintech { background: #cffafe; color: #0e7490; }
.badge-low { background: #f3f4f6; color: #6b7280; }
.badge-locked { background: #fef2f2; color: #b91c1c; }
/* Override Bootstrap badges that cause white-on-white */
.badge.bg-primary { background: var(--primary-100) !important; color: var(--primary-dark) !important; }
.badge.bg-info { background: #cffafe !important; color: #0e7490 !important; }
.badge.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.badge.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.badge.bg-danger { background: #fef2f2 !important; color: #b91c1c !important; }
.badge.bg-secondary { background: #f3f4f6 !important; color: #4b5563 !important; }
.badge.bg-dark { background: #1f2937 !important; color: #f9fafb !important; }
.badge-reversed, .badge-escalated { background: #fae8ff; color: #86198f; }
.badge-draft, .badge-low, .badge-open { background: #f3f4f6; color: #4b5563; }
.badge-mno { background: var(--primary-100); color: var(--primary-dark); }
.badge-fintech { background: #cffafe; color: #0e7490; }

/* ═══ RESERVE GAUGE ═══ */
.reserve-gauge { height: 8px; border-radius: 4px; background: #f1f3f5; overflow: hidden; }
.reserve-gauge-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }

/* ═══ HELP GUIDE ═══ */
.help-account-tree { font-size: 0.84rem; }
.help-group { margin-bottom: 1rem; }
.help-group-title { font-weight: 700; font-size: 0.82rem; color: var(--primary); margin-bottom: 0.4rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.help-account { padding: 0.2rem 0 0.2rem 0.5rem; font-size: 0.82rem; color: var(--text); }
.help-account.indent { padding-left: 1.5rem; }
.help-account.indent2 { padding-left: 3rem; }
.help-account code { font-size: 0.75rem; margin-right: 0.5rem; }
.help-flow { }
.help-step { display: flex; gap: 0.75rem; margin-bottom: 1rem; align-items: flex-start; }
.help-step-num {
    width: 28px; height: 28px; border-radius: 50%; background: var(--primary-100); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.78rem; flex-shrink: 0;
}
.help-step-title { font-weight: 700; font-size: 0.88rem; color: var(--text); }
.help-step-desc { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.15rem; }
.help-info-card { padding: 0.75rem; border-left: 3px solid var(--primary); background: var(--primary-50); border-radius: 0 8px 8px 0; margin-bottom: 0.5rem; }
.help-info-title { font-weight: 700; font-size: 0.82rem; color: var(--text); }
.help-info-desc { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* Reserve alert banner */
.reserve-alert {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
    background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius); margin-bottom: 1rem;
    font-size: 0.84rem; color: #991b1b;
}
[data-theme="dark"] .reserve-alert { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: #fca5a5; }
.reserve-alert i { font-size: 1.2rem; }
.reserve-alert-text { flex: 1; }
.reserve-alert-text strong { display: block; }

/* ═══ STATUS DOT ═══ */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.status-dot.active { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.status-dot.maintenance { background: var(--warning); }
.status-dot.inactive { background: #d1d5db; }

/* ═══ BUTTONS ═══ */
.btn-primary, .btn-outline-primary { border-radius: 8px; font-weight: 600; font-size: 0.85rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--border); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: white; }
.btn-outline-secondary { border-radius: 8px; font-weight: 500; border-color: var(--border); color: var(--text-secondary); }

/* ═══ ALERTS ═══ */
.alert-info { background: var(--primary-50); border: 1px solid var(--primary-200); color: var(--primary-dark); border-radius: var(--radius); }
.alert-secondary { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-secondary); }

/* ═══ CARD FOOTER ═══ */
.card-footer { border-top: 1px solid var(--border); }

/* ═══ DRAWER ═══ */
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 999;
    backdrop-filter: blur(2px); animation: fadeIn 0.2s ease;
}
.drawer {
    position: fixed; top: 0; right: -560px; width: 540px; height: 100vh; z-index: 1000;
    background: white; box-shadow: -8px 0 40px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer.open { right: 0; }
.drawer-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-title { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 0; }
.drawer-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; display: block; }
.drawer-close {
    width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px;
    background: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: var(--transition); flex-shrink: 0;
}
.drawer-close:hover { background: #fef2f2; border-color: var(--error); color: var(--error); }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.drawer-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--border); flex-shrink: 0;
    display: flex; gap: 0.5rem; justify-content: flex-end; background: var(--surface);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Drawer detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }
.detail-item { }
.detail-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.15rem; }
.detail-value { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.detail-value.large { font-size: 1.4rem; font-weight: 800; }
.detail-value.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.82rem; }
.detail-full { grid-column: 1 / -1; }
.detail-section { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); margin: 1.25rem 0 0.75rem; padding-bottom: 0.4rem; border-bottom: 2px solid var(--primary-100); }
.detail-section:first-child { margin-top: 0; }

/* Timeline */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-dot {
    position: absolute; left: -1.5rem; top: 4px; width: 12px; height: 12px;
    border-radius: 50%; border: 2px solid white; box-shadow: 0 0 0 2px var(--border);
}
.timeline-dot.active { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.warning { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot.error { background: var(--error); box-shadow: 0 0 0 2px var(--error); }
.timeline-dot.muted { background: var(--text-muted); box-shadow: 0 0 0 2px var(--text-muted); }
.timeline-time { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.timeline-text { font-size: 0.84rem; color: var(--text); }

/* Action buttons in drawer */
.btn-action {
    padding: 0.5rem 1rem; border: 1.5px solid var(--border); border-radius: 8px;
    background: white; font-size: 0.82rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); font-family: inherit; display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn-action:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.btn-action.danger { color: var(--error); border-color: #fecaca; }
.btn-action.danger:hover { background: #fef2f2; border-color: var(--error); }
.btn-action.success { color: var(--success); border-color: #bbf7d0; }
.btn-action.success:hover { background: #f0fdf4; border-color: var(--success); }
.btn-action.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-action.primary:hover { background: var(--primary-dark); }

/* Scenario cards */
.scenario-card {
    padding: 0.75rem; border: 1.5px solid var(--border); border-radius: 8px;
    cursor: pointer; transition: var(--transition); margin-bottom: 0.5rem;
}
.scenario-card:hover { border-color: var(--primary); background: var(--primary-50); }
.scenario-card.selected { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 3px var(--primary-100); }
.scenario-title { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.scenario-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

/* View button in tables */
.btn-view {
    width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px;
    background: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition); font-size: 0.85rem;
}
.btn-view:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }

/* ═══ PAGER ═══ */
.pager {
    display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem;
    border-top: 1px solid var(--border); background: white;
}
.pager-info { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.pager-controls { display: flex; align-items: center; gap: 0.75rem; }
.pager-size {
    padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.78rem; color: var(--text-secondary); background: white; cursor: pointer;
    font-family: inherit;
}
.pager-size:focus { outline: none; border-color: var(--primary); }
.pager-buttons { display: flex; gap: 2px; }
.pager-btn {
    width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 6px;
    background: white; color: var(--text-secondary); cursor: pointer; display: flex;
    align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 600;
    transition: var(--transition); font-family: inherit;
}
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.pager-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.pager-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ═══ FILTER PANEL ═══ */
.filter-panel {
    display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.85rem 1.25rem; background: var(--surface-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.filter-panel-body { display: flex; gap: 0.75rem; flex-wrap: wrap; flex: 1; align-items: flex-end; }
.filter-panel-actions { display: flex; gap: 0.5rem; }
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); opacity: 0.7; }

/* ═══ GLOBAL SEARCH in filter bar ═══ */
.search-global {
    position: relative; flex: 1; min-width: 200px;
}
.search-global i {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: 0.9rem; pointer-events: none;
}
.search-global input {
    width: 100%; padding: 0.5rem 0.75rem 0.5rem 2.2rem !important;
}

/* ═══ CUSTOM FORM CONTROLS ═══ */
.form-select, select.form-select, .filter-select, select {
    padding: 0.5rem 2.2rem 0.5rem 0.75rem;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-size: 0.82rem; font-family: inherit; color: var(--text);
    background-color: var(--surface-card);
    cursor: pointer; transition: var(--transition); min-width: 150px;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%236B4FBB' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.75rem center;
    box-shadow: 0 1px 2px rgba(107,79,187,0.04);
}
.form-select:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100), 0 1px 2px rgba(107,79,187,0.04);
}
.form-select:hover, select:hover { border-color: var(--primary-light); }
.form-select option, select option {
    padding: 0.5rem; background: var(--surface-card); color: var(--text);
}
.form-control, input[type="text"], input[type="search"], input[type="date"], input[type="number"] {
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-size: 0.82rem; font-family: inherit; color: var(--text);
    background: var(--surface-card);
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(107,79,187,0.04);
}
.form-control:focus, input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100), 0 1px 2px rgba(107,79,187,0.04);
}
.form-control:hover, input[type="text"]:hover { border-color: var(--primary-light); }
.form-control::placeholder, input::placeholder { color: var(--text-muted); opacity: 0.7; }

.btn-filter {
    padding: 0.5rem 1rem; border: none; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white; font-size: 0.82rem; font-weight: 600;
    cursor: pointer; transition: var(--transition); font-family: inherit;
    display: flex; align-items: center; gap: 0.4rem; white-space: nowrap;
    box-shadow: 0 2px 6px rgba(107,79,187,0.2);
}
.btn-filter:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(107,79,187,0.3); }
.btn-filter-reset {
    padding: 0.5rem 0.75rem; border: 1.5px solid var(--border); border-radius: 10px;
    background: var(--surface-card); color: var(--text-secondary); font-size: 0.82rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); font-family: inherit;
    display: flex; align-items: center; gap: 0.4rem; white-space: nowrap;
}
.btn-filter-reset:hover { border-color: var(--error); color: var(--error); background: #fef2f2; }

/* ═══ KPI CARDS (updated) ═══ */
.kpi-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.3rem; }
.kpi-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ═══ TENANT SELECTOR ═══ */
.tenant-selector { display: flex; align-items: center; }
.tenant-select {
    padding: 0.35rem 2rem 0.35rem 0.6rem; border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 0.8rem; font-family: inherit; color: var(--text); background: white;
    cursor: pointer; min-width: 220px;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7194' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.6rem center;
}
.tenant-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }

/* ═══ TABS (modern) ═══ */
.nav-tabs-modern { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.25rem; }
.tab-btn {
    padding: 0.6rem 1.25rem; border: none; background: none; cursor: pointer;
    font-size: 0.85rem; font-weight: 600; color: var(--text-muted); position: relative;
    transition: var(--transition); font-family: inherit; border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 18px; border-radius: 9px; font-size: 0.68rem;
    font-weight: 700; margin-left: 0.4rem; padding: 0 0.4rem;
    background: var(--primary-100); color: var(--primary);
}
.tab-btn.active .tab-count { background: var(--primary); color: white; }

/* ═══ MISC ═══ */
.font-monospace { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.8rem; }
.spinner-border { color: var(--primary) !important; }
code { background: var(--primary-50); color: var(--primary); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.82rem; }
hr { border-color: var(--border); opacity: 0.5; }
.text-right { text-align: right; }
.text-truncate-id { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; opacity: 0.3; display: block; margin-bottom: 0.5rem; }
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.loading .spinner-border { width: 2rem; height: 2rem; }
