/* ═══════════════════════════════════════════════════════
   SIMANPACIS v3 — styles.css (Refactored & Cleaned)
   Semua dead code dihapus. Glassmorphism + GSAP animations
   tetap utuh 100%. Ditambah dukungan DARK MODE!
   ═══════════════════════════════════════════════════════ */

/* ─── CSS Variables System (Light & Dark Theme) ─── */
:root {
    /* Colors - Light Theme */
    --bg-base: #dde4f0;
    --bg-gradient-1: #c8d8f8;
    --bg-gradient-2: #c8edd9;
    --bg-gradient-3: #fde9c2;
    --text-main: #0b0f1a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* Accents */
    --accent-main: #5b8dee;
    --accent-dark: #3a6fd8;
    --accent-gradient: linear-gradient(135deg, #5b8dee 0%, #3a6fd8 100%);
    --accent-blob: linear-gradient(135deg, #5b8dee 0%, #7c5cd6 100%);

    /* Glass Surfaces */
    --glass-bg-1: rgba(255, 255, 255, 0.55);
    --glass-bg-2: rgba(255, 255, 255, 0.76);
    --glass-bg-3: rgba(255, 255, 255, 0.96);
    --glass-border: rgba(255, 255, 255, 0.72);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);

    /* Cards & Inputs */
    --card-bg: #ffffff;
    --input-bg: rgba(255, 255, 255, 0.8);
    --input-border: rgba(0, 0, 0, 0.1);

    /* States */
    --hover-bg: rgba(91, 141, 238, 0.08);
    --active-bg: rgba(91, 141, 238, 0.12);
    --divider: rgba(0, 0, 0, 0.06);

    /* Scrollbar */
    --scroll-thumb: rgba(91, 141, 238, 0.22);
    --scroll-hover: rgba(91, 141, 238, 0.38);

    /* ── Modal / Popup System Tokens (UI-STANDARDIZE) ─── */
    --modal-radius: 24px;
    --modal-radius-inner: 16px;
    --modal-shadow: 0 32px 80px rgba(0, 0, 0, 0.22);
    --modal-shadow-light: 0 24px 64px rgba(0, 0, 0, 0.15);
    --modal-backdrop: rgba(11, 15, 26, 0.4);
    --modal-max-width-sm: 420px;
    --modal-max-width-md: 560px;
    --modal-max-width-lg: 800px;
}

body.dark {
    /* Colors - Dark Theme */
    --bg-base: #0b0f1a;
    --bg-gradient-1: #152238;
    --bg-gradient-2: #0f291e;
    --bg-gradient-3: #2a1f10;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    /* Accents (Slightly brighter for dark mode) */
    --accent-main: #739df0;
    --accent-dark: #5b8dee;
    --accent-gradient: linear-gradient(135deg, #739df0 0%, #5b8dee 100%);
    --accent-blob: linear-gradient(135deg, #739df0 0%, #9066f4 100%);

    /* Glass Surfaces (Dark Glass) */
    --glass-bg-1: rgba(18, 24, 38, 0.55);
    --glass-bg-2: rgba(18, 24, 38, 0.76);
    --glass-bg-3: rgba(18, 24, 38, 0.96);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);

    /* Cards & Inputs */
    --card-bg: #111827;
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.1);

    /* States */
    --hover-bg: rgba(255, 255, 255, 0.05);
    --active-bg: rgba(255, 255, 255, 0.08);
    --divider: rgba(255, 255, 255, 0.06);

    /* Scrollbar */
    --scroll-thumb: rgba(255, 255, 255, 0.15);
    --scroll-hover: rgba(255, 255, 255, 0.25);
}

/* ─── Dark Mode Tailwind Overrides ─── */
body.dark .text-slate-800,
body.dark .text-gray-800,
body.dark .text-slate-900 {
    color: var(--text-main) !important;
}

body.dark .text-slate-500,
body.dark .text-gray-500,
body.dark .text-slate-600 {
    color: var(--text-muted) !important;
}

body.dark .text-slate-400,
body.dark .text-gray-400 {
    color: var(--text-faint) !important;
}

body.dark .bg-white {
    background-color: transparent !important;
}

body.dark .bg-slate-50,
body.dark .bg-gray-50 {
    background-color: var(--input-bg) !important;
}

body.dark .border-slate-200,
body.dark .border-gray-200 {
    border-color: var(--input-border) !important;
}

body.dark .border-slate-100,
body.dark .border-gray-100 {
    border-color: rgba(255, 255, 255, 0.05) !important;
}

body.dark .divide-slate-100> :not([hidden])~ :not([hidden]),
body.dark .divide-gray-100> :not([hidden])~ :not([hidden]) {
    border-color: var(--input-border) !important;
}

body.dark .hover\:bg-slate-50:hover,
body.dark .hover\:bg-gray-50:hover {
    background-color: var(--hover-bg) !important;
}

body.dark input,
body.dark select,
body.dark textarea {
    color: var(--text-main) !important;
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
}

/* ─── Reset & Base ─── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-base);
    background-image:
        radial-gradient(ellipse at 0% 0%, var(--bg-gradient-1) 0%, transparent 55%),
        radial-gradient(ellipse at 100% 100%, var(--bg-gradient-2) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 80%, var(--bg-gradient-3) 0%, transparent 50%);
    background-attachment: fixed;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--text-main);
    transition: background 0.4s ease, color 0.4s ease;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-hover);
}

/* ─── Ambient Orbs ─── */
.orb {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    /* BUG-FIX Z-INDEX: orbs must stay at z-index 0 so they never cover
       any interactive layer. All interactive UI starts at z-index 1+. */
    z-index: 0;
    filter: blur(90px);
    opacity: 0.28;
    will-change: transform;
    /* BUG-FIX VIEWPORT OVERFLOW: orbs are larger than the viewport (680px).
       They overflow the body edge. Clip at the html level handles this via
       overflow:hidden on body, but to be safe also ensure they can't create
       a scrollable area by setting overflow:hidden on their containing block. */
}

#orb1 {
    width: 680px;
    height: 680px;
    background: radial-gradient(circle, rgba(170, 196, 250, 0.8), rgba(124, 92, 214, 0.3) 40%, transparent 70%);
    top: -240px;
    left: -200px;
}

#orb2 {
    width: 580px;
    height: 580px;
    background: radial-gradient(circle, rgba(144, 224, 184, 0.7), rgba(52, 199, 138, 0.2) 40%, transparent 70%);
    bottom: -100px;
    right: -180px;
}

#orb3 {
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(253, 208, 158, 0.7), rgba(245, 166, 35, 0.2) 40%, transparent 70%);
    top: 30%;
    left: 28%;
}

/* ─── Glass System ─── */
.glass {
    background: var(--glass-bg-1);
    backdrop-filter: blur(32px) saturate(2.0);
    -webkit-backdrop-filter: blur(32px) saturate(2.0);
    border: 1px solid var(--glass-border);
}

.glass-strong {
    background: var(--glass-bg-2);
    backdrop-filter: blur(48px) saturate(2.2);
    -webkit-backdrop-filter: blur(48px) saturate(2.2);
    box-shadow: var(--glass-shadow), 0 0 0 1px var(--glass-border) inset;
}

.glass-ultra {
    background: var(--glass-bg-3);
    backdrop-filter: blur(64px) saturate(2.6);
    -webkit-backdrop-filter: blur(64px) saturate(2.6);
    box-shadow: 0 24px 72px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--glass-border) inset;
}

/* ─── Resizable Popups ─── */
.resizable-popup {
    resize: horizontal;
    overflow: hidden;
    min-width: 320px;
}

/* ─── App Shell ─── */
#app-shell {
    display: flex;
    width: 100vw;
    height: 100vh;
    /* BUG-FIX VIEWPORT OVERFLOW: clip anything that escapes the shell
       (e.g. orbs or 3D-transform elements with translateZ) from causing
       a horizontal scrollbar on 320-430px screens */
    overflow: hidden;
    position: relative;
    /* Ensure children cannot push past viewport width */
    max-width: 100vw;
}

/* ─── Sidebar ─── */
#sidebar {
    width: 256px;
    height: calc(100vh - 20px);
    flex-shrink: 0;
    overflow: hidden;
    transition: width .5s cubic-bezier(.34, 1.56, .64, 1), margin .5s cubic-bezier(.34, 1.56, .64, 1), transform .5s cubic-bezier(.32, 1.6, .6, 1), background 0.4s;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    margin: 10px 0 10px 10px;
    border-radius: 26px;
}

#sidebar.collapsed {
    width: 70px;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 10px;
    overflow: hidden;
}

#sidebar.collapsed .sidebar-inner {
    padding: 16px 6px;
    align-items: center;
}

/* ─── Logo ─── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px;
    margin-bottom: 20px;
    flex-shrink: 0;
    transition: justify-content .3s;
}

#sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 4px 0;
}

.logo-blob {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-blob);
    box-shadow: 0 6px 20px rgba(91, 141, 238, .38);
    animation: blob-float 8s ease-in-out infinite;
}

@keyframes blob-float {

    0%,
    100% {
        border-radius: 60% 40% 30% 70%/60% 30% 70% 40%;
    }

    33% {
        border-radius: 30% 60% 70% 40%/50% 60% 30% 60%;
    }

    66% {
        border-radius: 50% 30% 50% 70%/30% 50% 60% 50%;
    }
}

#sidebar-close-btn {
    display: none;
    /* Hanya muncul di mobile */
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#sidebar-close-btn:hover {
    background: var(--hover-bg);
    color: var(--text-main);
}


.sidebar-logo-text {
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: -.025em;
    color: var(--text-main);
    white-space: nowrap;
    transition: opacity .2s, max-width .25s, margin .25s, color 0.4s;
    flex: 1;
}

#sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

#sidebar:not(.collapsed) .sidebar-logo-text {
    opacity: 1;
    max-width: 180px;
    transition: opacity .35s .12s, max-width .35s .08s;
}

/* ─── Nav Labels & Spacers ─── */
.nav-section-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-faint);
    padding: 0 10px;
    margin-bottom: 4px;
    margin-top: 2px;
    white-space: nowrap;
    transition: height .3s, opacity .2s, margin .3s, padding .3s, color 0.4s;
    overflow: hidden;
    flex-shrink: 0;
}

#sidebar.collapsed .nav-section-label {
    height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.nav-section-spacer {
    height: 12px;
    flex-shrink: 0;
    transition: height .3s;
}

#sidebar.collapsed .nav-section-spacer {
    height: 6px;
}

/* ─── Nav Items ─── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 14px;
    padding: 7px 10px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    position: relative;
    transition: color .22s, background .28s cubic-bezier(.34, 1.56, .64, 1), box-shadow .28s;
    will-change: transform;
    user-select: none;
    flex-shrink: 0;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

#sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 8px;
    width: 50px;
    margin: 0 auto;
}

.nav-item.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 6px 20px rgba(91, 141, 238, .38);
}

.nav-item:not(.active):hover {
    background: var(--hover-bg);
    color: var(--text-main);
}

.nav-item:active:not(.active) {
    transform: scale(.94);
}

.nav-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    transition: background .22s, box-shadow .22s, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.nav-item.active .nav-icon-wrap {
    background: rgba(255, 255, 255, .22);
}

.nav-item.active .nav-icon-wrap i {
    color: #fff;
}

.nav-item:not(.active) .nav-icon-wrap i {
    color: var(--text-faint);
    transition: color .22s;
}

.nav-item:not(.active):hover .nav-icon-wrap i {
    color: var(--accent-main);
}

.nav-label-text {
    white-space: nowrap;
    transition: opacity .2s, max-width .25s;
    flex: 1;
}

#sidebar.collapsed .nav-label-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

#sidebar:not(.collapsed) .nav-label-text {
    opacity: 1;
    max-width: 180px;
    transition: opacity .35s .12s, max-width .35s .08s;
}

.badge-pill {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #fdeef0, #fdd8dc);
    color: #f26878;
    flex-shrink: 0;
}

#sidebar.collapsed .badge-pill {
    display: none;
}

.sidebar-divider {
    height: 1px;
    background: var(--divider);
    margin: 8px 8px;
    flex-shrink: 0;
    transition: opacity .2s, background 0.4s;
}

#sidebar.collapsed .sidebar-divider {
    margin: 6px 4px;
}

/* ─── Quick Access (Auto-Login) — collapsed state ─── */
#sidebar.collapsed .quick-access-label,
#sidebar.collapsed .quick-access-arrow {
    display: none;
}

#sidebar.collapsed .quick-access-btn {
    justify-content: center;
    padding: 9px 0;
}

#sidebar.collapsed .quick-access-section {
    padding: 8px 6px 4px;
}

/* ─── Submenu (Accordion) ─── */
.nav-group {
    position: relative;
    width: 100%;
}

.submenu-container {
    position: relative;
    overflow: hidden;
    padding-left: 18px;
    margin-top: 2px;
    display: none;
}

#sidebar.collapsed .submenu-container {
    display: none !important;
}

.submenu-line {
    position: absolute;
    left: 27px;
    top: 0;
    bottom: 12px;
    width: 1px;
    background: var(--divider);
    transition: background 0.4s;
}

.submenu-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
}

.submenu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    transition: color 0.2s, background 0.2s;
    cursor: pointer;
}

.submenu-item:hover {
    color: var(--text-main);
    background: var(--hover-bg);
}

.submenu-item.active {
    color: var(--accent-main);
    font-weight: 600;
    background: var(--active-bg);
}

.submenu-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-faint);
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.submenu-item:hover .submenu-dot {
    background: var(--accent-main);
    transform: scale(1.5);
}

.submenu-item.active .submenu-dot {
    background: var(--accent-main);
    transform: scale(1.5);
    box-shadow: 0 0 6px rgba(91, 141, 238, 0.4);
}

#sidebar.collapsed .submenu-caret {
    display: none;
}

/* ─── Sidebar Footer ─── */
.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    margin-top: auto;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 14px;
    transition: background .2s, justify-content .3s;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-footer:hover {
    background: var(--hover-bg);
}

.sidebar-footer:active {
    transform: scale(.97);
}

#sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding: 8px 0;
}

.sidebar-footer-text {
    overflow: hidden;
    transition: opacity .2s, max-width .25s;
    flex: 1;
    min-width: 0;
}

#sidebar.collapsed .sidebar-footer-text,
#sidebar.collapsed .sidebar-footer-icon {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

#sidebar:not(.collapsed) .sidebar-footer-text {
    opacity: 1;
    max-width: 160px;
    transition: opacity .35s .12s, max-width .35s .08s;
}

/* ─── Stat Cards ─── */
.stat-card {
    border-radius: 20px;
    will-change: transform, box-shadow;
    transition: box-shadow .35s, background 0.4s, color 0.4s;
    box-shadow: var(--glass-shadow), 0 0 0 1px var(--glass-border) inset;
    position: relative;
    overflow: visible;
    /* Diubah dari hidden agar isi flex tidak terpotong */
    background: var(--glass-bg-2);
    backdrop-filter: blur(36px) saturate(2.2);
    -webkit-backdrop-filter: blur(36px) saturate(2.2);
    flex-shrink: 0;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent);
    z-index: 1;
    pointer-events: none;
}

/* ─── Badge ─── */
.badge {
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 700;
    padding: 3px 10px;
    display: inline-flex;
    align-items: center;
    letter-spacing: .01em;
}

/* ─── Flash Messages (iOS Style) ─── */
.flash-msg {
    position: fixed;
    top: 20px;
    /* BUG-FIX VIEWPORT OVERFLOW: Use left+right with max-width instead of
       left:50% + translateX(-50%). On 320px screens the pill can clip outside
       the viewport edge when the text is long, causing invisible horizontal overflow. */
    left: 12px;
    right: 12px;
    width: auto;
    max-width: 480px;
    margin: 0 auto;
    /* Original transform kept only for the slide-in animation Y axis */
    transform: translateY(-100px);
    /* BUG-FIX #7: z-index 10001 agar flash selalu di atas modal (z-9999) dan panel (z-1000) */
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(2.5);
    -webkit-backdrop-filter: blur(24px) saturate(2.5);
    color: var(--text-main);
    animation: ios-alert-slide 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    pointer-events: auto;
}

body.dark .flash-msg {
    background: rgba(20, 25, 35, 0.85);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

@keyframes ios-alert-slide {

    /* BUG-FIX: Removed translateX(-50%) since flash-msg now uses left+right layout */
    0% {
        transform: translateY(-100px) scale(0.85);
        opacity: 0;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.flash-success i {
    color: #34c78a;
    font-size: 1.1rem;
}

.flash-error i {
    color: #f26878;
    font-size: 1.1rem;
}

/* ─── Global Stretch Physics (iOS Feel) ───
   PENTING: tidak pakai !important di sini lagi. Sebelumnya rule ini
   memaksa transform lewat !important, yang artinya CSS akan
   menimpa transform inline yang sedang dianimasikan GSAP pada
   .nav-item / .sidebar-footer (tilt 3D, scale, dsb). Akibatnya saat
   item ditekan, GSAP & CSS rebutan kontrol transform di properti yang
   sama -> efek "snap"/kedutan sesaat (sumber utama animasi terasa
   tidak stabil). Tanpa !important, inline style dari GSAP otomatis
   menang (specificity inline > class), sementara elemen polos yang
   TIDAK disentuh GSAP (mis. <button> generik) tetap mendapat feedback
   tekan dari CSS ini seperti biasa. */
button,
.btn-stretch,
.nav-item,
.sidebar-footer {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s, box-shadow 0.25s;
}

button:active,
.btn-stretch:active,
.nav-item:active,
.sidebar-footer:active {
    transform: scale(0.94);
    transition: transform 0.1s ease-out;
}


/* ─── Search Bar ─── */
.search-bar {
    transition: box-shadow .32s cubic-bezier(.34, 1.56, .64, 1), transform .32s cubic-bezier(.34, 1.56, .64, 1);
}

.search-bar:focus-within {
    box-shadow: 0 0 0 3px rgba(91, 141, 238, .2), 0 4px 20px rgba(91, 141, 238, .1);
    transform: translateY(-1px) scale(1.005);
}

/* ─── Table ─── */
.table-row {
    transition: background .2s;
}

.table-row:hover {
    background: var(--hover-bg);
}

/* ─── Chart Bars ─── */
.chart-bar {
    border-radius: 10px 10px 4px 4px;
    position: relative;
    overflow: hidden;
    transition: filter .3s, transform .3s cubic-bezier(.34, 1.56, .64, 1);
    min-height: 4px;
}

.chart-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, .3) 0%, transparent 100%);
    border-radius: 10px 10px 0 0;
}

.chart-bar-wrap {
    position: relative;
}

.chart-bar-wrap:hover .chart-bar {
    filter: brightness(1.12);
    transform: scaleY(1.04);
    transform-origin: bottom;
}

.chart-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(.85) translateY(4px);
    background: rgba(11, 15, 26, .92);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 10px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .35s cubic-bezier(.34, 1.56, .64, 1);
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}

.chart-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(11, 15, 26, .92);
}

.chart-bar-wrap:hover .chart-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
}

/* ─── Progress ─── */
.progress-fill {
    height: 100%;
    border-radius: 999px;
    position: relative;
    overflow: hidden;
    transition: width 1.4s cubic-bezier(.34, 1.56, .64, 1);
    /* BUG-FIX #5: Hapus !important agar GSAP bisa menganimasikan width via inline style.
       !important pada class SELALU menang atas inline style — menyebabkan bar stuck di 0. */
    width: 0;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .52), transparent);
    animation: shimmer-bar 2.4s infinite .5s;
}

@keyframes shimmer-bar {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

/* ─── Floating Panels ─── */
#panels-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}

.float-panel {
    position: absolute;
    pointer-events: none;
    transform: translateY(-14px) scale(0.9);
    transform-origin: top right;
    transition: opacity .32s cubic-bezier(.34, 1.56, .64, 1), transform .32s cubic-bezier(.34, 1.56, .64, 1);
    opacity: 0;
    top: 72px;
    right: 14px;
    left: auto;
    bottom: auto;
}

@keyframes popup-stretch-down {
    0% {
        transform: translateY(-40px) scaleX(.8) scaleY(1.2);
        opacity: 0;
    }

    40% {
        transform: translateY(8px) scaleX(1.06) scaleY(.94);
        opacity: 1;
    }

    70% {
        transform: translateY(-2px) scaleX(.98) scaleY(1.02);
        opacity: 1;
    }

    100% {
        transform: translateY(0) scaleX(1) scaleY(1);
        opacity: 1;
    }
}

@keyframes popup-stretch-right {
    0% {
        transform: translateX(-40px) scaleX(1.2) scaleY(.8);
        opacity: 0;
    }

    40% {
        transform: translateX(8px) scaleX(.94) scaleY(1.06);
        opacity: 1;
    }

    70% {
        transform: translateX(-2px) scaleX(1.02) scaleY(.98);
        opacity: 1;
    }

    100% {
        transform: translateX(0) scaleX(1) scaleY(1);
        opacity: 1;
    }
}

.float-panel.open {
    opacity: 1;
    pointer-events: all;
    animation: popup-stretch-down .65s cubic-bezier(.2, .8, .2, 1) forwards;
    transform: translateY(0) scale(1);
}

#notif-panel {
    width: min(370px, calc(100vw - 28px));
    max-height: calc(100vh - 90px);
    display: flex;
    flex-direction: column;
    border-radius: 26px;
}

#notif-panel .panel-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 90px - 186px);
    flex: 1 1 auto;
}

#profile-panel {
    width: min(292px, calc(100vw - 28px));
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 26px;
}

#profile-panel.from-sidebar {
    top: auto;
    bottom: 18px;
    left: 270px;
    right: auto;
    transform-origin: bottom left;
}

#profile-panel.from-sidebar:not(.open) {
    transform: translateX(-18px) scale(.92);
}

#profile-panel.from-sidebar.open {
    animation: popup-stretch-right .65s cubic-bezier(.2, .8, .2, 1) forwards;
    transform: translateX(0) scale(1);
}

#panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: none;
    background: rgba(11, 15, 26, .2);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

#panel-backdrop.show {
    display: block;
    animation: fadeBackdrop .3s ease-out forwards;
}

@keyframes fadeBackdrop {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes ios-breathe {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(242, 104, 120, .55);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(242, 104, 120, 0);
    }
}

.ios-breathe {
    animation: ios-breathe 2.5s ease-in-out infinite;
}

/* ─── Click Ripple (sebelumnya hilang -> efek ripple tidak pernah benar2 main) ─── */
@keyframes ripple-expand {
    0% {
        transform: scale(0);
        opacity: .55;
    }

    100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

/* ─── Skeleton Loading (notifikasi) ─── */
.skeleton-pulse {
    background: linear-gradient(90deg, var(--hover-bg) 25%, var(--active-bg) 50%, var(--hover-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ─── Notif & Menu Items ─── */
.notif-item {
    padding: 11px 12px;
    border-radius: 15px;
    transition: background .22s, transform .22s cubic-bezier(.34, 1.56, .64, 1);
    cursor: pointer;
}

.notif-item:hover {
    background: var(--hover-bg);
    transform: scale(1.01);
}

.notif-item:active {
    transform: scale(.97);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 13px;
    font-size: .84rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: background .2s, transform .2s cubic-bezier(.34, 1.56, .64, 1);
}

.menu-item:hover {
    background: var(--hover-bg);
    transform: translateX(3px);
}

.menu-item:active {
    transform: scale(.97);
}

.menu-item.danger {
    color: #f26878;
}

.menu-item.danger:hover {
    background: rgba(242, 104, 120, .08);
}

.menu-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ios-divider {
    height: 1px;
    background: var(--divider);
    margin: 4px 0;
}

/* ─── Header Buttons ─── */
.header-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    transition: background .22s, transform .22s cubic-bezier(.34, 1.56, .64, 1), box-shadow .22s, color 0.4s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: transparent;
    color: var(--text-muted);
}

.header-btn:hover {
    background: var(--active-bg);
    transform: scale(1.06);
    color: var(--text-main);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
}

.header-btn:active {
    transform: scale(.92);
}

/* ─── Main Layout ─── */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

#main-header {
    margin: 10px 10px 0 10px;
    border-radius: 20px;
    height: 60px;
    box-shadow: var(--glass-shadow), 0 0 0 1px var(--glass-border) inset;
    flex-shrink: 0;
    background: var(--glass-bg-2);
    backdrop-filter: blur(24px);
    /* BUG-FIX Z-INDEX: header must sit above main content glass layers (z-index 1)
       but below panels (z-index 1000) and sidebar (z-index 10 desktop / 50 mobile) */
    position: relative;
    z-index: 15;
}

main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 14px 16px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    /* BUG-FIX: ensure no child wider than viewport causes horizontal scroll */
    max-width: 100%;
}

.fade-section {
    opacity: 0;
    transform: translateY(20px);
}

/* BUG-FIX #10: Fallback jika JS / GSAP gagal load.
   Gunakan @supports untuk mendeteksi apakah GSAP pernah berjalan.
   Jika tidak, elemen akan terlihat setelah 2 detik via animation delay. */
@keyframes fade-section-fallback {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-section {
    /* Fallback: tampil otomatis setelah 2s jika GSAP tidak pernah mengubah opacity */
    animation: fade-section-fallback 0.6s ease-out 2s both;
}

/* Jika GSAP berhasil berjalan, ia akan set opacity via inline style → animation tak berpengaruh */
.fade-section[style*="opacity"] {
    animation: none;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ─── Grids ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.chart-grid {
    display: grid;
    grid-template-columns: 5fr 3fr;
    gap: 12px;
}

.activity-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
}

/* ─── Table Scroll ─── */
.table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 20px 20px;
}

.table-scroll-wrap::-webkit-scrollbar {
    height: 4px;
}

.table-scroll-wrap table {
    min-width: 640px;
    width: 100%;
    border-collapse: collapse;
}

/* ─── Responsive ─── */
@media (max-width:1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 11px;
    }

    .chart-grid {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .activity-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* BUG-FIX DYNAMIC CONTENT SCALING: On very small screens (320px)
   a 2-col grid with long content can overflow. Force 1-col at 430px. */
@media (max-width:430px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
}

/* BUG-FIX #8: Unifikasi breakpoint ke 767px (sama persis dengan mobile.css).
   Sebelumnya 768px menyebabkan 1px gap di mana tidak ada rule yang berlaku
   (768px = tepat di breakpoint, berlaku di styles.css tapi belum di mobile.css). */
@media (max-width: 767px) {

    /* BUG-FIX Z-INDEX CONFLICT: sidebar z-index 50 must be above main-header z-index 15
       but below panels-root z-index 1000. Sidebar overlay matches sidebar. */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-110%);
        transition: transform .4s cubic-bezier(.32, .72, 0, 1);
        width: 272px !important;
        height: 100dvh;
        margin: 0;
        border-radius: 0 26px 26px 0;
        box-shadow: 20px 0 60px rgba(0, 0, 0, .14), 4px 0 12px rgba(0, 0, 0, .06);
    }

    #sidebar.mobile-open {
        transform: translateX(0);
        transition: transform .5s cubic-bezier(.32, 1.1, .6, 1);
    }

    /* BUG-FIX Z-INDEX: overlay must sit between sidebar (50) and content (15)
       so tapping it closes sidebar without interacting with content below */
    #sidebar-overlay {
        z-index: 49;
    }

    #sidebar-close-btn {
        display: flex;
    }

    #main-header {
        margin: 8px 8px 0 8px;
        border-radius: 17px;
        height: 54px;
        padding: 0 12px !important;
        z-index: 15;
    }

    #main-header .search-bar {
        display: none;
    }

    /* BUG-FIX ELEMENT CLASHING: Ensure scrollable main has enough bottom padding
       so the last content row is never hidden under the fixed bottom safe area.
       Also guard overflow-x explicitly to prevent horizontal scroll. */
    main {
        padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 10px)) 12px !important;
        overflow-x: hidden !important;
    }

    /* BUG-FIX DYNAMIC CONTENT SCALING: guard all flex children from overflowing */
    main>* {
        min-width: 0;
        max-width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .chart-grid,
    .activity-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        border-radius: 17px;
        /* BUG-FIX: guard long text inside stat cards */
        overflow: hidden;
        word-break: break-word;
    }

    #page-title h1 {
        font-size: 1.28rem;
        /* BUG-FIX DYNAMIC CONTENT SCALING: prevent long names from overflowing */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-btn {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }

    /* BUG-FIX: Topbar user name text — truncate on small screens */
    #main-header .user-name-text {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* BUG-FIX Z-INDEX: float panels appear above header (z-index 15) but below
       sidebar overlay (z-index 49). panels-root is z-index 1000, so this is safe. */
    /* BUG-FIX #1 & #9: Hierarchy z-index yang benar di mobile:
       sidebar        = z-9000  (mobile.css §1)
       panel-backdrop = z-9998  (tepat di bawah panel, di atas sidebar)
       notif/profile  = z-9999  (tertinggi, selalu di depan)
       Sebelumnya panel-backdrop di-override ke 9998 tapi dengan cara
       yang berpotensi bertabrakan. Diperjelas di sini. */
    #panel-backdrop {
        z-index: 9998 !important;
        /* Pastikan backdrop menutup seluruh viewport termasuk sidebar area */
        inset: 0;
        position: fixed;
    }

    #panels-root {
        z-index: 9999 !important;
    }

    .float-panel {
        top: 64px !important;
        left: 10px !important;
        right: 10px !important;
        bottom: auto !important;
        width: auto !important;
        max-width: none !important;
        transform-origin: top center !important;
    }

    .float-panel:not(.open) {
        transform: translateY(-10px) scale(.92) !important;
    }

    #notif-panel {
        max-height: calc(100dvh - 78px);
    }

    #profile-panel {
        max-height: calc(100dvh - 78px);
    }

    #profile-panel.from-sidebar {
        left: 10px !important;
        right: 10px !important;
        bottom: auto !important;
        top: 64px !important;
        transform-origin: top center !important;
    }
}

/* ─── Prefers Reduced Motion ───
   Animasi state-change tetap ada (durasinya sudah dipersingkat lewat
   JS), tapi animasi ambient/loop yang terus-menerus jalan (blob,
   breathing badge, shimmer, parallax orb) dimatikan karena ini yang
   paling sering memicu rasa tidak nyaman / motion sickness pada
   pengguna yang mengaktifkan setting ini di OS mereka. */
@media (prefers-reduced-motion: reduce) {

    .logo-blob,
    .ios-breathe,
    .progress-fill::after,
    .skeleton-pulse {
        animation: none !important;
    }

    .orb {
        display: none !important;
    }
}

/* ══════════════════════════════════════════════════
   Modul Guru & Siswa — Utility Classes
   ══════════════════════════════════════════════════ */

/* Badge component */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Glass Ultra — modal surface */
.glass-ultra {
    background: var(--glass-bg-3, rgba(255, 255, 255, 0.97));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.72));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

body.dark .glass-ultra {
    background: var(--glass-bg-3, rgba(15, 24, 40, 0.97));
    border-color: var(--glass-border, rgba(255, 255, 255, 0.08));
}

/* ═══════════════════════════════════════════════
   MODAL / POPUP SYSTEM — Standar terpusat (UI-STANDARDIZE)
   Gunakan class ini di semua popup agar konsisten.
   ═══════════════════════════════════════════════ */

/* Overlay backdrop standar */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--modal-backdrop, rgba(11, 15, 26, 0.4));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: auto;
}

/* BUG-FIX #4: Saat modal-overlay ditampilkan, HARUS menggunakan display:flex
   agar align-items/justify-content (centering) bekerja.
   Gunakan class .show untuk toggle — jangan ubah display ke 'block'. */
.modal-overlay.show {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

/* Box modal standar — border-radius terpusat dari token */
.modal-box {
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: var(--modal-radius, 24px);
    box-shadow: var(--modal-shadow, 0 32px 80px rgba(0, 0, 0, 0.22));
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    scrollbar-width: none;
}

.modal-box::-webkit-scrollbar {
    display: none;
}

/* BUG-FIX #4b: .modal-box sendiri punya opacity:0 & scale(0.95) sebagai state awal,
   tapi sebelumnya tidak ada aturan yang mengembalikannya ke opacity:1 saat overlay
   berstatus .show — akibatnya overlay/blur muncul namun kotak modal tetap tak terlihat. */
.modal-overlay.show .modal-box {
    opacity: 1;
    transform: scale(1);
}

/* Ukuran variant */
.modal-box--sm {
    max-width: var(--modal-max-width-sm, 420px);
}

.modal-box--md {
    max-width: var(--modal-max-width-md, 560px);
}

.modal-box--lg {
    max-width: var(--modal-max-width-lg, 800px);
}

/* Header standar */
.modal-header {
    padding: 20px 24px 0;
    padding-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--divider, rgba(0, 0, 0, 0.06));
}

.modal-header h2,
.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

/* Body padding standar */
.modal-body {
    padding: 20px 24px;
}

/* Footer standar */
.modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--divider, rgba(0, 0, 0, 0.06));
}

/* Stretch-physics button — scale X/Y on active */
.btn-stretch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-stretch:hover {
    transform: scaleX(1.04) scaleY(0.96);
}

.btn-stretch:active {
    transform: scaleX(0.96) scaleY(1.04);
}

/* === iOS Modern Buttons === */
.ios-btn {
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.84rem;
    padding: 0 16px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.ios-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    opacity: 0;
    transition: opacity 0.25s;
}

.ios-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.ios-btn:hover::after {
    opacity: 1;
}

.ios-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ios-btn:disabled,
.ios-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    pointer-events: none;
}

.ios-btn i {
    font-size: 16px;
}

/* Variants */
.ios-btn-primary {
    background: linear-gradient(180deg, #5CA4FF 0%, #007AFF 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 122, 255, 0.3);
}

.ios-btn-success {
    background: linear-gradient(180deg, #34D058 0%, #28A745 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.3);
}

.ios-btn-danger {
    background: linear-gradient(180deg, #FF6B6B 0%, #FF3B30 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(255, 59, 48, 0.3);
}

.ios-btn-warning {
    background: linear-gradient(180deg, #FFD166 0%, #FF9500 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(255, 149, 0, 0.3);
}

.ios-btn-info {
    background: linear-gradient(180deg, #64D2FF 0%, #5AC8FA 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(90, 200, 250, 0.3);
}

.ios-btn-dark {
    background: linear-gradient(180deg, #4A4A4A 0%, #1C1C1E 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(28, 28, 30, 0.3);
}

.ios-btn-secondary {
    background: #F2F2F7;
    color: #007AFF;
    box-shadow: none;
}