/* Token warna dari desain (claude.ai/artifact/XzJgVuup3NgEQpHiMdW3im). */
:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --border: #E4E1D8;
  --border-strong: #D9D6CC;
  --track: #E9E6DC;
  --text: #1B2B27;
  --muted: #5B6661;
  --muted-strong: #3F4B46;
  --primary: #0F6B5C;
  --primary-dark: #0F3D36;
  --on-primary: #FFFFFF;
  --warn: #B45309;
  --warn-text: #7A4A07;
  --warn-bg: #FBF1DF;
  --danger: #B42318;
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.4 Inter, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.screen-body {
  flex: 1;
  padding: max(24px, env(safe-area-inset-top)) 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.title { font-size: 20px; font-weight: 600; margin: 0; }
.eyebrow { font-size: 13px; color: var(--muted); }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  border-radius: 22px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 22px; border: none;
  background: var(--primary); color: var(--on-primary);
  font-weight: 600; cursor: pointer;
}

/* Pilihan jenis transaksi */
.segmented {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
  background: var(--track); border-radius: var(--radius); padding: 4px;
}
.segmented button {
  height: 44px; border: none; border-radius: 9px; background: transparent;
  color: var(--muted-strong); font-weight: 500; font-size: 14px; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }

/* Kartu dan baris form */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.field { padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field input {
  border: none; outline: none; padding: 0; background: transparent; width: 100%;
  font-weight: 500; font-size: 15px;
}
.field.amount input { font-size: 30px; font-weight: 600; }
.card:focus-within { border-color: var(--primary); }

.rows > * + * { border-top: 1px solid var(--border); }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; min-height: 48px; font-size: 14px;
}
.row > label, .row > .label { color: var(--muted); flex: none; }
.row select, .row input[type="date"], .row .value {
  border: none; background: transparent; font-weight: 500; font-size: 14px;
  text-align: right; text-align-last: right; min-width: 0; max-width: 62%;
  padding: 6px 0; cursor: pointer;
}
.row select:focus-visible, .row input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.toggle { cursor: pointer; color: var(--text) !important; }
.toggle input { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }
.toggle.emergency input { accent-color: var(--warn); }
.toggle .text { display: flex; flex-direction: column; gap: 2px; }
.toggle .hint { font-size: 12px; color: var(--warn-text); }

.error {
  background: #FDECEA; color: var(--danger); border-radius: var(--radius);
  padding: 10px 14px; font-size: 14px;
}

.footer {
  position: sticky; bottom: 0; background: var(--bg);
  padding: 12px 20px max(20px, env(safe-area-inset-bottom));
}
.btn-primary {
  width: 100%; height: 52px; border: none; border-radius: 14px;
  background: var(--primary); color: var(--on-primary);
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary:disabled { opacity: .6; cursor: progress; }

/* Daftar transaksi */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.section-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.trx-list { list-style: none; margin: 0; padding: 0; }
.trx-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.trx-item .main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trx-item .name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trx-item .meta { font-size: 12px; color: var(--muted); }
.trx-item .meta.warn { color: var(--warn-text); }
.trx-item .right { display: flex; align-items: center; gap: 4px; flex: none; }
.trx-item .amt { font-size: 14px; font-weight: 500; white-space: nowrap; }
.trx-item .amt.in { color: var(--primary); }
.trx-item .del {
  width: 44px; height: 44px; border: none; background: transparent; color: var(--muted);
  border-radius: 22px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.empty { color: var(--muted); font-size: 14px; padding: 16px 0; }
.note-box {
  background: var(--warn-bg); border: 1px solid #EBD3A4; border-radius: var(--radius);
  padding: 12px 14px; font-size: 13px; color: var(--warn-text);
}

/* Navigasi bawah */
.tabbar {
  position: sticky; bottom: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
}
.tabbar a, .tabbar span { text-align: center; font-size: 12px; color: var(--muted); padding: 12px 0; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 600; }
.tabbar span { opacity: .5; }
.tabbar .fab {
  justify-self: center; width: 52px; height: 52px; border-radius: 26px; padding: 0;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
}

/* Login */
.login { justify-content: center; gap: 16px; }
.login h1 { font-size: 24px; margin: 0; }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  width: min(440px, calc(100% - 32px));
  background: var(--primary-dark); color: #fff; border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
#toast.warn { background: var(--danger); }

/* ---------- Beranda ---------- */
.home { gap: 12px; }
.topbar-actions { display: flex; gap: 8px; }
.picker { position: relative; overflow: hidden; }
.picker select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 16px;
}
.picker:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }

.hero {
  background: var(--primary-dark); color: #fff; border-radius: 16px;
  padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 10px;
}
.hero-label { font-size: 13px; color: #BFE0D8; }
.hero-amount { font-size: 34px; font-weight: 600; letter-spacing: -0.5px; line-height: 1.15; }
.hero-amount.neg { color: #FFB4A9; }
.hero-track { height: 8px; border-radius: 4px; background: #1F5A51; overflow: hidden; }
.hero-track > div { height: 100%; background: #7FD6BF; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.tile-value.small { font-size: 14px; }
.in { color: var(--primary); }
.tiny { font-size: 12px; }
.warn-text { font-size: 13px; color: var(--warn-text); }

.daily { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.daily.over { border-color: var(--danger); }
.daily-head, .daily-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.daily-title { font-size: 14px; font-weight: 600; }
.daily-track { position: relative; height: 10px; border-radius: 5px; background: var(--track); overflow: hidden; }
.daily-track > div { position: absolute; top: 0; height: 100%; }
.daily-track .ok { left: 0; background: var(--primary); }
.daily-track .bad { background: var(--danger); }
.daily-track .mark { width: 2px; background: #fff; }
.daily-warn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--danger); }

.emergency-card {
  background: var(--warn-bg); border-color: #EBD3A4;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.em-track { height: 6px; border-radius: 3px; background: #F0DDB6; overflow: hidden; }
.em-track > div { height: 100%; background: var(--warn); }

/* Slider kartu (budget makan, rekening darurat) */
.slider { display: flex; flex-direction: column; gap: 8px; }
.slider-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: 100%; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.slider-track::-webkit-scrollbar { display: none; }
.slide { scroll-snap-align: start; display: flex; }
.slide > .card { flex: 1; }
.slider-dots { display: flex; justify-content: center; gap: 2px; }
.slider-dots button {
  width: 24px; height: 24px; border: none; background: transparent; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.slider-dots button::before {
  content: ''; width: 7px; height: 7px; border-radius: 4px; background: var(--border-strong);
  transition: width .2s, background .2s;
}
.slider-dots button[aria-current="true"]::before { width: 18px; background: var(--primary); }
@media (prefers-reduced-motion: reduce) { .slider-dots button::before { transition: none; } }

/* ---------- Tagihan berulang ---------- */
.topbar.start { justify-content: flex-start; }
a.tile { color: var(--text); }
a.tile:focus-visible, .link-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.danger-text { font-size: 12px; color: var(--danger); font-weight: 500; }
.bill-summary { padding: 16px; border-radius: 16px; display: flex; flex-direction: column; gap: 8px; }
.big-amount { font-size: 28px; font-weight: 600; letter-spacing: -0.5px; }
.em-track.neutral { height: 8px; border-radius: 4px; background: var(--track); }
.em-track.neutral > div { background: var(--primary); }
.amt.strong { font-weight: 600; }
.amt.muted { color: var(--muted); text-decoration: line-through; }
.trx-item .right { gap: 10px; }
.btn-pill {
  height: 44px; padding: 0 16px; border-radius: 22px; border: none;
  background: var(--primary); color: var(--on-primary);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-pill.outline { background: var(--surface); color: var(--primary); border: 1.5px solid var(--primary); }
.link-row { color: var(--text); }
.btn-outline {
  height: 52px; border-radius: 14px; border: 1.5px solid var(--primary);
  background: var(--surface); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.btn-text {
  min-height: 44px; padding: 0 12px; border: none; background: transparent;
  color: var(--primary); font-weight: 600; cursor: pointer;
}

/* Dialog bawah (bayar tagihan) */
dialog.sheet {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: 0; border: none;
  border-radius: 20px 20px 0 0; background: var(--bg); color: var(--text);
}
dialog.sheet::backdrop { background: rgba(15, 30, 26, .45); }
.sheet-body {
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-actions { display: flex; justify-content: space-between; }

/* Pilihan jadwal tagihan */
.segmented.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.inline-num { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.inline-num input {
  width: 64px; padding: 6px 8px; text-align: right; font-weight: 500;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
}

/* ---------- Rekening darurat ---------- */
a.emergency-card { color: var(--text); }
.emergency-hero {
  background: var(--warn-bg); border-color: #EBD3A4; border-radius: 16px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.em-track.thick { height: 8px; border-radius: 4px; }
.rules { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.rules-text { font-size: 13px; color: var(--muted-strong); line-height: 1.5; }
.warn-amt { color: var(--warn-text); }
.btn-primary.warn { background: var(--warn); }
.btn-text.small { font-size: 13px; padding: 0 8px; }
.footer.tight { position: static; padding-bottom: 8px; }
fieldset.plain { margin: 0; padding: 0; min-width: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
dialog.sheet { max-height: 90dvh; overflow-y: auto; }

/* ---------- Tabungan ---------- */
.as-button {
  width: 100%; border: none; border-bottom: 1px solid var(--border); background: transparent;
  text-align: left; cursor: pointer; font: inherit; color: var(--text);
}
.as-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.trx-item .main.end { align-items: flex-end; text-align: right; }
.btn-primary.as-link { display: flex; align-items: center; justify-content: center; }

/* ---------- Laporan dan Transaksi ---------- */
.see-all { font-size: 13px; padding: 10px 0; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -20px; padding: 0 20px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted-strong);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tiles.three .tile { padding: 10px 12px; gap: 2px; }
.report { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.report h2 { margin: 0; }
.cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cat-head {
  width: 100%; border: none; background: transparent; padding: 6px 0; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--text); min-height: 44px;
}
.cat-head:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.cat-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.cat-line.static { padding: 4px 0; }
.cat-name { font-weight: 500; }
.cat-track { display: block; height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.cat-track > span { display: block; height: 100%; background: var(--primary); }
.cat-track > span.over { background: var(--danger); }
.facts .row { min-height: 44px; }
.date-head { font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0 0; }
a.cat-head { text-decoration: none; }
.cat-right { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.cat-line.link { color: var(--text); min-height: 44px; align-items: center; }
.cat-line.link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.date-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.date-row .date-head { margin: 0; }
.icon-btn.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 18px; border: 1px solid var(--primary); background: #E4F1EE; color: var(--primary);
  font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---------- Anggota keluarga ---------- */
a.avatar { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.member { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.member-name { font-size: 15px; font-weight: 600; }
.perms { display: flex; flex-wrap: wrap; gap: 6px; }
.perm { font-size: 12px; font-weight: 500; padding: 6px 10px; border-radius: 14px; background: #DDEFE9; color: #0B4A40; }
.perm.off { background: #ECE9E0; color: var(--muted-strong); }
.member-edit { align-self: flex-start; padding: 0; min-height: 32px; }
.small-note { padding: 12px 14px; gap: 4px; border-radius: var(--radius); }
.link-row { color: var(--text); text-decoration: none; }
.danger-row { color: var(--danger); font-weight: 500; border-bottom: none; }

/* Ubah transaksi */
a.edit-link { color: inherit; text-decoration: none; flex: 1; min-width: 0; min-height: 44px; justify-content: center; }
a.edit-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.btn-text.danger { color: var(--danger); width: 100%; margin-top: 4px; }

/* Pengaturan anggaran */
.money-input {
  border: none; background: transparent; text-align: right; font-weight: 500; font-size: 14px;
  min-width: 0; width: 55%; padding: 6px 0;
}
.money-input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.money-input::placeholder { color: var(--muted); font-weight: 400; }
.see-all.start { align-self: flex-start; padding: 6px 0; }

.segmented.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segmented.four button { font-size: 13px; padding: 0 2px; }
