/* ==========================================================================
   Kas Bani Achmad — lapisan desain (mobile-first, terang & gelap)
   Dibangun di atas Bootstrap 5.3 lokal. Semua warna lewat token di bawah.
   ========================================================================== */

@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/plus-jakarta-sans-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/plus-jakarta-sans-600.woff2") format("woff2");
    font-weight: 500 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/plus-jakarta-sans-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Plus Jakarta Sans";
    src: url("../fonts/plus-jakarta-sans-800.woff2") format("woff2");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* ---------------------------------------------------------------- Token */
:root,
[data-bs-theme="light"] {
    --app-bg: #f3f6f4;
    --app-surface: #ffffff;
    --app-surface-2: #f0f4f1;
    --app-border: #e2e8e4;
    --app-text: #13201a;
    --app-muted: #5d6d64;
    --app-primary: #15803d;          /* tombol & aksen (kontras putih 5:1) */
    --app-primary-hover: #116632;
    --app-primary-text: #15803d;     /* teks hijau di atas permukaan */
    --app-primary-soft: #e3f5e9;
    --app-income: #15803d;
    --app-income-soft: #e3f5e9;
    --app-expense: #c53030;
    --app-expense-soft: #fde8e8;
    --app-warn-soft: #fff4dc;
    --app-neutral-soft: #eef1ef;
    --app-hero-from: #15803d;
    --app-hero-to: #0f766e;
    --app-shadow: 0 1px 2px rgba(16, 32, 24, .05), 0 6px 20px rgba(16, 32, 24, .06);
    --app-shadow-lg: 0 10px 30px rgba(16, 32, 24, .12);
    --app-nav-bg: rgba(255, 255, 255, .92);
    --app-radius: 16px;
    --app-radius-sm: 12px;

    /* Grafik (palet kategorikal tervalidasi, langkah mode terang) */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --chart-text: #5d6d64;
    --chart-grid: #e6ebe8;
    --chart-surface: #ffffff;

    color-scheme: light;
}

[data-bs-theme="dark"] {
    --app-bg: #0c1210;
    --app-surface: #151c18;
    --app-surface-2: #1b241f;
    --app-border: #27322c;
    --app-text: #e6eee9;
    --app-muted: #9aaca2;
    --app-primary: #15803d;
    --app-primary-hover: #16913f;
    --app-primary-text: #4ade80;
    --app-primary-soft: #16301f;
    --app-income: #4ade80;
    --app-income-soft: #16301f;
    --app-expense: #f87171;
    --app-expense-soft: #3a1c1c;
    --app-warn-soft: #3a2f14;
    --app-neutral-soft: #1f2823;
    --app-hero-from: #14532d;
    --app-hero-to: #134e4a;
    --app-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
    --app-shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
    --app-nav-bg: rgba(21, 28, 24, .92);

    /* Grafik (langkah mode gelap dari palet yang sama) */
    --series-1: #3987e5;
    --series-2: #d95926;
    --chart-text: #9aaca2;
    --chart-grid: #27322c;
    --chart-surface: #151c18;

    color-scheme: dark;
}

/* Hubungkan token ke variabel Bootstrap */
:root,
[data-bs-theme] {
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-emphasis-color: var(--app-text);
    --bs-secondary-color: var(--app-muted);
    --bs-tertiary-bg: var(--app-surface-2);
    --bs-border-color: var(--app-border);
    --bs-link-color: var(--app-primary-text);
    --bs-link-hover-color: var(--app-primary-text);
    --bs-link-color-rgb: 21, 128, 61;
    --bs-font-sans-serif: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: 1rem;
    --bs-body-line-height: 1.55;
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 14px;
    --bs-card-bg: var(--app-surface);
}
[data-bs-theme="dark"] {
    --bs-link-color-rgb: 74, 222, 128;
}

/* ---------------------------------------------------------------- Dasar */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -.2em;
}

.text-muted, .text-body-secondary { color: var(--app-muted) !important; }
.text-success { color: var(--app-income) !important; }
.text-danger { color: var(--app-expense) !important; }
.money, .tabular { font-variant-numeric: tabular-nums; }
.fw-800 { font-weight: 800; }
.small, small { font-size: .875rem; }

a { text-underline-offset: 3px; }

:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--app-primary) 55%, transparent);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------- Header (atas) */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--app-nav-bg);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--app-border);
}

.app-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 60px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--app-text);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: -.01em;
    white-space: nowrap;
}
.app-brand:hover { color: var(--app-text); }

.brand-logo {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex: none;
}

.app-topnav {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-right: auto;
}

.app-topnav a {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .7rem;
    border-radius: 10px;
    color: var(--app-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: .93rem;
    white-space: nowrap;
}
/* Laptop kecil: menu admin cukup teks, nama akun disembunyikan agar tidak sesak */
@media (max-width: 1199.98px) {
    .app-topnav a .icon { display: none; }
}
@media (max-width: 1399.98px) {
    .account-btn .account-name { display: none; }
    .account-btn { padding: .25rem; }
}
.account-btn .account-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (min-width: 768px) {
    .seg-tabs { max-width: 560px; }
}
.app-topnav a:hover { background: var(--app-surface-2); color: var(--app-text); }
.app-topnav a.active { background: var(--app-primary-soft); color: var(--app-primary-text); }
.app-topnav .sep { width: 1px; height: 22px; background: var(--app-border); margin: 0 .35rem; }

.account-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    border-radius: 999px;
    padding: .25rem .75rem .25rem .25rem;
    min-height: 40px;
    font-weight: 600;
    font-size: .9rem;
}
.account-btn:hover { background: var(--app-surface-2); }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--app-primary-soft);
    color: var(--app-primary-text);
    font-weight: 800;
    font-size: .85rem;
}

/* Tombol cepat terang/gelap */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    padding: 0;
}
.theme-toggle:hover { background: var(--app-surface-2); }
.theme-toggle .icon { width: 20px; height: 20px; }
.theme-toggle .when-dark { display: none; }
[data-bs-theme="dark"] .theme-toggle .when-light { display: none; }
[data-bs-theme="dark"] .theme-toggle .when-dark { display: inline; }
.auth-theme { position: fixed; top: 14px; right: 14px; z-index: 10; }

/* Pilihan tampilan di menu akun */
.theme-seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-border);
}
.theme-seg button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 52px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--app-muted);
    font-size: .76rem;
    font-weight: 600;
}
.theme-seg button.active {
    background: var(--app-surface);
    color: var(--app-primary-text);
    box-shadow: var(--app-shadow);
}

.dropdown-menu {
    --bs-dropdown-bg: var(--app-surface);
    --bs-dropdown-border-color: var(--app-border);
    --bs-dropdown-link-hover-bg: var(--app-surface-2);
    --bs-dropdown-link-color: var(--app-text);
    --bs-dropdown-link-hover-color: var(--app-text);
    border-radius: var(--app-radius-sm);
    box-shadow: var(--app-shadow-lg);
    padding: .4rem;
    min-width: 230px;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    border-radius: 8px;
    padding: .6rem .7rem;
    font-weight: 500;
}

/* ---------------------------------------------------------------- Konten */
.app-main {
    padding-top: 1.25rem;
    padding-bottom: 2rem;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.1rem;
}

.page-title,
.app-main h1.h4 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0;
}

.page-sub {
    color: var(--app-muted);
    font-size: .9rem;
    margin: .15rem 0 0;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

/* ---------------------------------------------------------------- Kartu */
.card {
    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-card-cap-bg: transparent;
    --bs-card-border-radius: var(--app-radius);
    --bs-card-inner-border-radius: calc(var(--app-radius) - 1px);
    box-shadow: var(--app-shadow);
}
.card-header {
    padding: .9rem 1.1rem;
    border-bottom-color: var(--app-border);
    font-weight: 700;
}
.card-header.bg-white { background: transparent !important; }
.card-footer.bg-white { background: transparent !important; }
.card-body { padding: 1.1rem; }

.stat-card .card-body { padding: 1rem 1.1rem; }

.stat-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--app-muted);
    letter-spacing: .01em;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-top: .2rem;
}

.stat-icon {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--app-surface-2);
}
.stat-icon.in { background: var(--app-income-soft); color: var(--app-income); }
.stat-icon.out { background: var(--app-expense-soft); color: var(--app-expense); }

/* Kartu utama saldo */
.hero-card {
    position: relative;
    overflow: hidden;
    border: 0;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--app-hero-from), var(--app-hero-to));
    color: #fff;
    box-shadow: var(--app-shadow-lg);
}
.hero-card.is-alert {
    background: linear-gradient(135deg, #b42318, #9a3412);
}
[data-bs-theme="dark"] .hero-card.is-alert {
    background: linear-gradient(135deg, #7f1d1d, #7c2d12);
}
.hero-card::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
.hero-card .card-body { position: relative; z-index: 1; padding: 1.3rem 1.3rem 1.2rem; }
.hero-label { font-size: .85rem; font-weight: 600; opacity: .9; display: flex; align-items: center; gap: .4rem; }
.hero-value {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.15;
    margin: .25rem 0 .35rem;
    font-variant-numeric: tabular-nums;
}
.hero-meta { font-size: .82rem; opacity: .85; }

/* ---------------------------------------------------------------- Tombol & form */
.btn {
    --bs-btn-font-weight: 600;
    --bs-btn-border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 44px;
    padding-inline: 1rem;
}
.btn-sm {
    --bs-btn-border-radius: 10px;
    min-height: 36px;
    padding-inline: .75rem;
    font-size: .875rem;
}
.btn-link { min-height: 0; padding: 0; }

.btn-success,
.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-hover);
    --bs-btn-hover-border-color: var(--app-primary-hover);
    --bs-btn-active-bg: var(--app-primary-hover);
    --bs-btn-active-border-color: var(--app-primary-hover);
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
}
.btn-outline-success {
    --bs-btn-color: var(--app-primary-text);
    --bs-btn-border-color: color-mix(in srgb, var(--app-primary-text) 45%, transparent);
    --bs-btn-hover-bg: var(--app-primary-soft);
    --bs-btn-hover-color: var(--app-primary-text);
    --bs-btn-hover-border-color: var(--app-primary-text);
    --bs-btn-active-bg: var(--app-primary-soft);
    --bs-btn-active-color: var(--app-primary-text);
}
.btn-outline-secondary,
.btn-light {
    --bs-btn-color: var(--app-text);
    --bs-btn-bg: var(--app-surface);
    --bs-btn-border-color: var(--app-border);
    --bs-btn-hover-bg: var(--app-surface-2);
    --bs-btn-hover-color: var(--app-text);
    --bs-btn-hover-border-color: var(--app-border);
    --bs-btn-active-bg: var(--app-surface-2);
    --bs-btn-active-color: var(--app-text);
    --bs-btn-active-border-color: var(--app-border);
}
.btn-secondary {
    --bs-btn-bg: var(--app-text);
    --bs-btn-border-color: var(--app-text);
    --bs-btn-color: var(--app-surface);
    --bs-btn-hover-bg: var(--app-text);
    --bs-btn-hover-color: var(--app-surface);
}
.btn-outline-danger {
    --bs-btn-color: var(--app-expense);
    --bs-btn-border-color: color-mix(in srgb, var(--app-expense) 45%, transparent);
    --bs-btn-hover-bg: var(--app-expense-soft);
    --bs-btn-hover-color: var(--app-expense);
    --bs-btn-hover-border-color: var(--app-expense);
}

/* Bulan bayar di muka (belum jatuh tempo): biru, penuh saat dicentang */
:root,
[data-bs-theme="light"] {
    --app-advance: #1d63b8;
    --app-advance-soft: #e7f0fc;
    --app-advance-solid: #2a78d6;
}
[data-bs-theme="dark"] {
    --app-advance: #7db5f5;
    --app-advance-soft: #15263b;
    --app-advance-solid: #2a6fc4;
}
.text-advance { color: var(--app-advance) !important; }
.btn-advance {
    --bs-btn-color: var(--app-advance);
    --bs-btn-bg: var(--app-surface);
    --bs-btn-border-color: color-mix(in srgb, var(--app-advance) 50%, transparent);
    --bs-btn-hover-bg: var(--app-advance-soft);
    --bs-btn-hover-color: var(--app-advance);
    --bs-btn-hover-border-color: var(--app-advance);
    --bs-btn-active-bg: var(--app-advance-solid);
    --bs-btn-active-color: #fff;
    --bs-btn-active-border-color: var(--app-advance-solid);
}

.form-control,
.form-select {
    min-height: 46px;
    font-size: 1rem; /* 16px: mencegah zoom otomatis di iPhone */
    border-radius: 12px;
    background-color: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text);
}
.form-control-sm,
.form-select-sm {
    min-height: 40px;
    font-size: .95rem;
    border-radius: 10px;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary-text);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--app-primary) 18%, transparent);
}
.form-label { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.form-text { color: var(--app-muted); font-size: .82rem; }
.input-group > .btn { min-height: auto; }
.input-group-sm > .form-control,
.input-group-sm > .form-select { min-height: 40px; font-size: .95rem; }
.form-check-input { width: 1.2em; height: 1.2em; margin-top: .2em; }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }

.alert {
    border-radius: var(--app-radius-sm);
    border: 1px solid transparent;
    font-size: .95rem;
}
.alert-light { background: var(--app-surface); border-color: var(--app-border); color: var(--app-text); }

.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }
.badge.text-bg-light { background: var(--app-surface-2) !important; color: var(--app-text) !important; }
.badge.text-bg-success { background: var(--app-primary) !important; }

/* Pill/chip navigasi (tahun, tab) */
.chip-row {
    display: flex;
    gap: .45rem;
    overflow-x: auto;
    padding-bottom: .25rem;
    scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 38px;
    padding: .35rem .95rem;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    white-space: nowrap;
}
.chip:hover { background: var(--app-surface-2); color: var(--app-text); }
.chip.active { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }

.seg-tabs {
    display: flex;
    gap: .25rem;
    padding: .25rem;
    border-radius: 14px;
    background: var(--app-surface-2);
    border: 1px solid var(--app-border);
    overflow-x: auto;
    scrollbar-width: none;
}
.seg-tabs a {
    flex: 1 0 auto;
    text-align: center;
    padding: .55rem .9rem;
    border-radius: 10px;
    color: var(--app-muted);
    font-weight: 600;
    font-size: .92rem;
    text-decoration: none;
    white-space: nowrap;
}
.seg-tabs a.active { background: var(--app-surface); color: var(--app-text); box-shadow: var(--app-shadow); }

/* ---------------------------------------------------------------- Tabel (laptop) */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
    --bs-table-hover-bg: var(--app-surface-2);
    --bs-table-hover-color: var(--app-text);
    --bs-table-striped-bg: var(--app-surface-2);
    margin-bottom: 0;
}
.table > thead th,
.table thead.table-light th {
    --bs-table-bg: var(--app-surface-2);
    --bs-table-color: var(--app-muted);
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom-width: 1px;
    white-space: nowrap;
}
/* Wadah tabel hanya boleh digeser menyamping; tidak perlu scrollbar vertikal
   (overflow-x:auto dari Bootstrap otomatis membuat sumbu-y ikut "auto") */
.table-responsive { overflow-y: hidden; }

/* Satuan di judul kolom, mis. "DEBET (Rp)": tetap ditulis "Rp", bukan "RP" */
.table th .unit {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
}
.table tfoot.table-light th,
.table tfoot.table-light td,
.table tr.table-light td,
.table tr.table-light th {
    --bs-table-bg: var(--app-surface-2);
    --bs-table-color: var(--app-text);
}
.table > :not(caption) > * > * { padding: .7rem .8rem; }
.table-sm > :not(caption) > * > * { padding: .45rem .6rem; }
.table td.money,
.table th.money {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.card > .table-responsive:first-child > .table > thead > tr:first-child > th:first-child { border-top-left-radius: calc(var(--app-radius) - 1px); }
.card > .table-responsive:first-child > .table > thead > tr:first-child > th:last-child { border-top-right-radius: calc(var(--app-radius) - 1px); }

.ledger-table td:nth-child(3) { min-width: 220px; }
.ledger-note td { background: var(--app-warn-soft) !important; }
.col-urutan { width: 80px; }

/* ---------------------------------------------------------------- Daftar (HP) */
.list-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    overflow: hidden;
}
.list-card > .list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid var(--app-border);
}

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-item {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: .75rem;
    align-items: center;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--app-border);
}
.tx-item:last-child { border-bottom: 0; }
.tx-item.is-note { background: var(--app-warn-soft); }

.tx-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--app-neutral-soft);
    color: var(--app-muted);
}
.tx-icon.in { background: var(--app-income-soft); color: var(--app-income); }
.tx-icon.out { background: var(--app-expense-soft); color: var(--app-expense); }

.tx-body { min-width: 0; }
.tx-title {
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.tx-meta {
    font-size: .8rem;
    color: var(--app-muted);
    margin-top: .15rem;
    display: flex;
    flex-wrap: wrap;
    gap: .15rem .5rem;
    align-items: center;
}
.tx-meta a { font-weight: 600; text-decoration: none; }
.tx-amount {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tx-amount .tx-saldo {
    display: block;
    font-size: .75rem;
    font-weight: 500;
    color: var(--app-muted);
}
.amount-in { color: var(--app-income); }
.amount-out { color: var(--app-expense); }

.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list > li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--app-border);
}
.simple-list > li:last-child { border-bottom: 0; }
.simple-list a.row-link { color: inherit; text-decoration: none; display: contents; }

/* Grid menu (halaman Kelola) */
.menu-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.menu-tile {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1rem;
    border-radius: var(--app-radius);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
    color: var(--app-text);
    text-decoration: none;
}
.menu-tile:hover { color: var(--app-text); border-color: color-mix(in srgb, var(--app-primary-text) 40%, var(--app-border)); }
.menu-tile .tile-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--app-primary-soft);
    color: var(--app-primary-text);
}
.menu-tile .tile-icon .icon { width: 24px; height: 24px; }
.menu-tile .tile-title { font-weight: 700; }
.menu-tile .tile-desc { font-size: .84rem; color: var(--app-muted); }
.menu-tile > .icon:last-child { margin-left: auto; color: var(--app-muted); }

/* ---------------------------------------------------------------- Iuran */
.iuran-grid th,
.iuran-grid td { font-size: .86rem; white-space: nowrap; }
.iuran-grid.table-sm > :not(caption) > * > * { padding: .4rem .45rem; }
.iuran-grid .iuran-name {
    position: sticky;
    left: 0;
    background: var(--app-surface);
    z-index: 1;
    min-width: 132px;
}
.iuran-grid thead .iuran-name,
.iuran-grid tfoot th { background: var(--app-surface-2); }
/* Beri jarak dari tepi kiri kartu untuk kolom nama & label total */
.iuran-grid.table-sm > :not(caption) > * > .iuran-name,
.iuran-grid.table-sm > tfoot > tr > th:first-child { padding-left: 1rem; }
.iuran-cell { width: 40px; font-weight: 700; }
/* Kolom yang cukup selebar isinya (tunggakan & tombol aksi) */
.iuran-grid .col-fit { width: 1%; white-space: nowrap; }
.iuran-grid .th-small { font-size: .68rem; letter-spacing: .02em; }

/* Tombol aksi kecil berupa ikon (mis. "+" catat pembayaran) */
.btn-icon-sm {
    --bs-btn-border-radius: 9px;
    width: 32px;
    min-height: 32px;
    height: 32px;
    padding: 0;
}
.btn-icon-sm .icon { width: 18px; height: 18px; }
.iuran-cell a { text-decoration: none; color: inherit; display: block; }

.is-lunas { background: var(--app-income-soft) !important; color: var(--app-income) !important; }
.is-tunggakan { background: var(--app-expense-soft) !important; color: var(--app-expense) !important; }
.is-belum_tempo { background: var(--app-surface) !important; color: var(--app-muted) !important; }
.is-bukan { background: var(--app-neutral-soft) !important; color: transparent !important; }

.iuran-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .82rem; color: var(--app-muted); }
.iuran-legend .dot {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-weight: 700;
    margin-right: .3rem;
    border: 1px solid var(--app-border);
}

/* Dropdown tahun (HP): tombol "Gambar WA" sejajar dengan kotak pilihan */
.year-select { min-width: 0; }
@media (max-width: 767.98px) {
    .year-select + .chip-row + div .btn { min-height: 46px; }
}

/* Kartu iuran per anggota (HP) */
.member-card { padding: .95rem 1rem; border-bottom: 1px solid var(--app-border); }
.member-card:last-child { border-bottom: 0; }
.member-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.member-name { font-weight: 700; }
.month-chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.month-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border-radius: 10px;
    border: 1px solid var(--app-border);
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
}
.month-chip .mk { font-size: .95rem; font-weight: 800; }
.month-chip.is-bukan { color: var(--app-muted) !important; opacity: .55; }
.month-chip.is-bukan .mk { visibility: hidden; }
.month-chip.is-lunas { border-color: transparent; }
.month-chip.is-tunggakan { border-color: transparent; }

.bulan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.bulan-grid .btn { line-height: 1.2; flex-direction: column; min-height: 52px; }

/* Grid periode */
.periode-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.periode-cell { border: 1px solid var(--app-border); border-radius: 12px; padding: 8px; min-height: 84px; font-size: .85rem; }
.periode-cell.is-open { background: var(--app-income-soft); border-color: transparent; }
.periode-cell.is-empty { background: var(--app-neutral-soft); }
.periode-month { font-weight: 700; }
.periode-nominal { font-variant-numeric: tabular-nums; }
.periode-meta { font-size: .75rem; color: var(--app-muted); }
.periode-edit { display: flex; flex-direction: column; gap: 2px; margin-bottom: 2px; }
.periode-cell form .btn-link { font-size: .78rem; text-align: left; justify-content: flex-start; }

/* ---------------------------------------------------------------- Kolom tanggal dd/mm/yyyy */
.date-field { position: relative; }
.date-field .date-native {
    /* Tetap dirender (agar kalender bisa dibuka) tetapi tidak terlihat */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}
.date-field > input[type="text"] { padding-right: 2.75rem; font-variant-numeric: tabular-nums; }
.date-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--app-muted);
}
.date-btn:hover { background: var(--app-surface-2); color: var(--app-text); }
.date-field .form-control-sm ~ .date-btn { width: 32px; height: 32px; }

.backup-ico { width: 44px; height: 44px; border-radius: 13px; }
.backup-ico .icon { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- Riwayat aktivitas */
.audit-item { grid-template-columns: 40px 1fr; align-items: start; }
.audit-item .tx-meta .icon { width: 14px; height: 14px; vertical-align: -2px; }
.audit-detail { margin-top: .5rem; font-size: .85rem; }
.audit-detail summary { cursor: pointer; color: var(--app-primary-text); font-weight: 600; }
.audit-detail .table { margin-top: .4rem; }
.audit-detail td { overflow-wrap: anywhere; min-width: 90px; }

/* ---------------------------------------------------------------- Popup konfirmasi */
.confirm-dialog { max-width: 420px; }
.confirm-content { border-radius: 22px; border: 0; box-shadow: var(--app-shadow-lg); }
.confirm-content .modal-body { padding: 1.75rem 1.5rem .5rem; }
.confirm-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
}
.confirm-icon .icon { width: 30px; height: 30px; }
#confirm-modal[data-type="danger"] .confirm-icon { background: var(--app-expense-soft); color: var(--app-expense); }
#confirm-modal[data-type="primary"] .confirm-icon { background: var(--app-primary-soft); color: var(--app-primary-text); }
#confirm-modal[data-type="logout"] .confirm-icon { background: var(--app-surface-2); color: var(--app-text); }
/* Hanya ikon yang sesuai tipe yang ditampilkan */
.confirm-icon > span { display: none; }
#confirm-modal[data-type="danger"] .confirm-icon-danger,
#confirm-modal[data-type="primary"] .confirm-icon-primary,
#confirm-modal[data-type="logout"] .confirm-icon-logout,
#confirm-modal:not([data-type]) .confirm-icon-danger { display: inline-flex; }
.confirm-title { font-size: 1.2rem; font-weight: 800; margin: 0 0 .4rem; letter-spacing: -.01em; }
.confirm-text { color: var(--app-muted); margin: 0; overflow-wrap: anywhere; }
.confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
    padding: 1.25rem 1.5rem 1.5rem;
}
.btn-danger {
    --bs-btn-bg: #c53030;
    --bs-btn-border-color: #c53030;
    --bs-btn-hover-bg: #a92828;
    --bs-btn-hover-border-color: #a92828;
    --bs-btn-active-bg: #a92828;
    --bs-btn-active-border-color: #a92828;
}
@media (max-width: 575.98px) {
    /* HP: popup menempel di bawah layar seperti lembar aksi, mudah dijangkau jempol */
    #confirm-modal .modal-dialog { align-items: flex-end; min-height: 100%; margin: 0; max-width: none; }
    #confirm-modal .confirm-content { border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
    #confirm-modal.fade .modal-dialog { transform: translateY(40px); }
    #confirm-modal.show .modal-dialog { transform: none; }
}

/* ---------------------------------------------------------------- Pratinjau gambar rekap (WA) */
.rekap-preview {
    max-height: 74vh;
    overflow-y: auto;
    border-radius: 12px;
    background: var(--app-surface-2);
}
.rekap-canvas { display: block; width: 100%; height: auto; }
@media (max-width: 575.98px) {
    .rekap-preview { max-height: calc(100vh - 140px); }
}

/* ---------------------------------------------------------------- Popup bukti */
.modal {
    --bs-modal-bg: var(--app-surface);
    --bs-modal-border-color: var(--app-border);
    --bs-modal-header-border-color: var(--app-border);
    --bs-modal-footer-border-color: var(--app-border);
    --bs-modal-border-radius: 18px;
}
.bukti-modal .modal-body { padding: .75rem; }
.bukti-stage {
    display: grid;
    place-items: center;
    min-height: 240px;
    border-radius: 12px;
    background: var(--app-surface-2);
    overflow: hidden;
}
.bukti-img {
    display: block;
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
}
.bukti-stage.is-pdf { place-items: stretch; align-content: start; }
.bukti-pdf {
    max-height: 72vh;
    overflow-y: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}
.bukti-pdf-page { margin: 0 0 14px; }
.bukti-pdf-page:last-child { margin-bottom: 0; }
.bukti-pdf-page canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: var(--app-shadow);
}
.bukti-pdf-page figcaption { text-align: center; font-size: .78rem; color: var(--app-muted); margin-top: 6px; }
@media (max-width: 575.98px) {
    .bukti-pdf { max-height: calc(100vh - 150px); padding: 8px; }
}
.bukti-msg { text-align: center; padding: 2rem 1.25rem; color: var(--app-muted); max-width: 420px; }
.bukti-msg-icon { width: 40px; height: 40px; margin-bottom: .5rem; }
.bukti-modal .modal-footer { gap: .4rem; }
@media (max-width: 575.98px) {
    .bukti-modal .modal-body { display: flex; flex-direction: column; }
    .bukti-stage { flex: 1; }
    .bukti-img { max-height: none; max-height: calc(100vh - 150px); }
}

/* ---------------------------------------------------------------- Grafik */
.chart-box { position: relative; height: 260px; }

/* ---------------------------------------------------------------- Paginasi */
.pagination {
    --bs-pagination-bg: var(--app-surface);
    --bs-pagination-color: var(--app-text);
    --bs-pagination-border-color: var(--app-border);
    --bs-pagination-hover-bg: var(--app-surface-2);
    --bs-pagination-hover-color: var(--app-text);
    --bs-pagination-active-bg: var(--app-primary);
    --bs-pagination-active-border-color: var(--app-primary);
    --bs-pagination-disabled-bg: var(--app-surface);
    --bs-pagination-disabled-color: var(--app-muted);
    gap: .3rem;
}
.pagination .page-link { border-radius: 10px !important; min-width: 40px; min-height: 40px; display: grid; place-items: center; }

/* ---------------------------------------------------------------- Menu bawah (HP) */
.app-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: var(--app-nav-bg);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-top: 1px solid var(--app-border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.app-bottomnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    color: var(--app-muted);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 600;
    border-radius: 12px;
}
.app-bottomnav .nav-ico {
    display: grid;
    place-items: center;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    transition: background-color .15s ease;
}
.app-bottomnav .icon { width: 22px; height: 22px; }
.app-bottomnav a.active { color: var(--app-primary-text); }
.app-bottomnav a.active .nav-ico { background: var(--app-primary-soft); }

/* Menu bawah tampil sampai lebar 991px: beri ruang agar konten tidak tertutup */
@media (max-width: 991.98px) {
    .app-main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

@media (max-width: 767.98px) {
    .app-main { padding-top: 1rem; }
    .container { --bs-gutter-x: 2rem; } /* 16px kiri-kanan */
    .page-title, .app-main h1.h4 { font-size: 1.3rem; }
    .hero-value { font-size: 1.85rem; }
    .stat-value { font-size: 1.08rem; }
    .stat-card .card-body { padding: .85rem .9rem; }
    .card-body { padding: 1rem; }
    .chart-box { height: 230px; }
    .account-btn .account-name { display: none; }
    .account-btn { padding: .25rem; }
}

/* ---------------------------------------------------------------- Halaman login */
.auth-body {
    background:
        radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--app-hero-from) 22%, transparent), transparent 70%),
        var(--app-bg);
}
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; border-radius: 22px; }
.auth-card .card-body { padding: 2rem 1.5rem; }
/* Logo login: ikon + nama (meniru logo panjang), warna teks ikut mode terang/gelap */
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    margin-bottom: .35rem;
}
.auth-brand-logo {
    width: 68px;
    height: 68px;
    object-fit: contain;
    flex: none;
    filter: drop-shadow(0 4px 10px rgba(16, 32, 24, .18));
}
.auth-brand-name {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.1;
    color: var(--app-primary-text);
}
@media (max-width: 380px) {
    .auth-brand-logo { width: 56px; height: 56px; }
    .auth-brand-name { font-size: 1.4rem; }
}

.report-head { display: none; }

/* ---------------------------------------------------------------- Cetak */
@media print {
    @page { size: A4; margin: 14mm 12mm; }
    :root { color-scheme: light; }
    .app-header, .app-bottomnav, .theme-toggle, .auth-theme, footer, .btn, form, .no-print, .alert, .nav-tabs, .seg-tabs, .chip-row, details { display: none !important; }
    body { background: #fff !important; color: #000 !important; font-size: 11px; }
    .app-main { padding: 0 !important; }
    main.container { max-width: none; padding: 0 !important; }
    .d-md-none { display: none !important; }
    .d-none.d-md-block { display: block !important; }
    .report-head { display: block; border-bottom: 2px solid #000; padding-bottom: 6px; }
    .card, .list-card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; background: #fff !important; }
    .hero-card { color: #000 !important; background: #fff !important; }
    .table-responsive { overflow: visible !important; }
    .table { --bs-table-color: #000; }
    .ledger-table td, .ledger-table th { font-size: 10px; padding: 2px 4px; }
    thead { display: table-header-group; }
    tr { break-inside: avoid; }
    .report-summary .col-6 { width: 25%; }
    a { color: inherit; text-decoration: none; }
    .text-success, .text-danger { color: #000 !important; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- Statistik kunjungan */
.stat-row { padding: .6rem 0; border-bottom: 1px solid var(--app-border); }
.stat-row:first-child { padding-top: 0; }
.stat-row:last-child { border-bottom: 0; padding-bottom: 0; }
.stat-row .icon { width: 1.05em; height: 1.05em; margin-right: .3rem; vertical-align: -.15em; }
.stat-bar {
    display: block; width: 100%; height: 6px; margin-top: .45rem;
    border: 0; border-radius: 999px; overflow: hidden;
    background: var(--app-neutral-soft); appearance: none; -webkit-appearance: none;
}
.stat-bar::-webkit-progress-bar { background: var(--app-neutral-soft); border-radius: 999px; }
.stat-bar::-webkit-progress-value { background: var(--series-1); border-radius: 999px; }
.stat-bar::-moz-progress-bar { background: var(--series-1); border-radius: 999px; }
p .icon { width: 1.05em; height: 1.05em; vertical-align: -.15em; }
