:root {
  --accent: #0E9C90;
  --accent-dark: #0B7D74;
  --accent-soft: #E1F5F2;
  --accent-contrast: #FFFFFF;

  --bg: #F4F8F7;
  --card-bg: #FFFFFF;
  --surface-alt: #EBF3F1;
  --border: #E1E9E7;

  --text-main: #10201E;
  --text-muted: #6F827E;

  --hero-bg: #0A1A18;
  --hero-text-muted: #93A9A5;
  --hero-surface: #16302C;

  --purple: #9B8CFF;
  --orange: #FFB648;
  --red: #FF5A5F;
  --green: #17A34A;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(16,32,30,0.06);
  --nav-bg: rgba(244,248,247,0.9);
  --overlay: rgba(8,18,17,0.45);
}

[data-theme="dark"] {
  --accent: #2DD4BF;
  --accent-dark: #14B8A6;
  --accent-soft: rgba(45,212,191,0.14);
  --accent-contrast: #06201C;

  --bg: #0A0F0F;
  --card-bg: #151D1C;
  --surface-alt: #1E2827;
  --border: #2A3634;

  --text-main: #EAF6F3;
  --text-muted: #8CA6A2;

  --hero-bg: #000000;
  --hero-text-muted: #7C9A95;
  --hero-surface: #121C1A;

  --shadow: 0 2px 14px rgba(0,0,0,0.45);
  --nav-bg: rgba(10,15,15,0.85);
  --overlay: rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, color 0.2s ease;
}
/* Bikin terasa seperti app native: cegah pinch-zoom & double-tap-zoom di semua browser,
   tapi tetap izinkan scroll biasa (vertikal & horizontal untuk elemen yang butuh, misal filter-row) */
html { touch-action: pan-x pan-y; -ms-touch-action: pan-x pan-y; }
/* Cegah teks/ikon UI ke-select & muncul context menu saat long-press (kecuali di dalam form input) */
body, button, .card, .wallet-row, .goal-card, .menu-item, .bottom-nav, .page-title, .page-sub {
  -webkit-user-select: none; -moz-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, select, [contenteditable="true"] {
  -webkit-user-select: text; -moz-user-select: text; user-select: text;
  -webkit-touch-callout: default;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }
.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
.logo-badge { background: var(--accent); color: var(--accent-contrast); font-weight: 800; padding: 8px 12px; border-radius: 12px; font-size: 18px; }
.logo-word { font-weight: 800; font-size: 26px; }
.auth-tagline { text-align: center; color: var(--text-muted); margin: 0 0 28px; }
.auth-tabs { display: flex; background: var(--surface-alt); border-radius: 14px; padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 10px; font-weight: 700; color: var(--text-muted); cursor: pointer; }
.auth-tab.active { background: var(--card-bg); color: var(--text-main); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-top: 10px; }
.auth-form input { border: 1.5px solid var(--border); border-radius: 12px; padding: 13px 14px; font-size: 16px; outline: none; background: var(--card-bg); color: var(--text-main); }
.auth-form input:focus { border-color: var(--accent); }
.auth-error { color: var(--red); font-size: 13px; min-height: 16px; margin: 4px 0 0; }
.btn-primary { margin-top: 18px; background: var(--accent); color: var(--accent-contrast); border: none; padding: 15px; border-radius: 14px; font-weight: 800; font-size: 15px; cursor: pointer; }
.btn-primary:active { background: var(--accent-dark); }

/* ---------- App shell ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 110px; position: relative; background: var(--bg); }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; background: var(--bg); position: sticky; top: 0; z-index: 20; }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-icons { display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-alt); border: none; color: var(--text-main); display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; }

.page { padding: 4px 18px 8px; }
.page-title { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.page-sub { color: var(--text-muted); margin: 0 0 16px; font-size: 14px; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; }
.fab-add { width: 48px; height: 48px; border-radius: 16px; background: var(--accent); color: var(--accent-contrast); border: none; font-size: 22px; font-weight: 800; cursor: pointer; flex-shrink: 0; }

/* ---------- Cards ---------- */
.card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card-dark { background: var(--hero-bg); color: #fff; border-radius: var(--radius-lg); padding: 22px; margin-bottom: 14px; }
.card-dark .muted { color: var(--hero-text-muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.card-dark .big-number { font-size: 30px; font-weight: 800; margin: 6px 0; }

.hero-row { display: flex; justify-content: space-between; margin-top: 18px; }
.hero-col .muted { display:block; margin-bottom: 4px; }
.hero-col .val-income { color: #4ADE9C; font-weight: 700; font-size: 17px; }
.hero-col .val-expense { color: #FF8FA3; font-weight: 700; font-size: 17px; }
.hero-note { text-align: center; color: var(--hero-text-muted); font-size: 13px; margin-top: 14px; font-style: italic; }

/* Menu grid */
.menu-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 6px; margin: 14px 0; }
.menu-item { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; background: none; border: none; }
.menu-icon { width: 54px; height: 54px; border-radius: 50%; background: var(--surface-alt); color: var(--text-main); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.menu-icon svg { width: 24px; height: 24px; }
.menu-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

/* Progress */
.progress-block { margin-bottom: 12px; }
.progress-label-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.progress-label-row .status { color: var(--text-muted); font-weight: 500; margin-left: 6px; font-size: 12px; }
.progress-track { height: 8px; border-radius: 6px; background: var(--surface-alt); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; }
.fill-purple { background: var(--purple); }
.fill-orange { background: var(--orange); }
.fill-accent { background: var(--accent); }
.fill-red { background: var(--red); }

/* Calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 700; padding-bottom: 4px; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; background: var(--surface-alt); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; padding: 2px; }
.cal-cell.has-activity { background: var(--accent-soft); }
.cal-cell.today { outline: 2px solid var(--accent); }
.cal-cell .d { font-weight: 700; font-size: 11px; }
.cal-cell .amt { color: var(--red); font-size: 9px; font-weight: 700; }

/* Goals */
.goal-card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; border: 2px solid transparent; }
.goal-card.highlight { border-color: var(--accent); }
.goal-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--surface-alt); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 12px; }
.goal-name { font-weight: 700; font-size: 15px; margin: 0 0 2px; overflow-wrap: break-word; }
.goal-date { color: var(--text-muted); font-size: 12px; display: flex; align-items: center; gap: 5px; margin-bottom: 14px; }
.goal-progress-row { display: flex; align-items: center; gap: 16px; }
.goal-ring { width: 62px; height: 62px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex-shrink: 0; background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-alt) 0); position: relative; }
.goal-ring::before { content: ''; position: absolute; inset: 6px; background: var(--card-bg); border-radius: 50%; }
.goal-ring span { position: relative; z-index: 1; }
.goal-amt { font-weight: 700; font-size: 16px; }
.goal-amt-sub { color: var(--text-muted); font-size: 12px; }
.goal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.goal-foot button { border: none; background: none; color: var(--red); cursor: pointer; font-size: 13px; }

/* Wallet */
.wallet-section-title { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 8px; }
.wallet-section-title .label { font-size: 12px; font-weight: 800; color: var(--text-muted); letter-spacing: 0.04em; }
.wallet-section-title .total { font-weight: 800; }
.wallet-row { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.wallet-left { display: flex; align-items: center; gap: 12px; }
.wallet-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-alt); color: var(--text-main); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.wallet-icon svg { width: 20px; height: 20px; }
.wallet-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.wallet-type { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; font-weight: 700; }
.wallet-balance { font-weight: 700; font-size: 13.5px; }
.wallet-balance.negative { color: var(--red); }

/* Transactions */
.search-bar { background: var(--card-bg); border-radius: 14px; padding: 13px 16px; box-shadow: var(--shadow); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.search-bar input { border: none; outline: none; flex: 1; font-size: 16px; background: transparent; color: var(--text-main); }
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.filter-chip { border: 1px solid var(--border); background: var(--card-bg); border-radius: 20px; padding: 8px 14px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tx-date-header { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 12px; font-weight: 700; margin: 14px 0 8px; text-transform: uppercase; }
.tx-row { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.tx-left { display: flex; align-items: center; gap: 12px; }
.tx-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.tx-title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.tx-cat { color: var(--text-muted); font-size: 11px; }
.tx-amt { font-weight: 700; font-size: 13px; }
.tx-amt.income { color: var(--green); }
.tx-amt.expense { color: var(--red); }
.tx-delete { background: none; border: none; color: var(--text-muted); opacity: 0.6; font-size: 15px; cursor: pointer; margin-left: 4px; padding: 6px; }
.tx-edit { background: none; border: none; color: var(--text-muted); opacity: 0.7; cursor: pointer; margin-left: 4px; display: inline-flex; align-items: center; justify-content: center; padding: 6px; }
.tx-edit svg { width: 16px; height: 16px; }

/* Health score */
.score-ring-wrap { display: flex; flex-direction: column; align-items: center; padding: 10px 0 6px; }
.score-ring { width: 200px; height: 200px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-alt) 0); display: flex; align-items: center; justify-content: center; position: relative; }
.score-ring::before { content: ''; position: absolute; inset: 14px; background: var(--card-bg); border-radius: 50%; }
.score-ring .score-num { position: relative; z-index: 1; font-size: 44px; font-weight: 800; }
.score-ring .score-den { position: relative; z-index: 1; color: var(--text-muted); font-size: 16px; margin-top: -6px; }
.score-title { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 20px; font-weight: 800; margin-top: 16px; }
.score-desc { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 8px auto 4px; max-width: 300px; }
.score-badge { display: block; width: fit-content; margin: 10px auto 20px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; font-size: 13px; padding: 6px 16px; border-radius: 20px; }
.score-bar-block { margin-bottom: 16px; }
.score-bar-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 8px; }

/* Bottom nav */
.bottom-nav { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 448px; background: var(--nav-bg); backdrop-filter: blur(10px); border-radius: 28px; display: flex; align-items: center; justify-content: space-around; padding: 10px 8px; box-shadow: var(--shadow); z-index: 50; }
.nav-btn { background: none; border: none; font-size: 20px; color: var(--text-muted); padding: 8px 14px; border-radius: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.nav-btn svg { width: 22px; height: 22px; display: block; }
.nav-btn.active { color: var(--accent-dark); background: var(--accent-soft); }
.nav-fab { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); border: none; font-size: 26px; font-weight: 800; cursor: pointer; margin-top: -30px; box-shadow: 0 4px 14px rgba(14,156,144,0.45); }

/* Sheet / modal */
.sheet-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card-bg); width: 100%; max-width: 480px; border-radius: 26px 26px 0 0; padding: 20px 20px 30px; max-height: 85vh; overflow-y: auto; }
.sheet-handle { width: 40px; height: 5px; background: var(--border); border-radius: 4px; margin: 0 auto 16px; }
.sheet-title { font-size: 19px; font-weight: 800; margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; background: var(--card-bg); color: var(--text-main); }
.field input:focus, .field select:focus { border-color: var(--accent); }
.type-toggle { display: flex; gap: 8px; }
.type-toggle button { flex: 1; padding: 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-main); font-weight: 700; cursor: pointer; }
.type-toggle button.active-expense { background: #FFECEE; border-color: var(--red); color: var(--red); }
.type-toggle button.active-income { background: #E9FBEF; border-color: var(--green); color: var(--green); }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn-secondary { flex: 1; background: var(--surface-alt); color: var(--text-main); border: none; padding: 14px; border-radius: 14px; font-weight: 700; cursor: pointer; }
.sheet .btn-primary { flex: 2; margin-top: 0; }
.sheet .btn-primary.btn-danger { background: var(--red); color: #fff; }

.empty-state { text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 14px; }

/* ---- Tanya AI (chat) ---- */
.chat-list { display: flex; flex-direction: column; gap: 10px; min-height: 40vh; max-height: 62vh; overflow-y: auto; padding-bottom: 10px; }
.chat-bubble { max-width: 82%; padding: 12px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; box-shadow: var(--shadow); }
.chat-bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-contrast); border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: var(--card-bg); color: var(--text-main); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 10px; align-items: center; position: sticky; bottom: 8px; background: var(--bg); padding-top: 8px; }
.chat-input-row input { flex: 1; border: 1.5px solid var(--border); border-radius: 22px; padding: 13px 16px; font-size: 16px; outline: none; background: var(--card-bg); color: var(--text-main); }
.chat-input-row input:focus { border-color: var(--accent); }
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--hero-bg); color: #fff; padding: 12px 20px; border-radius: 14px; font-size: 14px; font-weight: 600; z-index: 200; opacity: 0; transition: opacity 0.25s; }
.toast.show { opacity: 1; }

@media (min-width: 480px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
/* Net worth breakdown */
.nw-section { font-size: 12px; font-weight: 800; letter-spacing: 0.05em; color: var(--text-muted); text-transform: uppercase; margin: 14px 0 4px; }
.nw-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.nw-row .v { font-weight: 700; white-space: nowrap; }
.nw-row .v.neg { color: var(--red); }
.nw-row.total { font-weight: 800; border-bottom: none; padding-top: 10px; }
.nw-row.grand { font-weight: 800; font-size: 16px; border-top: 2px solid var(--border); border-bottom: none; margin-top: 12px; padding-top: 12px; }

/* Transfer */
.tx-amt.transfer { color: var(--text-main); }
.fab-secondary { background: var(--surface-alt); color: var(--text-main); }
.fab-secondary svg { width: 22px; height: 22px; display: block; margin: 0 auto; }

/* ===== Tata letak baris data: SELALU sama, tidak berubah mengikuti panjang teks ===== */
html { overflow-x: hidden; }                               /* halaman tidak pernah bisa digeser ke samping */
@supports (overflow: clip) { .app { overflow-x: clip; } }
.wallet-row, .tx-row { gap: 10px; }
.wallet-row > .wallet-left, .tx-row > .tx-left { flex: 1 1 0; min-width: 0; }   /* kolom nama mengambil sisa ruang */
.wallet-left > div:last-child, .tx-left > div:last-child { min-width: 0; }
.wallet-icon, .tx-icon { flex-shrink: 0; }
.wallet-name, .tx-title, .tx-cat, .wallet-type { overflow-wrap: break-word; }     /* nama panjang membungkus ke bawah */
.wallet-row > div:last-child:not(.wallet-left), .tx-row > div:last-child:not(.tx-left) { flex-shrink: 0; }
.wallet-balance, .tx-amt, .nw-row .v, .card-dark .big-number, .goal-amt { white-space: nowrap; }  /* nominal selalu 1 baris */
.nw-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }

/* Aset tetap: ikon | (nama di atas, lalu nominal + tombol sebaris di bawahnya) */
.asset-row { display: flex; align-items: center; gap: 12px; }
.asset-body { flex: 1 1 0; min-width: 0; }
.asset-body .wallet-name { margin-bottom: 2px; }
.asset-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; }   /* wrap = hanya jika nominal sangat besar di layar sangat sempit */
.asset-actions { display: flex; align-items: center; flex-shrink: 0; margin: -6px -6px -6px auto; }
.asset-actions .tx-edit, .asset-actions .tx-delete { margin-left: 0; }

/* Utang & piutang */
.debt-top { gap: 10px; }
.debt-left { flex: 1 1 0; min-width: 0; }
.debt-right { flex-shrink: 0; }
.debt-left .wallet-type { overflow-wrap: break-word; }
.hero-col { min-width: 0; }
.hero-col .val-income, .hero-col .val-expense { white-space: nowrap; }
.menu-item { min-width: 0; }
.menu-label { text-align: center; max-width: 100%; overflow-wrap: anywhere; line-height: 1.2; }
