:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --line: #dde4de;
  --text: #15201b;
  --muted: #5d6b64;
  --accent: #0f7a55;
  --accent-ink: #ffffff;
  --accent-soft: #d9f2e5;
  --in: #11865a;
  --out: #c93d3d;
  --warn: #b26a00;
  --warn-soft: #fff1d6;
  --shadow: 0 1px 2px rgb(16 32 24 / 6%), 0 4px 16px rgb(16 32 24 / 5%);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1412;
    --surface: #151e1b;
    --surface-2: #1c2723;
    --line: #26332e;
    --text: #e6efe9;
    --muted: #93a39b;
    --accent: #3ccf93;
    --accent-ink: #062016;
    --accent-soft: #163a2b;
    --in: #4cd59a;
    --out: #ff7a75;
    --warn: #ffbd5c;
    --warn-soft: #3a2c12;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1412; --surface: #151e1b; --surface-2: #1c2723; --line: #26332e; --text: #e6efe9; --muted: #93a39b;
  --accent: #3ccf93; --accent-ink: #062016; --accent-soft: #163a2b; --in: #4cd59a; --out: #ff7a75;
  --warn: #ffbd5c; --warn-soft: #3a2c12; --shadow: 0 1px 2px rgb(0 0 0 / 30%); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-mark img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

/* ---------- tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--out); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); outline: none;
}
.field textarea { min-height: 90px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 2px; flex: none; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------- kunci / login ---------- */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.lock-box { width: min(440px, 100%); }
.lock-head { text-align: center; margin-bottom: 22px; }
.lock-head img { width: 64px; height: 64px; }
.lock-head h1 { font-size: 24px; margin-top: 12px; }
.lock-head p { margin: 6px 0 0; color: var(--muted); }
.lock .card { padding: 22px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: -6px; margin-bottom: 4px; }
.meter i { display: block; height: 100%; width: 0; background: var(--out); transition: width .2s, background .2s; }
.meter i.mid { background: var(--warn); }
.meter i.good { background: var(--in); }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; }
.notes { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.notes li { display: flex; gap: 8px; }
.notes li::before { content: "🔒"; }
.err { color: var(--out); font-weight: 600; min-height: 1.5em; margin: 4px 0 10px; }

/* ---------- kerangka app ---------- */
.shell { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.01em; }
.brand img { width: 28px; height: 28px; }
.brand span { display: none; }
@media (min-width: 600px) { .brand span { display: inline; } }
.month { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.month b { min-width: 0; text-align: center; font-size: 14px; white-space: nowrap; }
.month .icon-btn { width: 34px; }
.pill span { display: none; }
.pill { padding: 8px; }
@media (min-width: 600px) {
  .month b { min-width: 128px; font-size: 15px; }
  .month .icon-btn { width: 40px; }
  .pill span { display: inline; }
  .pill { padding: 4px 10px; }
}
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 0; cursor: pointer; white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--in); }
.pill.busy i { background: var(--warn); animation: pulse 1s infinite; }
.pill.err { color: var(--out); }
.pill.err i { background: var(--out); }
.pill.off i { background: var(--muted); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav a { display: grid; justify-items: center; gap: 2px; padding: 9px 4px 10px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--accent); }

main { padding: 16px 12px 24px; max-width: 1120px; margin: 0 auto; display: grid; gap: 14px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0; }
.card > h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card > h3 .more { margin-left: auto; font-size: 13px; font-weight: 600; }
.grid2 { display: grid; gap: 14px; }

/* ---------- beranda ---------- */
.quick { display: grid; gap: 6px; }
.quick-form { display: flex; gap: 8px; }
.quick-form input { flex: 1; min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); outline: none; font-size: 16px; }
.quick-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-form .btn { min-height: 52px; border-radius: 14px; }
.quick-preview { font-size: 13px; color: var(--muted); min-height: 1.4em; padding-left: 6px; }
.quick-preview b { color: var(--text); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats .stat:last-child { grid-column: span 2; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.stats .stat:last-child b { margin-top: 0; }
.stat { padding: 14px; }
.stat span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat b { display: block; font-size: clamp(16px, 4.8vw, 22px); margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat.in b { color: var(--in); }
.stat.out b { color: var(--out); }

.review { background: var(--warn-soft); border-color: transparent; }
.review > h3 { color: var(--warn); }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 5px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar-label b { font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--accent); }
.bar.over i { background: var(--out); }
.bar-sub { font-size: 12px; color: var(--muted); }

.chart svg { width: 100%; height: 150px; display: block; }
.chart .b { fill: var(--accent); opacity: .85; }
.chart .b.today { fill: var(--warn); }
.chart .axis { fill: var(--muted); font-size: 9px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; }

/* ---------- daftar transaksi ---------- */
.txs { display: grid; }
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 700; padding: 14px 4px 6px; }
.tx {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 10px 6px; border: 0; background: transparent; border-radius: 12px; cursor: pointer;
}
.tx:hover { background: var(--surface-2); }
.tx-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 19px; }
.tx-main { min-width: 0; }
.tx-main b { display: block; font-weight: 600; }
.tx-main small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amt.in { color: var(--in); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); margin-left: 4px; vertical-align: 1px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
.filters .row { flex-wrap: nowrap; }
.filters select { min-height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 10px; flex: 1; min-width: 0; }
.fab {
  position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 19; width: 58px; height: 58px; border-radius: 18px;
  border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgb(0 0 0 / 22%); cursor: pointer; display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; }

/* ---------- saran claude ---------- */
.md { line-height: 1.65; overflow-wrap: anywhere; }
.md h4 { font-size: 16px; margin: 16px 0 6px; }
.md h5 { font-size: 14px; margin: 12px 0 4px; }
.md p { margin: 8px 0; }
.md ul { margin: 6px 0; padding-left: 20px; }
.md li { margin: 3px 0; }
.md:empty { display: none; }
.ai-box { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 10px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.hist { display: grid; gap: 4px; }
.hist button { text-align: left; border: 0; background: transparent; padding: 10px 8px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.hist button:hover { background: var(--surface-2); }
pre.ctx { white-space: pre-wrap; font: 12px/1.5 var(--mono); background: var(--surface-2); padding: 12px; border-radius: 10px; max-height: 320px; overflow: auto; }
details summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }

/* ---------- pengaturan ---------- */
.set-list { display: grid; gap: 2px; }
.set-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.set-item:last-child { border-bottom: 0; }
.budget-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.budget-grid .field { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.ok-text { color: var(--in); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }

/* ---------- modal & toast ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / 42%); display: grid; align-items: end; justify-items: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet h2 { font-size: 18px; margin-bottom: 14px; }
.raw { font: 12px/1.5 var(--mono); background: var(--surface-2); border-radius: 10px; padding: 10px; white-space: pre-wrap; margin-bottom: 14px; color: var(--muted); }
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); display: flex; gap: 12px; align-items: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast button { background: transparent; border: 0; color: var(--accent-soft); font-weight: 800; cursor: pointer; padding: 0; }

@media (min-width: 760px) {
  .stats { gap: 14px; grid-template-columns: repeat(3, 1fr); }
  .stats .stat:last-child { grid-column: auto; display: block; }
  .stats .stat:last-child b { margin-top: 4px; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr auto; }
  .budget-grid { grid-template-columns: 1fr 1fr; }
  .backdrop { align-items: center; }
  .sheet { border-radius: 22px; }
}
@media (min-width: 1000px) {
  .shell { padding: 0 0 0 220px; }
  .nav {
    top: 0; right: auto; width: 220px; grid-template-columns: 1fr; align-content: start; gap: 4px; padding: 76px 12px 12px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav a { grid-template-columns: 24px 1fr; justify-items: start; align-items: center; gap: 12px; font-size: 15px; padding: 11px 14px; border-radius: 12px; }
  .nav a[aria-current="page"] { background: var(--accent-soft); }
  .top { padding-left: 20px; padding-right: 20px; }
  .top .brand { position: fixed; left: 24px; top: 18px; }
  main { padding: 24px; }
  .fab { bottom: 28px; right: 28px; }
  #toast { bottom: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
