:root {
    --primary: #0d6efd;
    --sidebar-bg: #164574;
    --sidebar-width: 260px;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: #0d6efd;
    --text-muted: #9fc1e4;
    --topbar-height: 56px;
}

/* =========================================================
   DASAR
   ========================================================= */
* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    padding: 0;
    background-color: #f4f6f9;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow-x: hidden;
}

/* =========================================================
   HEADER TETAP
   ========================================================= */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;

    width: 100%;
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    max-height: var(--topbar-height);

    margin: 0;
    padding-top: 0;
    padding-bottom: 0;

    background: linear-gradient(90deg, #103a68, #0d6efd);
    z-index: 1030;
}

/*
 * Header menggunakan position fixed sehingga keluar dari alur halaman.
 * Padding atas ini memberikan ruang tepat sebesar tinggi header.
 */
.app-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: var(--topbar-height) 0 0;
}

/* =========================================================
   SIDEBAR TETAP DAN SCROLL MANDIRI
   ========================================================= */
.app-sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;

    width: var(--sidebar-width);

    /* Fallback browser lama */
    height: calc(100vh - var(--topbar-height));

    /* Browser modern */
    height: calc(100dvh - var(--topbar-height));

    margin: 0;
    padding: 0;

    background-color: var(--sidebar-bg);
    z-index: 1020;

    overflow-y: scroll;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;

    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #8cabc9 rgba(255, 255, 255, 0.08);

    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/*
 * Scroll tidak lagi dipasang pada pembungkus.
 * Scroll ditangani langsung oleh .app-sidebar.
 */
.sidebar-scroll {
    display: block;
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
}

/* Scrollbar Chrome, Edge, dan Safari */
.app-sidebar::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar::-webkit-scrollbar-track {
    background-color: rgba(255, 255, 255, 0.08);
}

.app-sidebar::-webkit-scrollbar-thumb {
    min-height: 40px;
    background-color: #8cabc9;
    border: 2px solid var(--sidebar-bg);
    border-radius: 10px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background-color: #ffffff;
}

/* =========================================================
   NAVIGASI SIDEBAR
   ========================================================= */
.sidebar-scroll .nav {
    display: flex;
    flex-direction: column;

    width: 100%;
    margin: 0;
    padding: 10px 10px 30px;
}

.sidebar-scroll .nav-section {
    padding: 14px 12px 5px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar-scroll .nav-link {
    position: relative;
    display: flex;
    align-items: center;

    min-height: 40px;
    margin-bottom: 3px;
    padding: 8px 12px;

    color: #e0e6ed;
    font-size: 13.5px;
    font-weight: 400;
    text-decoration: none;

    border-radius: 7px;

    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        padding-left 0.2s ease;
}

.sidebar-scroll .nav-link i {
    width: 24px;
    min-width: 24px;
    font-size: 18px;
    text-align: center;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.sidebar-scroll .nav-link:hover {
    padding-left: 15px;
    color: #ffffff;
    background-color: var(--sidebar-hover);
}

.sidebar-scroll .nav-link:hover i {
    opacity: 1;
}

.sidebar-scroll .nav-link.active {
    color: #ffffff;
    font-weight: 600;
    background-color: var(--sidebar-active);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35);
}

.sidebar-scroll .nav-link.active i {
    opacity: 1;
}

.sidebar-scroll .nav-link.active::before {
    content: '';
    position: absolute;
    top: 20%;
    left: 0;

    width: 4px;
    height: 60%;

    background-color: #ffffff;
    border-radius: 0 4px 4px 0;
}

/* =========================================================
   KONTEN UTAMA
   ========================================================= */
.app-content {
    width: calc(100% - var(--sidebar-width));
    min-height: calc(100vh - var(--topbar-height));

    margin: 0 0 0 var(--sidebar-width);
    padding: 20px 24px 24px;

    transition:
        margin-left 0.3s ease,
        width 0.3s ease;
}

/* =========================================================
   KARTU DAN KOMPONEN
   ========================================================= */
.card-stat {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-stat .icon-box {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 52px;
    height: 52px;

    color: #ffffff;
    font-size: 22px;
    border-radius: 12px;
}

.criteria-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.criteria-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

/* =========================================================
   HALAMAN LOGIN
   ========================================================= */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 100vh;
    margin: 0;
    padding: 20px;

    background: linear-gradient(135deg, #103a68, #0d6efd);
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

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

    body.sidebar-open {
        overflow: hidden;
    }

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

    .app-content {
        width: 100%;
        margin-left: 0;
        padding: 16px;
    }

    body.sidebar-open::before {
        content: '';
        position: fixed;
        top: var(--topbar-height);
        right: 0;
        bottom: 0;
        left: 0;

        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 1010;
    }
}