:root {
  --bg: #F4F6F3;
  --card: #FFFFFF;
  --ink: #16201B;
  --ink-2: #3D4842;
  --muted: #56615A;
  --line: #E3E7E3;
  --line-2: #D5DBD6;
  --green: #1F6B4A;
  --green-dark: #14503A;
  --green-soft: #DCF1E3;
  --income: #157F3D;
  --expense: #B42318;
  --warn-bg: #FFF7E6;
  --warn-line: #F5D9A3;
  --warn-ink: #6B4A12;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
h1 { margin: 0; font-size: 22px; font-weight: 700; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 20px 18px calc(100px + var(--safe-bottom)); }
.screen.plain { padding-bottom: calc(24px + var(--safe-bottom)); }
.screen.white { background: #fff; }
.topbar { display: flex; align-items: center; gap: 8px; margin: -6px -8px 0; }
.topbar h1 { font-size: 18px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { font-size: 13px; color: var(--muted); }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-top: 4px; text-transform: uppercase; }
.hidden { display: none !important; }

.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line-2); background: #fff; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); cursor: pointer; flex-shrink: 0; }
.icon-btn.bare { border: none; background: transparent; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.pad { padding: 14px 16px; }

.hero { background: var(--green); color: #fff; border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.hero .lbl { font-size: 13px; color: #CFE6DA; }
.hero .big { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.hero .tile { background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px 12px; }
.hero .tile b { display: block; font-size: 15px; font-weight: 600; }

.acct { padding: 12px 14px; }
.acct .name { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.acct .val { font-size: 16px; font-weight: 600; margin-top: 4px; }
.dot { width: 10px; height: 10px; border-radius: 5px; display: inline-block; flex-shrink: 0; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.banner.info { background: #EEF5F1; border: 1px solid #CFE3D7; }
.banner .ic { width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.banner.warn .ic { background: #FDE7B8; color: #92400E; }
.banner.info .ic { background: var(--green-soft); color: var(--green); }
.banner b { display: block; font-size: 14px; }
.banner span.s { font-size: 12px; color: var(--warn-ink); }
.banner.info span.s { color: var(--muted); }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid #EEF1EE; text-decoration: none; color: inherit; }
.item:last-child { border-bottom: none; }
.item .sw { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .d { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-size: 14px; font-weight: 600; white-space: nowrap; }
.amt.in { color: var(--income); }
.amt.out { color: var(--expense); }
.amt.neutral { color: var(--ink-2); }
.day-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 28px 16px; }

/* Form */
.f { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.input, .select { height: 48px; width: 100%; border-radius: 12px; border: 1px solid var(--line-2); background: #fff; padding: 0 14px; font-size: 15px; }
.input:focus, .select:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%233D4842' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.sel-wrap { position: relative; }
.sel-wrap .dot { position: absolute; left: 14px; top: 19px; pointer-events: none; }
.sel-wrap .select { padding-left: 34px; }
.money { display: flex; align-items: center; gap: 8px; height: 48px; border-radius: 12px; border: 1px solid var(--line-2); padding: 0 14px; background: #fff; }
.money input { flex: 1; min-width: 0; border: none; outline: none; font-size: 17px; font-weight: 600; background: transparent; }
.money:focus-within { border-color: var(--green); outline: 2px solid var(--green); }
.amount-big { text-align: center; padding: 6px 0 2px; }
.amount-big .wrap { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: 6px; }
.amount-big .rp { font-size: 22px; font-weight: 600; color: var(--muted); }
.amount-big input { width: 240px; border: none; outline: none; font-size: 40px; font-weight: 700; letter-spacing: -1px; background: transparent; }
.amount-big .bar { height: 2px; background: var(--green); width: 240px; margin: 6px auto 0; border-radius: 1px; }

.seg { display: grid; gap: 4px; background: #EEF1EE; border-radius: 12px; padding: 4px; }
.seg button { height: 40px; border: none; border-radius: 9px; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.types button[aria-pressed="true"][data-v="expense"] { background: var(--expense); color: #fff; }
.seg.types button[aria-pressed="true"][data-v="income"] { background: var(--income); color: #fff; }
.seg.types button[aria-pressed="true"][data-v="transfer"] { background: #3D4842; color: #fff; }
.seg.types button[aria-pressed="true"][data-v="cash_withdrawal"] { background: #6D28D9; color: #fff; }

.pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pick button { min-height: 48px; border-radius: 12px; border: 1px solid var(--line-2); background: #fff; font-size: 14px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 4px 8px; }
.pick button[aria-pressed="true"] { border: 2px solid var(--green); background: #EEF5F1; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line-2); background: #fff; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.btn { height: 50px; border-radius: 12px; border: none; background: var(--green); color: #fff; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; padding: 0 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.big { height: 54px; font-size: 16px; border-radius: 14px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.btn.outline { background: #fff; color: var(--green); border: 1px solid var(--green); }
.btn.danger { background: #fff; color: var(--expense); border: 1px solid #F0B4AE; }
.btn.sm { height: 40px; font-size: 13px; border-radius: 10px; }

.sticky-foot { position: sticky; bottom: 0; padding: 12px 0 calc(8px + var(--safe-bottom)); background: linear-gradient(to top, #fff 70%, rgba(255,255,255,0)); margin-top: auto; }
.screen:not(.white) .sticky-foot { background: linear-gradient(to top, var(--bg) 70%, rgba(244,246,243,0)); }

/* Nav */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(70px + var(--safe-bottom)); padding-bottom: var(--safe-bottom); background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; font-size: 11px; text-align: center; z-index: 10; max-width: 520px; margin: 0 auto; }
nav.tabs a { text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; }
nav.tabs a[aria-current="page"] { color: var(--green); font-weight: 600; }
nav.tabs a.fab { justify-self: center; width: 58px; height: 58px; border-radius: 29px; background: var(--green); color: #fff; justify-content: center; margin-top: -26px; box-shadow: 0 6px 16px rgba(31,107,74,.35); padding: 0; }

/* Ringkasan */
.chart { display: grid; align-items: end; height: 140px; border-bottom: 1px solid var(--line-2); gap: 2px; }
.chart .g { display: flex; justify-content: center; align-items: flex-end; gap: 2px; height: 100%; border-radius: 6px 6px 0 0; padding-top: 4px; cursor: pointer; }
.chart .g.sel { background: #EEF5F1; }
.chart .b { width: 40%; max-width: 14px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-x { display: grid; text-align: center; font-size: 11px; color: var(--muted); gap: 2px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #EEF1EE; font-size: 14px; gap: 8px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-2); }
.kv b { white-space: nowrap; }
.kv.subrow { padding: 0 0 8px 12px; font-size: 12px; color: var(--muted); border-bottom: none; margin-top: -4px; }
.bar-track { height: 8px; background: #EEF1EE; border-radius: 4px; }
.bar-fill { height: 8px; border-radius: 4px; }
table.yr { width: 100%; border-collapse: collapse; font-size: 13px; }
table.yr th { text-align: right; font-weight: 600; color: var(--muted); font-size: 11px; padding: 6px 4px; border-bottom: 1px solid var(--line-2); }
table.yr th:first-child, table.yr td:first-child { text-align: left; }
table.yr td { text-align: right; padding: 8px 4px; border-bottom: 1px solid #EEF1EE; white-space: nowrap; }
table.yr tr.total td { font-weight: 700; border-bottom: none; }
.neg { color: var(--expense); }

/* Pengingat */
.datebox { width: 52px; flex-shrink: 0; text-align: center; background: #EEF1EE; border-radius: 10px; padding: 6px 0; }
.datebox .m { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.datebox .d { font-size: 18px; font-weight: 700; }
.datebox.soon { background: #FFF1D6; }
.datebox.soon .m { color: #92400E; }
.datebox.late { background: #FBE1DE; }
.datebox.late .m { color: #9F1C12; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 10px; padding: 3px 8px; }
.pill.warn { color: #92400E; background: #FDE7B8; }
.pill.late { color: #9F1C12; background: #FBE1DE; }
.pill.ok { color: var(--income); background: var(--green-soft); }
.pill.bad { color: #9F1C12; background: #FBE1DE; }

.notice { background: #FDF1EF; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #7A1F12; }
.notice.ok { background: #EEF5F1; color: var(--green-dark); }
.note-box { font-size: 12px; color: var(--muted); line-height: 1.45; background: #F6F8F6; border-radius: 10px; padding: 10px 12px; }
ul.hints { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
ul.hints li::marker { color: #B45309; }

.settings-link { display: flex; justify-content: space-between; align-items: center; min-height: 50px; padding: 0 16px; border-bottom: 1px solid #EEF1EE; text-decoration: none; color: var(--ink); font-size: 14px; }
.settings-link:last-child { border-bottom: none; }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast.err { background: #9F1C12; }
.loading { display: flex; justify-content: center; padding: 60px 0; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
