/* Asma Keuangan — bahasa visual: tinta cetak (CMYK) + tanda potong.
   Cyan = uang masuk, magenta = uang keluar, kuning = utang/piutang, tinta gelap = teks. */
:root {
  --paper: #f3f5f9;
  --sheet: #ffffff;
  --key: #141b2d;
  --key-2: #556078;
  --line: #dce1ea;
  --c: #0098cc;       /* cyan */
  --c-ink: #00688f;   /* teks cyan di atas putih */
  --c-btn: #00789f;
  --c-wash: #e3f4fb;
  --m: #d41c6b;       /* magenta */
  --m-ink: #b3125a;
  --m-btn: #c4165f;
  --m-wash: #fce6f0;
  --y: #f7bc00;       /* kuning */
  --y-ink: #6f5200;
  --y-wash: #fff4cc;
  --danger: #b3261e;
  --focus: #0098cc;
  --shadow: 0 -10px 30px rgba(20, 27, 45, .18);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d121c;
    --sheet: #161d2b;
    --key: #e9eef8;
    --key-2: #9aa6bc;
    --line: #2a3347;
    --c: #2db8e8;
    --c-ink: #62cff3;
    --c-btn: #0b87b5;
    --c-wash: #0f2f3c;
    --m: #f0558f;
    --m-ink: #ff8ab3;
    --m-btn: #d1286f;
    --m-wash: #3a1526;
    --y: #f7bc00;
    --y-ink: #ffd65c;
    --y-wash: #3a3010;
    --danger: #ff8a80;
    --shadow: 0 -10px 30px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--key);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 6px 12px 6px 16px;
  padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--paper);
}
.top .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; flex: 1; }
.top .brand svg { width: 28px; height: 28px; }
.top h1 { flex: 1; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent;
}
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 24px; height: 24px; }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main#view { padding: 4px 0 8px; }
.pad { padding: 0 16px; }
.title { padding: 6px 16px 10px; }
.title h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.title p { color: var(--key-2); font-size: 14px; margin-top: 2px; }

/* ---------- lembar saldo (tanda potong + strip CMYK) ---------- */
.slip {
  position: relative; margin: 14px 20px 18px;
  background: var(--sheet); border: 1px solid var(--line);
}
.slip .strip { display: flex; height: 7px; }
.slip .strip i { flex: 1; }
.strip i:nth-child(1) { background: var(--c); }
.strip i:nth-child(2) { background: var(--m); }
.strip i:nth-child(3) { background: var(--y); }
.strip i:nth-child(4) { background: var(--key); }
.crop { position: absolute; width: 14px; height: 14px; border: 0 solid var(--key-2); pointer-events: none; }
.crop.tl { left: -9px; top: -9px; border-right-width: 1.5px; border-bottom-width: 1.5px; }
.crop.tr { right: -9px; top: -9px; border-left-width: 1.5px; border-bottom-width: 1.5px; }
.crop.bl { left: -9px; bottom: -9px; border-right-width: 1.5px; border-top-width: 1.5px; }
.crop.br { right: -9px; bottom: -9px; border-left-width: 1.5px; border-top-width: 1.5px; }
.slip .in-pad { padding: 14px 16px 6px; }
.slip .lbl { font-size: 14px; color: var(--key-2); font-weight: 600; }
.slip .total { font-size: clamp(34px, 11vw, 46px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: 2px; overflow-wrap: anywhere; }
.slip .total.neg { color: var(--m-ink); }
.accts { padding: 6px 16px 12px; }
.accts li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 15px; }
.accts li:first-child { border-top: 0; }
.accts li span { min-width: 0; overflow-wrap: anywhere; }
.accts li b { font-weight: 700; white-space: nowrap; }
.accts li b.neg { color: var(--m-ink); }
.tag { font-style: normal; font-size: 12px; font-weight: 700; padding: 1px 7px; margin-left: 6px; border-radius: 99px; background: var(--c-wash); color: var(--c-ink); }

/* ---------- blok ringkasan ---------- */
.block { padding: 0 16px; margin: 0 0 24px; }
.block > h2 { font-size: 17px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.block > h2 a, .link { font-size: 14px; font-weight: 700; color: var(--c-ink); text-decoration: none; background: none; border: 0; padding: 0; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.kv > div { padding-left: 10px; border-left: 4px solid var(--line); }
.kv .k { font-size: 13px; color: var(--key-2); }
.kv .v { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.kv .in { border-color: var(--c); } .kv .in .v { color: var(--c-ink); }
.kv .out { border-color: var(--m); } .kv .out .v { color: var(--m-ink); }
.ratio { display: flex; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.ratio i:first-child { background: var(--c); }
.ratio i:last-child { background: var(--m); }
.result { margin-top: 12px; font-weight: 700; font-size: 16px; }
.result.pos { color: var(--c-ink); } .result.neg { color: var(--m-ink); }

.trend { width: 100%; height: auto; display: block; }
.trend text { fill: var(--key-2); font-size: 10px; text-anchor: middle; }
.trend .b-in { fill: var(--c); } .trend .b-out { fill: var(--m); }
.trend .base { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--key-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: block; text-decoration: none; color: inherit; text-align: left;
  padding: 12px 14px; background: var(--y-wash); border: 0; border-top: 5px solid var(--y); border-radius: 0 0 10px 10px;
}
.tile .k { font-size: 13px; color: var(--key-2); }
.tile .v { font-size: 19px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.tile .s { font-size: 13px; color: var(--key-2); margin-top: 2px; }

.bars li { display: grid; grid-template-columns: minmax(80px, 1fr) 1.2fr auto; gap: 10px; align-items: center; padding: 7px 0; font-size: 14.5px; }
.bars .bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; }
.bars.out .bar i { background: var(--m); } .bars.in .bar i { background: var(--c); }
.bars b { font-weight: 700; white-space: nowrap; font-size: 14px; }

/* ---------- daftar baris (riwayat, dll.) ---------- */
.group { margin-bottom: 8px; }
.group > h3 { padding: 12px 16px 6px; font-size: 13px; font-weight: 700; color: var(--key-2); }
.rows li + li { border-top: 1px solid var(--line); }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 11px 16px; background: transparent; border: 0; min-height: 56px;
}
.row:active { background: var(--line); }
.row .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .mid b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .mid small { color: var(--key-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--key-2); width: 20px; height: 20px; }
.gl { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--line); color: var(--key); }
.gl svg { width: 20px; height: 20px; }
.gl.in { background: var(--c-wash); color: var(--c-ink); }
.gl.out { background: var(--m-wash); color: var(--m-ink); }
.gl.y { background: var(--y-wash); color: var(--y-ink); }
.amt.in { color: var(--c-ink); } .amt.out { color: var(--m-ink); }
.row.danger .mid b { color: var(--danger); }

/* ---------- chips & segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--sheet); font-weight: 600; font-size: 14.5px;
}
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--key); color: var(--paper); border-color: var(--key); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; margin: 0 16px 16px; background: var(--line); border-radius: 14px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; font-size: 15px; color: var(--key-2); }
.seg button[aria-selected="true"] { background: var(--sheet); color: var(--key); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

/* ---------- formulir ---------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; font-weight: 650; margin-bottom: 6px; }
.field small { display: block; color: var(--key-2); font-size: 13px; margin-top: 4px; }
.in-ctl, select.in-ctl {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--sheet);
}
.in-ctl:focus { outline: none; border-color: var(--key); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }
.amount {
  display: block; margin: 0 16px 10px; padding: 12px 14px 10px; background: var(--sheet); border-left: 6px solid var(--line);
}
.amount > span { font-size: 14px; font-weight: 650; color: var(--key-2); }
.amount .line { display: flex; align-items: baseline; gap: 6px; }
.amount i { font-style: normal; font-size: 22px; font-weight: 700; color: var(--key-2); }
.amount input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 38px; font-weight: 800; letter-spacing: -.02em; padding: 0; outline: none; font-variant-numeric: tabular-nums; }
.entry.in .amount { border-color: var(--c); background: var(--c-wash); }
.entry.out .amount { border-color: var(--m); background: var(--m-wash); }
.entry.p .amount { border-color: var(--key); }
.quick { display: flex; gap: 8px; padding: 0 16px 14px; flex-wrap: wrap; }
.quick button { min-height: 36px; padding: 0 12px; border-radius: 99px; border: 1.5px dashed var(--key-2); background: transparent; font-weight: 650; font-size: 14px; }
.entry .fields { padding: 0 16px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; border: 0; border-radius: 14px; font-weight: 800; font-size: 16px; color: #fff; background: var(--key);
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn.c { background: var(--c-btn); } .btn.m { background: var(--m-btn); } .btn.k { background: var(--key); color: var(--paper); }
.btn.ghost { background: transparent; color: var(--key); border: 1.5px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger { color: #1a0a09; } }
.btn.small { min-height: 40px; width: auto; padding: 0 16px; font-size: 14.5px; border-radius: 12px; }
.entry .actions { padding: 6px 16px 0; }

/* ---------- utang/piutang ---------- */
.debt { padding: 14px 16px; }
.debt + .debt { border-top: 1px solid var(--line); }
.debt .hd { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.debt .hd b:first-child { font-weight: 700; overflow-wrap: anywhere; }
.debt small { display: block; color: var(--key-2); font-size: 13px; margin-top: 2px; }
.prog { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.prog i { display: block; height: 100%; background: var(--y); }
.debt .acts { display: flex; gap: 8px; margin-top: 10px; }
.sum-line { margin: 0 16px 8px; padding: 12px 14px; background: var(--y-wash); border-top: 5px solid var(--y); border-radius: 0 0 10px 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sum-line b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- bottom nav ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--sheet); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; }
#nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; text-decoration: none; color: var(--key-2); font-size: 12px; font-weight: 650;
}
#nav a svg { width: 24px; height: 24px; }
#nav a[aria-current="page"] { color: var(--key); }
#nav a[aria-current="page"] svg { stroke-width: 2.6; }
#nav a.add { color: #fff; }
#nav a.add span.pill {
  display: grid; place-items: center; width: 54px; height: 54px; margin-top: -18px; border-radius: 18px;
  background: var(--key); color: var(--paper); box-shadow: 0 6px 16px rgba(20, 27, 45, .3);
  border-bottom: 5px solid var(--c);
}
#nav a.add { color: var(--key-2); min-height: 66px; }
#nav a.add[aria-current="page"] { color: var(--key); }

/* ---------- sheet, toast, kosong ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 24, .5); display: none; align-items: flex-end; justify-content: center; }
.overlay.open { display: flex; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto;
  background: var(--sheet); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 4px; }
.sheet .sub { color: var(--key-2); font-size: 14.5px; margin-bottom: 14px; }
.sheet .stack { display: grid; gap: 10px; margin-top: 6px; }
.dl { margin: 6px 0 14px; }
.dl div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px dashed var(--line); font-size: 15px; }
.dl div:first-child { border-top: 0; }
.dl dt { color: var(--key-2); } .dl dd { margin: 0; font-weight: 650; text-align: right; overflow-wrap: anywhere; }
.warn { background: var(--y-wash); border-left: 5px solid var(--y); padding: 10px 12px; margin: 8px 0 14px; font-size: 14.5px; }
.code { font-size: 34px; font-weight: 800; letter-spacing: .25em; text-align: center; padding: 8px 0; font-variant-numeric: tabular-nums; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 8px; justify-items: center; padding: 0 14px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 520px; width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--key); color: var(--paper); padding: 12px 14px; border-radius: 14px; font-size: 15px; font-weight: 600;
  border-left: 6px solid var(--c); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); white-space: pre-line;
  animation: up .16s ease-out;
}
.toast.err { border-color: var(--m); }
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: var(--y); font-weight: 800; padding: 6px 4px; min-height: 36px; }

.empty { padding: 36px 24px; text-align: center; color: var(--key-2); }
.empty p { margin-bottom: 14px; }
.empty .btn { width: auto; display: inline-flex; padding: 0 22px; }
.skel { margin: 14px 20px; height: 120px; background: linear-gradient(90deg, var(--line), var(--sheet), var(--line)); background-size: 200% 100%; animation: sh 1.2s linear infinite; border-radius: 6px; }
.skel.s { height: 60px; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- login ---------- */
.login { max-width: 420px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 22px 40px; }
.login .logo { width: 64px; height: 64px; margin-bottom: 18px; }
.login h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.login .lead { color: var(--key-2); margin: 6px 0 22px; }
.login .strip { display: flex; height: 6px; margin: 22px 0 18px; }
.login .strip i { flex: 1; }
.err-msg { color: var(--m-ink); font-weight: 650; font-size: 14.5px; margin: -4px 0 12px; min-height: 1.2em; }
.login details { margin-top: 20px; color: var(--key-2); font-size: 14px; }
.login summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .toast, .skel { animation: none; }
}
@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 22px; }
}
