/* =========================================================
   Catatan Pengeluaran — stylesheet
   Prinsip: teks besar, kontras tinggi, tombol lega, minim hiasan.
   ========================================================= */

:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-soft: #f8f5ef;
  --ink: #16202b;
  --ink-soft: #5d6773;
  --ink-faint: #8b939d;
  --line: #e6e0d4;
  --line-strong: #d6cfc0;

  --primary: #14568f;
  --primary-dark: #0e3f6b;
  --primary-soft: #e8f0f8;
  --ok: #17703d;
  --ok-soft: #e5f3ea;
  --danger: #a92020;
  --danger-soft: #fbeaea;
  --warn: #9a6400;
  --warn-soft: #fdf3dd;

  --radius: 18px;
  --radius-sm: 12px;
  --tap: 64px;
  --font: 21px;

  --shadow-sm: 0 1px 2px rgba(22, 32, 43, 0.05);
  --shadow: 0 2px 4px rgba(22, 32, 43, 0.04), 0 10px 24px -16px rgba(22, 32, 43, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--font);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.loading { padding: 48px 20px; text-align: center; color: var(--ink-soft); }

/* ---------- Struktur layar ---------- */
.screen {
  flex: 1; display: flex; flex-direction: column;
  padding: 18px 16px 0; width: 100%;
}
.screen-body { flex: 1; padding-bottom: 24px; }
.screen-foot {
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}

h1 { font-size: 1.4em; margin: 0; line-height: 1.2; }
h2 {
  font-size: 0.86em; margin: 22px 0 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-soft); font-weight: 800;
}
h2:first-child { margin-top: 4px; }
p { margin: 0 0 12px; }

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 16px; max-width: 900px; margin: 0 auto; width: 100%;
}
.topbar-text { flex: 1; min-width: 0; }
.topbar h1 { font-size: 1.16em; letter-spacing: -0.01em; }
.topbar .sub {
  font-size: 0.68em; opacity: 0.82; font-weight: 500; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-back, .icon-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff; border: none;
  font-size: 1.15em; padding: 0; transition: background .15s ease;
}
.topbar-back:active, .icon-btn:active { background: rgba(255, 255, 255, 0.28); }

/* ---------- Kartu ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.total-card { text-align: center; padding: 22px 18px; }
.total-card .label {
  font-size: 0.72em; color: var(--ink-soft); font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.total-card .amount {
  font-size: 2.05em; font-weight: 800; letter-spacing: -0.03em;
  margin-top: 6px; font-variant-numeric: tabular-nums;
}

/* ---------- Pencarian kategori ---------- */
.search-box {
  position: relative; display: flex; align-items: center;
  margin-bottom: 14px;
}
.search-box .search-icon {
  position: absolute; left: 16px; display: grid; place-items: center;
  color: var(--ink-faint); pointer-events: none;
}
.search-box input {
  width: 100%; font: inherit; font-size: 0.95em; font-weight: 600;
  padding: 15px 48px 15px 50px;
  border: 2px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
  -webkit-appearance: none; appearance: none;
}
.search-box input::placeholder { color: var(--ink-faint); font-weight: 500; }
.search-box input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 10px; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 50%;
  border: none; background: var(--surface-soft); color: var(--ink-soft);
  font-size: 1.2em; line-height: 1; cursor: pointer; padding: 0;
}
.search-clear:active { background: var(--line); }

.result-list { display: flex; flex-direction: column; gap: 8px; }
.result-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .09s ease, border-color .15s ease;
}
.result-btn:active { transform: scale(0.985); border-color: var(--primary); }
.result-btn .ico {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 1.2em; line-height: 1;
}
.result-btn .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.result-btn .r-name {
  font-weight: 800; font-size: 0.9em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-btn .r-meta { font-size: 0.64em; color: var(--ink-soft); font-weight: 600; }
.result-btn .chev { color: var(--ink-faint); font-size: 1.1em; flex: none; }

.search-empty { text-align: center; font-size: 0.84em; color: var(--ink-soft); }
.search-hint { font-size: 0.76em; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }

/* ---------- Grid kategori ---------- */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.cat-btn {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 8px;
  min-height: 148px; padding: 18px 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink); font: inherit;
  cursor: pointer; text-align: center; line-height: 1.2;
  box-shadow: var(--shadow-sm);
  transition: transform .09s ease, box-shadow .15s ease, border-color .15s ease;
}
.cat-btn:active { transform: scale(0.975); box-shadow: none; }
.cat-btn .emoji-wrap {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: var(--cat-soft, var(--primary-soft));
}
.cat-btn .emoji { font-size: 1.75em; line-height: 1; }
.cat-btn .name {
  font-size: 0.86em; font-weight: 800; line-height: 1.25;
  margin-top: 2px; min-height: 2.5em;
  display: flex; align-items: center; justify-content: center;
}
.cat-btn .sum {
  font-size: 0.66em; font-weight: 700; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.cat-btn .sum.zero { color: var(--ink-faint); font-weight: 600; }

/* ---------- Tombol ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: var(--tap); padding: 14px 18px;
  font: inherit; font-size: 1em; font-weight: 800;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: transform .09s ease, opacity .15s ease, background .15s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -10px var(--primary); }
.btn-ok { background: var(--ok); color: #fff; box-shadow: 0 6px 16px -10px var(--ok); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #e8b7b7; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-sm {
  width: auto; min-height: 46px; padding: 0 18px;
  font-size: 0.78em; border-radius: 12px;
}

/* ---------- Keypad ---------- */
.amount-display {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; text-align: right; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.amount-display .currency {
  font-size: 0.68em; color: var(--ink-soft); font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.amount-display .value {
  font-size: 2.3em; font-weight: 800; letter-spacing: -0.03em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.amount-display.empty .value { color: var(--ink-faint); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key {
  min-height: 68px; font: inherit; font-size: 1.4em; font-weight: 700;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
  transition: background .1s ease, transform .08s ease;
}
.key:active { background: #ece7dc; transform: scale(0.97); }
.key.fn { font-size: 0.95em; color: var(--ink-soft); }

/* ---------- Pemilih (kategori detail / orang) ---------- */
.picker-list { display: flex; flex-direction: column; gap: 10px; }
.picker-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: var(--tap); padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: 0.98em; font-weight: 700; color: var(--ink);
  cursor: pointer; text-align: left; box-shadow: var(--shadow-sm);
  transition: transform .09s ease, border-color .15s ease;
}
.picker-btn:active { transform: scale(0.985); border-color: var(--primary); }
.picker-btn .avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 1em; font-weight: 800; flex: none;
}
.picker-btn .label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.picker-btn .chev { color: var(--ink-faint); font-size: 1.2em; flex: none; }
.picker-btn.add {
  background: var(--surface-soft); border-style: dashed; border-color: var(--line-strong);
  color: var(--primary); justify-content: center;
}

/* ---------- Feedback ---------- */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 999px;
  font-size: 0.84em; font-weight: 700; z-index: 60; max-width: 92vw;
  box-shadow: 0 10px 30px rgba(22, 32, 43, 0.3);
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

/* ---------- Overlay / modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(22, 32, 43, 0.42);
  backdrop-filter: blur(2px); overflow-y: auto;
}
.overlay-sheet {
  width: 100%; max-width: 460px; background: var(--surface);
  border-radius: 22px; padding: 24px 20px;
  box-shadow: 0 24px 60px rgba(22, 32, 43, 0.3);
  margin: auto;
}
.overlay-sheet h2 {
  margin: 0 0 14px; font-size: 1.05em; text-transform: none;
  letter-spacing: -0.01em; color: var(--ink);
}
.overlay-sheet .sheet-emoji { font-size: 2.6em; text-align: center; line-height: 1; }
.overlay-sheet .sheet-amount {
  text-align: center; font-size: 1.5em; font-weight: 800;
  margin: 6px 0 2px; font-variant-numeric: tabular-nums;
}
.overlay-sheet .sheet-sub {
  text-align: center; font-size: 0.78em; color: var(--ink-soft);
  margin-bottom: 18px;
}
.overlay-sheet .sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* Overlay sukses */
.success-overlay {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 28px; text-align: center;
}
.success-overlay .badge {
  width: 92px; height: 92px; border-radius: 50%; background: var(--ok-soft);
  display: grid; place-items: center; color: var(--ok);
}
.success-overlay .badge svg { width: 46px; height: 46px; }
.success-overlay .title { font-size: 1.5em; font-weight: 800; color: var(--ok); }
.success-overlay .detail { font-size: 0.95em; color: var(--ink); line-height: 1.5; }
.success-overlay .detail strong { font-size: 1.3em; font-variant-numeric: tabular-nums; }
.success-overlay .actions { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

/* ---------- Baris daftar umum ---------- */
.expense-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.expense-row:last-child { border-bottom: none; }
.expense-row .icon { font-size: 1.5em; flex: none; }
.expense-row .body { flex: 1; min-width: 0; }
.expense-row .title { font-weight: 700; overflow-wrap: anywhere; font-size: 0.94em; }
.expense-row .meta { font-size: 0.72em; color: var(--ink-soft); margin-top: 2px; }
.empty {
  text-align: center; color: var(--ink-soft); padding: 30px 14px;
  font-size: 0.86em;
}

/* ---------- Bottom nav ----------
 * Bilah mengambang dengan sudut membulat, lebarnya mengikuti padding
 * konten (.screen) supaya sejajar dengan kartu di atasnya. */
.nav {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
  width: calc(100% - 32px); max-width: 868px;
  margin: 0 auto calc(10px + env(safe-area-inset-bottom));
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 26px -14px rgba(22, 32, 43, 0.5),
              0 1px 2px rgba(22, 32, 43, 0.04);
}
.nav button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 56px; padding: 8px 2px 6px; border: none; background: none;
  border-radius: 16px;
  font: inherit; font-size: 0.58em; font-weight: 700; color: var(--ink-soft);
  cursor: pointer; position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav button svg { width: 24px; height: 24px; }
.nav button .ic { display: grid; place-items: center; line-height: 1; }
.nav button.active { color: var(--primary); background: var(--primary-soft); }

/* ---------- Pairing / form ---------- */
.center-screen {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 28px 22px; gap: 14px; max-width: 520px; margin: 0 auto; width: 100%;
}
.center-screen h1 { font-size: 1.5em; margin-bottom: 2px; }
.code-box {
  font-size: 2.4em; font-weight: 800; letter-spacing: 0.16em;
  text-align: center; padding: 20px 12px; background: var(--surface);
  border: 2px solid var(--primary); border-radius: var(--radius); color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.pin-input {
  width: 100%; font: inherit; font-size: 1.7em; font-weight: 800; letter-spacing: 0.32em;
  text-align: center; padding: 16px; border: 2px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.pin-input:focus, .field input:focus, .field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.hint { font-size: 0.76em; color: var(--ink-soft); text-align: center; line-height: 1.5; }
.hint code { background: var(--surface-soft); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 0.74em; font-weight: 700; color: var(--ink-soft);
  margin-bottom: 6px; letter-spacing: 0.02em;
}
.field input, .field select {
  width: 100%; font: inherit; font-size: 0.96em; padding: 14px 16px;
  border: 2px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
.field input::placeholder { color: var(--ink-faint); }

/* ---------- Banner offline ---------- */
.offline-bar {
  background: var(--warn); color: #fff; text-align: center;
  padding: 9px 16px; font-size: 0.74em; font-weight: 700;
}

@media (min-width: 720px) {
  :root { --font: 22px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .screen { max-width: 900px; margin: 0 auto; padding: 22px 20px 0; }
  .nav { max-width: 860px; }
  .keypad, .amount-display { max-width: 480px; margin-left: auto; margin-right: auto; }
  .keypad { margin-bottom: 0; }
  .screen-foot { max-width: 480px; margin: 0 auto; width: 100%; }
}

/* Layar lebar (tablet landscape): 4 kolom agar tidak perlu banyak menggulir. */
@media (min-width: 1000px) {
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .screen { max-width: 980px; }
  .nav { max-width: 940px; }
}

/* Landscape di layar pendek: rapatkan tinggi agar keypad + tombol Simpan
 * tetap terlihat tanpa menggulir. */
@media (orientation: landscape) and (max-height: 620px) {
  .topbar-inner { padding: 8px 14px 10px; }
  .topbar h1 { font-size: 1em; }
  .topbar .sub { font-size: 0.6em; margin-top: 0; }
  .topbar-back, .icon-btn { width: 40px; height: 40px; }

  .screen { padding-top: 10px; }
  h2 { margin: 14px 0 8px; }

  .amount-display { padding: 10px 16px; margin-bottom: 10px; }
  .amount-display .currency { font-size: 0.6em; }
  .amount-display .value { font-size: 1.75em; }

  .keypad { gap: 8px; }
  .key { min-height: 50px; font-size: 1.15em; }

  .screen-foot { padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
  .screen-foot .btn { min-height: 52px; font-size: 0.9em; }

  .total-card { padding: 14px; }
  .total-card .amount { font-size: 1.6em; }
  .cat-btn { min-height: 118px; padding: 12px 10px 10px; }
  .cat-btn .emoji-wrap { width: 46px; height: 46px; }
  .cat-btn .emoji { font-size: 1.4em; }

  .nav { bottom: calc(6px + env(safe-area-inset-bottom)); margin-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .nav button { min-height: 46px; padding: 6px 2px 4px; }
  .nav button svg { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Filter periode ---------- */
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: #e9e3d7; border-radius: 14px; padding: 4px; margin-bottom: 12px;
}
.seg-btn {
  min-height: 50px; border: none; border-radius: 11px; background: transparent;
  font: inherit; font-size: 0.82em; font-weight: 700; color: var(--ink-soft);
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.seg-btn.active {
  background: var(--surface); color: var(--primary);
  box-shadow: 0 1px 3px rgba(22, 32, 43, 0.14);
}

.period-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.period-nav .btn { min-height: 54px; font-size: 0.8em; }

/* ---------- Statistik ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat { background: var(--surface-soft); border-radius: 14px; padding: 12px 12px 10px; text-align: left; }
.stat-label {
  font-size: 0.62em; color: var(--ink-soft); font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.stat-value {
  font-size: 1.05em; font-weight: 800; margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.stat-note { font-size: 0.6em; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Perbandingan ---------- */
.compare {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 16px; border-radius: 14px; margin-bottom: 14px;
  font-size: 0.8em; font-weight: 700;
}
.compare.up { background: var(--danger-soft); color: var(--danger); }
.compare.down { background: var(--ok-soft); color: var(--ok); }
.compare.neutral { background: #ece7dc; color: var(--ink-soft); }
.compare-prev { font-weight: 500; font-size: 0.88em; opacity: 0.85; }

/* ---------- Donut ---------- */
.donut-wrap { display: flex; flex-direction: column; gap: 18px; }
.donut { width: 100%; max-width: 220px; margin: 0 auto; display: block; }
.donut-label { font-size: 13px; fill: var(--ink-soft); font-weight: 700; letter-spacing: 0.04em; }
.donut-total { font-size: 20px; fill: var(--ink); font-weight: 800; }

.legend { display: flex; flex-direction: column; gap: 2px; }
.legend-row {
  display: flex; align-items: center; gap: 10px; font-size: 0.78em;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.legend-row:last-child { border-bottom: none; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.legend-pct {
  color: var(--ink-soft); font-weight: 700; min-width: 38px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.legend-amt {
  font-weight: 800; min-width: 96px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tren harian ---------- */
.trend {
  display: flex; align-items: flex-end; gap: 3px; padding-top: 6px;
  border-bottom: 1px solid var(--line-strong); padding-bottom: 0;
}
.trend-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.trend-bar-area { position: relative; height: 116px; }
.trend-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--primary); border-radius: 5px 5px 0 0;
  transition: height .2s ease; min-height: 3px;
}
.trend-bar.empty { background: #e6e0d4; }
.trend-label {
  font-size: 0.56em; text-align: center; color: var(--ink-faint);
  margin-top: 6px; font-weight: 700; height: 1.2em; line-height: 1.2em;
  white-space: nowrap; overflow: visible;
  font-variant-numeric: tabular-nums;
}
.trend-label.weekend { color: var(--danger); }
.trend-scale {
  font-size: 0.66em; color: var(--ink-soft); margin-top: 12px; text-align: right;
  font-weight: 600;
}

/* ---------- Breakdown kategori ---------- */
.breakdown-item { border-bottom: 1px solid var(--line); }
.breakdown-item:last-child { border-bottom: none; }
.breakdown-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 0; background: none; border: none; font: inherit;
  color: var(--ink); cursor: pointer; text-align: left;
}
.breakdown-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 1.15em;
}
.breakdown-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.breakdown-title { font-weight: 800; font-size: 0.9em; }
.breakdown-sub { font-size: 0.64em; color: var(--ink-soft); font-weight: 600; }
.breakdown-track { display: block; height: 7px; background: #ece7dc; border-radius: 4px; overflow: hidden; margin-top: 2px; }
.breakdown-fill { display: block; height: 100%; border-radius: 4px; }
.breakdown-amt {
  font-weight: 800; font-size: 0.84em; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.breakdown-chev { color: var(--ink-faint); font-size: 0.8em; flex: none; }

.breakdown-detail {
  padding: 2px 0 14px 54px; display: flex; flex-direction: column; gap: 8px;
}
.sub-row {
  display: flex; align-items: baseline; gap: 8px; font-size: 0.72em;
  padding-bottom: 7px; border-bottom: 1px dashed var(--line);
}
.sub-row:last-child { border-bottom: none; padding-bottom: 0; }
.sub-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.sub-count { color: var(--ink-faint); min-width: 26px; text-align: right; }
.sub-pct { color: var(--ink-soft); font-weight: 700; min-width: 34px; text-align: right; }
.sub-amt { font-weight: 800; min-width: 92px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Ranking ---------- */
.rank {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-soft);
  display: grid; place-items: center; font-size: 0.7em; font-weight: 800;
  flex: none; color: var(--ink-soft);
}

/* ---------- Baris "Terbesar" ---------- */
.top-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.top-row:last-child { border-bottom: none; }
.top-row .icon { font-size: 1.3em; flex: none; }
.top-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.top-name { font-weight: 700; font-size: 0.82em; overflow-wrap: anywhere; line-height: 1.25; }
.top-meta { font-size: 0.62em; color: var(--ink-soft); }
.top-amt { font-weight: 800; font-size: 0.8em; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Hutang ---------- */
.debt-list { display: flex; flex-direction: column; gap: 12px; }

.debt-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "head chev" "body body";
  gap: 10px 12px;
  width: 100%; padding: 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .09s ease, border-color .15s ease;
}
.debt-row:active { transform: scale(0.99); border-color: var(--primary); }

.debt-head { grid-area: head; display: flex; align-items: center; gap: 10px; min-width: 0; }
.debt-avatar {
  width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft);
  color: var(--primary); display: grid; place-items: center;
  font-size: 1em; font-weight: 800; flex: none;
}
.debt-name {
  font-weight: 800; font-size: 0.92em; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.debt-badge {
  font-size: 0.54em; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  white-space: nowrap; flex: none; letter-spacing: 0.02em;
}
.debt-badge.active { background: var(--danger-soft); color: var(--danger); }
.debt-badge.settled { background: var(--ok-soft); color: var(--ok); }
.debt-chev { grid-area: chev; color: var(--ink-faint); font-size: 1.1em; align-self: center; }

.debt-body { grid-area: body; display: flex; flex-direction: column; gap: 8px; }
.debt-figure { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.debt-remaining {
  font-weight: 800; font-size: 1.2em; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.debt-caption { font-size: 0.64em; color: var(--ink-soft); font-weight: 600; }

.debt-track { height: 8px; background: #ece7dc; border-radius: 5px; overflow: hidden; display: block; }
.debt-fill { display: block; height: 100%; background: var(--ok); border-radius: 5px; }

.debt-foot {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.62em; color: var(--ink-soft);
}
.debt-note {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 55%; text-align: right; font-style: italic;
}

/* ---------- Tagihan ---------- */
.bill-list { display: flex; flex-direction: column; gap: 10px; }

.bill-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon main"
    "icon side";
  align-items: start; gap: 6px 12px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
  border-left: 5px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.bill-row.paid { border-left-color: var(--ok); }
.bill-row.overdue { border-left-color: var(--danger); background: #fdf7f7; }
.bill-row.soon { border-left-color: #d99a00; background: #fffdf6; }

.bill-icon {
  grid-area: icon; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-soft); display: grid; place-items: center;
  font-size: 1.2em; line-height: 1;
}

.bill-main { grid-area: main; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bill-top { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.bill-name { font-weight: 800; font-size: 0.88em; overflow-wrap: anywhere; line-height: 1.2; }
.bill-meta { font-size: 0.64em; color: var(--ink-soft); }

.bill-badge {
  font-size: 0.5em; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap; flex: none; letter-spacing: 0.03em;
}
.bill-badge.paid { background: var(--ok-soft); color: var(--ok); }
.bill-badge.overdue { background: var(--danger-soft); color: var(--danger); }
.bill-badge.soon { background: var(--warn-soft); color: var(--warn); }

.bill-side {
  grid-area: side;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-width: 0; margin-top: 4px;
}
.bill-amt { font-weight: 800; font-size: 0.86em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bill-amt.none { color: var(--ink-faint); font-weight: 600; font-size: 0.7em; }
.bill-row.paid .bill-amt { color: var(--ok); }

.bill-pay {
  min-height: 44px; padding: 0 22px; border-radius: 11px;
  background: var(--primary); color: #fff; border: none;
  font: inherit; font-size: 0.68em; font-weight: 800; cursor: pointer;
  flex: none; box-shadow: 0 5px 14px -9px var(--primary);
}
.bill-pay:active { transform: scale(0.97); }

/* ---------- Tombol export ---------- */
.export-btn {
  margin-top: 22px; margin-bottom: 4px;
  color: var(--primary); border-color: #bcd3e8;
  background: var(--primary-soft);
}

/* ---------- Daftar transaksi ----------
 * Hanya padding vertikal yang dirapatkan; padding horizontal tetap dari
 * .card supaya baris tidak menempel ke tepi kartu. */
.tx-list { padding-top: 4px; padding-bottom: 10px; }
.tx-day { border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 4px; }
.tx-day:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.tx-day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 12px 0 4px; font-size: 0.62em; font-weight: 800;
  color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em;
}
.tx-day-head .day-total { color: var(--ink); font-variant-numeric: tabular-nums; }

.tx-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px;
  width: 100%; padding: 11px 0;
  background: none; border: none; border-top: 1px solid #f0ebe1;
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  transition: background .12s ease;
}
.tx-row:active { background: var(--surface-soft); }

.tx-icon { font-size: 1.25em; line-height: 1; }
.tx-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-title {
  font-weight: 700; font-size: 0.84em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tx-meta {
  font-size: 0.6em; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tx-amt { font-weight: 800; font-size: 0.8em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-chev { color: var(--ink-faint); font-size: 0.85em; }

.tx-more {
  width: 100%; margin-top: 10px; padding: 12px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-soft); color: var(--primary);
  font: inherit; font-size: 0.78em; font-weight: 800; cursor: pointer;
}
.tx-more:active { background: var(--primary-soft); }
