/* ==========================================================
   Uangku - design system
   Simpan di: public/assets/css/app.css
   (menggantikan style.css lama, dimuat SETELAH bootstrap.min.css)
   ========================================================== */

:root {
  --bg: #F4F2FB;
  --surface: #FFFFFF;
  --ink: #17133A;
  --muted: #7B7899;
  --line: #E9E6F5;
  --brand: #5B3DF5;
  --brand-deep: #4328D6;
  --brand-soft: #ECE8FF;
  --amber: #FFB020;
  --danger: #E5484D;
  --danger-soft: #FDECEC;

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', var(--font);

  --shadow-float: 0 10px 30px -10px rgba(23, 19, 58, .28);
}

/* ---------- Kategori: satu warna untuk ikon, chip, dan grafik ---------- */
.c-makanan       { --c: #FF7A59; }
.c-tempat_tinggal{ --c: #5B3DF5; }
.c-jajan         { --c: #F0509B; }
.c-olahraga      { --c: #12B28C; }
.c-transportasi  { --c: #2E90FA; }
.c-hiburan       { --c: #E8A200; }
.c-lainnya       { --c: #8A87A6; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background: #E4E0F4;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, white);
  outline-offset: 2px;
}

.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 130px;
  background: var(--bg);
}

@media (min-width: 520px) {
  .app { box-shadow: 0 0 60px rgba(23, 19, 58, .12); }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: calc(26px + env(safe-area-inset-top)) 22px 46px;
  color: #fff;
  background: var(--brand);
  border-radius: 0 0 34px 34px;
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.hero::before { width: 240px; height: 240px; right: -70px; top: -90px; background: rgba(255, 255, 255, .10); }
.hero::after  { width: 150px; height: 150px; left: -50px; bottom: -70px; background: rgba(0, 0, 0, .10); }
.hero > * { position: relative; z-index: 1; }

.hero-greet { margin: 0; font-size: 14px; font-weight: 500; opacity: .85; }
.hero-title { margin: 2px 0 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.01em; }

.hero-label { margin: 26px 0 2px; font-size: 13px; font-weight: 500; opacity: .8; }
.hero-amount {
  display: flex; align-items: baseline; gap: 8px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 46px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em;
}
.hero-amount .cur { font-size: 20px; font-weight: 600; opacity: .7; letter-spacing: 0; }

.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border-radius: 999px;
}

/* ---------- Segmented control ---------- */
.segmented {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  margin: -24px 18px 0;
  padding: 5px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-float);
}
.segmented button {
  height: 42px;
  border: 0; border-radius: 14px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: transparent;
  transition: background .2s, color .2s;
}
.segmented button[aria-selected="true"] { color: #fff; background: var(--ink); }

.content { padding: 18px 18px 0; }

/* ---------- Field ---------- */
.field, .field-label + .field {
  width: 100%;
}
.field {
  display: block;
  height: 50px;
  padding: 0 16px;
  font: 500 15px var(--font);
  color: var(--ink);
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 14px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field::placeholder { color: #A9A6C2; }
.field:focus { background: #fff; border-color: var(--brand); }

.field-label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

.date-wrap { position: relative; }
.date-wrap > i {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--muted); pointer-events: none;
}
.date-wrap .field { padding-left: 42px; }
.date-wrap.sm .field { height: 40px; font-size: 13px; padding-left: 36px; border-radius: 12px; }
.date-wrap.sm > i { left: 13px; font-size: 12px; }

.flatpickr-calendar { z-index: 1100 !important; font-family: var(--font); border-radius: 18px; box-shadow: var(--shadow-float); }

/* ---------- List pengeluaran ---------- */
.date-filter { margin-bottom: 14px; }
.date-filter[hidden] { display: none; }

.expense-list { display: grid; gap: 10px; }

.expense {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  transition: transform .15s, border-color .15s;
}
.expense:active { transform: scale(.985); }
.expense:hover { border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }

.ico {
  flex: none;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  font-size: 18px;
  color: var(--c, var(--brand));
  background: color-mix(in srgb, var(--c, var(--brand)) 13%, white);
  border-radius: 15px;
}

.expense-main { flex: 1; min-width: 0; }
.expense-title { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-date  { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.expense-side  { flex: none; text-align: right; }
.expense-amount{ margin: 0; font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.expense-cat   { margin: 2px 0 0; font-size: 12px; font-weight: 600; color: var(--c); }

/* ---------- Empty ---------- */
.empty { padding: 44px 24px; text-align: center; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; margin: 0 auto 14px; font-size: 24px; border-radius: 22px; --c: var(--brand); }
.empty h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--ink); }
.empty p  { margin: 0; font-size: 13px; line-height: 1.5; }
.empty.sm { padding: 28px 12px; }

/* ---------- Dock (navigasi bawah) ---------- */
.dock {
  position: fixed; z-index: 1030;
  left: 50%; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 4px;
  padding: 7px;
  background: var(--ink);
  border-radius: 999px;
  box-shadow: 0 16px 36px -10px rgba(23, 19, 58, .55);
  transform: translateX(-50%);
  transition: transform .3s cubic-bezier(.3, .8, .3, 1);
}
body.sheet-open .dock { transform: translate(-50%, 160%); }

.dock a {
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 16px;
  font-size: 13px; font-weight: 600;
  color: rgba(255, 255, 255, .55);
  text-decoration: none;
  border-radius: 999px;
  transition: background .2s, color .2s;
}
.dock a i { font-size: 17px; }
.dock a span { display: none; }
.dock a.active { color: #fff; background: rgba(255, 255, 255, .14); }
.dock a.active span { display: inline; }

.dock .add-btn {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin-left: 4px;
  font-size: 20px;
  color: var(--ink);
  background: var(--amber);
  border: 0; border-radius: 50%;
  transition: transform .15s;
}
.dock .add-btn:active { transform: scale(.92); }

/* ---------- Bottom sheet ---------- */
.sheet.offcanvas-bottom {
  height: auto; max-height: 92vh;
  max-width: 480px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 28px 28px 0 0;
}
.sheet .grab { width: 40px; height: 4px; margin: 10px auto 0; background: var(--line); border-radius: 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px 4px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.sheet-close {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  color: var(--muted); background: var(--bg);
  border: 0; border-radius: 50%;
}
.sheet-body { padding: 8px 22px 24px; overflow-y: auto; }

.amount-box { display: flex; align-items: baseline; gap: 8px; padding: 6px 0 14px; margin-bottom: 14px; border-bottom: 2px solid var(--line); }
.amount-box:focus-within { border-color: var(--brand); }
.amount-box .cur { font-size: 18px; font-weight: 700; color: var(--muted); }
.amount-box input {
  width: 100%; min-width: 0;
  padding: 0;
  font: 700 38px var(--font-display); letter-spacing: -.02em;
  color: var(--ink);
  background: transparent; border: 0; outline: none;
}
.amount-box input::placeholder { color: #CFCCE2; }

.form-row { margin-bottom: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px;
  font-size: 13px; font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip i { color: var(--c); font-size: 14px; }
.chip[aria-pressed="true"] { color: #fff; background: var(--c); border-color: var(--c); }
.chip[aria-pressed="true"] i { color: #fff; }

.btn-main {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 54px;
  font-size: 15px; font-weight: 700;
  color: #fff; background: var(--brand);
  border: 0; border-radius: 16px;
  transition: background .15s, opacity .15s;
}
.btn-main:hover { background: var(--brand-deep); }
.btn-main:disabled { opacity: .6; }

/* Sheet detail (aksi) */
.detail { display: flex; align-items: center; gap: 14px; padding: 6px 0 18px; }
.detail .ico { width: 54px; height: 54px; font-size: 22px; border-radius: 18px; }
.detail-title { margin: 0; font-size: 16px; font-weight: 700; }
.detail-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.detail-amount { margin: 0 0 0 auto; font-family: var(--font-display); font-size: 20px; font-weight: 700; }

.btn-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.btn-ghost, .btn-danger {
  height: 52px;
  font-size: 14px; font-weight: 700;
  border: 0; border-radius: 16px;
  transition: background .15s, color .15s;
}
.btn-ghost  { color: var(--ink); background: var(--bg); }
.btn-danger { color: var(--danger); background: var(--danger-soft); }
.btn-danger.confirm { color: #fff; background: var(--danger); }

/* ---------- Insight ---------- */
.hero.slim { padding-bottom: 40px; }

.card-x {
  margin-bottom: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 26px;
}
.card-x:first-child { margin-top: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-h h2 { margin: 0; font-size: 16px; font-weight: 700; }
.card-h .tools { display: flex; align-items: center; gap: 6px; }
.card-h .date-wrap { width: 150px; }

.reset-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  font-size: 12px;
  color: var(--muted); background: var(--bg);
  border: 0; border-radius: 50%;
}
.reset-btn[hidden] { display: none; }

#pie-chart, #bar-chart { width: 100%; }
#pie-chart { height: 230px; }
#bar-chart { height: 290px; }

.donut-c { text-align: center; line-height: 1.15; pointer-events: none; }
.donut-c b { display: block; font: 700 30px var(--font-display); letter-spacing: -.02em; color: var(--ink); }
.donut-c span { font: 600 12px var(--font); color: var(--muted); }

.legend { margin: 10px 0 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.legend .pct { margin-left: auto; font-family: var(--font-display); font-weight: 700; }

/* ---------- Login PIN ---------- */
body.auth { display: block; }
.auth-wrap { display: flex; flex-direction: column; max-width: 480px; min-height: 100vh; margin: 0 auto; background: var(--bg); }
.auth-top {
  position: relative; overflow: hidden;
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 300px;
  padding: 40px 28px 44px;
  color: #fff; background: var(--brand);
  border-radius: 0 0 40px 40px;
}
.auth-top::before { content: ""; position: absolute; width: 300px; height: 300px; right: -110px; top: -100px; border-radius: 50%; background: rgba(255, 255, 255, .10); }
.auth-top::after  { content: ""; position: absolute; width: 180px; height: 180px; left: -70px; top: 40%; border-radius: 50%; background: rgba(0, 0, 0, .10); }
.auth-top > * { position: relative; z-index: 1; }
.auth-logo { display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 22px; background: #fff; border-radius: 22px; }
.auth-logo img { width: 38px; }
.auth-top h1 { margin: 0 0 6px; font-family: var(--font-display); font-size: 36px; font-weight: 700; letter-spacing: -.02em; }
.auth-top p { margin: 0; font-size: 15px; opacity: .85; line-height: 1.5; }

.auth-form { padding: 28px 28px calc(36px + env(safe-area-inset-bottom)); }
.pin-input {
  height: 64px; margin-bottom: 14px;
  text-align: center; letter-spacing: .5em; text-indent: .5em;
  font: 700 26px var(--font-display);
  background: #fff; border: 2px solid var(--line);
}
.pin-input::placeholder { font: 500 15px var(--font); letter-spacing: 0; text-indent: 0; }
.pin-input.shake { border-color: var(--danger); animation: shake .35s; }
.auth-hint { min-height: 20px; margin: 0 0 10px; font-size: 13px; text-align: center; color: var(--danger); }

@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* iziToast mengikuti font aplikasi */
.iziToast { font-family: var(--font) !important; border-radius: 16px !important; }
