:root {
  --bg: #FCF4F5; --card: #FFFFFF; --line: #EED3D8; --line-soft: #F4E3E6;
  --primary: #A34955; --dark: #7E3442; --soft: #F6E1E5; --soft2: #FBEFF1;
  --text: #3B2328; --muted: #8A6B71; --muted2: #6E4E55;
  --green: #2E6B3F; --green-bg: #E3F0E6; --wa: #1F8F4E;
  --red: #B4232B; --red-bg: #FBE9EA; --amber: #A85A12; --amber-bg: #FDF1DC;
  --radius: 18px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; position: relative; }
.splash { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.splash img { width: 160px; opacity: .9; }

/* layout */
.page { display: flex; flex-direction: column; gap: 14px; padding: 0 0 110px; }
.page.with-bar { padding-bottom: 120px; }
.hdr { display: flex; align-items: center; gap: 4px; padding: calc(14px + env(safe-area-inset-top)) 12px 0; }
.hdr h1 { margin: 0; font-size: 19px; font-weight: 700; color: var(--dark); }
.hdr .sub { font-size: 12px; color: var(--muted); }
.hdr .spacer { flex: 1; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--dark); flex-shrink: 0; }
.iconbtn:active { background: var(--soft); }
.greet { padding: calc(18px + env(safe-area-inset-top)) 20px 0; display: flex; align-items: center; gap: 12px; }
.greet .hello { font-family: 'Cormorant Garamond', serif; font-style: italic; font-weight: 600; font-size: 28px; color: var(--dark); line-height: 1.1; }
.greet .date { font-size: 12px; color: var(--muted); }
.greet img { height: 40px; margin-left: auto; }

.card { margin: 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.tight { padding: 2px 14px; gap: 0; }
.card h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card.hero { background: linear-gradient(140deg, #A34955, #7E3442); color: #fff; border: 0; }
.card.hero .muted { color: rgba(255,255,255,.8); }
.card.alert { background: var(--red-bg); border-color: #F2CDD2; }
.card.soft { background: var(--soft2); border-color: #F2CDD2; }
.section-title { margin: 4px 20px 0; font-size: 13px; font-weight: 700; color: var(--dark); display: flex; justify-content: space-between; align-items: baseline; }
.section-title span:last-child { font-weight: 400; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.big { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.pos { color: var(--green); } .neg { color: var(--red); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.row .v { font-weight: 600; white-space: nowrap; }
.row.total { border-top: 1px dashed var(--line); padding-top: 9px; font-weight: 700; }
.list-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-size: 14px; font-weight: 600; }
.list-item .meta { font-size: 12px; color: var(--muted); }
.list-item .amt { font-size: 14px; font-weight: 700; white-space: nowrap; }
.dot { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 17px; font-weight: 700; }
.mx { margin-left: 16px; margin-right: 16px; }

/* bars */
.bar { height: 8px; border-radius: 4px; background: #F4ECEE; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }

/* chips & badges */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 16px; margin: 0; }
.chip { height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted2); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.badge { font-size: 11px; font-weight: 700; border-radius: 7px; padding: 3px 8px; white-space: nowrap; display: inline-block; }
.b-red { background: #FBE3E5; color: var(--red); } .b-amber { background: var(--amber-bg); color: var(--amber); }
.b-grey { background: #ECEAEB; color: #6E6468; } .b-green { background: var(--green-bg); color: var(--green); }
.b-pink { background: #FBE3EC; color: var(--primary); } .b-blue { background: #EAF1FB; color: #2B5C9E; }

/* tabs */
.tabs { margin: -4px 16px 0; display: flex; border-bottom: 1px solid var(--line); }
.tabs a { flex: 1; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; }
.tabs a.on { color: var(--dark); font-weight: 700; border-bottom-color: var(--primary); }
.seg { margin: 0 16px; background: var(--soft); border-radius: 13px; padding: 3px; display: flex; gap: 3px; }
.seg button { flex: 1; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--dark); font-weight: 700; box-shadow: 0 1px 3px rgba(126,52,66,.15); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12px; font-weight: 700; color: var(--muted2); }
.label .opt { font-weight: 400; color: var(--muted); }
.input, select.input, textarea.input { height: 48px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0 14px; font-size: 15px; font-weight: 600; width: 100%; outline: none; }
textarea.input { height: auto; min-height: 76px; padding: 12px 14px; font-weight: 500; line-height: 1.45; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(163,73,85,.12); }
.money { position: relative; }
.money .input { padding-left: 40px; }
.money::before { content: 'Rp'; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); font-weight: 600; pointer-events: none; }
.money.big .input { height: 56px; font-size: 22px; font-weight: 700; border: 1.5px solid var(--primary); }
.hint { font-size: 12px; color: var(--muted); }
.found { border: 1px solid #9CC7A8; background: #F1F8F3; border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--green); }
.found.new { border-color: #EBCB8B; background: #FDF6E9; color: #8A5A12; }
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle input { display: none; }
.toggle .sw { width: 46px; height: 28px; border-radius: 14px; background: #D9C4C8; position: relative; flex-shrink: 0; transition: background .15s; }
.toggle .sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 11px; background: #fff; transition: left .15s; }
.toggle input:checked + .sw { background: var(--primary); }
.toggle input:checked + .sw::after { left: 21px; }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid #D9AEB7; background: #fff; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.check.on { background: var(--green); border-color: var(--green); }

/* buttons */
.btn { height: 48px; border-radius: 14px; border: 0; padding: 0 18px; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.pri { background: var(--primary); color: #fff; }
.btn.pri:active { background: var(--dark); }
.btn.sec { background: #fff; color: var(--muted2); border: 1px solid var(--line); }
.btn.out { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.sm { height: 40px; font-size: 13px; padding: 0 12px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.savebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); display: flex; gap: 10px; z-index: 20; }
.savebar .btn.pri { flex: 1; height: 52px; font-size: 16px; }
.fab { position: fixed; right: max(16px, calc(50% - 244px)); bottom: calc(86px + env(safe-area-inset-bottom)); height: 52px; padding: 0 20px; border-radius: 26px; background: var(--primary); color: #fff; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; box-shadow: 0 6px 16px rgba(126,52,66,.28); z-index: 15; border: 0; cursor: pointer; }

/* bottom nav */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; background: #fff; border-top: 1px solid var(--line); display: flex; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.nav a.on { color: var(--primary); font-weight: 700; }
.nav svg { width: 22px; height: 22px; }

/* sheet / modal */
.sheet-bg { position: fixed; inset: 0; background: rgba(59,35,40,.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet h3 { margin: 0 20px; font-size: 17px; color: var(--dark); }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: 24px; }
.login img { width: 220px; align-self: center; }
.login .card { margin: 0; gap: 14px; }

#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: right; font-size: 11px; color: var(--muted); font-weight: 700; padding: 0 0 6px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td { text-align: right; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-weight: 600; }
table.t tr.tot td { font-weight: 700; color: var(--dark); border-top: 1.5px solid var(--line); border-bottom: 0; }
@media (min-width: 560px) { body { background: #F6E9EC; } #app { background: var(--bg); box-shadow: 0 0 0 1px var(--line); } }
[hidden] { display: none !important; }
