/* Dashboard Catetin — mobile-first, satu kolom. Warna merek = hijau uang (pemasukan & saldo juga hijau). */

:root {
  --bg: #f2f7f3;
  --card: #ffffff;
  --ink: #10201a;
  --muted: #566a5d;
  --line: #dce9e0;
  --brand: #15803d;
  --brand-ink: #ffffff;
  --brand-soft: #ecf8f0;
  --in: #15803d;
  --out: #bf3a2b;
  --in-soft: #ecf8f0;
  --out-soft: #fbe8e5;
  --hero-from: #16883f;
  --hero-to: #14532d;
  --focus: #1b6ef3;
  --shadow: 0 1px 2px rgba(16, 32, 26, 0.06), 0 6px 18px rgba(16, 32, 26, 0.05);
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b130e;
    --card: #131f17;
    --ink: #e6f2ea;
    --muted: #9ab3a1;
    --line: #213428;
    --brand: #4ade80;
    --brand-ink: #04210f;
    --brand-soft: #143222;
    --in: #4ade80;
    --out: #ff8f80;
    --in-soft: #143222;
    --out-soft: #3b2220;
    --hero-from: #16803c;
    --hero-to: #0f4a27;
    --focus: #7fb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.boot { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- header & navigasi ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; padding-top: max(14px, env(safe-area-inset-top)); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: 0.01em; color: var(--brand); }
.topbar .who { color: var(--muted); font-size: 13px; }

main { flex: 1; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 2px 9px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 500;
}
.tabbar a[aria-current="page"] { color: var(--brand); font-weight: 700; }

/* ---------- komponen umum ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--muted); text-transform: none; }
.section-label { margin: 8px 2px -4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row .k { color: var(--muted); }
.in { color: var(--in); }
.out { color: var(--out); }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.hero {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.hero .label { display: flex; align-items: center; gap: 8px; font-size: 14px; opacity: 0.92; }
.hero .amount { font-size: 32px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.hero .sub { font-size: 13px; opacity: 0.85; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { border-radius: var(--radius); padding: 14px; border: 1px solid var(--line); background: var(--card); }
.stat .label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.stat .value { font-size: 19px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.in-card { background: var(--in-soft); border-color: transparent; }
.stat.out-card { background: var(--out-soft); border-color: transparent; }

.cta { display: flex; align-items: center; gap: 12px; }
.cta .ico { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.cta .txt { flex: 1; min-width: 0; }
.cta .txt strong { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; text-decoration: none;
  background: var(--brand); color: var(--brand-ink);
}
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--out); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* ---------- transaksi ---------- */
.chips { display: flex; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.group-title { margin: 14px 2px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.tx { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; margin-bottom: 8px; }
.tx .dot { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.tx .dot.in { background: var(--in-soft); color: var(--in); }
.tx .dot.out { background: var(--out-soft); color: var(--out); }
.tx .body { flex: 1; min-width: 0; }
.tx .desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .meta { font-size: 12.5px; color: var(--muted); }
.tx .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon-btn { flex: none; border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 10px; }
.icon-btn:hover { color: var(--out); background: var(--out-soft); }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.empty svg { opacity: 0.6; margin-bottom: 8px; }

/* ---------- analisis ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 8px 0; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

.chart { width: 100%; height: auto; display: block; }
.bar-in { fill: var(--in); }
.bar-out { fill: var(--out); }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .li { background: var(--in); }
.legend .lo { background: var(--out); }

.cat { margin: 10px 0 12px; }
.cat .line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.cat .bar { height: 8px; border-radius: 999px; background: var(--line); margin-top: 6px; overflow: hidden; }
.cat .bar span { display: block; height: 100%; border-radius: 999px; background: var(--out); }
.cat.income .bar span { background: var(--in); }
.cat .meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- catatan: utang, piutang, tabungan ---------- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.card-head .total { font-weight: 700; font-variant-numeric: tabular-nums; }
.debt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.debt + .debt { border-top: 1px solid var(--line); }
.debt .who { flex: 1; min-width: 0; }
.debt .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debt .meta { font-size: 12.5px; color: var(--muted); }

/* ---------- formulir ---------- */
form { display: flex; flex-direction: column; gap: 10px; }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="password"], input[type="tel"], input[type="number"] {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px; font-size: 16px; color: var(--ink);
}
.msg { min-height: 1.2em; font-size: 13px; }
.msg.err { color: var(--out); }
.msg.ok { color: var(--in); }

.login { margin: auto 0; padding: 24px 16px; }
.login .brand { text-align: center; margin-bottom: 18px; }
.login .brand .logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 6px 0 0; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; z-index: 20;
}

.skeleton { height: 84px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line), var(--card), var(--line)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; margin-bottom: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
