/* =========================================================
   DOMPETKU — Design tokens (fintech modern: gradient indigo/violet)
   ========================================================= */
:root {
  /* Warna */
  --emerald-900: #2E2A85;
  --emerald-700: #5B5FEF;
  --emerald-600: #6D5BFF;
  --emerald-100: #EBEBFF;
  --emerald-50: #F5F5FF;
  --gold-500: #F5B94D;
  --gold-600: #E09A1F;
  --gold-100: #FDF0D8;
  --cream-bg: #F3F4FA;
  --paper: #FFFFFF;
  --ink: #171A2E;
  --ink-soft: #666C89;
  --ink-faint: #9BA0BB;
  --line: #E7E8F5;
  --red-600: #E5484D;
  --red-100: #FDECEC;

  /* Warna "tetap" — permukaan solid brand indigo/violet & teks di atasnya.
     Nilainya TIDAK ikut berubah antar tema (light/dark), supaya elemen
     seperti kartu saldo / tombol utama tetap konsisten. */
  --brand-deep: #5B4FE8;
  --on-emerald: #FFFFFF;
  --brand-grad: linear-gradient(135deg, #6D5DF6 0%, #5B4FE8 48%, #8B3FE8 100%);
  --accent-teal: #17C79B;
  --accent-pink: #F857A6;

  /* Tipografi */
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --shadow-card: 0 1px 2px rgba(23,26,46,0.04), 0 10px 28px rgba(43,42,90,0.08);
  --shadow-brand: 0 12px 28px rgba(91,79,232,0.32), 0 2px 6px rgba(91,79,232,0.18);
  --bottom-nav-h: 70px;
  --max-w: 480px;
  color-scheme: light;
}

/* =========================================================
   Dark Mode — diaktifkan lewat atribut [data-theme="dark"] di <html>
   (lihat js/theme.js). Nama variabel tetap sama, cuma nilainya diganti,
   jadi seluruh CSS di bawah otomatis ikut tanpa perlu duplikasi rule.
   ========================================================= */
html[data-theme="dark"] {
  color-scheme: dark;
  --cream-bg: #0A0D1D;
  --paper: #141833;
  --ink: #EEF0FB;
  --ink-soft: #A7ACC9;
  --ink-faint: #6A7093;
  --line: #262B4C;

  --emerald-900: #C9CDFB;
  --emerald-700: #9B93FF;
  --emerald-600: #8A83FF;
  --emerald-100: rgba(139, 131, 255, 0.16);
  --emerald-50: rgba(139, 131, 255, 0.08);

  --gold-500: #FFCF75;
  --gold-600: #F5B94D;
  --gold-100: rgba(245, 185, 77, 0.16);

  --red-600: #FF7A7F;
  --red-100: rgba(255, 122, 127, 0.14);

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.38);
  --shadow-brand: 0 16px 34px rgba(91,79,232,0.38), 0 2px 8px rgba(0,0,0,0.3);
}
/* Body luar #app di layar lebar (tablet) & skeleton shimmer punya warna hardcode */
html[data-theme="dark"] body { background: #060814; }
html[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--emerald-100) 25%, rgba(139,131,255,0.22) 37%, var(--emerald-100) 63%);
  background-size: 400% 100%;
}
html[data-theme="dark"] .wallet-card { box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset; }
html[data-theme="dark"] .card, html[data-theme="dark"] .sheet, html[data-theme="dark"] .dialog,
html[data-theme="dark"] .sidebar, html[data-theme="dark"] .bottom-nav, html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select, html[data-theme="dark"] .field textarea, html[data-theme="dark"] .search-box,
html[data-theme="dark"] .icon-btn, html[data-theme="dark"] .chip, html[data-theme="dark"] .icon-pick {
  border: 1px solid var(--line);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--cream-bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  transition: background-color .15s ease, color .15s ease;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font-family: inherit; }

.num, .amount, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

:focus-visible {
  outline: 2px solid var(--emerald-700);
  outline-offset: 2px;
}

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

/* =========================================================
   App shell
   ========================================================= */
#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--cream-bg);
  position: relative;
  padding-bottom: calc(var(--bottom-nav-h) + 18px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--cream-bg);
  padding: 18px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--brand-grad);
  display: flex; align-items: center; justify-content: center;
  color: var(--on-emerald);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow-brand);
}
.topbar h1 { font-size: 18px; color: var(--emerald-900); }
.topbar .greet { font-size: 12px; color: var(--ink-faint); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--emerald-900);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--emerald-100); }
.icon-btn.active { background: var(--brand-grad); color: var(--on-emerald); border-color: transparent; box-shadow: var(--shadow-brand); }

main.view { padding: 4px 18px 18px; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform:none; } }

/* =========================================================
   Kartu saldo — signature element: kartu gradient ala credit card
   ========================================================= */
.receipt-card {
  position: relative;
  background: var(--brand-grad);
  color: var(--on-emerald);
  border-radius: var(--radius-lg);
  padding: 24px 24px 26px;
  overflow: hidden;
  margin-bottom: 22px;
  box-shadow: var(--shadow-brand);
  isolation: isolate;
}
.receipt-card::before {
  content: '';
  position: absolute;
  top: -70px; right: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0) 70%);
  z-index: -1;
}
.receipt-card::after {
  content: '';
  position: absolute;
  bottom: -90px; left: -40px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 70%);
  z-index: -1;
}
.receipt-card .label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.8);
  opacity: 0.95;
}
.receipt-card .label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.balance-eye-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.14);
  color: var(--on-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.balance-eye-btn svg { width: 16px; height: 16px; }
.balance-eye-btn:active { transform: scale(0.92); }
.receipt-card .balance {
  font-size: 34px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1.1;
  word-break: break-all;
}
.receipt-card .sub-row {
  display: flex;
  gap: 18px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.18);
}
.receipt-card .sub-row .item { flex: 1; }
.receipt-card .sub-row .item .t { font-size: 11px; color: rgba(255,255,255,0.7); }
.receipt-card .sub-row .item .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.receipt-card .sub-row .item.income .v { color: #A6F5D8; }
.receipt-card .sub-row .item.expense .v { color: #FFC2C6; }

/* dulu "gerigi" ala struk kasir — sekarang disembunyikan demi tampilan kartu polos modern */
.receipt-teeth { height: 0; margin: 0; background: none; }

/* =========================================================
   Kartu umum & list
   ========================================================= */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
}
.card + .card { margin-top: 16px; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 12px;
}
.section-title h2 { font-size: 16px; font-weight: 700; color: var(--emerald-900); }
.section-title .link { font-size: 12px; color: var(--emerald-700); font-weight: 700; cursor: pointer; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-actions button {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 4px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  transition: transform .12s ease;
}
.quick-actions button:active { transform: scale(0.96); }
.quick-actions .qi {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.qi.income { background: linear-gradient(135deg, #22D3A6, #17C79B); }
.qi.expense { background: linear-gradient(135deg, #FF7A7F, #E5484D); }
.qi.transfer { background: linear-gradient(135deg, #FFCF75, #F5B94D); }
.qi.debt { background: var(--brand-grad); }

.trx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.trx-item:last-child { border-bottom: none; }
.trx-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--emerald-100); color: var(--emerald-700);
  flex-shrink: 0;
}
.trx-icon.expense { background: var(--red-100); color: var(--red-600); }
.trx-icon.transfer { background: var(--gold-100); color: var(--gold-600); }
.trx-mid { flex: 1; min-width: 0; }
.trx-mid .t1 { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trx-mid .t2 { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.trx-amt { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.trx-amt.income { color: var(--emerald-700); }
.trx-amt.expense { color: var(--red-600); }
.trx-amt.transfer { color: var(--gold-600); }

/* =========================================================
   Kalender Pengeluaran (heatmap harian)
   ========================================================= */
.cal-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav button {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--paper); color: var(--emerald-900); font-size: 16px; cursor: pointer;
}
.cal-nav .lbl { font-size: 13.5px; font-weight: 600; color: var(--emerald-900); text-transform: capitalize; }
.cal-weekday-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 10.5px; color: var(--ink-faint); margin-bottom: 6px;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.cal-cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--emerald-50);
  cursor: pointer;
  position: relative;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell .cal-daynum { font-size: 11px; color: var(--ink-faint); }
.cal-cell.lvl1 { background: var(--gold-100); }
.cal-cell.lvl1 .cal-daynum { color: var(--gold-600); }
.cal-cell.lvl2 { background: rgba(245, 185, 77, 0.45); }
.cal-cell.lvl2 .cal-daynum { color: var(--ink); font-weight: 600; }
.cal-cell.lvl3 { background: rgba(229, 72, 77, 0.55); }
.cal-cell.lvl3 .cal-daynum { color: #fff; font-weight: 600; }
.cal-cell.lvl4 { background: var(--red-600); }
.cal-cell.lvl4 .cal-daynum { color: #fff; font-weight: 700; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--emerald-700); }
.cal-cell.is-future { opacity: 0.45; cursor: default; }
.cal-legend {
  display: flex; align-items: center; gap: 5px; justify-content: flex-end;
  margin-top: 10px; font-size: 10.5px; color: var(--ink-faint);
}
.cal-legend-dot { width: 11px; height: 11px; border-radius: 3px; }
.cal-legend-dot.lvl1 { background: var(--gold-100); }
.cal-legend-dot.lvl2 { background: rgba(245, 185, 77, 0.45); }
.cal-legend-dot.lvl3 { background: rgba(229, 72, 77, 0.55); }
.cal-legend-dot.lvl4 { background: var(--red-600); }
.cal-day-summary {
  display: flex; gap: 14px; margin-top: 4px;
}
.cal-day-summary .item { flex: 1; background: var(--emerald-50); border-radius: 12px; padding: 10px 12px; }
.cal-day-summary .item.expense { background: var(--red-100); }
.cal-day-summary .item .t { font-size: 11px; color: var(--ink-faint); }
.cal-day-summary .item .v { font-size: 15px; font-weight: 700; margin-top: 2px; color: var(--emerald-900); }
.cal-day-summary .item.expense .v { color: var(--red-600); }

.insight-card { padding: 6px 16px; }
.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.insight-item:last-child { border-bottom: none; }
.insight-icon { font-size: 16px; line-height: 1.4; flex-shrink: 0; }
.insight-text { font-size: 13px; line-height: 1.45; color: var(--ink); }
.insight-positive .insight-text { color: var(--emerald-700); font-weight: 500; }
.insight-warning .insight-text { color: var(--red-600); font-weight: 500; }
.insight-money .insight-text { color: var(--gold-600); font-weight: 600; }
.insight-info .insight-text { color: var(--ink); }

.empty-state {
  text-align: center;
  padding: 34px 12px;
  color: var(--ink-faint);
}
.empty-state .em-icon { font-size: 30px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* =========================================================
   Bottom nav
   ========================================================= */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  width: calc(100% - 24px);
  max-width: calc(var(--max-w) - 24px);
  height: var(--bottom-nav-h);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  display: flex;
  z-index: 30;
  box-shadow: var(--shadow-card);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1;
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 600;
  padding: 6px 0;
  border-radius: 14px;
}
.bottom-nav button.active { color: var(--emerald-700); }
.bottom-nav button svg { width: 21px; height: 21px; }
.bottom-nav .fab {
  position: relative;
  top: -18px;
  background: var(--brand-grad) !important;
  color: var(--on-emerald) !important;
  width: 52px; height: 52px;
  border-radius: 50%;
  flex: 0 0 52px;
  margin: 0 6px;
  box-shadow: var(--shadow-brand);
}
.bottom-nav .fab svg { width: 24px; height: 24px; }

/* =========================================================
   Forms & buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease;
}
.btn-primary { background: var(--brand-grad); color: var(--on-emerald); box-shadow: var(--shadow-brand); }
.btn-primary:active { filter: brightness(0.94); transform: scale(0.99); }
.btn-secondary { background: var(--emerald-100); color: var(--emerald-700); }
.btn-outline { background: transparent; color: var(--emerald-900); border: 1px solid var(--line); }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-ghost { background: none; color: var(--ink-faint); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--emerald-600);
  outline: none;
}
.field input.amount-input { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }
.field-error { color: var(--red-600); font-size: 11.5px; margin-top: 5px; }
.field-hint { color: var(--ink-faint); font-size: 11.5px; margin-top: 5px; }

.seg {
  display: flex;
  background: var(--emerald-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--emerald-900);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg button.active { background: var(--brand-grad); color: var(--on-emerald); box-shadow: var(--shadow-brand); }

/* =========================================================
   Pencarian & filter transaksi
   ========================================================= */
.trx-search-row { display: flex; gap: 10px; align-items: center; }
.search-box {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
}
.search-box svg { width: 17px; height: 17px; color: var(--ink-faint); flex-shrink: 0; }
.search-box input {
  flex: 1; border: none; background: none; outline: none;
  padding: 11px 0; font-size: 13.5px; color: var(--ink);
}
.trx-search-row .icon-btn { position: relative; flex-shrink: 0; }
.filter-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--red-600); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 1;
  min-width: 15px; height: 15px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
#trxActiveFilters .chip { padding-right: 8px; }
#trxActiveFilters .chip svg { width: 11px; height: 11px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.chip.active { background: var(--brand-grad); border-color: transparent; color: var(--on-emerald); box-shadow: var(--shadow-brand); }

/* =========================================================
   Modal / sheet
   ========================================================= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10,13,29,0.55);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .15s ease;
}
.sheet {
  width: 100%;
  max-width: var(--max-w);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--cream-bg);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px 26px;
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet .handle {
  width: 40px; height: 4px; background: var(--line); border-radius: 4px;
  margin: 6px auto 14px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.sheet-header h3 { font-size: 16px; color: var(--emerald-900); }

/* Modal tengah (dialog kecil, non-sheet) */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(10,13,29,0.55);
  backdrop-filter: blur(2px);
  z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 20px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-card);
}
.dialog h3 { font-size: 15px; margin-bottom: 10px; color: var(--emerald-900); }
.dialog p { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.row-btn { display: flex; gap: 10px; }
.row-btn .btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.row-btn .btn svg { width: 16px; height: 16px; }

/* =========================================================
   Auth screen
   ========================================================= */
.auth-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 32px 26px;
  max-width: var(--max-w);
  margin: 0 auto;
}
.auth-logo {
  width: 62px; height: 62px; border-radius: 18px;
  background: var(--brand-grad);
  display: flex; align-items: center; justify-content: center;
  color: var(--on-emerald);
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-brand);
}
.auth-wrap h1 { font-size: 24px; color: var(--emerald-900); margin-bottom: 4px; }
.auth-wrap .sub { color: var(--ink-faint); font-size: 13.5px; margin-bottom: 26px; }
.auth-tabs { display: flex; gap: 20px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.auth-tabs button {
  background: none; border: none; padding: 8px 2px 12px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--ink-faint);
  border-bottom: 2px solid transparent;
}
.auth-tabs button.active { color: var(--emerald-900); border-color: var(--emerald-700); }
.auth-error {
  background: var(--red-100); color: var(--red-600);
  padding: 10px 12px; border-radius: 10px; font-size: 12.5px; margin-bottom: 14px;
}

/* =========================================================
   Wallet cards (grid)
   ========================================================= */
.wallet-card {
  border-radius: var(--radius-md);
  padding: 16px;
  color: white;
  position: relative;
  overflow: hidden;
  min-height: 108px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 10px 22px rgba(23,26,46,0.16);
  isolation: isolate;
}
.wallet-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0) 45%), radial-gradient(circle at 100% 100%, rgba(0,0,0,0.14), transparent 60%);
  z-index: -1;
}
.wallet-card .wt { font-size: 11.5px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.06em; }
.wallet-card .wn { font-size: 14.5px; font-weight: 700; margin-top: 2px; }
.wallet-card .wb { font-size: 19px; font-weight: 700; margin-top: 10px; }
.wallet-card .wdots {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,0.18);
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.wallet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* =========================================================
   Debts (hutang piutang)
   ========================================================= */
.debt-item {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.debt-item:last-child { border-bottom: none; }
.debt-item .drow1 { display: flex; justify-content: space-between; align-items: center; }
.debt-item .person { font-size: 14px; font-weight: 700; }
.debt-item .person svg { width: 16px; height: 16px; }
.debt-item .amt { font-size: 14px; font-weight: 700; font-family: var(--font-mono); }
.debt-item .meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }
.progress-bar {
  height: 6px; background: var(--emerald-100); border-radius: 4px; margin-top: 8px; overflow: hidden;
}
.progress-bar > div { height: 100%; background: var(--emerald-700); }
.badge { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.lunas { background: var(--emerald-100); color: var(--emerald-700); }
.badge.belum { background: var(--gold-100); color: var(--gold-600); }
.badge.telat { background: var(--red-100); color: var(--red-600); }

/* =========================================================
   Target Tabungan (savings goals)
   ========================================================= */
.goal-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.goal-item:last-child { border-bottom: none; }
.goal-ic {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--emerald-100); color: var(--emerald-900);
}
.goal-ic svg { width: 20px; height: 20px; }
.goal-body { flex: 1; min-width: 0; }
.goal-row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.goal-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-pct { font-size: 12.5px; font-weight: 700; color: var(--emerald-700); font-family: var(--font-mono); flex-shrink: 0; }
.goal-meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.goal-meta b { color: var(--ink-soft); }
.goal-item .progress-bar { margin-top: 8px; }
.progress-bar > div.over,
.progress-bar > div.warn { background: var(--gold-600); }
.goal-hint {
  margin-top: 6px; font-size: 11px; color: var(--emerald-700); font-weight: 600;
  background: var(--emerald-50); display: inline-block; padding: 3px 8px; border-radius: 8px;
}
.goal-mini-list { display: flex; flex-direction: column; gap: 14px; }
.goal-mini { display: flex; align-items: center; gap: 10px; }
.goal-mini .goal-ic { width: 34px; height: 34px; border-radius: 10px; }
.goal-mini .goal-ic svg { width: 17px; height: 17px; }
.goal-mini .goal-body { flex: 1; min-width: 0; }
.goal-mini .goal-name { font-size: 12.5px; }
.goal-mini .goal-pct { font-size: 11px; }
.goal-mini .progress-bar { height: 5px; margin-top: 5px; }

/* =========================================================
   Charts (SVG, tanpa lib eksternal)
   ========================================================= */
.chart-wrap { width: 100%; overflow: visible; }
.bar-chart .bar-bg { fill: var(--emerald-100); }
.bar-chart text { font-family: var(--font-mono); fill: var(--ink-faint); font-size: 9.5px; }
.legend-row { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.legend-row .li { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-soft); }
.legend-row .dot { width: 9px; height: 9px; border-radius: 50%; }

.cat-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.cat-row .cbar { flex: 1; height: 8px; border-radius: 4px; background: var(--emerald-100); overflow: hidden; }
.cat-row .cbar > div { height: 100%; background: var(--emerald-700); }
.cat-row .cname { width: 108px; font-size: 12px; font-weight: 600; flex-shrink: 0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cat-row .cval { width: 84px; text-align: right; font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* =========================================================
   Toast
   ========================================================= */
.toast-wrap {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 100; width: calc(100% - 32px); max-width: 420px;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--brand-grad); color: var(--on-emerald);
  padding: 12px 16px; border-radius: 14px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-brand);
  animation: fadein .15s ease;
}
.toast.error { background: var(--red-600); }

.skeleton { background: linear-gradient(90deg, var(--emerald-100) 25%, #e2e2ff 37%, var(--emerald-100) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* =========================================================
   Ukuran ikon default (svg inline tanpa width/height eksplisit)
   ========================================================= */
.icon-btn svg { width: 19px; height: 19px; }
.trx-icon svg { width: 19px; height: 19px; }
.quick-actions .qi svg { width: 18px; height: 18px; }
.wdots svg { width: 16px; height: 16px; }
.empty-state svg { width: 34px; height: 34px; }
.settings-row-ic svg { width: 20px; height: 20px; }
.cat-chip-ic svg { width: 15px; height: 15px; }
.icon-pick svg { width: 21px; height: 21px; }
.sidebar-nav svg, .sidebar-logout svg { width: 19px; height: 19px; }
.sidebar-add svg { width: 17px; height: 17px; }
.cat-chip-del svg { width: 12px; height: 12px; }
.chevron-slot { flex-shrink: 0; display: flex; align-items: center; }
.chevron-slot svg { width: 18px; height: 18px; }

/* =========================================================
   Pengaturan (Profil, Password, Kategori)
   ========================================================= */
.settings-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink-faint);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-ic {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--emerald-100); color: var(--emerald-900);
  display: flex; align-items: center; justify-content: center;
}
.settings-row-mid { flex: 1; min-width: 0; }
.settings-row-mid .t1 { font-size: 14.5px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.settings-row-mid .t2 { font-size: 12px; color: var(--ink-faint); margin-top: 3px; line-height: 1.45; }

/* =========================================================
   Notifikasi (toggle switch + baris sub-preferensi)
   ========================================================= */
.notif-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.notif-row:last-child { border-bottom: none; }
.notif-row-mid { flex: 1; min-width: 0; }
.notif-row-mid .t1 { font-size: 14.5px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.notif-row-mid .t2 { font-size: 12px; color: var(--ink-faint); margin-top: 3px; line-height: 1.45; }
.notif-row.sub { padding-left: 14px; opacity: 1; transition: opacity .15s ease; }
.notif-row.sub.disabled { opacity: .45; pointer-events: none; }

.toggle-switch {
  position: relative; flex-shrink: 0;
  width: 42px; height: 25px; border-radius: 999px;
  background: var(--line); border: none; cursor: pointer;
  transition: background .15s ease;
}
.toggle-switch::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.toggle-switch.on { background: var(--brand-grad); }
.toggle-switch.on::after { transform: translateX(17px); }
.toggle-switch:disabled { opacity: .5; cursor: not-allowed; }

.notif-freq-seg { display: flex; gap: 6px; margin-top: 8px; padding-left: 2px; }
.notif-freq-seg button {
  font-size: 11.5px; font-weight: 600; padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-faint); cursor: pointer;
}
.notif-freq-seg button.active { background: var(--brand-grad); color: #fff; border-color: transparent; }

/* =========================================================
   Anggaran Bulanan (Budget)
   ========================================================= */
.budget-month-nav {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 12px;
}
.budget-month-nav button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-faint); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.budget-month-nav button:hover { background: var(--emerald-100); }
.budget-month-nav .lbl { font-size: 13px; font-weight: 700; color: var(--ink); min-width: 110px; text-align: center; }

.budget-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 2px 14px; border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.budget-total .t1 { font-size: 11.5px; color: var(--ink-faint); }
.budget-total .t2 { font-size: 15px; font-weight: 800; color: var(--ink); }

.budget-item { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.budget-item:last-child { border-bottom: none; }
.budget-item-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 7px; cursor: pointer;
}
.budget-item-ic {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: var(--emerald-100); color: var(--emerald-900);
  display: flex; align-items: center; justify-content: center;
}
.budget-item-ic svg { width: 16px; height: 16px; }
.budget-item-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--ink); }
.budget-item-nums { font-size: 11.5px; font-weight: 600; color: var(--ink-faint); text-align: right; }
.budget-item-nums b { color: var(--ink); font-weight: 700; }
.budget-item-empty { font-size: 11.5px; color: var(--ink-faint); font-style: italic; }

.budget-bar-track {
  height: 8px; border-radius: 999px; background: var(--emerald-100); overflow: hidden;
}
.budget-bar-fill { height: 100%; border-radius: 999px; transition: width .2s ease, background .2s ease; }
.budget-bar-fill.ok { background: var(--brand-grad); }
.budget-bar-fill.warn { background: var(--gold-500); }
.budget-bar-fill.over { background: var(--red-600); }

.cat-chip-wrap { display: flex; flex-wrap: wrap; gap: 9px; }
.cat-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px 8px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--emerald-50);
}
.cat-chip-ic {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--emerald-100); color: var(--emerald-900);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cat-chip-name { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.cat-chip-del {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--red-600); background: var(--red-100); cursor: pointer; flex-shrink: 0;
}

.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px;
  margin-top: 2px;
}
.icon-pick {
  width: 46px; height: 46px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft); cursor: pointer;
}
.icon-pick.active { background: var(--brand-grad); border-color: transparent; color: var(--on-emerald); }

/* =========================================================
   Shell responsif: sidebar (tablet lebar / desktop) + bottom-nav (mobile)
   ========================================================= */
.shell { display: block; }
.sidebar { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* =========================================================
   Responsif — tablet (>=640px): lebih lega, grid lebih lebar
   ========================================================= */
@media (min-width: 640px) {
  :root { --max-w: 640px; }
  body { background: #E9EAF6; }
  html[data-theme="dark"] body { background: #05060F; }
  #app { box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(23,26,46,0.10); min-height: 100vh; }
  html[data-theme="dark"] #app { box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0,0,0,0.5); }
  .wallet-grid { grid-template-columns: repeat(3, 1fr); }
  .quick-actions { gap: 14px; }
}

/* =========================================================
   Responsif — desktop (>=1024px): sidebar navigasi tetap, konten multi-kolom
   ========================================================= */
@media (min-width: 1024px) {
  :root { --bottom-nav-h: 0px; }
  #app { max-width: 1240px; padding-bottom: 32px; box-shadow: none; background: transparent; }
  body { background: var(--cream-bg); }
  .auth-wrap { max-width: 480px; }
  .sheet { max-width: 480px; }
  .bottom-nav { max-width: 480px; }

  .shell { display: flex; align-items: flex-start; gap: 24px; padding-top: 24px; }
  .main-col { flex: 1; min-width: 0; }

  .sidebar {
    display: flex; flex-direction: column;
    width: 240px; flex-shrink: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 22px 16px;
    position: sticky; top: 24px;
    gap: 20px;
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
  .sidebar-brand h1 { font-size: 17px; color: var(--emerald-900); }
  .sidebar-brand .greet { font-size: 11.5px; color: var(--ink-faint); }
  .sidebar-add { width: auto; }
  .sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar-nav button, .sidebar-logout {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px;
    border: none; background: none; border-radius: var(--radius-sm);
    color: var(--ink-soft); font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-align: left; width: 100%;
    transition: background .15s ease, color .15s ease;
  }
  .sidebar-nav button:hover, .sidebar-logout:hover { background: var(--emerald-100); color: var(--emerald-700); }
  .sidebar-nav button.active { background: var(--brand-grad); color: var(--on-emerald); box-shadow: var(--shadow-brand); }
  .sidebar-logout { color: var(--red-600); margin-top: auto; }

  .topbar { display: none; }
  .bottom-nav { display: none; }

  main.view { padding: 4px 0 0; max-width: 960px; }

  .wallet-grid { grid-template-columns: repeat(3, 1fr); }
  .quick-actions { max-width: 460px; }

  /* ---- Dashboard: bento grid biar layar lebar kepakai penuh, bukan cuma 1 kolom sempit ---- */
  .dash-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    grid-template-areas:
      "hero    hero"
      "insight insight"
      "debt    debt"
      "trx     goals";
    gap: 20px;
    align-items: start;
  }
  .dash-area-hero { grid-area: hero; }
  .dash-area-insights { grid-area: insight; }
  .dash-area-debt { grid-area: debt; margin-top: 0 !important; }
  .dash-area-goals { grid-area: goals; }
  .dash-area-trx { grid-area: trx; }
  .dash-area-insights > .section-title:first-child,
  .dash-area-goals > .section-title:first-child,
  .dash-area-trx > .section-title:first-child { margin-top: 0 !important; }

  .dash-hero-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: stretch; }
  .dash-hero-row .receipt-card { margin-bottom: 0; height: 100%; }
  .dash-hero-row .quick-actions { max-width: none; grid-template-columns: repeat(2, 1fr); height: 100%; align-content: center; }

  /* ---- Laporan: kalender dijejer sama grafik tren, kategori di bawah kalender, anggaran di bawah grafik ----
     (susunan DOM tetap sama kayak mobile, cuma diposisikan ulang pakai grid-area) */
  .reports-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "cal     monthly"
      "cat     budget";
    gap: 18px;
    align-items: start;
  }
  .reports-grid .card { margin-top: 0; }
  .reports-area-cal { grid-area: cal; }
  .reports-area-budget { grid-area: budget; }
  .reports-area-monthly { grid-area: monthly; }
  .reports-area-cat { grid-area: cat; }
  .cal-card-compact .cal-weekday-row,
  .cal-card-compact .cal-grid { max-width: 300px; margin-left: auto; margin-right: auto; }
  .cal-card-compact .cal-legend { max-width: 300px; margin-left: auto; margin-right: auto; }
}

/* =========================================================
   Responsif — desktop lebar (>=1360px): panel kanan opsional lebih lega
   ========================================================= */
@media (min-width: 1360px) {
  #app { max-width: 1360px; }
  main.view { max-width: 1040px; }
  .wallet-grid { grid-template-columns: repeat(4, 1fr); }
  .dash-grid { grid-template-columns: 1.7fr 1fr; gap: 24px; }
  .reports-grid { gap: 22px; }
}
