:root {
    --sidebar-w: 268px;
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --bg: #f0f4f8;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
    --shadow-lg: 0 8px 30px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

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

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-w);
    background: #0f172a;
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform .28s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.35rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; margin-bottom: .75rem;
}

.sidebar-brand h5 { margin: 0; font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em; }
.sidebar-brand small { color: rgba(255,255,255,.45); font-size: .72rem; }

.sidebar-section {
    padding: .5rem 1.25rem .25rem;
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.35);
    margin-top: .5rem;
}

.sidebar-menu { list-style: none; padding: .5rem 0 1rem; margin: 0; flex: 1; }

.sidebar-menu a {
    display: flex; align-items: center; gap: .7rem;
    padding: .62rem 1.25rem;
    margin: 2px .6rem;
    border-radius: 10px;
    color: rgba(255,255,255,.7);
    font-size: .875rem;
    font-weight: 500;
    transition: all .18s;
}

.sidebar-menu a i { font-size: 1.05rem; width: 20px; text-align: center; opacity: .85; }
.sidebar-menu a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-menu a.active {
    background: linear-gradient(135deg, rgba(37,99,235,.35), rgba(99,102,241,.25));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(99,102,241,.3);
}

.sidebar-menu .badge { margin-left: auto; font-size: .6rem; padding: .25em .55em; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.06);
    font-size: .72rem;
    color: rgba(255,255,255,.35);
}

/* ─── Main ─── */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

.topbar {
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: .65rem 1.5rem;
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 1rem;
}

.topbar-search { flex: 1; max-width: 380px; position: relative; }
.topbar-search input {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .5rem 1rem .5rem 2.4rem;
    width: 100%;
    background: var(--bg);
    font-size: .875rem;
    transition: border-color .2s, box-shadow .2s;
}
.topbar-search input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
    background: #fff;
}
.topbar-search::before {
    content: '\F52A';
    font-family: 'bootstrap-icons';
    position: absolute; left: .85rem; top: 50%;
    transform: translateY(-50%);
    color: var(--muted); font-size: .9rem; pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: .45rem; margin-left: auto; }

.btn-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted);
    position: relative;
    transition: all .18s;
}
.btn-icon:hover { border-color: var(--primary-light); color: var(--primary); background: #f8fafc; }
.btn-icon .notif-dot {
    position: absolute; top: 7px; right: 7px;
    width: 7px; height: 7px;
    background: var(--danger); border-radius: 50%;
    border: 2px solid #fff;
}

.btn-quick-add {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff; border: none;
    border-radius: 10px;
    padding: .5rem 1.1rem;
    font-weight: 600; font-size: .85rem;
    display: inline-flex; align-items: center; gap: .4rem;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
    transition: transform .15s, box-shadow .15s;
}
.btn-quick-add:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,99,235,.4); }

.content-area { padding: 1.5rem; max-width: 1440px; }

/* ─── Page header ─── */
.page-header {
    display: flex; flex-wrap: wrap;
    align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.03em; }
.page-header .subtitle { color: var(--muted); font-size: .875rem; margin-top: .2rem; }

/* ─── Stat cards ─── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.15rem 1.2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-card::after {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-green::after { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-red::after { background: linear-gradient(90deg, #ef4444, #f87171); }
.stat-blue::after { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-orange::after { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-purple::after { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.stat-teal::after { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }

.stat-card .icon-wrap {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; margin-bottom: .85rem;
}
.stat-green .icon-wrap { background: #ecfdf5; color: #059669; }
.stat-red .icon-wrap { background: #fef2f2; color: #dc2626; }
.stat-blue .icon-wrap { background: #eff6ff; color: #2563eb; }
.stat-orange .icon-wrap { background: #fffbeb; color: #d97706; }
.stat-purple .icon-wrap { background: #f5f3ff; color: #7c3aed; }
.stat-teal .icon-wrap { background: #f0fdfa; color: #0d9488; }

.stat-card .stat-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.stat-card .stat-label { color: var(--muted); font-size: .75rem; font-weight: 500; margin-top: .25rem; }

/* ─── Cards & tables ─── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: .9rem;
    display: flex; align-items: center; justify-content: space-between;
}

.table { margin: 0; font-size: .875rem; }
.table th {
    color: var(--muted); font-weight: 600; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .05em;
    background: #f8fafc; border-bottom: 1px solid var(--border);
    padding: .7rem 1rem;
}
.table td { padding: .75rem 1rem; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ─── Badges ─── */
.badge-balance-positive { background: #dcfce7; color: #166534; font-weight: 600; padding: .35em .65em; border-radius: 6px; }
.badge-balance-negative { background: #fee2e2; color: #991b1b; font-weight: 600; padding: .35em .65em; border-radius: 6px; }
.badge-balance-zero { background: #f1f5f9; color: #64748b; }
.badge-pending { background: #fef3c7; color: #92400e; }

/* ─── Quick actions ─── */
.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.quick-actions .btn { border-radius: 10px; font-size: .82rem; font-weight: 500; padding: .4rem .9rem; }

/* ─── Empty state ─── */
.empty-state {
    text-align: center; padding: 2.5rem 1rem; color: var(--muted);
}
.empty-state i { font-size: 2.5rem; opacity: .3; display: block; margin-bottom: .75rem; }

/* ─── Widget cards ─── */
.widget-card {
    background: linear-gradient(135deg, #1e40af, #4f46e5);
    color: #fff; border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(37,99,235,.3);
}
.widget-card h2 { font-size: 2rem; font-weight: 700; margin: 0; }
.widget-card small { opacity: .8; }

.activity-item {
    padding: .75rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: .82rem;
}
.activity-item:last-child { border-bottom: none; }

.chart-wrap { position: relative; height: 300px; padding: .5rem; }

/* ─── Login ─── */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
}
.login-card {
    width: 100%; max-width: 420px;
    border-radius: 20px; border: none;
    box-shadow: 0 25px 60px rgba(0,0,0,.35);
}

.ledger-debit { color: var(--danger); font-weight: 600; }
.ledger-credit { color: var(--success); font-weight: 600; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

.avatar { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; background: #e2e8f0; }
.avatar-lg { width: 80px; height: 80px; border-radius: 16px; }

.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #128c7e; color: #fff; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1035; }

.filter-bar {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

@media (max-width: 1200px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .topbar-search { display: none; }
    .content-area { padding: 1rem; }
}
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
}
