:root {
    --brand-50: #eefaf1;
    --brand-100: #d3f1db;
    --brand-500: #1f9d55;
    --brand-600: #18803f;
    --brand-700: #146633;
    --brand-900: #0d3d1f;
    --ink-900: #1b2430;
    --ink-700: #3d4a5c;
    --ink-500: #6b7787;
    --surface: #f4f7f6;
    --sidebar-width: 268px;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font-sans);
    background-color: var(--surface);
    color: var(--ink-900);
}

/* ---------- Layout ---------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left .2s ease;
}

.app-content {
    flex: 1;
}

.app-footer {
    border-top: 1px solid #e5e9ec;
    background: #fff;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand-700), var(--brand-900));
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: 1.1rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 2px;
}

.sidebar-logo-fallback {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,.15);
    font-size: 1.1rem;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: .98rem;
    color: #fff;
    line-height: 1.2;
    max-width: 160px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .9rem .7rem 1.5rem;
}

.sidebar-heading {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.55);
    margin: 1.1rem .6rem .4rem;
    font-weight: 700;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .58rem .75rem;
    border-radius: .55rem;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .89rem;
    font-weight: 500;
    margin-bottom: .15rem;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(255,255,255,.18);
    color: #fff;
    box-shadow: inset 3px 0 0 #fff;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 20, .5);
    z-index: 1030;
}

/* ---------- Navbar ---------- */
.app-navbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border-bottom: 1px solid #e5e9ec;
    padding: .75rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.btn-toggle-sidebar {
    border: none;
    background: var(--brand-50);
    color: var(--brand-700);
    width: 40px;
    height: 40px;
    border-radius: .6rem;
    font-size: 1.2rem;
}

.role-badge {
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 600;
    padding: .4rem .7rem;
    border-radius: 2rem;
}

.btn-user-menu {
    display: flex;
    align-items: center;
    gap: .55rem;
    border: 1px solid #e5e9ec;
    background: #fff;
    border-radius: 2rem;
    padding: .35rem .8rem .35rem .35rem;
    font-weight: 600;
    font-size: .88rem;
    color: var(--ink-900);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand-500);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

/* ---------- Cards & widgets ---------- */
.stat-card {
    border: none;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    padding: 1.25rem;
    height: 100%;
}

.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--ink-900);
}

.stat-card .stat-label {
    color: var(--ink-500);
    font-size: .82rem;
    font-weight: 600;
}

.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eef1f3;
    font-weight: 700;
    border-top-left-radius: 1rem !important;
    border-top-right-radius: 1rem !important;
}

.table {
    font-size: .89rem;
}

.table thead th {
    background: #f8fafb;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-500);
    font-weight: 700;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.btn-brand {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
}

.btn-brand:hover {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
}

.badge-lunas { background: var(--brand-50); color: var(--brand-700); }
.badge-hutang { background: #fdecec; color: #b3261e; }

.nav-pills .nav-link { color: var(--ink-700); font-weight: 600; font-size: .88rem; }
.nav-pills .nav-link.active { background-color: var(--brand-500); }

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, var(--brand-700), var(--brand-900));
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 1.2rem;
    border: none;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-backdrop.show {
        display: block;
    }
}
