:root {
    --brand-1: #4f46e5;
    --brand-2: #7c3aed;
    --brand-3: #06b6d4;
    --bg-soft: #f4f6fb;
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-soft);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2333;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, #1e1b3a 0%, #2c1a52 100%);
    color: #fff;
    z-index: 1040;
    transition: transform .3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.4rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .logo-badge {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-3), var(--brand-1));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-brand .brand-text { line-height: 1.15; }
.sidebar-brand .brand-text small { color: rgba(255,255,255,.55); font-size: .72rem; }

.sidebar .nav-section-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.35);
    padding: 1rem 1.25rem .35rem;
}

.sidebar .nav-link {
    color: rgba(255,255,255,.75);
    padding: .65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .92rem;
    border-left: 3px solid transparent;
    border-radius: 0;
    transition: all .15s ease;
}

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

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

.sidebar .nav-link.active {
    background: rgba(255,255,255,.09);
    color: #fff;
    border-left-color: var(--brand-3);
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .78rem;
    color: rgba(255,255,255,.45);
}

/* ===== Main content ===== */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .3s ease;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #eaecf3;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar .btn-toggle {
    border: none;
    background: var(--bg-soft);
    width: 40px; height: 40px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
}

.page-content { padding: 1.5rem; flex: 1; }

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

/* ===== Cards ===== */
.stat-card {
    border: none;
    border-radius: 16px;
    padding: 1.4rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    min-height: 130px;
}
.stat-card .stat-icon {
    position: absolute;
    right: 1rem; top: 1rem;
    font-size: 2.2rem;
    opacity: .35;
}
.stat-card h3 { font-weight: 700; margin-bottom: .15rem; }
.stat-card .stat-label { font-size: .85rem; opacity: .9; }

.bg-grad-1 { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.bg-grad-2 { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.bg-grad-3 { background: linear-gradient(135deg, #10b981, #059669); }
.bg-grad-4 { background: linear-gradient(135deg, #f59e0b, #ef4444); }

.card-modern {
    border: none;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(30, 27, 58, .06);
}

.badge-cluster-tinggi, .badge-cluster-sangat-tinggi { background: #10b981 !important; }
.badge-cluster-sedang { background: #f59e0b !important; }
.badge-cluster-rendah, .badge-cluster-sangat-rendah { background: #ef4444 !important; }

.table-modern thead th {
    background: #f8f9fc;
    border-bottom: 2px solid #eaecf3;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    white-space: nowrap;
}
.table-modern td { vertical-align: middle; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #4f46e5, #1e1b3a 60%);
    padding: 1rem;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-side {
    background: linear-gradient(160deg, #1e1b3a, #4f46e5);
    color: #fff;
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .topbar .btn-toggle { display: inline-flex; }
    .sidebar-backdrop.show { display: block; }
}

@media (max-width: 575.98px) {
    .page-content { padding: 1rem; }
    .stat-card { min-height: 110px; padding: 1.1rem; }
}
