@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* MAMBU-STYLE MODERN FINTECH PALETTE */
    --bg-body: #f8fafc; /* Ultra-clean, breathable light gray */
    --bg-surface: #ffffff; /* Pure white floating cards */
    --border-subtle: #f1f5f9;
    --border-strong: #e2e8f0;
    
    --text-main: #0f172a; /* Deep Slate (Softer than pure black) */
    --text-muted: #64748b;
    
    --brand-primary: #a3e635; /* Vibrant Lemon Green */
    --brand-hover: #84cc16; /* Slightly darker lime for hovers */
    --brand-text: #020617; /* Extreme Dark Navy for text on Lemon Green */
    
    --fin-green: #10b981;
    --fin-green-bg: #d1fae5;
    --fin-red: #ef4444;
    --fin-red-bg: #fee2e2;
    --fin-orange: #f59e0b;
    --fin-orange-bg: #fef3c7;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout --- */
#dashboardScreen {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==========================================
   LIGHT THEME SIDEBAR (FIELD-OPTIMIZED)
   ========================================== */
.sidebar {
    width: 260px;
    background: #ffffff; 
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.04); /* Soft Mambu-style shadow */
    border-right: 1px solid var(--border-strong);
    transition: all 0.3s ease;
}

.sidebar h2 { color: var(--text-main) !important; }
.sidebar button#logoutBtn { color: var(--text-muted) !important; border-color: var(--border-strong) !important; font-weight: 600 !important; border-radius: 8px;}
.sidebar button#logoutBtn:hover { background: var(--fin-red-bg) !important; color: var(--fin-red) !important; border-color: var(--fin-red-bg) !important; }

/* Lemon Green Logo Accent */
.sidebar svg rect { fill: var(--brand-primary) !important; fill-opacity: 0.3 !important; }
.sidebar svg path, .sidebar svg circle { stroke: var(--fin-green) !important; fill: var(--fin-green) !important; }

.nav-menu {
    flex-grow: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    padding: 12px 20px;
    margin: 4px 16px;
    border-radius: 8px; /* Modern rounded edges */
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background: #f8fafc;
    color: var(--text-main);
    transform: translateX(4px); /* Slick micro-interaction */
}

.nav-item.active {
    background: var(--brand-primary); 
    color: var(--brand-text); 
    font-weight: 700;
    border-left: 4px solid #047857; /* Deep green indicator */
    box-shadow: 0 4px 12px rgba(163, 230, 53, 0.4);
}

/* Live Action Notification Badge */
.nav-badge {
    background-color: var(--fin-red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-left: auto;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 64px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.main-content {
    padding: 32px;
    overflow-y: auto;
    flex-grow: 1;
}

/* --- Enterprise Cards & Dashboard --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
}

.page-header h1 {
    margin: 0 0 6px 0;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: 12px; /* Soft cloud-banking corners */
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

.kpi-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.kpi-card h4 {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.kpi-card h2 {
    margin: 0 0 8px 0;
    font-size: 2rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace; 
    letter-spacing: -1px;
}

.kpi-card p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Strict Financial Colors */
.val-primary { color: var(--text-main); }
.val-danger { color: var(--fin-red); }
.val-warning { color: var(--fin-orange); }
.val-success { color: var(--fin-green); }

.badge-neutral { background: var(--border-strong); color: var(--text-main); padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;}
.badge-danger { background: var(--fin-red-bg); color: var(--fin-red); padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;}
.badge-warning { background: var(--fin-orange-bg); color: var(--fin-orange); padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;}
.badge-success { background: var(--fin-green-bg); color: var(--fin-green); padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;}

.card {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* --- Data-Dense Tables --- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem; 
}

thead th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-strong);
    background-color: var(--bg-body);
}

thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

tbody tr { transition: background-color 0.15s ease; }
tbody tr:hover { background-color: #f8fafc; cursor: pointer; }

/* --- Strict Forms --- */
label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 20px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
}

input:focus, select:focus {
    background-color: var(--bg-surface);
    border-color: var(--fin-green);
    box-shadow: 0 0 0 3px var(--fin-green-bg);
}

button {
    background-color: var(--brand-primary);
    color: var(--brand-text);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(163, 230, 53, 0.2);
}

button:hover {
    background-color: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(163, 230, 53, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: var(--border-strong);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* --- Search & Utils --- */
.search-container { position: relative; }
.search-container input {
    margin: 0; padding: 10px 16px 10px 36px; width: 300px; border-radius: 8px; background: var(--bg-body); border-color: transparent;
}
.search-container input:focus {
    background: var(--bg-surface); border-color: var(--border-strong); box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.9rem;
}
.breadcrumbs { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.breadcrumbs span { color: var(--text-main); font-weight: 700; }

/* --- Action Drawers --- */
.drawer-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease; z-index: 1000;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.slide-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 480px;
    background: var(--bg-surface);
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.1);
    transform: translateX(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001; display: flex; flex-direction: column;
}
.slide-drawer.open { transform: translateX(0); }

.drawer-header {
    padding: 24px; border-bottom: 1px solid var(--border-strong);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-body);
}
.drawer-header h3 { margin: 0; color: var(--text-main); font-size: 1.2rem; font-weight: 700; }
.close-drawer-btn {
    background: white; color: var(--text-muted); font-size: 1.5rem;
    padding: 0; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-strong);
    display: flex; justify-content: center; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.close-drawer-btn:hover { background: var(--fin-red-bg); color: var(--fin-red); border-color: var(--fin-red-bg); }
.drawer-content { padding: 24px; overflow-y: auto; flex-grow: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Print */
@media print {
    body * { visibility: hidden; }
    #printableReceipt, #printableReceipt * { visibility: visible; }
    #printableReceipt { position: absolute; left: 0; top: 0; width: 80mm; padding: 10px; font-family: 'JetBrains Mono', monospace; }
}

/* ==========================================
   MOBILE & TABLET RESPONSIVENESS ENGINE
   ========================================== */
@media (max-width: 768px) {
    #mobileMenuBtn { display: inline-block !important; }
    .search-container { display: none !important; }
    
    .sidebar {
        position: fixed;
        top: 0; left: -260px; bottom: 0;
        z-index: 2000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(15, 23, 42, 0.2);
    }
    .sidebar.mobile-open { left: 0; }

    .kpi-grid, 
    [style*="grid-template-columns: 1.5fr 1fr"], 
    [style*="grid-template-columns: 1fr 1fr"], 
    [style*="grid-template-columns: 350px 1fr"], 
    [style*="grid-template-columns: 250px 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .main-content { padding: 16px 12px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 16px;}
    .page-header button { width: 100%; }
    .top-bar { padding: 0 16px; }

    .card { overflow-x: auto; padding: 16px; }
    table { min-width: 600px; } 

    .slide-drawer { width: 100vw; }
    
    #loginScreen { flex-direction: column; }
    .login-sidebar { width: 100%; min-width: 100%; padding: 24px; }
    .login-image-cover { display: none; }
}

/* Fix Login Screen Button specific to Mambu aesthetic */
#loginBtn { background: var(--brand-primary); color: var(--brand-text); font-size: 1rem; box-shadow: 0 4px 12px rgba(163, 230, 53, 0.3); }
#loginBtn:hover { background: var(--brand-hover); box-shadow: 0 6px 16px rgba(163, 230, 53, 0.4); }