/* =========================================================
   Farmly — stylesheet
   1. Token  2. Dasar  3. Teks  4. Tombol  5. Kartu & daftar
   6. Beranda & grafik  7. Filter  8. Form  9. Sheet & toast
   10. Ternak & timeline  11. Tab bar  12. Onboarding
   ========================================================= */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  color-scheme: light;
  --page: #E9EEEB;
  --bg: #F4F7F5;
  --surface: #FFFFFF;
  --surface-2: #EEF3F0;
  --text: #0F1A14;
  --text-2: #46554C;
  --muted: #6F7D75;
  --border: #E1E8E3;
  --primary: #167653;
  --primary-strong: #0E5A3F;
  --primary-soft: #E3F2EA;
  --on-primary: #FFFFFF;
  --pos: #11734B;
  --pos-soft: #E3F2EA;
  --neg: #B93A32;
  --neg-soft: #FBEAE8;
  --warn: #8A5A00;
  --warn-soft: #FDF1DA;
  --info: #2160B0;
  --info-soft: #E5EEFA;
  --violet: #6A3FC0;
  --violet-soft: #EFE9FB;
  --hero-1: #1B8560;
  --hero-2: #0B4F37;
  --toast-action: #8FE0BC;
  --shadow: 0 1px 2px rgba(15, 26, 20, .04), 0 4px 16px rgba(15, 26, 20, .05);
  --shadow-lg: 0 -8px 40px rgba(15, 26, 20, .16);
  /* grafik: slot kategori 1 & 2 dari palet tervalidasi */
  --series-in: #2a78d6;
  --series-out: #eb6834;
  --grid: #E3E7E4;
  --axis: #C9D1CC;

  --r-md: 14px;
  --r-lg: 20px;
  --tabbar-h: 54px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #070A08; --bg: #0D1210; --surface: #151C18; --surface-2: #1D2621;
    --text: #EDF2EE; --text-2: #B6C2BB; --muted: #8A968F; --border: #25302A;
    --primary: #33A97D; --primary-strong: #2A9169; --primary-soft: #173527; --on-primary: #04140C;
    --pos: #45C493; --pos-soft: #173527; --neg: #F2766C; --neg-soft: #3A1D1A;
    --warn: #F0B54A; --warn-soft: #3A2C10; --info: #7FB0F0; --info-soft: #172A44;
    --violet: #B49CF0; --violet-soft: #2A2144;
    --hero-1: #17684B; --hero-2: #0A3626; --toast-action: #11734B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .5);
    --series-in: #3987e5; --series-out: #d95926; --grid: #232C27; --axis: #36423B;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #070A08; --bg: #0D1210; --surface: #151C18; --surface-2: #1D2621;
  --text: #EDF2EE; --text-2: #B6C2BB; --muted: #8A968F; --border: #25302A;
  --primary: #33A97D; --primary-strong: #2A9169; --primary-soft: #173527; --on-primary: #04140C;
  --pos: #45C493; --pos-soft: #173527; --neg: #F2766C; --neg-soft: #3A1D1A;
  --warn: #F0B54A; --warn-soft: #3A2C10; --info: #7FB0F0; --info-soft: #172A44;
  --violet: #B49CF0; --violet-soft: #2A2144;
  --hero-1: #17684B; --hero-2: #0A3626; --toast-action: #11734B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .5);
  --series-in: #3987e5; --series-out: #d95926; --grid: #232C27; --axis: #36423B;
}

/* ---------- 2. DASAR ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
h1, h2, h3, h4, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.i { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num { font-variant-numeric: tabular-nums; }

.app {
  position: relative;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 600px) {
  body { display: grid; place-items: center; }
  .app { width: 420px; height: min(880px, 94dvh); border-radius: 32px; border: 1px solid var(--border); box-shadow: 0 30px 80px rgba(0,0,0,.18); }
}
.view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px); }
.page { display: none; padding: calc(var(--safe-t) + 14px) 16px 0; }
.page.active { display: block; animation: pageIn .28s var(--ease); }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Animasi perpindahan halaman (kelas dipasang oleh route() di ui.js) */
.page.active.anim-push  { animation: pagePush .34s var(--ease); }   /* buka halaman detail: masuk dari kanan */
.page.active.anim-pop   { animation: pagePop .3s var(--ease); }     /* kembali: masuk dari kiri */
.page.active.anim-right { animation: pageRight .3s var(--ease); }   /* pindah tab ke kanan */
.page.active.anim-left  { animation: pageLeft .3s var(--ease); }    /* pindah tab ke kiri */
@keyframes pagePush  { from { opacity: 0; transform: translateX(30%); } to { opacity: 1; transform: none; } }
@keyframes pagePop   { from { opacity: 0; transform: translateX(-18%); } to { opacity: 1; transform: none; } }
@keyframes pageRight { from { opacity: 0; transform: translateX(12%); } to { opacity: 1; transform: none; } }
@keyframes pageLeft  { from { opacity: 0; transform: translateX(-12%); } to { opacity: 1; transform: none; } }

/* Isi halaman muncul berurutan saat halaman dibuka */
.page.enter [id$="-body"] > * { animation: rise .42s var(--ease) both; }
.page.enter [id$="-body"] > :nth-child(2) { animation-delay: .04s; }
.page.enter [id$="-body"] > :nth-child(3) { animation-delay: .08s; }
.page.enter [id$="-body"] > :nth-child(4) { animation-delay: .12s; }
.page.enter [id$="-body"] > :nth-child(5) { animation-delay: .16s; }
.page.enter [id$="-body"] > :nth-child(6) { animation-delay: .2s; }
.page.enter [id$="-body"] > :nth-child(n+7) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Efek gelombang saat diketuk (span.ripple ditambahkan oleh app.js) */
.list-row, .btn, .qa-tile, .act { position: relative; overflow: hidden; }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); pointer-events: none; animation: ripple .55s ease-out forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* Isi bottom sheet bergeser saat berganti form */
.sheet-body.swap > :not(.sheet-head) { animation: sheetSwap .26s var(--ease); }
@keyframes sheetSwap { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ---------- 3. TEKS ---------- */
.page-head { display: flex; align-items: center; gap: 8px; min-height: 48px; margin-bottom: 14px; }
.page-head h1 { flex: 1; min-width: 0; font-size: 26px; font-weight: 750; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head.sub h1 { font-size: 20px; }
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.eyebrow { font-size: 13px; color: var(--muted); font-weight: 500; }
.home-head h1 { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.group-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 22px 4px 8px; }
.group-label:first-child { margin-top: 4px; }
.sub-title { font-size: 14px; font-weight: 700; margin: 18px 0 8px; }
.link { color: var(--primary); font-size: 13px; font-weight: 650; padding: 6px 2px; white-space: nowrap; }
.foot-note { text-align: center; font-size: 12px; color: var(--muted); margin: 24px 0 8px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--neg); color: #fff; font-size: 11px; font-weight: 750; }

/* ---------- 4. TOMBOL ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 650; transition: transform .15s var(--ease), background .2s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn .i { width: 18px; height: 18px; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--neg); color: #fff; }
.btn.danger-text { color: var(--neg); }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row > .btn { flex: 1; }
.btn-stack { display: flex; flex-direction: column; gap: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; transition: background .2s, transform .15s; }
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { color: var(--text-2); }
.icon-btn.ghost:active { background: var(--surface-2); }
.icon-btn.primary { background: var(--primary); color: var(--on-primary); }
.icon-btn.on-dark { width: 36px; height: 36px; color: rgba(255,255,255,.85); background: rgba(255,255,255,.12); }
.icon-btn.on-dark .i { width: 18px; height: 18px; }

/* ---------- 5. KARTU & DAFTAR ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.list { padding: 4px 16px; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px;
  padding: 10px 0; text-align: left; border-bottom: 1px solid var(--border);
}
.list > .list-row:last-child, .card.list > .list-row:last-child { border-bottom: 0; }
button.list-row:active, .list-row > button.row-main:active { opacity: .6; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.row-title { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.row-amount { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-amount.in { color: var(--pos); }
.row-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); }
.row-icon .i { width: 20px; height: 20px; }
.row-icon.in, .row-icon.k-ok { background: var(--pos-soft); color: var(--pos); }
.row-icon.out, .row-icon.k-death { background: var(--neg-soft); color: var(--neg); }
.row-icon.k-health { background: var(--info-soft); color: var(--info); }
.row-icon.k-birth, .row-icon.k-repro { background: var(--violet-soft); color: var(--violet); }
.row-icon.k-feed, .row-icon.k-debt { background: var(--warn-soft); color: var(--warn); }
.row-icon.k-task { background: var(--primary-soft); color: var(--primary); }
.list-row > .i { color: var(--muted); width: 18px; height: 18px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 750; font-size: 15px; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-sq { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 750; flex-shrink: 0; }
.delta { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-style: normal; white-space: nowrap; vertical-align: 1px; }
.badge.ok { background: var(--pos-soft); color: var(--pos); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--neg-soft); color: var(--neg); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); }
.profile-card > .i { color: var(--muted); }
.check-btn { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--axis); display: grid; place-items: center; flex-shrink: 0; color: transparent; transition: all .15s; }
.check-btn .i { width: 16px; height: 16px; stroke-width: 3; }
.check-btn.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.done .row-title { text-decoration: line-through; color: var(--muted); }

/* Empty state */
.empty { text-align: center; padding: 28px 12px; }
.empty-ic { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.empty p { font-size: 14px; color: var(--muted); margin-bottom: 16px; }

/* ---------- 6. BERANDA & GRAFIK ---------- */
.hero { position: relative; overflow: hidden; color: #fff; border-radius: 24px; padding: 18px 18px 16px; margin-bottom: 18px; background: linear-gradient(150deg, var(--hero-1), var(--hero-2)); box-shadow: 0 14px 30px -12px rgba(11, 79, 55, .55); }
.hero::after { content: ''; position: absolute; width: 220px; height: 220px; right: -70px; top: -90px; border-radius: 50%; background: rgba(255,255,255,.07); pointer-events: none; }
.hero-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; opacity: .9; position: relative; z-index: 1; }
.hero-amount { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; position: relative; z-index: 1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-amount.neg { color: #FFD9D5; }
.hero-sub { font-size: 12px; opacity: .75; margin-bottom: 16px; position: relative; z-index: 1; }
.hero-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; position: relative; z-index: 1; }
.hero-split > div { background: rgba(255,255,255,.1); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.hs-label { display: flex; align-items: center; gap: 4px; font-size: 12px; opacity: .85; margin-bottom: 2px; }
.hs-label .i { width: 14px; height: 14px; }
.hero-split b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 4px 0; text-align: center; }
.qa-ic { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--primary); box-shadow: var(--shadow); transition: transform .15s var(--ease); }
.qa:active .qa-ic { transform: scale(.92); }
.qa-ic.in { color: var(--pos); }
.qa-ic.out { color: var(--neg); }
.qa-ic.k-health { color: var(--info); }
.qa-ic.k-repro { color: var(--violet); }
.qa-ic.k-feed { color: var(--warn); }
.banner { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--warn-soft); color: var(--warn); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.banner .row-main { color: var(--text); }
.banner .row-sub { white-space: normal; }
.big-stat { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
.big-stat b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.big-stat span { color: var(--muted); font-size: 14px; }
.split-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.split-2 > div { background: var(--surface-2); border-radius: var(--r-md); padding: 12px; min-width: 0; }
.split-2 small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.split-2 b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cf-readout { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.cf-month { width: 100%; font-weight: 700; color: var(--text); text-transform: capitalize; }
.cf-key { display: inline-flex; align-items: center; gap: 6px; }
.cf-key b { color: var(--text); font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.sw.in { background: var(--series-in); }
.sw.out { background: var(--series-out); }
.cf-plot { position: relative; height: 132px; margin-left: 42px; border-bottom: 1px solid var(--axis); display: flex; }
.cf-grid { position: absolute; left: -42px; right: 0; height: 0; border-top: 1px solid var(--grid); pointer-events: none; }
.cf-grid span { position: absolute; left: 0; top: -8px; width: 36px; text-align: right; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cf-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; position: relative; z-index: 1; border-radius: 8px 8px 0 0; }
.cf-col.sel { background: var(--surface-2); }
.cf-bar { display: block; width: 10px; border-radius: 4px 4px 0 0; transition: height .4s var(--ease), opacity .2s; }
.cf-bar.in { background: var(--series-in); }
.cf-bar.out { background: var(--series-out); }
.cf-col:not(.sel) .cf-bar { opacity: .5; }
.cf-x { display: flex; margin-left: 42px; margin-top: 6px; }
.cf-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.cf-x span.sel { color: var(--text); font-weight: 700; }

.hbar { margin-bottom: 14px; }
.hbar:last-child { margin-bottom: 2px; }
.hbar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.hbar-top b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-top small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 4px; }
.hbar-track i.in { background: var(--series-in); }
.hbar-track i.out { background: var(--series-out); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpis > div { background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.kpis small { display: block; font-size: 11px; color: var(--muted); }
.kpis b { display: block; font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 7. FILTER, SEGMEN, CHIP ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg label { position: relative; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .seg button { display: block; width: 100%; text-align: center; padding: 9px 4px; border-radius: 9px; font-size: 14px; font-weight: 650; color: var(--text-2); transition: background .2s, color .2s; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg input:checked + span, .seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }
.chips { display: flex; gap: 8px; margin-bottom: 14px; }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip, .chip-r span {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text-2);
  font-size: 14px; font-weight: 600; transition: all .15s; cursor: pointer;
}
.chip .i { width: 16px; height: 16px; }
.chip.on, .chip-r input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip.static { min-height: 32px; cursor: default; }
.chip.dashed { border-style: dashed; }
.chip-r { position: relative; }
.chip-r input { position: absolute; opacity: 0; pointer-events: none; }
.chip-r input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.period { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.period-label { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border-radius: 12px; font-weight: 700; font-size: 16px; text-transform: capitalize; }
.period-label:active { background: var(--surface-2); }
.period-label .i { width: 16px; height: 16px; color: var(--muted); }
.sum3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.sum3 > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.sum3 span { display: block; font-size: 12px; color: var(--muted); }
.sum3 b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { position: relative; margin-bottom: 14px; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; }
.group { margin-bottom: 4px; }
.group-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 650; color: var(--muted); padding: 6px 4px 8px; }
.group-head .over { color: var(--neg); }
.debt-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 14px; }
.debt-total span { font-size: 13px; color: var(--muted); }
.debt-total b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
details.more-list { margin-top: 6px; }
details.more-list summary { cursor: pointer; font-size: 14px; font-weight: 650; color: var(--text-2); padding: 12px 4px; list-style: none; }
details.more-list summary::-webkit-details-marker { display: none; }

/* ---------- 8. FORM ---------- */
.field { margin-bottom: 16px; min-width: 0; }
.field > label, .field-label { display: block; font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 8px; }
.field-label .i { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }
.input {
  width: 100%; min-width: 0; height: 50px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 16px; outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
textarea.input { height: 84px; padding: 12px 14px; resize: none; line-height: 1.4; }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; text-overflow: ellipsis; }
input[type="date"].input { padding-right: 8px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input::placeholder { color: var(--muted); opacity: .8; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.amount-field { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--border); padding: 6px 2px 8px; margin: 4px 0 18px; transition: border-color .2s; }
.amount-field:focus-within { border-color: var(--primary); }
.amount-field span { font-size: 20px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.amount-field input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.amount-field input::placeholder { color: var(--axis); }
.money { display: flex; align-items: center; gap: 8px; height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.money:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.money > span { color: var(--muted); font-weight: 650; white-space: nowrap; }
.money input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 16px; }
.stepper { display: flex; align-items: center; height: 50px; border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper:focus-within { border-color: var(--primary); }
.stepper button { width: 46px; height: 100%; font-size: 22px; font-weight: 600; color: var(--primary); flex-shrink: 0; }
.stepper button:active { background: var(--surface-2); }
.stepper input { flex: 1; min-width: 0; height: 100%; text-align: center; border: 0; outline: none; background: none; font-size: 16px; font-weight: 700; }
.hint { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.hint:empty { display: none; }
.hint > div { display: flex; justify-content: space-between; gap: 8px; }
.hint > div + div { margin-top: 4px; }
.hint b { color: var(--text); font-variant-numeric: tabular-nums; }
.hint b.pos { color: var(--pos); }
.hint b.neg { color: var(--neg); }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-md); margin-bottom: 16px; cursor: pointer; position: relative; }
.switch-row > span { flex: 1; }
.switch-row b { display: block; font-size: 14px; font-weight: 650; }
.switch-row small { display: block; font-size: 12px; color: var(--muted); }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 46px; height: 28px; border-radius: 999px; background: var(--axis); position: relative; flex-shrink: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch-row input:checked + .switch { background: var(--primary); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--primary); outline-offset: 2px; }
.invalid .input, .invalid.amount-field, .invalid .stepper, .invalid .money { border-color: var(--neg) !important; }
.form-error { color: var(--neg); font-size: 13px; font-weight: 600; }
.form-error:not(:empty) { margin-bottom: 10px; }
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form .input { flex: 1; }
.opt { color: var(--muted); font-weight: 500; }

/* ---------- 9. SHEET, TOAST, DETAIL ---------- */
.backdrop { position: absolute; inset: 0; background: rgba(5, 12, 8, .45); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 91; } /* di atas layar sambutan (90) agar form Masuk bisa dibuka dari sana */
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 92;
  max-height: 92%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(105%); transition: transform .34s var(--ease);
  padding-bottom: var(--safe-b);
}
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-grip { flex-shrink: 0; height: 22px; display: grid; place-items: center; touch-action: none; }
.sheet-grip::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--axis); }
.sheet-body { overflow-y: auto; padding: 0 20px 20px; overscroll-behavior: contain; }
.sheet-head { display: flex; align-items: center; gap: 4px; margin: 0 -8px 14px 0; position: sticky; top: 0; background: var(--surface); z-index: 2; padding-top: 2px; }
.sheet-head .back { margin-left: -12px; }
.sheet-titles { flex: 1; min-width: 0; }
.sheet-titles h2 { font-size: 19px; font-weight: 750; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-titles p { font-size: 13px; color: var(--muted); margin-top: 1px; }
.sheet-foot { position: sticky; bottom: -20px; background: var(--surface); padding: 12px 0 20px; margin-bottom: -20px; z-index: 2; }
.sheet-foot .btn-row { margin-top: 0; }
.sheet-msg { font-size: 15px; color: var(--text-2); margin-bottom: 16px; }
.toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 93;
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 10px 10px 16px;
  background: var(--text); color: var(--bg); border-radius: var(--r-md); font-size: 14px; font-weight: 550;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  transform: translateY(16px); opacity: 0; pointer-events: none; transition: all .25s var(--ease);
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast.error { background: var(--neg); color: #fff; }
.toast span { flex: 1; }
.toast-btn { font-weight: 750; color: var(--toast-action); padding: 8px 10px; border-radius: 8px; text-transform: uppercase; font-size: 13px; letter-spacing: .03em; }
.detail-amount { font-size: 32px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.detail-amount.in { color: var(--pos); }
.detail-amount.neg { color: var(--neg); }
.detail-desc { font-size: 16px; color: var(--text-2); margin: 2px 0 16px; }
.kv { background: var(--surface-2); border-radius: var(--r-md); padding: 4px 14px; margin-bottom: 8px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); flex-shrink: 0; }
.kv dd { font-weight: 650; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; min-width: 0; }
.stat small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-bottom: 4px; }
.qa-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 4px; border-radius: var(--r-md); background: var(--surface-2); font-size: 12.5px; font-weight: 650; text-align: center; transition: transform .15s; min-width: 0; }
.qa-tile:active { transform: scale(.96); }
.qa-tile .qa-ic { width: 44px; height: 44px; border-radius: 14px; box-shadow: none; }

/* ---------- 10. HALAMAN TERNAK & TIMELINE ---------- */
.a-hero { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.a-hero .avatar-sq { width: 56px; height: 56px; border-radius: 18px; font-size: 22px; }
.a-hero h2 { font-size: 20px; font-weight: 750; letter-spacing: -.01em; overflow-wrap: anywhere; }
.a-hero p { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.act-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 2px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 650; color: var(--text-2); text-align: center; box-shadow: var(--shadow); }
.act { transition: transform .15s var(--ease); }
.act:active { transform: scale(.96); }
.act .i { width: 22px; height: 22px; }
.act.k-health { color: var(--info); }
.act.k-repro { color: var(--violet); }
.act.k-sell { color: var(--primary); }
.act span { color: var(--text-2); }
.tl { position: relative; padding-left: 8px; }
.tl-item { position: relative; display: flex; gap: 12px; width: 100%; text-align: left; padding: 8px 0; }
.tl-item::before { content: ''; position: absolute; left: 19px; top: 44px; bottom: -8px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-item .row-icon { width: 40px; height: 40px; border-radius: 50%; z-index: 1; }
.tl-body { flex: 1; min-width: 0; padding-top: 2px; }
.tl-body b { display: block; font-size: 14px; font-weight: 650; }
.tl-body span { display: block; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.tl-date { font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 3px; }

/* ---------- 11. TAB BAR ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: 1fr 1fr 64px 1fr 1fr; align-items: center;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 100%; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .01em; transition: color .2s; min-width: 0; }
.tab .i { width: 22px; height: 22px; }
.tab.active { font-weight: 700; }
.tab span:not(.dot) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .i { transition: transform .25s var(--ease); }
.tab.active { color: var(--primary); }
.tab.active .i { transform: translateY(-1px); }
.tab .dot { position: absolute; top: 6px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--neg); border: 2px solid var(--surface); }
.fab { justify-self: center; width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 14px -6px rgba(22, 118, 83, .6); transform: translateY(-8px); transition: transform .2s var(--ease); }
.fab:active { transform: translateY(-8px) scale(.92); }
.fab .i { width: 24px; height: 24px; stroke-width: 2.4; transition: transform .3s var(--ease); }
.fab:active .i { transform: rotate(90deg); }

/* tab aktif: latar lembut melebar di belakang ikon + ikon memantul */
.tab { isolation: isolate; }
.tab::before { content: ''; position: absolute; z-index: -1; top: 5px; left: 50%; width: 54px; height: 28px; margin-left: -27px; border-radius: 14px; background: var(--primary-soft); opacity: 0; transform: scaleX(.4); transition: transform .3s var(--ease), opacity .2s; }
.tab.active::before { opacity: 1; transform: scaleX(1); }
.tab.active .i { animation: tabPop .42s var(--ease); }
@keyframes tabPop { 0% { transform: scale(.8); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* ---------- 12. ONBOARDING & BANTUAN ---------- */
.onboard { position: absolute; inset: 0; z-index: 90; background: var(--bg); overflow-y: auto; animation: pageIn .3s var(--ease); }
.ob { min-height: 100%; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 36px) 24px calc(var(--safe-b) + 24px); }
.ob-hero { margin-bottom: 24px; }
.brand-mark { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: linear-gradient(150deg, var(--hero-1), var(--hero-2)); color: #fff; margin-bottom: 22px; box-shadow: 0 14px 30px -12px rgba(11, 79, 55, .6); }
.brand-mark .i { width: 32px; height: 32px; }
.ob h1 { font-size: 28px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; margin-bottom: 10px; }
.ob-hero p { color: var(--text-2); font-size: 15px; }
.ob-foot { margin-top: auto; padding-top: 24px; }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.ob-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--axis); transition: width .2s; }
.ob-dots i.on { width: 20px; background: var(--primary); }
.prose { font-size: 14px; color: var(--text-2); line-height: 1.6; }
.prose h3 { font-size: 15px; color: var(--text); margin: 0 0 6px; }
.prose ol, .prose ul { padding-left: 20px; margin: 0; }
.prose li + li { margin-top: 4px; }

/* ---------- Akun ---------- */
.danger-text { color: var(--neg); }
.warn-text { color: var(--warn); }
.link-row { display: flex; justify-content: flex-end; margin: -8px 0 4px; }
.sheet-alt { text-align: center; font-size: 14px; color: var(--text-2); margin: 14px 0 0; }
.sheet-alt .link { font-size: 14px; }
.check-line { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); margin: 4px 0 6px; cursor: pointer; }
.check-line input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.check-line .link { padding: 0; }
.acc-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--primary-soft); color: var(--primary); font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.acc-status span { color: var(--text); }
.code-input { font-size: 24px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Server: pengumuman, iklan, wajib update ---------- */
.notice { display: flex; align-items: flex-start; gap: 4px; background: var(--primary-soft); border-radius: var(--r-md); padding: 4px 4px 4px 14px; margin-bottom: 14px; }
.notice.info { background: var(--info-soft); }
.notice > .row-main { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; text-align: left; }
.notice > .row-main > .i { flex: none; margin-top: 1px; color: var(--primary); }
.notice.info > .row-main > .i { color: var(--info); }
.notice .row-title { display: block; font-size: 14px; font-weight: 700; }
.notice .row-sub { display: block; font-size: 13px; color: var(--text-2); white-space: normal; overflow-wrap: anywhere; }
.notice .link { display: inline-flex; align-items: center; gap: 2px; padding: 6px 0 0; }
.notice .link .i { width: 14px; height: 14px; }
.notice .icon-btn { width: 36px; height: 36px; }
.notice .icon-btn .i { width: 18px; height: 18px; }

.ad-box { position: relative; aspect-ratio: 4 / 1; margin-bottom: 14px; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow); }
.ad-track { display: flex; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.45, 0, .2, 1); will-change: transform; touch-action: pan-y; }
.ad-slide { flex: 0 0 100%; height: 100%; padding: 0; display: block; }
.ad-slide img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-select: none; }
.ad-label { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 700; letter-spacing: .02em; color: #fff; background: rgba(0, 0, 0, .5); padding: 2px 7px; border-radius: 99px; pointer-events: none; }
.ad-dots { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.ad-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); transition: width .2s; }
.ad-dots i.on { width: 18px; background: #fff; }

.gate { position: absolute; inset: 0; z-index: 95; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-card h2 { font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.gate-card p { color: var(--text-2); margin: 0 0 24px; }
.gate-card .btn { margin-bottom: 10px; }
.gate-card small { display: block; margin-top: 8px; }

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