/* ============================================================
   DompetKu - Style Utama
   Desain: Modern, Clean, Mobile-first
   ============================================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #14b8a6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
    --shadow-lg: 0 10px 40px rgba(99, 102, 241, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
}

/* ============ DARK MODE ============ */
html[data-theme="dark"] {
    --bg: #0f1424;
    --card-bg: #1a2138;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #2d3654;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .login-body {
    background: linear-gradient(135deg, #2a2f6e 0%, #0d4f48 100%);
}

html[data-theme="dark"] .calc-display { background: #060a16; }
html[data-theme="dark"] .calc-btn { background: #242c4a; color: var(--text); }
html[data-theme="dark"] .calc-btn.op { background: #2b2f5e; color: var(--primary-light); }
html[data-theme="dark"] .calc-btn.clear { background: #3a1f2e; color: var(--danger); }
html[data-theme="dark"] tbody tr:hover { background: #20283f; }
html[data-theme="dark"] th { background: #161d33; }
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group textarea { background: #11182c; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .btn-secondary { background: #20283f; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .jenis-box { background: #11182c; }
html[data-theme="dark"] .jenis-box.jenis-masuk.selected { background: #0c2920; }
html[data-theme="dark"] .jenis-box.jenis-keluar.selected { background: #2a1414; }
html[data-theme="dark"] code { background: #11182c; padding: 2px 6px; border-radius: 4px; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html { transition: background-color 0.3s ease; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.card, .stat-card, .app-header, .bottom-nav, .modal-box, table, th, td, input, select, textarea, .calc-display, .calc-btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

a { text-decoration: none; color: var(--primary); }

/* ============ LOGIN PAGE ============ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #14b8a6 100%);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-bg-shapes { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    animation: float 8s ease-in-out infinite;
}
.shape1 { width: 300px; height: 300px; top: -100px; left: -100px; }
.shape2 { width: 200px; height: 200px; bottom: -50px; right: -50px; animation-delay: 2s; }
.shape3 { width: 150px; height: 150px; top: 40%; right: 10%; animation-delay: 4s; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.05); }
}

.login-wrapper { position: relative; z-index: 1; width: 100%; max-width: 420px; }

.login-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon {
    font-size: 48px;
    width: 80px; height: 80px;
    margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px;
    box-shadow: var(--shadow);
}
.login-logo h1 { font-size: 26px; color: var(--text); font-weight: 800; }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: all 0.2s ease;
    background: #fff;
    color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}

.btn {
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.btn-primary:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-secondary { background: var(--bg); color: var(--text); border: 2px solid var(--border); }
.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: #fff; }
.btn-danger { background: linear-gradient(135deg, var(--danger), #dc2626); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-footer { text-align: center; margin-top: 20px; }
.link-public { font-size: 13px; font-weight: 600; color: var(--secondary); }
.copyright { text-align: center; color: rgba(255,255,255,0.8); font-size: 12px; margin-top: 16px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    font-weight: 600;
    animation: popIn 0.3s ease;
}
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }

html[data-theme="dark"] .alert-error { background: #2a1414; color: #f87171; border-color: #4a1f1f; }
html[data-theme="dark"] .alert-success { background: #0c2920; color: #34d399; border-color: #1a4a3a; }
html[data-theme="dark"] .alert-warning { background: #2a2010; color: #fbbf24; border-color: #4a3a1a; }
html[data-theme="dark"] .alert-info { background: #14213a; color: #60a5fa; border-color: #1f3a5f; }

/* ============ APP LAYOUT ============ */
.app-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.app-header .brand .ico {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.user-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); padding: 6px 12px; border-radius: 100px; font-size: 13px; font-weight: 600;
}
.user-chip .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}

.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 100px; }

/* ============ STAT CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; width: 5px; height: 100%;
}
.stat-card.saldo::before { background: var(--primary); }
.stat-card.masuk::before { background: var(--success); }
.stat-card.keluar::before { background: var(--danger); }
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 8px; }
.stat-card.saldo .value { color: var(--primary); }
.stat-card.masuk .value { color: var(--success); }
.stat-card.keluar .value { color: var(--danger); }
.stat-card .icon { position: absolute; right: 16px; top: 16px; font-size: 28px; opacity: 0.15; }

/* ============ CARD ============ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-title {
    font-size: 16px; font-weight: 800; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between;
}

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--bg); font-weight: 700; color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

.badge { padding: 4px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; display: inline-block; }
.badge-masuk { background: #d1fae5; color: #059669; }
.badge-keluar { background: #fee2e2; color: #dc2626; }
.badge-aktif { background: #d1fae5; color: #059669; }
.badge-koreksi { background: #fef3c7; color: #d97706; }
.badge-batal { background: #f1f5f9; color: #64748b; }
.badge-pending { background: #fef3c7; color: #d97706; }
.badge-approved { background: #d1fae5; color: #059669; }
.badge-rejected { background: #fee2e2; color: #dc2626; }

.amount-masuk { color: var(--success); font-weight: 700; }
.amount-keluar { color: var(--danger); font-weight: 700; }

/* ============ FORM SEARCH ============ */
.search-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr) auto;
    gap: 10px;
    align-items: end;
}
@media (max-width: 900px) {
    .search-bar { grid-template-columns: 1fr 1fr; }
    .search-bar .btn { grid-column: span 2; }
}
.search-bar .form-group { margin-bottom: 0; }
.search-bar label { font-size: 11px; }
.search-bar input, .search-bar select { padding: 10px 12px; font-size: 13px; }

/* ============ BOTTOM NAV (Mobile) ============ */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    z-index: 99;
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    padding: 4px 14px; border-radius: 12px; transition: all 0.2s;
}
.bottom-nav a.active { color: var(--primary); background: #eef2ff; }
.bottom-nav .nav-icon { font-size: 20px; }

@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .container { padding-bottom: 40px; }
}

/* ============ FAB Calculator Button ============ */
.fab-calc {
    position: fixed;
    bottom: 90px; right: 20px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), #0d9488);
    color: #fff;
    border: none;
    font-size: 24px;
    box-shadow: 0 6px 20px rgba(20,184,166,0.4);
    cursor: pointer;
    z-index: 98;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
.fab-calc:active { transform: scale(0.9); }
@media (min-width: 768px) { .fab-calc { bottom: 30px; } }

/* ============ Calculator Modal ============ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 200; padding: 16px; backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    width: 100%; max-width: 320px;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.2s ease;
}
@keyframes popIn { from{transform:scale(0.9); opacity:0} to{transform:scale(1); opacity:1} }

.modal-box.modal-wide { max-width: 480px; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h3 { font-size: 16px; font-weight: 800; }
.modal-close { background: var(--bg); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; }

.calc-display {
    background: var(--text); color: #fff;
    border-radius: var(--radius-sm);
    padding: 20px 16px;
    text-align: right;
    font-size: 28px; font-weight: 700;
    margin-bottom: 14px;
    word-break: break-all;
    min-height: 70px;
    display: flex; flex-direction: column; justify-content: flex-end;
}
.calc-display .calc-sub { font-size: 13px; color: #94a3b8; min-height: 16px; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.calc-btn {
    padding: 16px 0; border-radius: var(--radius-sm); border: none;
    font-size: 18px; font-weight: 700; cursor: pointer;
    background: var(--bg); color: var(--text);
    transition: all 0.1s;
}
.calc-btn:active { transform: scale(0.95); }
.calc-btn.op { background: #eef2ff; color: var(--primary); }
.calc-btn.equal { background: var(--primary); color: #fff; grid-row: span 2; height: 100%; }
.calc-btn.clear { background: #fee2e2; color: var(--danger); }
.calc-btn.zero { grid-column: span 2; }

/* ============ Misc ============ */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

.flow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .flow-grid { grid-template-columns: 1fr; } }

.realtime-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--success); margin-right: 6px;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
    70% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.text-muted { color: var(--text-muted); font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.tag-pill {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--bg); padding: 4px 10px; border-radius: 100px;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
}

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 100px; margin-bottom: 16px; overflow-x: auto; }
.tab-item {
    flex: 1; text-align: center; padding: 10px 16px; border-radius: 100px;
    font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer;
    white-space: nowrap; transition: all 0.2s;
}
.tab-item.active { background: var(--card-bg); color: var(--primary); box-shadow: var(--shadow); }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700;
    background: var(--bg); color: var(--text-muted);
}
.pagination a.active, .pagination .current { background: var(--primary); color: #fff; }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 16px;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.loading-overlay.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-spinner {
    width: 56px; height: 56px;
    border: 5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    font-weight: 800; font-size: 14px; color: var(--text-muted);
    display: flex; align-items: center; gap: 8px;
}
.loading-logo {
    width: 64px; height: 64px; border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    animation: pulseLogo 1.2s ease-in-out infinite;
    box-shadow: var(--shadow-lg);
}
@keyframes pulseLogo {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Inline button loading state */
.btn.is-loading { pointer-events: none; opacity: 0.75; position: relative; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading::after {
    content: '';
    position: absolute; left: 50%; top: 50%;
    width: 18px; height: 18px; margin: -9px 0 0 -9px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.btn-secondary.is-loading::after, .btn.is-loading.btn-secondary::after {
    border: 2.5px solid rgba(99,102,241,0.25);
    border-top-color: var(--primary);
}

/* Page transition fade */
.page-fade { animation: pageFadeIn 0.35s ease; }
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CONFIRM MODAL (Replace native confirm())
   ============================================================ */
.confirm-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.55);
    display: none; align-items: center; justify-content: center;
    z-index: 300; padding: 16px; backdrop-filter: blur(3px);
}
.confirm-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
.confirm-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 24px;
    width: 100%; max-width: 340px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.25s ease;
}
.confirm-icon {
    width: 64px; height: 64px; margin: 0 auto 14px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
}
.confirm-icon.question { background: #eef2ff; color: var(--primary); }
.confirm-icon.danger { background: #fef2f2; color: var(--danger); }
.confirm-icon.warning { background: #fffbeb; color: var(--warning); }
.confirm-icon.success { background: #f0fdf4; color: var(--success); }
.confirm-title { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.confirm-message { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast-container {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 400; display: flex; flex-direction: column; gap: 8px;
    width: 100%; max-width: 360px; padding: 0 16px;
}
.toast {
    background: var(--card-bg); color: var(--text);
    padding: 14px 16px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 13px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
    animation: toastIn 0.3s ease;
    border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity:0; transform: translateY(-20px); } to { opacity:1; transform: translateY(0); } }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity:0; transform: translateY(-20px); } }

/* ============================================================
   DARK MODE TOGGLE
   ============================================================ */
.theme-toggle {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--bg); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   CHART / DASHBOARD EXTRAS
   ============================================================ */
.chart-card canvas { max-height: 280px; }
.chart-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chart-tab {
    padding: 6px 14px; border-radius: 100px; font-size: 12px; font-weight: 700;
    background: var(--bg); color: var(--text-muted); cursor: pointer; border: 1px solid var(--border);
}
.chart-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   EXPORT BUTTONS
   ============================================================ */
.export-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.export-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 700; cursor: pointer; border: 1px solid var(--border);
    background: var(--bg); color: var(--text);
}
.export-btn.excel { color: #16a34a; }
.export-btn.pdf { color: #dc2626; }

/* ============================================================
   INFO CARD VARIANTS (dark-mode aware)
   ============================================================ */
.card-info-warning { background:#fffbeb; border: 1px solid #fde68a; }
.card-info-danger { background:#fef2f2; border: 1px solid #fecaca; }
.card-info-primary { background:#eef2ff; border: 1px solid #c7d2fe; }
.card-info-success { background:#f0fdf4; border: 1px solid #bbf7d0; }

html[data-theme="dark"] .card-info-warning { background:#2a2010; border-color:#4a3a1a; }
html[data-theme="dark"] .card-info-danger { background:#2a1414; border-color:#4a1f1f; }
html[data-theme="dark"] .card-info-primary { background:#181f3a; border-color:#2d3a6b; }
html[data-theme="dark"] .card-info-success { background:#0c2920; border-color:#1a4a3a; }

/* ============ Dark mode badge adjustments ============ */
html[data-theme="dark"] .badge-masuk,
html[data-theme="dark"] .badge-aktif,
html[data-theme="dark"] .badge-approved { background: #0c2920; color: #34d399; }

html[data-theme="dark"] .badge-keluar,
html[data-theme="dark"] .badge-rejected { background: #2a1414; color: #f87171; }

html[data-theme="dark"] .badge-koreksi,
html[data-theme="dark"] .badge-pending { background: #2a2010; color: #fbbf24; }

html[data-theme="dark"] .badge-batal { background: #1f2640; color: #94a3b8; }

html[data-theme="dark"] .amount-masuk { color: #34d399; }
html[data-theme="dark"] .amount-keluar { color: #f87171; }

html[data-theme="dark"] .tag-pill { background: #1f2640; color: #94a3b8; }

html[data-theme="dark"] .empty-state { color: #64748b; }

html[data-theme="dark"] .stat-card.masuk .value { color: #34d399; }
html[data-theme="dark"] .stat-card.keluar .value { color: #f87171; }
html[data-theme="dark"] .stat-card.saldo .value { color: #818cf8; }

html[data-theme="dark"] .export-btn { background: #1f2640; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .export-btn.excel { color: #34d399; }
html[data-theme="dark"] .export-btn.pdf { color: #f87171; }

html[data-theme="dark"] .pagination a, html[data-theme="dark"] .pagination span { background: #1f2640; color: var(--text-muted); }
html[data-theme="dark"] .chart-tab { background: #1f2640; color: var(--text-muted); border-color: var(--border); }

/* ============ Code / Kode Transaksi Link ============ */
code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}
a code {
    color: var(--primary);
    font-weight: 700;
}
a:hover code { background: #eef2ff; }
html[data-theme="dark"] a:hover code { background: #1f2640; }

/* ============================================================
   APP LAYOUT v2 — Sidebar (Desktop) + Bottom Nav (Mobile)
   ============================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar (Desktop/Tablet) ---------- */
.sidebar {
    display: none;
    width: 240px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 18px;
    padding: 0 10px 20px;
}
.sidebar .brand .ico {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-weight: 700; font-size: 14px;
    transition: all 0.15s;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav a.active { background: #eef2ff; color: var(--primary); }
html[data-theme="dark"] .sidebar-nav a.active { background: #181f3a; color: var(--primary-light); }
.sidebar-nav .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-nav .nav-divider { height: 1px; background: var(--border); margin: 10px 6px; }
.sidebar-nav .nav-section-label {
    font-size: 11px; font-weight: 800; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 14px 4px;
}
.sidebar-cta {
    margin: 14px 6px; padding: 14px;
    background: linear-gradient(135deg, var(--success), #059669);
    border-radius: var(--radius-sm); color: #fff; text-align: center;
    font-weight: 800; font-size: 14px; display: block;
}
.sidebar-cta:hover { opacity: 0.92; }

/* ---------- Main content area ---------- */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

@media (min-width: 900px) {
    .sidebar { display: block; }
    .container { max-width: 1000px; padding: 24px 28px 60px; margin: 0; }
    .app-header { display: none; } /* header lama disembunyikan, header baru ada di topbar */
    .topbar { display: flex; }
}

/* ---------- Topbar (Desktop) ---------- */
.topbar {
    display: none;
    align-items: center; justify-content: space-between;
    padding: 16px 28px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 90;
}
.topbar h2 { font-size: 18px; font-weight: 800; }

/* ---------- Mobile Top Header ---------- */
.mobile-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
@media (min-width: 900px) { .mobile-header { display: none; } }
.mobile-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.mobile-header .brand .ico {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center; font-size: 17px;
}

/* ---------- User Dropdown Menu ---------- */
.user-menu { position: relative; }
.user-menu-trigger {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); padding: 6px 12px; border-radius: 100px;
    font-size: 13px; font-weight: 700; cursor: pointer; border: none;
    color: var(--text);
}
.user-menu-trigger .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}
.user-menu-trigger .chevron { font-size: 10px; transition: transform 0.2s; color: var(--text-muted); }
.user-menu.open .chevron { transform: rotate(180deg); }

.user-menu-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--card-bg); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border);
    width: 220px; padding: 8px; z-index: 150;
    display: none; flex-direction: column; gap: 2px;
    animation: popIn 0.15s ease;
}
.user-menu.open .user-menu-dropdown { display: flex; }
.user-menu-dropdown .dropdown-header {
    padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.user-menu-dropdown .dropdown-header .name { font-weight: 800; font-size: 14px; }
.user-menu-dropdown .dropdown-header .role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.user-menu-dropdown a, .user-menu-dropdown button {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 700; color: var(--text);
    text-align: left; width: 100%; border: none; background: none; cursor: pointer;
}
.user-menu-dropdown a:hover, .user-menu-dropdown button:hover { background: var(--bg); }
.user-menu-dropdown .dd-icon { font-size: 16px; width: 20px; text-align: center; }
.user-menu-dropdown .dd-danger { color: var(--danger); }
.user-menu-dropdown .dd-danger:hover { background: #fef2f2; }
html[data-theme="dark"] .user-menu-dropdown .dd-danger:hover { background: #2a1414; }

/* ---------- Bottom Nav v2 (Mobile) ---------- */
.bottom-nav-v2 {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
    z-index: 99;
}
@media (min-width: 900px) { .bottom-nav-v2 { display: none; } }

.bottom-nav-v2 a, .bottom-nav-v2 .bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 700; color: var(--text-muted);
    padding: 6px 10px; border-radius: 12px; transition: all 0.2s; flex: 1;
    cursor: pointer;
}
.bottom-nav-v2 a.active { color: var(--primary); }
.bottom-nav-v2 .nav-icon { font-size: 20px; }

/* Center FAB-style Add button */
.bottom-nav-v2 .bn-fab-wrap { flex: 1; display: flex; justify-content: center; position: relative; }
.bottom-nav-v2 .bn-fab {
    width: 54px; height: 54px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 26px; box-shadow: 0 6px 16px rgba(99,102,241,0.4);
    position: relative; top: -16px; border: 4px solid var(--card-bg);
    text-decoration: none;
}
.bottom-nav-v2 .bn-fab:active { transform: scale(0.93); }
.bottom-nav-v2 .bn-fab-label { font-size: 10px; font-weight: 800; color: var(--primary); position: relative; top: -10px; }

@media (min-width: 900px) {
    .container { padding-bottom: 40px; }
}

/* Adjust container top padding since mobile-header replaces app-header */
@media (max-width: 899px) {
    .container { padding-top: 16px; }
}

/* ============================================================
   MOBILE BOTTOM SHEET MENU (untuk tombol "Menu" di bottom nav)
   ============================================================ */
.sheet-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    display: none; align-items: flex-end; justify-content: center;
    z-index: 250; backdrop-filter: blur(2px);
}
.sheet-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
.sheet-box {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    width: 100%; max-width: 480px;
    padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    animation: sheetUp 0.25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
    width: 40px; height: 4px; background: var(--border); border-radius: 100px;
    margin: 8px auto 12px;
}
.sheet-header { padding: 0 16px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sheet-header .name { font-weight: 800; font-size: 16px; }
.sheet-header .role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sheet-box a, .sheet-box button {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 12px;
    font-size: 14px; font-weight: 700; color: var(--text);
    width: 100%; text-align: left; border: none; background: none; cursor: pointer;
}
.sheet-box a:active, .sheet-box button:active { background: var(--bg); }
.sheet-box .dd-icon { font-size: 20px; width: 24px; text-align: center; }
.sheet-box .dd-danger { color: var(--danger); }

/* ============================================================
   QR SCANNER MODAL
   ============================================================ */
.scan-fab {
    position: fixed;
    bottom: 90px; left: 50%; transform: translateX(-50%);
    width: 60px; height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    font-size: 26px;
    box-shadow: 0 6px 20px rgba(99,102,241,0.45);
    cursor: pointer;
    z-index: 98;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
.scan-fab:active { transform: translateX(-50%) scale(0.9); }

/* Saat sudah login, bottom-nav sudah punya FAB tengah (tambah transaksi),
   jadi tombol scan dipindah ke kiri bawah agar tidak tumpang tindih */
@media (max-width: 899px) {
    body.has-bottom-nav .scan-fab {
        left: 16px; bottom: 96px; transform: none;
        width: 50px; height: 50px; font-size: 22px;
    }
    body.has-bottom-nav .scan-fab:active { transform: scale(0.9); }
    body.has-bottom-nav .fab-calc { bottom: 96px; }
}

@media (min-width: 900px) {
    .scan-fab {
        bottom: 30px; left: auto; right: 96px; transform: none;
        width: 56px; height: 56px;
    }
    .scan-fab:active { transform: scale(0.9); }
}

.scan-modal .modal-box {
    max-width: 380px;
    padding: 0;
    overflow: hidden;
}
.scan-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.scan-header h3 { font-size: 16px; font-weight: 800; }

.scan-body { padding: 18px; }
.scan-viewport {
    position: relative;
    width: 100%; aspect-ratio: 1/1;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.scan-viewport video {
    width: 100%; height: 100%; object-fit: cover;
}
.scan-viewport canvas { display: none; }
.scan-frame {
    position: absolute; inset: 12%;
    border: 3px solid var(--primary);
    border-radius: 16px;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
    pointer-events: none;
}
.scan-frame::before, .scan-frame::after {
    content: ''; position: absolute; width: 24px; height: 24px;
    border: 4px solid #fff;
}
.scan-frame::before { top: -4px; left: -4px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-frame::after { bottom: -4px; right: -4px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }

.scan-line {
    position: absolute; left: 12%; right: 12%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: scanMove 2s ease-in-out infinite;
}
@keyframes scanMove {
    0%, 100% { top: 12%; }
    50% { top: 88%; }
}

.scan-placeholder {
    color: #fff; text-align: center; padding: 20px;
}
.scan-placeholder .icon { font-size: 40px; margin-bottom: 8px; }
.scan-placeholder p { font-size: 13px; opacity: 0.85; }

.scan-status {
    margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; text-align: center;
    background: var(--bg); color: var(--text-muted);
}
.scan-status.success { background: #f0fdf4; color: #16a34a; }
.scan-status.error { background: #fef2f2; color: #dc2626; }
html[data-theme="dark"] .scan-status.success { background: #0c2920; color: #34d399; }
html[data-theme="dark"] .scan-status.error { background: #2a1414; color: #f87171; }

.scan-actions { display: flex; gap: 10px; margin-top: 14px; }
.scan-actions .btn { flex: 1; }

.scan-tip {
    font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 10px;
}
