/* ==========================================================================
   1. CSS VARIABLES & THEME ENGINE
   ========================================================================== */
:root {
    --primary: #4f46e5; --primary-hover: #4338ca; --primary-light: rgba(79, 70, 229, 0.1);
    --success: #10b981; --danger: #ef4444; --warning: #f59e0b; --info: #3b82f6;
    --crypto: #f7931a; --purple: #8b5cf6;
    
    /* Light Mode */
    --bg-body: #f8fafc; --bg-surface: #ffffff;
    --text-main: #0f172a; --text-muted: #64748b;
    --border: #e2e8f0; --input-bg: #f1f5f9;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 10px 15px -3px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius-lg: 16px; --radius-md: 12px; --radius-sm: 8px;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --hover-row: #f8fafc;
}

[data-theme="dark"] {
    --bg-body: #0b1120; 
    --bg-surface: #1e293b; 
    --text-main: #f1f5f9; 
    --text-muted: #94a3b8;
    --border: #334155; 
    --input-bg: #0f172a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.5);
    --glass-bg: rgba(30, 41, 59, 0.85);
    --hover-row: #0f172a;
}

/* ==========================================================================
   2. GLOBAL RESETS & LAYOUT
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; transition: background-color 0.25s, border-color 0.25s, color 0.25s; }
h1, h2, h3, .brand { font-family: 'Poppins', sans-serif; }

body { background-color: var(--bg-body); color: var(--text-main); height: 100vh; width: 100%; overflow-x: hidden; display: flex; }
button { cursor: pointer; border: none; background: none; font-weight: 500; color: inherit; transition: all 0.2s; }
input, select { font-family: inherit; }
a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Sidebar --- */
aside { width: 280px; background: var(--bg-surface); border-right: 1px solid var(--border); padding: 24px 20px; display: flex; flex-direction: column; z-index: 20; flex-shrink: 0; overflow-y: auto;}
.brand { font-size: 1.5rem; font-weight: 800; color: var(--text-main); display: flex; align-items: center; gap: 10px; margin-bottom: 32px; letter-spacing: -0.5px;}
.brand span { 
    background: linear-gradient(135deg, var(--primary), #ec4899); 
    -webkit-background-clip: text; 
    background-clip: text; 
    -webkit-text-fill-color: transparent; 
    font-size: 24px;
}

nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--text-muted); border-radius: var(--radius-md); font-weight: 600; font-size: 0.85rem; text-decoration: none; position: relative; }
.nav-link:hover { background: var(--primary-light); color: var(--primary); }
.nav-link.active { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(79, 70, 229, 0.35); }
.nav-link.active .material-icons-round { color: white; }
.nav-link .material-icons-round { font-size: 28px; }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.profile-card { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--bg-body); border-radius: var(--radius-md); border: 1px solid var(--border); }
.profile-avatar { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #6366f1); color: white; display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 800; }
.btn-logout { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 8px; border-radius: var(--radius-sm); color: var(--danger); font-weight: 600; font-size: 0.8rem; border: 1px solid rgba(239, 68, 68, 0.2); background: rgba(239, 68, 68, 0.05); transition: all 0.2s; }
.btn-logout:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* --- Main Content --- */
main { flex: 1; display: flex; flex-direction: column; padding: 24px 32px; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth;}

header { max-width: 1400px; margin: 0 auto 14px auto; width: 100%; flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 8px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); z-index: 10; position: sticky; top: 0;}

.header-title h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.5px; line-height: 1.2; white-space: nowrap; }
.header-title p { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; font-weight: 500;}

.header-actions { display: flex; gap: 12px; align-items: center; flex-wrap: nowrap; }
.btn-icon { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main); border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; box-shadow: var(--shadow-sm); cursor: pointer;}
.btn-icon:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }

/* Time Machine Controls (Global/Desktop) */
.time-machine-group { display: flex; gap: 8px; align-items: center; background: var(--bg-surface); padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.time-machine-group select { 
    border: none; 
    background: transparent; 
    color: var(--text-main); 
    font-weight: 600; 
    font-size: 0.85rem; 
    padding: 6px 36px 6px 12px; /* Diubah: ruang kanan 36px untuk panah, kiri 12px */
    cursor: pointer; 
    outline: none; 
}
.time-machine-group select:focus { color: var(--primary); }

.view-section { max-width: 1400px; margin: 0 auto; width: 100%; display: none; flex-direction: column; animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1); gap: 14px; padding-bottom: 24px;}
.view-section.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================
   3. UI COMPONENTS (Cards, Grids, Forms, Tables)
   ========================================================== */
.panel { background: var(--bg-surface); padding: 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; width: 100%; position: relative;}
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.panel-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--text-main); flex-shrink: 0;}
.panel-title .material-icons-round { font-size: 18px; }
.panel-summary { background: rgba(79, 70, 229, 0.08); border: 1px solid rgba(79, 70, 229, 0.2); color: var(--primary); padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; white-space: nowrap;}

.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; } 
.grid-chart { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

.stat-card { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    padding: 20px 16px; /* <-- Padding diperbesar agar kotak lebih tinggi */
    background: var(--bg-surface); 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-md); 
    border: 1px solid var(--border); 
    transition: transform 0.2s, box-shadow 0.2s; 
    min-width: 0;
    min-height: 90px; /* <-- Mengunci tinggi minimal agar pasti setara */
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }

.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; flex-shrink: 0; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);}
.stat-info { flex: 1; min-width: 0; }
.stat-info h3 { font-size: 0.65rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.stat-info h2 { font-size: 1rem; font-weight: 800; color: var(--text-main); word-wrap: break-word; line-height: 1.2; letter-spacing: -0.5px;}

/* Financial Insight Banner */
.insight-banner { background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(236, 72, 153, 0.08)); border: 1px solid rgba(79, 70, 229, 0.2); border-left: 5px solid var(--primary); padding: 16px 24px; border-radius: var(--radius-lg); display: flex; align-items: center; gap: 16px; margin-bottom: 8px;}
.insight-banner .icon-box { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: flex; justify-content: center; align-items: center; flex-shrink: 0; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);}
.insight-text h4 { font-size: 0.95rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px;}
.insight-text p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5;}

/* Form Controls */
.form-group { width: 100%; margin-bottom: 16px; position: relative; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }
.form-control { width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background-color: var(--input-bg); color: var(--text-main); font-size: 0.85rem; outline: none; transition: all 0.2s; margin: 0; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); background-color: var(--bg-surface); }
.form-control::placeholder { color: var(--text-muted); opacity: 0.6; }

select.form-control { width: 100%; font-size: 0.95rem; padding: 8px 12px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; padding-right: 32px; cursor: pointer; }
select.time-select { 
    width: auto; 
    font-size: 0.85rem; 
    padding: 10px 12px; 
    appearance: none; 
    -webkit-appearance: none; 
    background-image: url("data:image/svg+xml;..."); 
    background-repeat: no-repeat; 
    background-position: right 12px center; /* Panah berada 12px dari dinding kanan */
    background-size: 16px; 
    padding-right: 36px; /* Batas teks berhenti 36px dari kanan (tidak menabrak panah) */
    cursor: pointer; 
}

[data-theme="dark"] select.form-control, [data-theme="dark"] select.time-select { background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); }

.format-helper { display: block; font-size: 0.75rem; font-weight: 700; color: var(--success); margin-top: 6px; min-height: 16px; opacity: 0.9; }

/* Buttons */
.btn-primary { width: 100%; padding: 8px; background: linear-gradient(135deg, var(--primary), #6366f1); color: white; font-weight: 600; font-size: 0.85rem; border-radius: var(--radius-sm); box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3); transition: all 0.2s;}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #b91c1c); box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3); }

/* Tables & Badges */
.table-wrapper { width: 100%; overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg-surface);}
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 600px; }
th { background: var(--bg-body); color: var(--text-muted); padding: 8px 12px; text-align: left; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; border-bottom: 1px solid var(--border); letter-spacing: 0.5px;}
td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem; vertical-align: middle; color: var(--text-main);}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover-row); }

.badge { padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-align: center; display: inline-block; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-income, .badge-buy, .badge-active { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2);}
.badge-expense, .badge-sell, .badge-inactive { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2);}
.badge-pay { background: rgba(139, 92, 246, 0.15); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.2); cursor: pointer; transition: all 0.2s;}
.badge-pay:hover { background: var(--purple); color: white; }

.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

/* Progress Bar */
.prog-container { width: 100%; background: var(--bg-body); border-radius: 10px; height: 10px; margin-top: 8px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.1); border: 1px solid var(--border);}
.prog-bar { height: 100%; border-radius: 10px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.chart-container { width: 100%; height: 320px; position: relative; }

/* ==========================================================
   4. MODALS, TOASTS, & LOGIN SCREEN
   ========================================================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; z-index: 99999; opacity: 0; visibility: hidden; transition: all 0.3s; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-card { background: var(--bg-surface); width: 90%; max-width: 420px; border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-lg); transform: scale(0.9); transition: all 0.3s; border: 1px solid var(--border);}
.modal-overlay.active .modal-card { transform: scale(1); }
.modal-title { font-size: 1.25rem; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; color: var(--text-main);}
.modal-body { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
.btn-modal { padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; }
.btn-cancel { background: var(--bg-body); color: var(--text-main); border: 1px solid var(--border); }
.btn-cancel:hover { background: var(--hover-row); border-color: var(--text-muted); }

#login-screen { position: fixed; inset: 0; background: var(--bg-body); display: flex; justify-content: center; align-items: center; z-index: 99999; }
.login-card { background: var(--bg-surface); padding: 48px 40px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; text-align: center; border: 1px solid var(--border); }

#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; pointer-events: none;}
.toast { background: var(--bg-surface); color: var(--text-main); padding: 16px 20px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); border-left: 5px solid var(--primary); display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 0.9rem; animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards, fadeOut 0.4s 4s forwards; border-right: 1px solid var(--border); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);}

.pwd-wrapper { position: relative; width: 100%; }
.pwd-wrapper input { padding-right: 45px; }
.btn-eye { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); background: none; border: none; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-eye:hover { color: var(--primary); }

@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(20px); visibility: hidden; } }

/* ==========================================================
   5. PROFILE PICTURE SETTINGS & RADIAL MENU (GLOBAL)
   ========================================================== */
.profile-avatar:has(img) { overflow: hidden !important; padding: 0 !important; background: transparent !important; display: flex !important; align-items: center !important; justify-content: center !important; }
.profile-avatar img { width: 100% !important; height: 100% !important; object-fit: cover !important; display: block !important; }
#sidebar .profile-avatar { width: 42px !important; height: 42px !important; margin-left: 18px !important; border-radius: 10px !important; flex-shrink: 0 !important; }

header .profile-avatar.header-avatar-mobile, header .header-lock-mobile { display: none; }

.hover-menu-wrapper { position: relative; display: inline-flex; align-items: center; padding-left: 20px; }
.hover-menu-wrapper .main-circle { width: 42px; height: 42px; border-radius: 50%; background: transparent; display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: var(--shadow-md); z-index: 10; position: relative; transition: transform 0.2s ease; overflow: hidden; }
.hover-menu-wrapper .main-circle img { width: 100%; height: 100%; object-fit: cover; }
.hover-menu-wrapper .main-circle:hover { transform: scale(1.05); }
.hover-menu-wrapper .submenu-container { position: absolute; right: 36px; display: flex; flex-direction: row; gap: 2px; padding-right: 15px; z-index: 5; }
.hover-menu-wrapper .sub-circle { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-surface); color: var(--text-main); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: flex; justify-content: center; align-items: center; cursor: pointer; outline: none; opacity: 0; transform: scale(0) translateX(20px); pointer-events: none; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55), background-color 0.2s, box-shadow 0.2s; }
.hover-menu-wrapper .sub-circle i { font-size: 18px; }
.hover-menu-wrapper .sub-circle:hover { background: var(--hover-row); transform: scale(1.1) !important; }
.hover-menu-wrapper .submenu-container .sub-circle:nth-child(1) { background: var(--danger); color: white; border: none; }
.hover-menu-wrapper .submenu-container .sub-circle:nth-child(1):hover { background: #dc2626; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4); }
.hover-menu-wrapper .submenu-container .sub-circle:nth-child(2) { background: var(--info); color: white; border: none; }
.hover-menu-wrapper .submenu-container .sub-circle:nth-child(2):hover { background: #2563eb; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4); }
.hover-menu-wrapper:hover .sub-circle { opacity: 1; transform: scale(1) translateX(0); pointer-events: auto; }
.hover-menu-wrapper:hover .sub-circle:nth-child(3) { transition-delay: 0.05s; }
.hover-menu-wrapper:hover .sub-circle:nth-child(2) { transition-delay: 0.1s; }
.hover-menu-wrapper:hover .sub-circle:nth-child(1) { transition-delay: 0.15s; }

/* ==========================================================
   6. MEDIA QUERIES (DESKTOP & TABLET)
   ========================================================== */
@media (max-width: 1024px) { 
    .grid-chart { grid-template-columns: 1fr; } 
}

@media (min-width: 769px) {
    header div.hover-menu-wrapper div.main-circle.header-avatar-mobile,
    header .profile-avatar.header-avatar-mobile { 
        display: none !important; 
    }
    .header-actions { display: flex !important; align-items: center !important; flex-grow: 1 !important; }
    .time-machine-group { order: 1 !important; margin-left: auto !important; margin-right: 20px !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 12px !important; background: var(--bg-surface) !important; padding: 6px 20px !important; border-radius: 30px !important; border: 1px solid var(--border) !important; box-shadow: var(--shadow-sm) !important; height: 42px !important; flex-wrap: nowrap !important; }
    .time-machine-group select, .time-machine-group input[type="date"] { background-color: transparent !important; border: none !important; font-size: 0.85rem !important; font-weight: 600 !important; color: var(--text-main) !important; cursor: pointer !important; outline: none !important; }
    #filter-range-inputs { align-items: center !important; gap: 12px !important; }
    /* KODE BARU YANG SUDAH SEIMBANG */
    .time-machine-group select.time-select { 
        background-color: var(--bg-surface) !important; 
        color: var(--text-main) !important; 
        border: none !important; 
        font-size: 0.85rem !important; 
        font-weight: 600 !important; 
        cursor: pointer !important; 
        outline: none !important; 
        padding: 6px 36px 6px 12px !important; /* Disamakan: Kanan 36px, Kiri 12px */
        appearance: none !important; /* Menggunakan kustom ikon agar posisinya presisi */
        -webkit-appearance: none !important;
    }
    .time-machine-group select.time-select option { background-color: var(--bg-surface) !important; color: var(--text-main) !important; }
    .time-machine-group select.time-select:focus { color: var(--primary) !important; }

    .hover-menu-wrapper { order: 2 !important; display: flex !important; }
    .hover-menu-wrapper .submenu-container { position: static !important; opacity: 1 !important; visibility: visible !important; display: flex !important; flex-direction: row !important; gap: 12px !important; transform: none !important; pointer-events: auto !important; }
    .hover-menu-wrapper .submenu-container .sub-circle { position: static !important; opacity: 1 !important; width: auto !important; height: 40px !important; border-radius: var(--radius-sm) !important; padding: 0 16px !important; display: flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important; box-shadow: var(--shadow-sm) !important; transform: none !important; }
    
    .lock-btn { display: none !important; }
    .csv-btn { background: var(--primary) !important; color: white !important; border: none !important; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3) !important; }
    .csv-text { display: inline !important; font-weight: 600; font-size: 0.85rem; }
    .theme-btn { width: 40px !important; padding: 0 !important; background: var(--bg-surface) !important; border: 1px solid var(--border) !important; color: var(--text-main) !important; }

    header-actions .lock-btn { 
        display: none !important; 
    }
}

/* ==========================================================
   7. MOBILE RESPONSIVE (≤768px) - NATIVE APP EXPERIENCE
   ========================================================== */
@media (max-width: 768px) {
    html, body { overflow-x: hidden; overscroll-behavior-y: none; font-size: 14px; }
    body { display: block !important; }
    
    #app-wrapper { display: flex; flex-direction: column !important; width: 100%; min-height: 100vh; padding-bottom: calc(75px + env(safe-area-inset-bottom)); box-sizing: border-box; }
    main { padding: 12px; width: 100%; box-sizing: border-box; margin: 0; flex: 1; gap: 12px; overflow-x: hidden; }

    /* Bottom Navigation Bar */
    aside { position: fixed; bottom: 0; left: 0; width: 100%; height: 75px; background: color-mix(in srgb, var(--bg-surface) 90%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--border); border-right: none; padding: 4px 8px env(safe-area-inset-bottom) 8px; display: flex !important; flex-direction: row; justify-content: space-around; align-items: center; z-index: 1000; box-shadow: 0 -4px 20px rgba(0,0,0,0.04); }
    [data-theme="dark"] aside { background: color-mix(in srgb, var(--bg-surface) 90%, transparent); }
    .brand, .sidebar-footer { display: none !important; } 
    nav { display: flex !important; flex-direction: row !important; width: 100%; justify-content: space-around; padding: 0; gap: 0; }
    .nav-link { flex: 1; flex-direction: column; justify-content: center; align-items: center; padding: 4px; min-height: 44px; color: var(--text-muted); background: transparent; gap: 4px; }
    .nav-link .material-icons-round { font-size: 22px; margin: 0; transition: all 0.2s ease; }
    .nav-link span { font-size: 0.65rem; font-weight: 600; display: block; text-align: center; }
    .nav-link.active { color: var(--primary); font-weight: 700; background: transparent; box-shadow: none; }
    .nav-link.active .material-icons-round { background: var(--primary-light); padding: 4px 14px; border-radius: 12px; color: var(--primary); }

    /* Mobile Header Controls */
    header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 16px; }
    .header-title { flex: 1; min-width: 0; }
    .header-actions { display: contents; }
    #btn-theme-toggle, #btn-export-csv, .header-lock-mobile, .header-avatar-mobile { width: 38px !important; height: 38px !important; min-width: unset !important; padding: 0 !important; border-radius: 50% !important; flex-shrink: 0; display: flex !important; align-items: center; justify-content: center; }
    #btn-theme-toggle { order: 1; margin-left: 6px; position: relative !important; }
    #btn-export-csv { order: 2; margin-left: 6px; position: relative !important; font-size: 0 !important; }
    .header-lock-mobile { order: 3; margin-left: 6px; position: relative !important; font-size: 0 !important; }
    .header-avatar-mobile { order: 4; margin-left: 6px; position: relative !important; }
    #btn-theme-toggle .material-icons-round, #btn-export-csv .material-icons-round, .header-lock-mobile .material-icons-round { position: absolute !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; margin: 0 !important; font-size: 20px !important; line-height: 1 !important; }
    #btn-export-csv span:not(.material-icons-round) { display: none !important; }

    /* --- THE FINAL CALENDAR / FILTER FIX (CSS GRID) --- */
    .time-machine-group {   
        order: 5 !important;
        width: 100% !important;
        max-width: 100% !important; 
        box-sizing: border-box !important;
        margin-top: 12px !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; /* INI KUNCI ANTI-MELEBAR */
        gap: 8px !important;
        background: transparent !important; 
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    .time-machine-group > .material-icons-round { display: none !important; }

    .time-machine-group select#filter-mode {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        background-color: var(--bg-surface) !important;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius-sm) !important;
        padding: 6px 24px 6px 8px !important; /* Nilai Disamakan */
        background-position: right 8px center !important; /* Nilai Disamakan */
        font-size: 0.75rem !important; 
        font-weight: 700 !important;
        color: var(--primary) !important;
        text-align: center !important;
        text-align-last: center !important; 
        box-shadow: var(--shadow-sm) !important;
        height: 34px !important; 
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    .time-machine-group select#filter-month,
    .time-machine-group select#filter-year {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        background-color: var(--bg-surface) !important;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius-sm) !important;
        padding: 6px 24px 6px 8px !important; /* Nilai Disamakan */
        background-position: right 8px center !important; /* Nilai Disamakan */
        background-size: 12px !important;
        font-size: 0.75rem !important; 
        font-weight: 600 !important;
        color: var(--text-main) !important;
        text-align: center !important;
        text-align-last: center !important;
        box-shadow: var(--shadow-sm) !important;
        height: 34px !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    #filter-range-inputs {
        grid-column: 1 / -1 !important; /* Penuhi 1 baris */
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        background-color: var(--bg-surface) !important;
        border: 1px solid var(--border) !important;
        border-radius: var(--radius-sm) !important;
        padding: 4px 8px !important; 
        display: flex;
        justify-content: space-between !important;
        align-items: center !important;
        box-shadow: var(--shadow-sm) !important;
        height: 34px !important;
        gap: 4px !important;
    }

    #filter-range-inputs input[type="date"] {
        flex: 1 !important;
        min-width: 0 !important;
        width: 100% !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        background-color: transparent !important;
        border: none !important;
        font-size: 0.7rem !important; 
        font-weight: 600 !important;
        text-align: center !important;
        color: var(--text-main) !important;
        padding: 0 !important;
        margin: 0 !important;
        letter-spacing: -0.5px !important; 
    }

    #filter-range-inputs span { font-size: 0.75rem !important; margin: 0 !important; font-weight: bold; color: var(--text-muted); }

    /* Layout & Cards Fixes */
    .grid-4 { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .grid-2, .grid-3, .grid-chart { display: flex !important; flex-direction: column !important; gap: 12px; width: 100%; }
    
    .stat-card { display: flex !important; flex-direction: row !important; align-items: center !important; padding: 12px 10px !important; gap: 8px !important; }
    .stat-icon { width: 32px !important; height: 32px !important; font-size: 16px !important; border-radius: 8px !important; }
    .stat-info { width: 100% !important; overflow: hidden !important; }
    .stat-info h3 { font-size: 0.65rem !important; margin-bottom: 4px !important; white-space: nowrap !important; }
    .stat-info h2 { font-size: 0.95rem !important; line-height: 1.2 !important; word-wrap: break-word !important; }
    
    .insight-banner { flex-direction: row !important; align-items: center !important; padding: 8px 12px !important; gap: 8px !important; border-radius: 10px !important; border-left-width: 3px !important; margin-bottom: 0px !important; }
    .insight-banner .icon-box { width: 24px !important; height: 24px !important; font-size: 13px !important; box-shadow: none !important; }
    .insight-banner .insight-text p { font-size: 0.75rem !important; line-height: 1.3 !important; margin: 0 !important; }
    
    .view-section { gap: 12px !important; padding-bottom: 12px !important; }
    .panel { padding: 10px 12px !important; border-radius: var(--radius-md) !important; width: 100%; box-sizing: border-box; }
    .panel-header { margin-bottom: 8px !important; gap: 4px !important; }
    .panel-title { font-size: 0.85rem !important; gap: 6px !important; }
    .panel-title .material-icons-round { font-size: 16px !important; }
    .panel-summary { padding: 2px 8px !important; font-size: 0.7rem !important; }
    
    .balance-amount, .stat-number, .crypto-price { font-size: 0.8rem !important; font-weight: 700 !important; margin-top: 2px !important; margin-bottom: 2px !important; }
    .stat-label, .balance-label { font-size: 0.75rem !important; color: var(--text-muted); }
    .dashboard-grid, .stats-grid { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
    
    /* Table Fixes */
    .table-wrapper { width: calc(100% + 24px); margin: 0 -12px; padding: 0 12px; border-radius: 0; border-left: none; border-right: none; overflow-x: auto; -webkit-overflow-scrolling: touch; background: transparent; }
    table { width: 100%; min-width: 480px; background: var(--bg-surface); border-radius: 12px; }
    th, td { padding: 12px 10px; font-size: 0.8rem; }
    th { font-size: 0.7rem; }
    .transaction-item, .list-row, tr th, tr td { padding: 6px 8px !important; font-size: 0.75rem !important; }
    
    canvas { max-height: 180px !important; }
    .modal-card { width: 95%; padding: 20px; }
    }

/* ==========================================================================
   DASHBOARD LIVE METRICS SUB-TEXT (ANTI-FLICKER)
   ========================================================================== */
.stat-main-val {
    display: block; /* Memastikan angka utama mengambil baris penuh */
}

/* ==========================================================================
   DASHBOARD LIVE METRICS SUB-TEXT (REFINED STYLE)
   ========================================================================== */
.stat-main-val {
    display: block;
}

.stat-sub-val {
    display: block;
    font-size: 0.78rem; /* Sedikit lebih kecil & elegan */
    color: var(--text-muted, #9ca3af);
    font-weight: 400; /* Tidak tebal (Normal) */
    margin-top: 10px; /* Memberikan SPACE DI ATAS yang pas */
    line-height: 1.4;
    letter-spacing: 0.3px;
    text-transform: none;
}

/* Memastikan teks dinamis di dalam sub-val tidak ikut menjadi bold tebal */
.stat-sub-val span {
    font-weight: 500 !important; /* Ketebalan medium/ringan, tidak kontras ekstrem */
}
