/* Catatan Keuangan — mobile first, satu tangan, tanpa animasi berlebihan. */
:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #17201d;
  --muted: #5f6b67;
  --line: #dfe5e2;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f0;
  --income: #0f7a3d;
  --expense: #b42318;
  --danger-soft: #fde8e6;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --card: #18201d;
    --text: #e7eeeb;
    --muted: #9aa8a3;
    --line: #2a3531;
    --accent: #2bb3a3;
    --accent-ink: #062521;
    --accent-soft: #163a35;
    --income: #4ccf86;
    --expense: #ff8a7a;
    --danger-soft: #3a1d1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.boot { text-align: center; color: var(--muted); margin-top: 40vh; }

.wrap { max-width: 520px; margin: 0 auto; padding: 12px 16px 32px; }

/* ---------- header */
.top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--tap); }
.top h1 { font-size: 17px; margin: 0; font-weight: 650; }
.icon-btn {
  width: var(--tap); height: var(--tap); border: 0; background: transparent; border-radius: 12px;
  font-size: 22px; line-height: 1; color: var(--muted);
}
.icon-btn:active { background: var(--line); }
.menu {
  position: absolute; right: 0; top: 50px; z-index: 10; min-width: 200px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; background: none;
  border-radius: 8px; color: var(--text); text-decoration: none;
}
.menu a:active, .menu button:active { background: var(--accent-soft); }

/* ---------- hadis harian */
.hadith {
  margin: 4px 0 10px; padding: 10px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 12px 12px 0;
}
.hadith blockquote { margin: 0; font-size: 15px; line-height: 1.45; }
.hadith figcaption { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

/* ---------- ringkasan */
.summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 4px 0 14px; }
.summary .label { font-size: 13px; color: var(--muted); }
.summary .balance { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.summary .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.summary .row b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.in { color: var(--income); }
.out { color: var(--expense); }

/* ---------- dua menu utama */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--line); padding: 4px; border-radius: var(--radius); }
.tabs button {
  min-height: 52px; border: 0; border-radius: 11px; background: transparent; font-weight: 650; font-size: 17px; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.tabs button[data-tab="income"][aria-selected="true"] { color: var(--income); }
.tabs button[data-tab="expense"][aria-selected="true"] { color: var(--expense); }

/* ---------- formulir */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin-top: 10px; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: var(--tap); padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); text-align: left; font-size: 15px; line-height: 1.2;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 650; }
.chip:last-child:nth-child(odd) { grid-column: 1 / -1; }

label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--bg); font-size: 16px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.amount-box { position: relative; }
.amount-box::before { content: "Rp"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
input.amount { padding-left: 46px; font-size: 26px; font-weight: 700; min-height: 60px; font-variant-numeric: tabular-nums; }
.inline { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn {
  width: 100%; min-height: 54px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 17px; margin-top: 4px;
}
.btn:disabled { opacity: 0.55; }
.btn.secondary { background: var(--line); color: var(--text); }
.form-error { color: var(--expense); font-size: 14px; margin: 0 0 8px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- riwayat */
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 650; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters select { grid-column: 1 / -1; }
.totals { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin: 10px 2px 6px; color: var(--muted); flex-wrap: wrap; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 8px; align-items: center; padding: 10px 6px 10px 14px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .what { min-width: 0; }
.list .what b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .what small { color: var(--muted); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .del { width: 40px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; font-size: 18px; }
.list .del:active { background: var(--danger-soft); color: var(--expense); }
.list .lock { width: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.more { display: block; margin: 10px auto 0; }

/* ---------- masuk */
.auth { max-width: 400px; margin: 0 auto; padding: 12vh 16px 32px; }
.auth h1 { font-size: 24px; margin: 0 0 4px; }
.auth p { color: var(--muted); margin: 0 0 18px; }

/* ---------- toast */
.toast {
  /* di atas, agar tidak menutupi tombol Simpan saat input beruntun */
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%);
  pointer-events: none;
  max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px;
  font-size: 15px; z-index: 20; box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}
.toast.error { background: var(--expense); color: #fff; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
