/* =========================================================================
   Dompet Audi — tema lucu & estetik
   Warna dikendalikan lewat variabel CSS pada <html data-theme="...">
   ========================================================================= */

@font-face {
  font-family: 'Quicksand';
  src: url('/fonts/quicksand-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------- Tema ---------------------------------- */
/* Catatan: selektor [data-theme="..."] sengaja tidak dibatasi ke <html>.
   Efeknya, setiap kartu pilihan tema di Pengaturan ikut mewarisi variabel
   temanya sendiri — jadi tiap bulatan punya bingkai & label sewarna. */

:root,
[data-theme="pink"] {
  --primary: #f472b6;
  --primary-deep: #db2777;
  --primary-soft: #ffe3f0;
  --primary-tint: #fff3f9;
  --bg: #fff7fb;
  --bg-2: #ffeaf5;
  --bg-3: #f6ecff;
  --surface: #ffffff;
  --surface-2: #fff7fb;
  --border: #ffdcec;
  --text: #4a2338;
  --muted: #b07d96;
  --shadow-color: 340, 82%, 60%;
}

[data-theme="lavender"] {
  --primary: #b088f9;
  --primary-deep: #7c3aed;
  --primary-soft: #f0e7ff;
  --primary-tint: #f8f3ff;
  --bg: #faf7ff;
  --bg-2: #f1e9ff;
  --bg-3: #ffeef8;
  --surface: #ffffff;
  --surface-2: #faf7ff;
  --border: #e8dcff;
  --text: #382a55;
  --muted: #9184ad;
  --shadow-color: 265, 80%, 62%;
}

[data-theme="mint"] {
  --primary: #5fd4b0;
  --primary-deep: #0f9b7a;
  --primary-soft: #dcf9ef;
  --primary-tint: #f1fdf9;
  --bg: #f5fffc;
  --bg-2: #e2fbf3;
  --bg-3: #eef7ff;
  --surface: #ffffff;
  --surface-2: #f4fdfa;
  --border: #d3f3e7;
  --text: #17453b;
  --muted: #6f9c90;
  --shadow-color: 165, 65%, 45%;
}

[data-theme="peach"] {
  --primary: #ffab7b;
  --primary-deep: #ef7c3d;
  --primary-soft: #ffeadc;
  --primary-tint: #fff6f1;
  --bg: #fffaf6;
  --bg-2: #ffefe3;
  --bg-3: #fff5e6;
  --surface: #ffffff;
  --surface-2: #fff9f5;
  --border: #ffe1cd;
  --text: #52301c;
  --muted: #b08a71;
  --shadow-color: 24, 95%, 62%;
}

[data-theme="sky"] {
  --primary: #7cc4f5;
  --primary-deep: #1f8fd4;
  --primary-soft: #e0f2ff;
  --primary-tint: #f2faff;
  --bg: #f6fbff;
  --bg-2: #e5f4ff;
  --bg-3: #eef2ff;
  --surface: #ffffff;
  --surface-2: #f5faff;
  --border: #d6ecff;
  --text: #1c3c56;
  --muted: #7593a8;
  --shadow-color: 200, 88%, 52%;
}

[data-theme="butter"] {
  --primary: #ffd166;
  --primary-deep: #e0a500;
  --primary-soft: #fff4d1;
  --primary-tint: #fffcf1;
  --bg: #fffdf5;
  --bg-2: #fff6d9;
  --bg-3: #fff2e6;
  --surface: #ffffff;
  --surface-2: #fffcf3;
  --border: #ffedbe;
  --text: #4d3a0c;
  --muted: #ab9264;
  --shadow-color: 40, 95%, 55%;
}

:root {
  --income: #12b886;
  --income-soft: #e4f9f1;
  --expense: #f0577f;
  --expense-soft: #ffe9ef;
  --warn: #e08c2e;
  --warn-soft: #fff5e4;

  --radius: 22px;
  --radius-sm: 14px;
  --radius-pill: 999px;

  --shadow: 0 2px 4px hsl(var(--shadow-color) / .05), 0 10px 28px -14px hsl(var(--shadow-color) / .28);
  --shadow-soft: 0 1px 2px hsl(var(--shadow-color) / .04), 0 6px 18px -12px hsl(var(--shadow-color) / .22);

  --font: 'Quicksand', ui-rounded, 'SF Pro Rounded', 'Segoe UI Variable', 'Segoe UI',
          system-ui, -apple-system, 'Helvetica Neue', sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(1000px 520px at 8% -8%, var(--bg-2) 0%, transparent 62%),
    radial-gradient(760px 440px at 105% 4%, var(--bg-3) 0%, transparent 58%),
    radial-gradient(700px 500px at 50% 108%, var(--bg-2) 0%, transparent 62%);
  background-attachment: fixed;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; font-size: inherit; font-weight: 600; cursor: pointer; }
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 7px;
  font-size: 12px;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  /* ruang bawah cukup untuk tabbar (88px) + tombol + (56px) sekaligus */
  padding: 0 16px calc(172px + env(safe-area-inset-bottom));
  position: relative;
}

/* ------------------------------- Topbar -------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 62%, hsl(var(--shadow-color) / 0));
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 15px;
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-deep) 100%);
  display: grid; place-items: center;
  box-shadow: 0 8px 18px -8px hsl(var(--shadow-color) / .7);
  flex: none;
  position: relative;
}
.brand-mark svg { width: 24px; height: 24px; color: #fff; }
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px 3px auto auto;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  filter: blur(1px);
}
.brand h1 {
  font-size: 17px; font-weight: 700; letter-spacing: -.2px;
  line-height: 1.2;
}
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.wa-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
  flex: none;
  transition: transform .12s;
}
.wa-pill:active { transform: scale(.96); }
.wa-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #d8c8d0;
  flex: none;
}
.wa-pill[data-state="open"] { color: var(--income); border-color: var(--income-soft); background: var(--income-soft); }
.wa-pill[data-state="open"] .dot { background: var(--income); box-shadow: 0 0 0 3px hsl(160 84% 39% / .18); }
.wa-pill[data-state="qr"] { color: var(--warn); border-color: #ffe8c4; background: var(--warn-soft); }
.wa-pill[data-state="qr"] .dot { background: #f7b955; animation: pulse 1.6s infinite; }
.wa-pill[data-state="close"], .wa-pill[data-state="error"] { color: var(--expense); border-color: var(--expense-soft); background: var(--expense-soft); }
.wa-pill[data-state="close"] .dot, .wa-pill[data-state="error"] .dot { background: var(--expense); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* -------------------------------- Views -------------------------------- */
.view { display: none; }
.view.active { display: block; animation: fadeUp .26s cubic-bezier(.2, .8, .3, 1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.banner {
  background: var(--warn-soft);
  border: 1.5px solid #ffe6bd;
  color: #8a5a10;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  margin-bottom: 14px;
  line-height: 1.5;
  font-weight: 600;
}
.banner b { font-weight: 700; }
.banner.danger { background: var(--expense-soft); border-color: #ffd3df; color: #b12a4e; }

/* --------------------------------- Hero -------------------------------- */
.hero {
  background: linear-gradient(140deg, var(--primary) 0%, var(--primary-deep) 105%);
  border-radius: 26px;
  padding: 22px;
  color: #fff;
  box-shadow: 0 16px 36px -18px hsl(var(--shadow-color) / .85);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  width: 200px; height: 200px;
  right: -70px; top: -90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.28), transparent 66%);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  width: 130px; height: 130px;
  left: -50px; bottom: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 68%);
  pointer-events: none;
}
.hero-label {
  font-size: 12px;
  opacity: .95;
  font-weight: 600;
  letter-spacing: .3px;
  display: flex; align-items: center; gap: 5px;
}
.hero-value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1.2px;
  margin: 4px 0 18px;
  font-variant-numeric: tabular-nums;
  position: relative;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}
.hero-split { display: flex; gap: 10px; position: relative; }
.split-item {
  flex: 1;
  display: flex; align-items: center; gap: 9px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 16px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}
.split-icon {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: rgba(255, 255, 255, .32);
  flex: none;
}
.split-label { font-size: 10.5px; opacity: .92; font-weight: 600; }
.split-value { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }

/* --------------------------------- Card -------------------------------- */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
  margin-top: 14px;
  box-shadow: var(--shadow-soft);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.card-head h2 {
  font-size: 14px; font-weight: 700; letter-spacing: -.1px;
  display: flex; align-items: center; gap: 6px;
}
.count {
  font-size: 11px; font-weight: 700; color: var(--primary-deep);
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}
.legend { display: flex; gap: 12px; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 9px; height: 9px; border-radius: 4px; display: inline-block; }
.sw.in { background: var(--income); }
.sw.out { background: var(--expense); }

/* --------------------------------- Chart ------------------------------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 118px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.chart-bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; }
.chart-bar {
  flex: 1;
  border-radius: 5px 5px 3px 3px;
  min-height: 2px;
  transition: height .35s cubic-bezier(.2, .8, .3, 1);
}
.chart-bar.in { background: linear-gradient(180deg, var(--income), var(--income-soft)); }
.chart-bar.out { background: linear-gradient(180deg, var(--expense), var(--expense-soft)); }
.chart-x { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px; color: var(--muted); font-weight: 600; }
.chart-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 30px 0; line-height: 1.7; font-weight: 500; }

/* ------------------------------- Kategori ------------------------------ */
.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat-row { display: flex; flex-direction: column; gap: 6px; }
.cat-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cat-emoji { font-size: 15px; }
.cat-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-amount { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; }
.cat-amount.out { color: var(--expense); }
.cat-amount.in { color: var(--income); }
.cat-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 99px; transition: width .4s cubic-bezier(.2, .8, .3, 1); }
.cat-fill.out { background: linear-gradient(90deg, var(--expense-soft), var(--expense)); }
.cat-fill.in { background: linear-gradient(90deg, var(--income-soft), var(--income)); }
.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 26px 0; line-height: 1.7; font-weight: 500; }

/* ----------------------------- Transaksi list -------------------------- */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
}
.tx:last-child { border-bottom: 0; padding-bottom: 2px; }
.tx-icon {
  width: 38px; height: 38px; border-radius: 13px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  flex: none;
}
.tx-icon.income { background: var(--income-soft); border-color: #c9f2e2; }
.tx-icon.expense { background: var(--expense-soft); border-color: #ffd9e4; }
.tx-body { flex: 1; min-width: 0; }
.tx-note {
  font-size: 13.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tx-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 500; }
.tx-badge {
  background: var(--primary-soft); color: var(--primary-deep);
  border-radius: 6px; padding: 1px 6px; font-size: 9.5px; font-weight: 700;
}
.tx-amount {
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; letter-spacing: -.2px;
}
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-del {
  border: 0; background: none; color: var(--border);
  font-size: 15px; padding: 4px 2px; line-height: 1;
  flex: none; transition: color .15s;
}
.tx-del:hover { color: var(--expense); }

/* -------------------------------- Riwayat ------------------------------ */
.filter-bar { display: flex; gap: 8px; }
.filter-bar .input { flex: 1; }
.filter-bar select { flex: 0 0 118px; }
.mini-summary { display: flex; gap: 8px; margin-top: 12px; font-size: 11.5px; }
.mini-summary > div {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  box-shadow: var(--shadow-soft);
}
.mini-summary span { display: block; color: var(--muted); font-size: 10.5px; margin-bottom: 2px; font-weight: 600; }
.mini-summary b { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 700; }
.mini-summary b.in { color: var(--income); }
.mini-summary b.out { color: var(--expense); }

.history-list { margin-top: 14px; }
.day-group { margin-bottom: 16px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  padding: 0 6px 7px;
}
.day-head b { color: var(--text); font-weight: 700; font-size: 12.5px; }
.day-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 15px;
  box-shadow: var(--shadow-soft);
}
.day-card .tx:last-child { border-bottom: 0; }

/* ------------------------------ Pengaturan ----------------------------- */
.field { margin-bottom: 13px; }
.label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--muted); opacity: .7; font-weight: 500; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

/* Sembunyikan panah spinner bawaan pada input angka */
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input.big { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
select.input {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b07d96' d='M1 1.5l5 5 5-5' stroke='%23b07d96' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}
.inline-field { display: flex; gap: 8px; }
.inline-field .input { flex: 1; }

.btn {
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text);
  transition: transform .1s, filter .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #fff;
  box-shadow: 0 8px 20px -10px hsl(var(--shadow-color) / .8);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-ghost { background: var(--surface); border-color: #ffd3df; color: var(--expense); }
.btn.small { padding: 8px 14px; font-size: 12.5px; }
.btn.block { display: block; width: 100%; text-align: center; text-decoration: none; }

.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.row-actions .btn { flex: 1; }

.radio { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; cursor: pointer; }
.radio input { margin-top: 3px; accent-color: var(--primary-deep); width: 16px; height: 16px; flex: none; }
.radio span { display: block; font-size: 13px; font-weight: 500; }
.radio em { display: block; font-style: normal; color: var(--muted); font-size: 11.5px; margin-top: 2px; font-weight: 500; }
.radio b { font-weight: 700; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 0 14px;
  cursor: pointer;
  font-size: 13px;
}
.switch-row em { display: block; font-style: normal; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.switch-row b { font-weight: 700; }
.switch {
  appearance: none; -webkit-appearance: none;
  width: 46px; height: 27px; border-radius: 99px;
  background: var(--border); position: relative; flex: none;
  transition: background .2s; cursor: pointer;
  border: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; transition: transform .22s cubic-bezier(.2, .8, .3, 1);
  box-shadow: 0 2px 5px hsl(var(--shadow-color) / .35);
}
.switch:checked { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); }
.switch:checked::after { transform: translateX(19px); }

.badge {
  font-size: 10.5px; font-weight: 700; padding: 4px 11px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--muted); border: 1.5px solid var(--border);
}
.badge.open { background: var(--income-soft); color: var(--income); border-color: #c9f2e2; }
.badge.qr { background: var(--warn-soft); color: var(--warn); border-color: #ffe8c4; }
.badge.close, .badge.error { background: var(--expense-soft); color: var(--expense); border-color: #ffd3df; }

.qr-box { text-align: center; padding: 6px 0; }
.qr-box img {
  width: 220px; height: 220px;
  border-radius: 18px; border: 1.5px solid var(--border);
  background: #fff; padding: 9px;
  margin-bottom: 10px;
}
.alert {
  background: var(--expense-soft); border: 1.5px solid #ffd3df; color: #b12a4e;
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 12px; margin-top: 12px;
  word-break: break-word; font-weight: 600; line-height: 1.5;
}

.group-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.group-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 2px; border-bottom: 1px dashed var(--border);
  cursor: pointer;
}
.group-item:last-child { border-bottom: 0; }
.group-avatar {
  width: 34px; height: 34px; border-radius: 12px; flex: none;
  background: var(--primary-soft); color: var(--primary-deep);
  display: grid; place-items: center; font-size: 14px;
}
.group-body { flex: 1; min-width: 0; display: block; }
.group-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.group-size { font-size: 11px; color: var(--muted); font-weight: 500; display: block; }

/* Ringkasan aktivitas WhatsApp: berapa pesan masuk, dicatat, dibalas */
.wa-activity { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 13px; }
.wa-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 700; color: var(--muted);
  line-height: 1.5;
}
.wa-chip.ok { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-deep); }

.test-result {
  margin-top: 12px;
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 13px; font-size: 12.5px; line-height: 1.7; font-weight: 500;
}
.test-result .hit { color: var(--primary-deep); font-weight: 700; }
.test-result .miss { color: var(--muted); }

/* Pratinjau balasan bot — sengaja dibuat mirip gelembung chat WhatsApp */
.reply-preview { margin-top: 13px; padding-top: 12px; border-top: 1px dashed var(--border); }
.reply-preview-label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  margin-bottom: 7px; letter-spacing: .2px;
}
.reply-bubble {
  background: var(--primary-tint);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 5px;
  padding: 11px 13px;
  font-size: 12.5px; line-height: 1.65; font-weight: 500;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.reply-preview-note { font-size: 11px; color: var(--muted); margin: 7px 0 0; line-height: 1.5; }
.reply-preview-note b { color: var(--primary-deep); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint-line { font-size: 11px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; font-weight: 500; }
.hidden { display: none !important; }
.footer-note { text-align: center; color: var(--muted); font-size: 11.5px; margin: 22px 0 8px; font-weight: 600; }

/* --------------------------------- Database ----------------------------- */
.db-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.db-row:last-of-type { border-bottom: 0; }
.db-label { color: var(--muted); flex: none; font-weight: 600; }
.db-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-align: right;
  word-break: break-all;
  color: var(--text);
  font-weight: 500;
}

/* -------------------------------- Piutang ------------------------------ */
/* Sengaja dibuat "kaca lembut" (bukan gradasi penuh) supaya terlihat
   terpisah dari kartu saldo utama. Semua warna ikut tema. */
.rec-hero {
  background:
    radial-gradient(120% 95% at 102% -4%, var(--primary-soft) 0%, transparent 58%),
    linear-gradient(150deg, var(--surface) 0%, var(--primary-tint) 100%);
  border: 1.5px solid var(--border);
  border-radius: 26px;
  padding: 22px;
  color: var(--text);
  box-shadow: 0 18px 40px -28px hsl(var(--shadow-color) / .6);
  position: relative;
  overflow: hidden;
}
.rec-hero::before {
  content: "";
  position: absolute;
  width: 200px; height: 200px;
  right: -70px; top: -90px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary) 0%, transparent 68%);
  opacity: .18;
  pointer-events: none;
}
.rec-hero-label { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .2px; }
.rec-hero-value {
  font-size: 34px; font-weight: 700; letter-spacing: -1.2px;
  margin: 4px 0 16px; font-variant-numeric: tabular-nums;
  color: var(--primary-deep);
}
.rec-hero-split { display: flex; gap: 10px; position: relative; }
.rec-hero-split > div {
  flex: 1;
  background: hsl(0 0% 100% / .74);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
}
.rec-hero-split span { display: block; font-size: 10.5px; color: var(--muted); font-weight: 700; }
.rec-hero-split b { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.rec-hero-note {
  display: flex; align-items: center; gap: 7px;
  margin-top: 13px; font-size: 10.5px; color: var(--muted);
  line-height: 1.5; font-weight: 600;
}
.rec-note-icon {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-deep);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; font-style: italic;
  flex: none;
}

.chips { display: flex; gap: 7px; margin-top: 14px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.chip:active { transform: scale(.96); }
.chip span {
  font-size: 10px;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
  min-width: 19px;
  text-align: center;
  font-weight: 700;
}
.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-deep);
}
.chip.active span { background: hsl(0 0% 100% / .78); color: var(--primary-deep); }

.rec-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

/* Pilihan Piutang / Utang saya di atas halaman */
.ledger-seg { margin-bottom: 14px; }
.ledger-seg .seg {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12.5px;
}
.ledger-seg .seg i {
  font-style: normal; font-size: 10px; font-weight: 700;
  background: hsl(0 0% 100% / .75); color: var(--muted);
  border-radius: var(--radius-pill); padding: 1px 7px; min-width: 20px;
  text-align: center;
}
.ledger-seg .seg.active i { background: var(--primary-soft); color: var(--primary-deep); }

/* Baris jatuh tempo */
.rec-due { color: var(--muted); }
.rec-due.soon { color: var(--primary-deep); font-weight: 700; }
.rec-due.late { color: var(--expense); font-weight: 700; }

/* Kartu utang saya dibedakan sedikit dari piutang */
.rec-item.is-debt { border-left-color: #9b8cff; }

/* Pilihan aplikasi paylater */
.app-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.app-chip {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 7px 12px;
  font-size: 11.5px; font-weight: 700;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.app-chip:active { transform: scale(.95); }
.app-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-deep);
}

/* Label aplikasi di kartu paylater */
.pl-app {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  margin-right: 2px;
  letter-spacing: .1px;
}
.pl-avatar { font-size: 13px; }
.rec-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 14px 15px;
  box-shadow: var(--shadow-soft);
  border-left: 4px solid var(--primary);
}
.rec-item.paid { border-left-color: var(--income); }
.rec-top { display: flex; align-items: flex-start; gap: 11px; }
.rec-avatar {
  width: 40px; height: 40px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-deep);
  flex: none;
}
.rec-item.paid .rec-avatar { background: var(--income-soft); color: var(--income); }
.rec-body { flex: 1; min-width: 0; }
.rec-name {
  font-size: 14px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rec-meta {
  font-size: 11px; color: var(--muted);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-top: 2px; font-weight: 500;
}
.rec-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  letter-spacing: .3px;
}
.rec-amount {
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; letter-spacing: -.3px;
  color: var(--primary-deep);
}
.rec-item.paid .rec-amount { color: var(--income); }
.rec-status {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px;
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}
.rec-status.unpaid { background: var(--primary-soft); color: var(--primary-deep); border: 1.5px solid var(--border); }
.rec-status.paid { background: var(--income-soft); color: var(--income); border: 1.5px solid #c9f2e2; }
.rec-status i { font-style: normal; opacity: .55; }

.rec-actions {
  display: flex; gap: 7px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1.5px dashed var(--border);
}
.rec-actions button {
  flex: 1;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 8px 9px;
  font-size: 11.5px;
  font-weight: 700;
  transition: background .15s, border-color .15s, transform .1s;
}
.rec-actions button:active { transform: scale(.97); }
.rec-actions button.pay { background: var(--income-soft); border-color: #c9f2e2; color: var(--income); }
.rec-actions button.unpay { background: var(--primary-soft); border-color: var(--border); color: var(--primary-deep); }
.rec-actions button.del { color: var(--expense); border-color: #ffd3df; flex: 0 0 42px; padding: 8px 0; }

/* Lampiran media di kartu piutang / paylater */
.rec-thumb {
  display: block;
  width: 100%;
  max-width: 260px;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  margin-top: 10px;
  cursor: zoom-in;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
}
.rec-media {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-deep);
  text-decoration: none;
  background: var(--primary-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
}

/* Lightbox */
.lightbox {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  display: grid;
  place-items: center;
}
.lightbox img {
  max-width: 100%;
  max-height: 92vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.lightbox-close {
  position: absolute;
  top: -44px;
  right: 0;
  background: rgba(255,255,255,.9);
  color: #333;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.label-opt { font-weight: 500; text-transform: none; letter-spacing: 0; opacity: .8; }

.tab-dot {
  position: absolute;
  top: 4px; right: calc(50% - 17px);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ff8fab;
  box-shadow: 0 0 0 2.5px var(--surface);
}
.tab { position: relative; }

/* ------------------------------ Pemilih tema --------------------------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 4px;
}
.theme-opt {
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  padding: 10px 8px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.theme-opt:active { transform: scale(.96); }
.theme-opt.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.theme-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .06);
}
.theme-dot::after {
  content: "";
  position: absolute;
  top: 5px; left: 8px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .65);
}
.theme-name {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: -.1px;
}
.theme-opt.active .theme-name { color: var(--primary-deep); }

.custom-color {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.custom-color label { font-size: 12px; font-weight: 700; color: var(--muted); flex: 1; }
.custom-color input[type="color"] {
  width: 40px; height: 32px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: none;
  padding: 2px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.custom-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }

/* -------------------------------- Tabbar ------------------------------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: calc(100% - 28px);
  max-width: 532px;
  display: flex;
  gap: 0;
  background: hsl(0 0% 100% / .88);
  backdrop-filter: blur(16px) saturate(1.4);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 6px;
  z-index: 30;
  box-shadow: 0 12px 32px -12px hsl(var(--shadow-color) / .4);
}
.tab {
  flex: 1;
  border: 0; background: none;
  color: var(--muted);
  font-size: 8.8px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2.5px;
  padding: 7px 0 5px;
  border-radius: 17px;
  transition: color .18s, background .18s, transform .1s;
}
.tab:active { transform: scale(.94); }
.tab svg {
  width: 21px; height: 21px;
  stroke-width: 1.9;
  transition: transform .2s cubic-bezier(.2, .8, .3, 1);
}
.tab.active {
  color: var(--primary-deep);
  background: var(--primary-soft);
}
.tab.active svg { transform: translateY(-1px) scale(1.06); }

/* Layar sangat kecil (≤340px): rapatkan label 5 tab agar tidak terpotong */
@media (max-width: 340px) {
  .tab { font-size: 8px; }
  .tab svg { width: 20px; height: 20px; }
  .tabbar { padding: 5px; }
}

.fab {
  position: fixed;
  right: max(20px, calc(50vw - 268px + 20px));
  bottom: calc(92px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(140deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 12px 26px -10px hsl(var(--shadow-color) / .9), 0 0 0 5px hsl(0 0% 100% / .55);
  z-index: 25;
  transition: transform .12s;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.9); }

/* -------------------------------- Modal -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: hsl(var(--shadow-color) / .22);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface);
  width: 100%; max-width: 560px;
  border-radius: 28px 28px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow-y: auto;
  border-top: 2px solid var(--border);
  animation: slideUp .28s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.icon-btn {
  border: 0; background: var(--surface-2); color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px;
  transition: background .15s;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-deep); }

.segmented {
  display: flex; gap: 4px; background: var(--surface-2);
  padding: 5px; border-radius: var(--radius-pill); margin-bottom: 16px;
  border: 1.5px solid var(--border);
}
.seg {
  flex: 1; border: 0; background: none; padding: 9px;
  border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 700; color: var(--muted);
  transition: background .18s, color .18s;
}
.seg.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -4px hsl(var(--shadow-color) / .4); }
.seg.active[data-type="expense"] { color: var(--expense); }
.seg.active[data-type="income"] { color: var(--income); }
.seg.active[data-status="unpaid"] { color: var(--primary-deep); }
.seg.active[data-status="paid"] { color: var(--income); }

.quick-amounts { display: flex; gap: 6px; margin-top: 9px; }
.quick-amounts button {
  flex: 1; border: 1.5px solid var(--border); background: var(--surface);
  border-radius: var(--radius-pill); padding: 8px 0; font-size: 11.5px; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.quick-amounts button:hover { background: var(--primary-soft); color: var(--primary-deep); border-color: var(--primary); }

/* -------------------------------- Toast -------------------------------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 11px 18px; border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 700;
  z-index: 90;
  box-shadow: 0 12px 28px -10px hsl(var(--shadow-color) / .7);
  animation: fadeUp .22s;
  max-width: 88vw; text-align: center;
}

@media (min-width: 600px) {
  .app { padding-left: 20px; padding-right: 20px; }
  .hero-value, .rec-hero-value { font-size: 38px; }
  .theme-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
