:root {
  --bg: #f5f1e8;
  --surface: #fffdf7;
  --ink: #26231f;
  --muted: #7a7266;
  --line: #e3dccd;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --warn: #b5562b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05);
}
:root[data-theme="moss"] { --bg:#eef2ea; --surface:#f9fbf6; --ink:#1f2a22; --muted:#66786b; --line:#d6e0cf; --accent:#4b7d3a; }
:root[data-theme="ink"]  { --bg:#17181c; --surface:#202229; --ink:#f1ede4; --muted:#9aa0ab; --line:#30333c; --accent:#d9b36c; --accent-ink:#17181c; --warn:#ff8a65; }
:root[data-theme="clay"] { --bg:#f7e9e1; --surface:#fff6f0; --ink:#3b2418; --muted:#8a6a5a; --line:#ecd3c5; --accent:#a0462a; }
:root[data-theme="sea"]  { --bg:#e8f1f5; --surface:#f7fbfd; --ink:#17303d; --muted:#5f7f8d; --line:#cfe0e8; --accent:#1f6f8b; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: 96px; -webkit-font-smoothing: antialiased; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 26px; margin: 20px 0 8px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .01em; }

.view { display: none; padding-top: 8px; }
.view.active { display: block; }

.month-bar { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px 0; font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.hero .big { font-size: 34px; font-weight: 700; margin: 6px 0 14px; }
.split { display: flex; gap: 12px; }
.split > div { flex: 1; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.split span { display: block; font-size: 12px; color: var(--muted); }
.split strong { font-size: 15px; }

.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: 0; }
.row-item .meta { display: flex; flex-direction: column; min-width: 0; }
.row-item .meta small { color: var(--muted); font-size: 12px; }
.row-item .amt { font-weight: 600; white-space: nowrap; }
.row-item .amt.income { color: var(--accent); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar > span.warn { background: var(--warn); }
.budget-item { margin-bottom: 12px; }
.budget-item .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.budget-item input { width: 130px; text-align: right; }

input, button, select { font: inherit; }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], input:not([type]), #note {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
}
button { cursor: pointer; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--surface); color: var(--ink); }
button.small { padding: 8px 12px; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }

.fab { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); width: 60px; height: 60px; border-radius: 50%; padding: 0; background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 1; box-shadow: 0 8px 20px rgba(0,0,0,.2); }

nav.bottom { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; background: var(--surface); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); }
nav.bottom button { background: transparent; color: var(--muted); font-size: 12px; padding: 8px 2px; border-radius: 10px; }
nav.bottom button.active { color: var(--accent); font-weight: 700; }
nav.bottom .fab { position: static; transform: none; margin: 0 auto; width: 56px; height: 56px; }

dialog { width: min(480px, calc(100vw - 24px)); border: 0; border-radius: 20px; padding: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
#txForm { display: flex; flex-direction: column; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { background: transparent; color: var(--muted); padding: 10px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.amount { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--line); padding: 4px 0; }
.amount span { color: var(--muted); font-size: 18px; }
.amount input { border: 0; background: transparent; font-size: 36px; font-weight: 700; padding: 0; width: 100%; outline: none; color: var(--ink); }
.chips, .cats { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button, .cats button { padding: 8px 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 14px; }
.chips button.on, .cats button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.actions button { min-width: 110px; }

.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.themes button { text-align: left; padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.themes button.on { outline: 2px solid var(--accent); }
.themes button[disabled] { opacity: .55; }
.themes small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.toggle { display: flex; align-items: center; gap: 10px; }

/* Halaman masuk */
#view-auth { display: none; }
body:not(.authed) #view-auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px 16px; }
body:not(.authed) .top, body:not(.authed) main, body:not(.authed) nav.bottom, body:not(.authed) .fab { display: none; }
body:not(.authed) { padding-bottom: 0; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.big-brand { font-size: 26px; margin-bottom: 4px; }
.auth-card .seg { margin: 16px 0; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }
.error { color: var(--warn); font-size: 13px; min-height: 0; margin: 0; }
.error:empty { display: none; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.google-slot { display: flex; justify-content: center; min-height: 44px; }
