/* ---------- Token warna ---------- */
:root {
  --bg: #f4f4f5; --surface: #fff; --surface-2: #fafafa; --fg: #0a0a0a; --muted: #71717a;
  --line: #e8e8ea; --pos: #10763f; --neg: #b3261e; --warn: #92600a; --info: #1d4ed8; --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000; --surface: #131315; --surface-2: #1b1b1e; --fg: #fafafa; --muted: #8e8e97;
    --line: #262629; --pos: #4ade80; --neg: #fb7185; --warn: #fbbf24; --info: #93b4fd;
  }
}
:root[data-theme="dark"] {
  --bg: #000; --surface: #131315; --surface-2: #1b1b1e; --fg: #fafafa; --muted: #8e8e97;
  --line: #262629; --pos: #4ade80; --neg: #fb7185; --warn: #fbbf24; --info: #93b4fd;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, p { margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 4px 10px; }
small { display: block; color: var(--muted); font-size: 13px; }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Kerangka ---------- */
.bar { position: sticky; top: 0; z-index: 5; max-width: 620px; margin: 0 auto; background: var(--bg);
       display: flex; align-items: center; gap: 10px; justify-content: space-between;
       padding: calc(14px + env(safe-area-inset-top)) 16px 12px; }
.bar h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.bar-actions { display: flex; align-items: center; gap: 4px; }
main { max-width: 620px; margin: 0 auto; padding: 4px 16px calc(130px + env(safe-area-inset-bottom)); }
.date { color: var(--muted); margin: 0 4px 14px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.muted { color: var(--muted); }
.err { font-size: 14px; font-weight: 600; color: var(--neg); }
.err:empty { display: none; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 26px 0 10px; }
.section-head h2 { margin: 0 4px; }
.section-head a, .section-head button.link { font-size: 14px; color: var(--muted); text-decoration: none; }
.link { background: none; border: 0; padding: 8px 4px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; }
.link:hover { color: var(--fg); }

/* ---------- Ringkasan ---------- */
.hero { background: var(--fg); color: var(--bg); border-radius: 24px; padding: 22px 22px 20px; margin-bottom: 12px; }
.hero > span { font-size: 14px; opacity: .65; }
.hero strong { display: block; font-size: 36px; line-height: 1.2; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-split { display: flex; gap: 22px; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgb(128 128 128 / .35); }
.hero-split div { min-width: 0; }
.hero-split span { display: block; font-size: 12px; opacity: .6; }
.hero-split b { font-size: 16px; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stats > * { background: var(--surface); border-radius: var(--r); padding: 14px 16px; color: inherit; text-decoration: none; }
.stats span { display: block; font-size: 13px; color: var(--muted); }
.stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stats b.pos { color: var(--pos); }
.stats b.neg { color: var(--neg); }

/* ---------- Grafik 6 bulan ---------- */
.chart { background: var(--surface); border-radius: var(--r); padding: 18px 16px 12px; }
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 132px; align-items: end; }
.bars > div { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.pair i { display: block; width: 11px; min-height: 3px; border-radius: 4px 4px 0 0; }
.pair i.masuk { background: var(--pos); }
.pair i.keluar { background: var(--neg); }
.bars small { font-size: 11px; }
.legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- Progres ---------- */
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 10px 4px 0; }
.progress i { display: block; height: 100%; background: var(--fg); border-radius: 99px; }

/* ---------- Daftar ---------- */
.group { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r); overflow: hidden; }
.group + .list-head { margin-top: 22px; }
.list-head { font-size: 12px; font-weight: 600; color: var(--muted); margin: 18px 4px 8px; }
.list-head:first-child { margin-top: 4px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 62px; }
.item + .item { border-top: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }
.grow b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.tap { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; cursor: pointer; }
.amt { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.amt.pemasukan { color: var(--pos); }
.amt.pengeluaran { color: var(--neg); }
.amt.hutang { color: var(--warn); }
.amt.transfer, .amt.tabungan { color: var(--muted); }
.past, .done-row { opacity: .55; }
.icon { flex: none; width: 40px; height: 40px; margin-right: -8px; display: grid; place-items: center;
        border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.icon svg { width: 20px; height: 20px; }
.item > .icon:first-child { margin-right: 0; margin-left: -6px; }
.icon:hover { color: var(--fg); background: var(--surface-2); }
.tag { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
       background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tag.pos { color: var(--pos); } .tag.neg { color: var(--neg); } .tag.warn { color: var(--warn); } .tag.info { color: var(--info); }

/* ---------- Tugas ---------- */
.dot, .check input { flex: none; width: 24px; height: 24px; margin: 0; border: 1.75px solid var(--fg); border-radius: 50%; }
.check { display: flex; align-items: center; gap: 14px; padding: 8px 0; cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; display: grid; place-content: center; background: none; cursor: pointer; }
.check input:checked { background: var(--fg); }
.check input:checked::after { content: ""; width: 10px; height: 5px; margin-top: -2px; border: solid var(--bg); border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.done .tap b { color: var(--muted); text-decoration: line-through; }
.quick { display: flex; gap: 8px; margin-bottom: 12px; }
.quick input { flex: 1; min-width: 0; background: var(--surface); border-color: transparent; }

/* ---------- Pencarian & filter ---------- */
.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 14px; width: 20px; color: var(--muted); }
.search input { padding-left: 42px; background: var(--surface); border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface);
        color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.month { display: flex; align-items: center; gap: 8px; }
.month input { background: var(--surface); border-color: transparent; }

/* ---------- Form & tombol ---------- */
input, select, textarea { width: 100%; min-height: 50px; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--fg);
        background: var(--bg); border: 1px solid var(--line); border-radius: 14px; }
textarea { min-height: 80px; resize: vertical; line-height: 1.4; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px;
       border: 0; border-radius: 14px; background: var(--fg); color: var(--bg); font: inherit; font-weight: 600;
       text-decoration: none; cursor: pointer; }
.btn.ghost { background: var(--bg); color: var(--fg); border: 1px solid var(--line); }
.btn.danger { background: var(--neg); color: #fff; }
.btn:disabled { opacity: .5; }
.btn:active, .fab:active { transform: scale(.97); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 0; min-height: 0; }
.seg span { display: block; padding: 12px 6px; text-align: center; font-size: 15px; font-weight: 500;
            border: 1px solid var(--line); border-radius: 14px; }
.seg input:checked + span { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.seg input:focus-visible + span { outline: 2px solid var(--fg); outline-offset: 2px; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 2px 0; }

/* ---------- Bottom sheet & dialog ---------- */
dialog { width: 100%; max-width: 520px; margin: auto auto 0; padding: 0; border: 0; border-radius: 24px 24px 0 0;
         background: var(--surface); color: var(--fg); max-height: 92dvh; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog[open] { animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(32px); opacity: 0; } }
.sheet { display: flex; flex-direction: column; gap: 14px; padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
         overflow-y: auto; max-height: 92dvh; }
.sheet h2 { font-size: 18px; margin: 0; }
.sheet input, .sheet select, .sheet textarea { background: var(--bg); }
.actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 4px; }
.ask { max-width: 380px; margin: auto; border-radius: 22px; }
.ask .sheet { gap: 10px; }
.fab { position: fixed; z-index: 9; right: 20px; bottom: calc(78px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
       display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--fg); color: var(--bg); cursor: pointer; }
.fab svg { width: 26px; height: 26px; stroke-width: 2; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
              bottom: calc(92px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--fg); color: var(--bg); padding: 13px 16px; border-radius: 14px; font-size: 14px; font-weight: 500;
         animation: rise .18s ease-out; }
.toast.bad { background: var(--neg); color: #fff; }

/* ---------- Pengaturan ---------- */
.card { background: var(--surface); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 16px; min-height: 60px;
       background: none; border: 0; font: inherit; color: var(--fg); text-align: left; text-decoration: none; cursor: pointer; }
.row + .row { border-top: 1px solid var(--line); }
.row:hover { background: var(--surface-2); }
.row .grow small { margin-top: 2px; }
.row.plain { cursor: default; }
.row.plain:hover { background: none; }
.row.warn-row { color: var(--neg); }
.theme-seg { padding: 14px 16px; }
.version { text-align: center; color: var(--muted); font-size: 12px; margin: 26px 0 0; }

/* ---------- Tab bawah ---------- */
.tabs { position: fixed; z-index: 10; inset: auto 0 0 0; display: grid; grid-template-columns: repeat(5, 1fr);
        background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 8px; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabs a.on { color: var(--fg); font-weight: 600; }

/* ---------- Login ---------- */
.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { font-size: 28px; letter-spacing: -.02em; }
.login-box input { background: var(--surface); border-color: transparent; }

/* ---------- Desktop ---------- */
@media (min-width: 880px) {
  body { padding-left: 224px; }
  .tabs { inset: 0 auto 0 0; width: 224px; grid-template-columns: 1fr; align-content: start; gap: 4px;
          padding: 28px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .tabs a { flex-direction: row; gap: 12px; padding: 12px 14px; font-size: 15px; border-radius: 12px; }
  .tabs a.on { background: var(--bg); }
  .fab { right: 32px; bottom: 32px; }
  dialog { margin: auto; border-radius: 24px; }
  .toast-wrap { bottom: 28px; }
  main { padding-bottom: 96px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
