/* Keuanganku: pink pastel yang hangat, teks arang yang netral. */
:root {
  --bg: #fdf6f8;
  --surface: #ffffff;
  --surface-2: #fbeef3;
  --surface-3: #f6e3eb;
  --ink: #2a2730;
  --muted: #6d6676;
  --line: #f0dbe4;
  --primary: #c8457a;
  --primary-ink: #ffffff;
  --primary-soft: #fadbe6;
  --primary-softer: #fdeef3;
  --lavender: #ebe8fd;
  --lavender-ink: #5a52b5;
  --mint: #ddf3ea;
  --mint-ink: #22795a;
  --peach: #fde9da;
  --peach-ink: #a4561f;
  --danger: #c2414b;
  --danger-soft: #fbe3e5;
  --positive: #22795a;
  --shadow: 0 1px 2px rgba(120, 60, 90, 0.06), 0 6px 20px rgba(120, 60, 90, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b191f;
    --surface: #24212a;
    --surface-2: #2c2832;
    --surface-3: #35303d;
    --ink: #f2eef4;
    --muted: #aaa2b3;
    --line: #3a3442;
    --primary: #f19bbb;
    --primary-ink: #2a1520;
    --primary-soft: #4a2b3a;
    --primary-softer: #33242d;
    --lavender: #34304e;
    --lavender-ink: #c5c0ff;
    --mint: #1f3a31;
    --mint-ink: #8fdcbd;
    --peach: #3f2e22;
    --peach-ink: #f3b98d;
    --danger: #ff8f97;
    --danger-soft: #45262a;
    --positive: #8fdcbd;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

[x-cloak] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-soft), var(--lavender));
  color: var(--primary); font-weight: 800;
}
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.center { display: grid; place-items: center; min-height: 50vh; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tiny { font-size: 0.75rem; }
.right { text-align: right; }
.pos { color: var(--positive); }
.neg { color: var(--danger); }
.strong { font-weight: 700; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.soft { background: var(--surface-2); box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.book-card { display: flex; flex-direction: column; gap: 8px; color: var(--ink); transition: transform 0.12s ease, border-color 0.12s ease; }
.book-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--primary-soft); }
.book-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem;
  background: var(--primary-softer);
}
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat.hero { background: linear-gradient(135deg, var(--primary-softer), var(--lavender)); border-color: transparent; }
.empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface-2); border-radius: var(--radius); border: 1px dashed var(--line); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.soft { background: var(--primary-softer); border-color: transparent; color: var(--primary); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 11px; font-size: 0.8rem; }
.btn.block { width: 100%; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 0.95rem; color: var(--ink);
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.amount-input { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- segmented, tabs, badges ---------- */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 999px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 0.85rem; color: var(--muted); cursor: pointer;
}
.seg button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.tabs {
  display: flex; gap: 4px; overflow-x: auto; margin: 18px 0; padding-bottom: 2px;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.tabs a {
  padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-3); color: var(--muted); white-space: nowrap;
}
.badge.pink { background: var(--primary-soft); color: var(--primary); }
.badge.lavender { background: var(--lavender); color: var(--lavender-ink); }
.badge.mint { background: var(--mint); color: var(--mint-ink); }
.badge.peach { background: var(--peach); color: var(--peach-ink); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--primary-softer); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 800; border-top: 2px solid var(--line); border-bottom: 0; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 8px; }

/* ---------- progress ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.bar.ok > span { background: var(--mint-ink); }
.bar.over > span { background: var(--danger); }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(40, 20, 30, 0.35);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto;
}
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgba(60, 20, 40, 0.25); padding: 22px; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.close { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; color: var(--muted); }

/* ---------- auth ---------- */
.auth { min-height: calc(100vh - 60px); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.auth-hero {
  border-radius: var(--radius); padding: 20px;
  background: linear-gradient(135deg, var(--primary-soft), var(--lavender) 60%, var(--mint));
}
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- misc ---------- */
.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--primary-softer); border: 1px dashed var(--primary);
}
.code-box .mono { font-size: 1.05rem; font-weight: 700; word-break: break-all; }
pre.snippet {
  margin: 8px 0 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  overflow-x: auto; font-size: 0.82rem; line-height: 1.5;
}
.steps { margin: 6px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; }
.steps li { margin: 3px 0; }
.prompt-chip { display: block; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--lavender); color: var(--lavender-ink); font-size: 0.88rem; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; }
.toast.success { background: var(--mint); color: var(--mint-ink); border-color: transparent; }
.toast.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.diff-ok { background: var(--mint); color: var(--mint-ink); }
.diff-bad { background: var(--peach); color: var(--peach-ink); }
.pill-note { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; }

/* ---------- ponsel ---------- */
@media (max-width: 760px) {
  h1 { font-size: 1.35rem; }
  .user-name { display: none; }
  .topbar { padding: 10px 14px; }
  .two-col { grid-template-columns: 1fr; }
  /* Kartu statistik dua kolom; kartu utama selebar layar */
  .three-col { grid-template-columns: 1fr 1fr; gap: 10px; }
  .three-col > .hero { grid-column: 1 / -1; }
  .card { padding: 14px; }
  .stat .value { font-size: 1.05rem; }
  /* Judul baris penuh, tombol aksi turun ke bawahnya */
  .row.between > .grow { flex-basis: 100%; }
  .row.between > .grow + .row { width: 100%; }
  .row.between > .grow + .row .btn { flex: 1; }
  a.muted.small { white-space: nowrap; }
  td:first-child { white-space: nowrap; }
  td, th { padding: 9px 7px; }
  .modal { padding: 18px; }
  /* Tabel ringkasan (tanpa header): sembunyikan kolom status agar nominal tidak terpotong */
  table:not(:has(thead)) tr.clickable td:has(> .badge:only-child) { display: none; }
}
