/* Palet sesuai color guideline */
:root {
  --bg: #000000;
  --surface: #1C2120;      /* dark */
  --surface-2: #232927;
  --line: #2C3331;
  --lime: #DCFFAD;         /* aksen utama */
  --sage: #7B9575;         /* aksen sekunder / teks redup */
  --white: #FFFFFF;
  --star: #3E4A3B;         /* motif bintang */
  --danger: #FF8B7B;       /* khusus aksi hapus */
  --font: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { color-scheme: dark; background: var(--bg); }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--white);
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(84px + var(--safe-b));
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.top { padding: calc(18px + var(--safe-t)) 16px 4px; }
.top-row { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.app-name { font-weight: 500; font-size: 20px; letter-spacing: -.3px; }
.star { width: 26px; height: 26px; fill: var(--star); }

.hero {
  position: relative; overflow: hidden;
  margin-top: 14px; background: var(--lime); color: var(--surface);
  border-radius: 22px; padding: 20px 20px 22px;
}
.balance-label { font-size: 14px; font-weight: 500; opacity: .7; }
.balance {
  font-weight: 700; font-size: 36px; letter-spacing: -1px;
  line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums;
  position: relative; z-index: 1;
}
.balance.neg { color: #8A3B2E; }
.hero-star { position: absolute; right: -18px; bottom: -22px; width: 110px; height: 110px; fill: rgba(28,33,32,.08); }

.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; background: var(--surface); border-radius: 14px; padding: 4px;
}
.month-nav button { background: none; border: 0; color: var(--white); width: 42px; height: 38px; font-size: 24px; border-radius: 10px; }
.month-nav button:active { background: var(--surface-2); }
#monthLabel { font-weight: 500; font-size: 15px; text-transform: capitalize; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.stat span { display: block; font-size: 12px; color: var(--sage); font-weight: 500; }
.stat strong { display: block; font-size: 17px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat.in strong { color: var(--lime); }
.stat.out strong { color: var(--white); }

/* ---------- Konten ---------- */
main { padding: 16px; }
.view { display: none; }
.view.active { display: block; }
.pos { color: var(--lime); }
.neg { color: var(--white); }
.muted { color: var(--sage); }
.small { font-size: 12px; }
.center { text-align: center; }

.day { margin-bottom: 16px; }
.day-head {
  display: flex; justify-content: space-between; font-size: 12px; font-weight: 500;
  color: var(--sage); padding: 0 4px 8px; text-transform: capitalize;
}
.tx {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: 0; border-radius: 16px;
  padding: 12px; margin-bottom: 6px; text-align: left;
}
.tx:active { background: var(--surface-2); }
.tx-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex: none; }
.tx-ic.out { background: rgba(255,255,255,.06); }
.tx-ic.in { background: rgba(220,255,173,.14); }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-cat { font-weight: 500; font-size: 15px; }
.tx-note { font-size: 13px; color: var(--sage); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.tx-amt { font-weight: 600; font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-amt.in { color: var(--lime); }
.tx-amt.out { color: var(--white); }

.empty { text-align: center; padding: 48px 20px; }
.empty-ic { font-size: 40px; }
.empty p { margin: 8px 0 0; }

.card { background: var(--surface); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.card h3 {
  font-size: 17px; font-weight: 500; letter-spacing: -.2px; margin: 0 0 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.card h3 span { font-size: 14px; color: var(--sage); font-weight: 500; }
.card p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; color: rgba(255,255,255,.82); }
.card p.muted { color: var(--sage); }
.card.net { display: flex; justify-content: space-between; align-items: center; }
.card.net strong { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }

.bar-row { margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.bar-top em { font-style: normal; color: var(--sage); font-size: 12px; margin-left: 6px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.bar i.out { background: var(--sage); }
.bar i.in { background: var(--lime); }

/* ---------- Tombol ---------- */
.btn {
  display: block; width: 100%; text-align: center;
  border: 1px solid var(--lime); background: var(--lime); color: var(--surface);
  border-radius: 14px; padding: 13px 14px; font-weight: 600; font-size: 15px; margin-top: 8px;
}
.btn.ghost { background: transparent; color: var(--white); border-color: var(--line); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger-ghost { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row .btn { margin-top: 0; }

.fab {
  position: fixed; right: max(20px, calc(50% - 240px)); bottom: calc(82px + var(--safe-b));
  width: 60px; height: 60px; border-radius: 20px; border: 0;
  background: var(--lime); color: var(--surface); font-size: 32px; font-weight: 300; line-height: 1;
  box-shadow: 0 10px 24px rgba(220,255,173,.18); z-index: 5;
}

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(10,12,12,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b)); z-index: 4;
}
.bottom-nav button {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 500; color: var(--sage); padding: 6px 0; border-radius: 10px;
}
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav button.active { color: var(--lime); }

/* ---------- Form (bottom sheet) ---------- */
.sheet-backdrop, .dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10;
}
.sheet-backdrop.open, .dialog-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(20px + var(--safe-b));
  transform: translateY(105%); transition: transform .25s ease; z-index: 11;
  max-height: 92vh; overflow-y: auto;
}
.sheet.open { transform: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 22px; font-weight: 500; letter-spacing: -.4px; margin: 0 0 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 500; color: var(--sage); }
.seg button.active[data-type="out"] { background: var(--white); color: var(--surface); }
.seg button.active[data-type="in"] { background: var(--lime); color: var(--surface); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--sage); margin-bottom: 6px; }
.field input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--white);
  border-radius: 14px; padding: 13px; font-size: 16px; outline: none;
}
.field input::placeholder { color: #4D5751; }
.field input:focus { border-color: var(--sage); }
.amount-wrap { display: flex; align-items: center; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 0 14px; }
.amount-wrap:focus-within { border-color: var(--lime); }
.amount-wrap b { color: var(--sage); font-weight: 500; }
.field .amount-wrap input {
  border: 0; font-size: 28px; font-weight: 600; letter-spacing: -.5px;
  padding: 10px 8px; font-variant-numeric: tabular-nums; background: transparent;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 8px 13px; font-size: 14px; }
.chip.active { background: var(--sage); border-color: var(--sage); color: var(--white); }
.sheet-actions { display: flex; gap: 8px; margin-top: 6px; }
.sheet-actions .btn { margin: 0; }
.sheet-actions .btn.primary { flex: 2; }
.sheet-actions .btn.danger-ghost { flex: 1; }

/* ---------- Dialog & toast ---------- */
.dialog-backdrop { display: grid; place-items: center; padding: 24px; z-index: 20; }
.dialog { background: var(--surface); border-radius: 20px; padding: 20px; max-width: 340px; width: 100%; }
.dialog p { margin: 0 0 16px; font-size: 15px; line-height: 1.5; }
.toast {
  position: fixed; left: 50%; bottom: calc(156px + var(--safe-b));
  transform: translate(-50%, 20px); background: var(--white); color: var(--surface);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 30; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- v2: rekening, transfer, pembagian gaji, kategori ---------- */
.hero-hint { font-size: 12px; opacity: .65; margin-top: 4px; position: relative; z-index: 1; min-height: 0; }
.hero-hint:empty { display: none; }

.accounts {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc(50% - 5px); gap: 10px;
  overflow-x: auto; margin-top: 10px; scrollbar-width: none;
}
.accounts::-webkit-scrollbar { display: none; }
.acc {
  background: var(--surface); border: 1px solid transparent; border-radius: 14px;
  padding: 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.acc.active { border-color: var(--lime); }
.acc-name { font-size: 12px; color: var(--sage); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-name i { font-style: normal; opacity: .8; }
.acc-bal { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.acc.active .acc-name { color: var(--lime); }

.seg3 { grid-template-columns: repeat(3, 1fr); }
.seg button.active[data-type="transfer"] { background: var(--sage); color: var(--white); }
.seg button.active[data-ctype] { background: var(--surface-2); color: var(--white); }

.tx-ic.tf { background: rgba(123,149,117,.18); color: var(--sage); font-size: 18px; }
.tx-amt.tf { color: var(--sage); }

.split { background: var(--bg); border-radius: 14px; padding: 12px 14px 4px; margin-bottom: 14px; }
.split-toggle { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; padding-bottom: 8px; }
.split-toggle input { width: 18px; height: 18px; accent-color: var(--lime); margin: 0; }
.split-rows.off { opacity: .35; }
.split-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.split-row b { font-weight: 500; }
.split-row small { display: block; color: var(--sage); font-size: 12px; margin-top: 1px; }
.split-row span { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.list { margin-bottom: 4px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; background: var(--bg);
  border: 0; border-radius: 12px; padding: 11px 12px; margin-bottom: 6px; text-align: left;
}
.row:active { background: var(--surface-2); }
.row-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 17px; flex: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main > span { font-weight: 500; font-size: 15px; }
.row-main small { color: var(--sage); font-size: 12px; margin-top: 1px; }
.row-right { font-weight: 600; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-empty { color: var(--sage); font-size: 14px; padding: 6px 2px 10px; }
#catSeg { margin-bottom: 10px; }

.pct-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.pct-rest { padding: 13px; border-radius: 14px; background: var(--surface-2); font-weight: 600; color: var(--lime); font-size: 16px; }
.field select {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--white);
  border-radius: 14px; padding: 13px; font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #7B9575 50%), linear-gradient(135deg, #7B9575 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

.dialog h3 { font-size: 18px; font-weight: 500; margin: 0 0 14px; }
.emoji-row { display: flex; gap: 8px; align-items: center; }
.field .emoji-input { width: 56px; flex: none; text-align: center; font-size: 22px; padding: 8px; }
.emoji-presets { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.emoji-presets::-webkit-scrollbar { display: none; }
.emoji-presets button { background: none; border: 0; font-size: 22px; padding: 4px 6px; border-radius: 8px; flex: none; }
.emoji-presets button:active { background: var(--surface-2); }
.dlg-actions { display: flex; gap: 8px; margin-top: 6px; }
.dlg-actions .btn { margin: 0; flex: 1; padding-left: 8px; padding-right: 8px; }
#dialog { z-index: 25; }
.toast { white-space: normal; text-align: center; max-width: 90vw; width: max-content; }

/* ---------- v3: sisa bulanan & utang ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; }
.badge.warn { background: rgba(255,139,123,.15); color: var(--danger); }
.badge.ok { background: rgba(220,255,173,.14); color: var(--lime); }
.acc-debt { font-size: 11px; color: var(--danger); font-weight: 500; }
.card.callout { border: 1px solid rgba(220,255,173,.35); }
.callout-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.callout-row b { display: block; font-weight: 500; font-size: 15px; }
.callout-row small { display: block; color: var(--sage); font-size: 12px; margin-top: 2px; }
.callout-amt { font-size: 20px; font-weight: 600; color: var(--lime); font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.mini-btn { border: 1px solid var(--line); background: none; color: var(--lime); border-radius: 10px; padding: 7px 11px; font-size: 13px; font-weight: 600; white-space: nowrap; flex: none; }
.mini-btn.solid { background: var(--lime); border-color: var(--lime); color: var(--surface); }
.debt-group + .debt-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.debt-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.debt-head span { font-size: 13px; color: var(--sage); }
.debt-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.debt-item:first-of-type { border-top: 0; }
.debt-item b { display: block; font-weight: 500; font-size: 14px; }
.debt-item small { display: block; color: var(--sage); font-size: 12px; margin-top: 1px; }
.debt-amt { font-weight: 600; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub-opts { padding-bottom: 10px; }
.sub-opts small { display: block; color: var(--sage); font-size: 12px; margin-bottom: 8px; }
.debt-item > div { flex: 1; min-width: 0; }
.callout-row { flex-direction: column; align-items: stretch; gap: 10px; }
.callout-row .mini-btn { padding: 11px 12px; font-size: 14px; border-radius: 12px; }
.neg-r { color: var(--danger); }
