:root {
  --bg: #F6F1E8;
  --card: #FFFDF9;
  --ink: #1E2A2B;
  --muted: #7A817C;
  --line: #E7DFD2;
  --accent: #1F6F66;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEBE6;
  --danger: #B4493B;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(30, 42, 43, .06), 0 6px 18px rgba(30, 42, 43, .06);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --c-gaji: #E9DDF6;  --i-gaji: #6B4C9A;
  --c-parkir: #DCE8F7; --i-parkir: #2F5F9E;
  --c-bensin: #F8E3D3; --i-bensin: #B0592A;
  --c-angpao: #F7DADA; --i-angpao: #B33A3A;
  --c-makan: #F6EBC9; --i-makan: #8C6A12;
  --c-lain: #E3E8E2;  --i-lain: #4F5D53;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { min-height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.view { max-width: 460px; margin: 0 auto; padding: 16px 18px 32px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }

/* Login */
#view-login { min-height: 100dvh; display: grid; place-items: center; }
.login-card { width: 100%; background: var(--card); border-radius: 24px; padding: 28px 22px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 22px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.login-card h1 { font-size: 24px; margin: 0 0 6px; }
.login-card p { margin: 0 0 18px; }
.login-card input { width: 100%; font: inherit; font-size: 17px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; outline: none; margin-bottom: 14px; }
.login-card input:focus { border-color: var(--accent); }
.code-input { text-align: center; letter-spacing: 12px; font-size: 26px !important; font-weight: 700; }
.error { color: var(--danger); min-height: 1.2em; margin: 12px 0 0 !important; font-size: 14px; }

.btn-primary { width: 100%; padding: 16px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px; transition: transform .08s, opacity .2s; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .35; }
.btn-secondary { width: 100%; padding: 14px; border-radius: 14px; background: var(--bg); font-weight: 600; }
.btn-link { width: 100%; padding: 12px; color: var(--muted); font-size: 15px; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: flex-start; padding: 6px 2px 12px; }
.hello { margin: 0; font-size: 15px; color: var(--muted); }
.month { margin: 2px 0 0; font-size: 15px; }
.month strong { font-size: 17px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); }
.icon-btn svg { fill: currentColor; stroke: none; }
.sync { background: #FFF4D6; color: #7A5B00; border-radius: 12px; padding: 8px 12px; font-size: 14px; margin-bottom: 10px; }

/* Entry */
.entry { background: var(--card); border-radius: 24px; padding: 18px 14px 14px; box-shadow: var(--shadow); }
.amount { text-align: center; font-weight: 800; font-size: 44px; letter-spacing: -1px; padding: 6px 0 16px; font-variant-numeric: tabular-nums; }
.amount .rp { font-size: 22px; color: var(--muted); font-weight: 700; margin-right: 6px; vertical-align: 14px; }
.amount.zero #amount-value { color: #C9C2B6; }

.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border-radius: 16px; background: var(--bg); font-size: 13px; font-weight: 600; border: 2px solid transparent; transition: transform .08s, border-color .15s, background .15s; }
.cat:active { transform: scale(.96); }
.cat .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.cat .ic svg { width: 22px; height: 22px; }
.cat[aria-checked="true"] { border-color: var(--ink); background: #fff; }

.extras { display: flex; gap: 8px; margin: 12px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: var(--bg); font-size: 14px; color: var(--ink); }
.chip svg { width: 17px; height: 17px; }
.chip.set { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.note { width: 100%; margin-top: 10px; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); outline: none; }
.note:focus { border-color: var(--accent); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 14px 0 12px; }
.keypad button { height: 54px; border-radius: 14px; font-size: 24px; font-weight: 600; background: transparent; display: grid; place-items: center; transition: background .1s; font-variant-numeric: tabular-nums; }
.keypad button:active { background: var(--bg); }
.keypad svg { width: 26px; height: 26px; }

/* Recent */
.recent { margin-top: 22px; }
.recent h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 4px 10px; }
.recent ul { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: 0; }
.recent li .ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.recent li .meta { flex: 1; min-width: 0; }
.recent li .t { font-weight: 600; font-size: 15px; }
.recent li .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent li .a { font-weight: 700; font-variant-numeric: tabular-nums; }
.recent li .del { color: var(--muted); padding: 6px; margin-right: -6px; }
.recent li.pending { opacity: .6; }
.empty { text-align: center; margin: 10px 0; }

/* Menu & toast */
dialog { border: 0; border-radius: 22px; padding: 22px 18px 10px; width: min(360px, 90vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(30, 42, 43, .35); }
dialog p { margin: 0 0 14px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
