:root {
  --g50:#f0fdf4; --g100:#dcfce7; --g200:#bbf7d0; --g400:#4ade80;
  --g500:#22c55e; --g600:#16a34a; --g700:#15803d;
  --wa:#25D366; --wa-dark:#128C7E; --wa-darker:#075E54;
  --ink:#0f172a; --ink3:#334155; --muted:#64748b; --border:#e2e8f0;
  --bg:#f1f5f9; --card:#ffffff; --red:#ef4444; --amber:#f59e0b;
}
* { box-sizing:border-box; margin:0; padding:0; }
html { scroll-behavior:smooth; }
body { font-family:'Plus Jakarta Sans',sans-serif; background:var(--bg); color:var(--ink); }
button { font-family:inherit; cursor:pointer; }

/* taste-skill polish: a11y focus, press feedback, tabular money figures */
a,button,input,select { transition:transform .12s ease, background .2s ease, box-shadow .2s ease, border-color .2s ease; }
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible { outline:2.5px solid var(--g500); outline-offset:2px; }
button:active { transform:translateY(1px) scale(.985); }
.stat-value,.tx-amt,.cat-bar-amt,.rec-amt,.ds-val,.goal-amt,.budget-amt,.a-card .stat-value,.rt-row b { font-variant-numeric:tabular-nums; font-feature-settings:"tnum" 1; }
@media(prefers-reduced-motion:reduce){ *{ animation:none!important; transition:none!important; } }

.btn-primary { background:var(--g600); color:#fff; border:none; border-radius:10px; padding:12px 18px; font-weight:600; font-size:.95rem; transition:.2s; }
.btn-primary:hover { background:var(--g700); }
.btn-block { width:100%; }
.btn-ghost { background:transparent; border:1.5px solid var(--border); color:var(--ink3); border-radius:8px; padding:7px 14px; font-weight:600; font-size:.82rem; transition:.2s; }
.btn-ghost:hover { border-color:var(--g400); color:var(--g700); }
.btn-ghost.sm { padding:5px 10px; font-size:.75rem; }

/* ---------- AUTH ---------- */
.auth-screen { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
  background:linear-gradient(150deg,#fff,var(--g50) 70%,#e0fde4); }
.auth-card { background:#fff; width:100%; max-width:400px; border-radius:20px; padding:36px;
  box-shadow:0 20px 60px rgba(15,23,42,.12); }
.auth-logo { display:block; text-align:center; font-size:1.6rem; font-weight:800; color:var(--ink); text-decoration:none; }
.auth-logo em { color:var(--g600); font-style:normal; }
.auth-tagline { text-align:center; color:var(--muted); font-size:.9rem; margin:6px 0 24px; }
.auth-tabs { display:flex; gap:4px; background:var(--bg); border-radius:99px; padding:4px; margin-bottom:24px; }
.auth-tab { flex:1; border:none; background:transparent; padding:9px; border-radius:99px; font-weight:600; font-size:.875rem; color:var(--muted); }
.auth-tab.active { background:var(--g600); color:#fff; }
.field { margin-bottom:16px; }
.field label { display:block; font-size:.78rem; font-weight:600; color:var(--ink3); margin-bottom:6px; }
.field input { width:100%; padding:11px 14px; border:1.5px solid var(--border); border-radius:10px; font-size:.95rem; font-family:inherit; }
.field input:focus { outline:none; border-color:var(--g400); }
.auth-error { color:var(--red); font-size:.82rem; margin-bottom:12px; min-height:18px; }
.auth-hint { text-align:center; color:var(--muted); font-size:.75rem; margin-top:16px; }

/* ---------- TOPBAR ---------- */
.topbar { height:60px; background:#fff; border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; padding:0 24px; position:sticky; top:0; z-index:10; }
.logo { font-size:1.2rem; font-weight:800; color:var(--ink); text-decoration:none; }
.logo em { color:var(--g600); font-style:normal; }
.topbar-right { display:flex; align-items:center; gap:14px; }
.user-name { font-size:.875rem; font-weight:600; color:var(--ink3); }
.ai-badge { font-size:.68rem; font-weight:600; padding:3px 9px; border-radius:99px; background:var(--g100); color:var(--g700); }
.ai-badge.demo { background:#fef3c7; color:#92400e; }
.plan-badge { font-size:.7rem; font-weight:700; padding:4px 11px; border-radius:99px; border:none; background:var(--ink); color:#fff; cursor:pointer; }
.plan-badge:hover { background:var(--g700); }

/* modal */
.modal { position:fixed; inset:0; z-index:50; background:rgba(15,23,42,.5); display:flex; align-items:center; justify-content:center; padding:20px; }
.modal-card { background:#fff; border-radius:18px; padding:26px; width:100%; max-width:720px; max-height:90vh; overflow-y:auto; }
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; }
.modal-head h3 { font-size:1.2rem; font-weight:800; }
.modal-close { background:none; border:none; font-size:1.1rem; color:var(--muted); cursor:pointer; }
.plan-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:14px; }
.plan-opt { border:1.5px solid var(--border); border-radius:14px; padding:18px; display:flex; flex-direction:column; gap:8px; }
.plan-opt.current { border-color:var(--g500); background:var(--g50); }
.plan-opt h4 { font-size:1rem; font-weight:800; }
.plan-price { font-size:1.5rem; font-weight:800; }
.plan-price span { font-size:.8rem; font-weight:500; color:var(--muted); }
.plan-blurb { font-size:.78rem; color:var(--muted); flex:1; }
.plan-opt button { margin-top:6px; }
.plan-note { font-size:.74rem; color:var(--muted); margin-top:14px; text-align:center; }
@media(max-width:600px){ .plan-grid { grid-template-columns:1fr; } }

/* ---------- LAYOUT ---------- */
.layout { max-width:1320px; margin:0 auto; padding:24px; display:grid; grid-template-columns:380px 1fr; gap:24px; align-items:start; }

/* ---------- CHAT ---------- */
.chat-panel { background:#fff; border-radius:16px; border:1px solid var(--border); overflow:hidden; display:flex; flex-direction:column; height:calc(100vh - 108px); position:sticky; top:84px; }
.chat-head { background:var(--wa-darker); color:#fff; padding:12px 16px; display:flex; align-items:center; gap:12px; }
.chat-avatar { width:38px; height:38px; border-radius:50%; background:var(--wa); display:flex; align-items:center; justify-content:center; font-size:1.1rem; }
.chat-title { font-weight:700; font-size:.9rem; }
.chat-sub { font-size:.68rem; opacity:.7; }
.chat-log { flex:1; overflow-y:auto; padding:14px; background:#ece5dd; display:flex; flex-direction:column; gap:8px; }
.msg { max-width:85%; padding:8px 12px; border-radius:10px; font-size:.82rem; line-height:1.45; white-space:pre-wrap; word-break:break-word; }
.msg.user { background:#dcf8c6; align-self:flex-end; border-radius:10px 2px 10px 10px; }
.msg.bot { background:#fff; align-self:flex-start; border-radius:2px 10px 10px 10px; box-shadow:0 1px 1px rgba(0,0,0,.08); }
.chat-input-bar { display:flex; gap:8px; padding:10px; background:#f0f0f0; }
.chat-input-bar input { flex:1; border:none; border-radius:20px; padding:9px 14px; font-size:.85rem; font-family:inherit; }
.chat-input-bar input:focus { outline:none; }
.chat-send { width:36px; height:36px; border-radius:50%; border:none; background:var(--wa); color:#fff; font-size:.9rem; }
.chat-attach { width:36px; height:36px; border-radius:50%; border:none; background:#fff; font-size:1rem; }
.chat-attach:disabled { opacity:.4; cursor:not-allowed; }
.chat-suggest { display:flex; gap:6px; padding:0 10px 10px; background:#f0f0f0; flex-wrap:wrap; }
.chat-suggest button { font-size:.7rem; background:#fff; border:1px solid var(--border); border-radius:99px; padding:4px 10px; color:var(--ink3); }

/* ---------- DASH ---------- */
.dash { display:flex; flex-direction:column; gap:20px; }
/* wide screens: masonry the panels into 2 columns; keep insight + stats full-width */
@media (min-width:1120px) {
  .dash { display:block; column-count:2; column-gap:20px; }
  .dash > * { break-inside:avoid; margin-bottom:20px; }
  .dash > .insight-panel, .dash > .stat-row { column-span:all; }
}
.stat-row { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
.stat-card { background:#fff; border-radius:14px; border:1px solid var(--border); padding:18px; }
.stat-card.income { border-top:3px solid var(--g500); }
.stat-card.expense { border-top:3px solid var(--red); }
.stat-card.balance { border-top:3px solid var(--wa-dark); }
.stat-label { font-size:.72rem; color:var(--muted); font-weight:500; margin-bottom:6px; }
.stat-value { font-size:1.35rem; font-weight:800; }

.panel { background:#fff; border-radius:14px; border:1px solid var(--border); padding:18px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.panel-head h3 { font-size:.95rem; font-weight:700; }
.empty { color:var(--muted); font-size:.84rem; padding:16px 8px; text-align:center; line-height:1.5; }
/* skeleton shimmer (feels-finished loading) */
@keyframes shimmer { 0%{background-position:-300px 0} 100%{background-position:300px 0} }
.skel { border-radius:8px; background:linear-gradient(90deg,#eef2f7 25%,#e2e8f0 37%,#eef2f7 63%); background-size:600px 100%; animation:shimmer 1.3s infinite linear; }
.skel-line { height:14px; margin:10px 0; }
.skel-dark { height:40px; border-radius:10px; margin:8px 0; background:linear-gradient(90deg,rgba(255,255,255,.06) 25%,rgba(255,255,255,.16) 37%,rgba(255,255,255,.06) 63%); background-size:600px 100%; animation:shimmer 1.3s infinite linear; }
@media(prefers-reduced-motion:reduce){ .skel,.skel-dark{ animation:none } }

.cat-bars { display:flex; flex-direction:column; gap:12px; }
.cat-bar-row { display:flex; flex-direction:column; gap:5px; }
.cat-bar-top { display:flex; justify-content:space-between; font-size:.8rem; }
.cat-bar-name { color:var(--ink3); font-weight:500; }
.cat-bar-amt { font-weight:700; }
.cat-bar-track { background:var(--bg); border-radius:99px; height:8px; overflow:hidden; }
.cat-bar-fill { height:100%; border-radius:99px; background:linear-gradient(90deg,var(--g600),var(--g400)); }

.budget-list { display:flex; flex-direction:column; gap:14px; }
.budget-row { display:flex; flex-direction:column; gap:5px; }
.budget-top { display:flex; justify-content:space-between; font-size:.8rem; align-items:center; }
.budget-name { color:var(--ink3); font-weight:600; }
.budget-amt { color:var(--muted); font-size:.75rem; }
.budget-track { background:var(--bg); border-radius:99px; height:8px; overflow:hidden; }
.budget-fill { height:100%; border-radius:99px; }
.budget-fill.ok { background:var(--g500); }
.budget-fill.warn { background:var(--amber); }
.budget-fill.over { background:var(--red); }
.budget-del { background:none; border:none; color:var(--muted); font-size:.9rem; }

/* utang-piutang */
.debt-summary { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:12px; }
.debt-sum-item { border-radius:10px; padding:12px; }
.debt-sum-item.utang { background:#fee2e2; }
.debt-sum-item.piutang { background:var(--g100); }
.ds-lbl { font-size:.68rem; color:var(--muted); }
.ds-val { font-size:1.05rem; font-weight:800; }
.ds-val.income { color:var(--g600); } .ds-val.expense { color:var(--red); }
.debt-list { display:flex; flex-direction:column; margin-bottom:12px; }
.debt-row { display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--border); font-size:.82rem; }
.debt-row:last-child { border:none; }
.debt-lunas { font-size:.6rem; background:var(--g100); color:var(--g700); padding:1px 6px; border-radius:99px; font-weight:700; }

/* goals */
.goal-list { display:flex; flex-direction:column; gap:14px; margin-bottom:12px; }
.goal-row { display:flex; flex-direction:column; gap:5px; }
.goal-top { display:flex; justify-content:space-between; font-size:.8rem; }
.goal-name { font-weight:600; } .goal-amt { color:var(--muted); font-size:.72rem; }
.goal-actions { display:flex; gap:6px; margin-top:2px; }

/* report */
.report-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:12px; }
.report-item { background:var(--bg); border-radius:10px; padding:12px; text-align:center; }
.report-tax { background:var(--g50); border:1px solid var(--g200); border-radius:10px; padding:12px 14px; }
.rt-lbl { font-size:.78rem; font-weight:700; color:var(--g700); margin-bottom:8px; }
.rt-row { display:flex; justify-content:space-between; font-size:.82rem; padding:3px 0; }
.rt-row b.expense { color:var(--red); }

/* recurring */
.rec-list { display:flex; flex-direction:column; margin-bottom:12px; }
.rec-row { display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--border); font-size:.82rem; }
.rec-row:last-child { border:none; }
.rec-day { width:30px; height:30px; border-radius:8px; background:var(--g100); color:var(--g700); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:.72rem; flex-shrink:0; }
.rec-main { flex:1; min-width:0; }
.rec-desc { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rec-meta { font-size:.7rem; color:var(--muted); }
.rec-amt { font-weight:700; }
.rec-amt.income { color:var(--g600); } .rec-amt.expense { color:var(--red); }
.rec-del { background:none; border:none; color:var(--muted); font-size:.85rem; cursor:pointer; }
.rec-form { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.rec-form select, .rec-form input { padding:9px 11px; border:1.5px solid var(--border); border-radius:9px; font-family:inherit; font-size:.82rem; }
.rec-form input[name=day_of_month] { }
.rec-form button { grid-column:1 / -1; }

/* settings */
.set-section { padding:14px 0; border-bottom:1px solid var(--border); }
.set-section:last-child { border:none; }
.set-section h4 { font-size:.82rem; font-weight:700; color:var(--ink3); margin-bottom:10px; }
.set-form { display:flex; gap:8px; }
.set-form input, .set-form select, .set-form-col input { padding:9px 12px; border:1.5px solid var(--border); border-radius:9px; font-family:inherit; font-size:.85rem; }
.set-form input { flex:1; }
.set-form-col { display:flex; flex-direction:column; gap:8px; }
.acc-list { display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }
.acc-row { display:flex; align-items:center; gap:8px; font-size:.84rem; padding:7px 10px; background:var(--bg); border-radius:8px; }
.acc-row .acc-default { font-size:.6rem; background:var(--g100); color:var(--g700); padding:1px 7px; border-radius:99px; font-weight:700; }
.acc-row .acc-name { flex:1; }
.set-section.danger h4 { color:var(--red); }
.btn-danger { background:#fee2e2; color:var(--red); border:1.5px solid #fecaca; border-radius:9px; padding:9px 14px; font-weight:600; font-size:.82rem; cursor:pointer; }
.btn-danger:hover { background:var(--red); color:#fff; }

.wa-ok { background:var(--g50); border:1px solid var(--g200); color:var(--g700); border-radius:10px; padding:11px 13px; font-size:.88rem; margin-bottom:6px; }

/* insight */
.insight-panel { background:linear-gradient(135deg,#0f172a,#15803d); border:none; color:#fff; }
.insight-panel .panel-head h3 { color:#fff; }
.insight-box { display:flex; flex-direction:column; gap:10px; }
.insight-box .empty { color:rgba(255,255,255,.6); }
.insight-item { display:flex; gap:10px; align-items:flex-start; font-size:.86rem; line-height:1.5; background:rgba(255,255,255,.08); border-radius:10px; padding:11px 13px; }
.insight-emoji { font-size:1.1rem; }

/* referral */
.referral-box { display:flex; flex-direction:column; gap:14px; }
.ref-code-row { display:flex; gap:8px; align-items:center; }
.ref-code { flex:1; font-family:'DM Mono',monospace; font-weight:600; background:var(--g50); border:1.5px dashed var(--g200); color:var(--g700); padding:10px 12px; border-radius:10px; font-size:.9rem; letter-spacing:1px; }
.ref-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.ref-stat { background:var(--bg); border-radius:10px; padding:12px; text-align:center; }
.ref-stat-num { font-size:1.2rem; font-weight:800; }
.ref-stat-lbl { font-size:.66rem; color:var(--muted); }
.ref-hint { font-size:.74rem; color:var(--muted); }

.tx-list { display:flex; flex-direction:column; }
.tx-row { display:flex; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid var(--border); }
.tx-row:last-child { border:none; }
.tx-icon { width:34px; height:34px; border-radius:9px; background:var(--g100); display:flex; align-items:center; justify-content:center; font-size:1rem; flex-shrink:0; }
.tx-icon.income { background:var(--g100); }
.tx-icon.expense { background:#fee2e2; }
.tx-main { flex:1; min-width:0; }
.tx-desc { font-size:.84rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tx-meta { font-size:.7rem; color:var(--muted); }
.tx-amt { font-weight:700; font-size:.85rem; }
.tx-amt.income { color:var(--g600); }
.tx-amt.expense { color:var(--red); }
.tx-del { background:none; border:none; color:var(--muted); font-size:.85rem; opacity:0; transition:.2s; }
.tx-row:hover .tx-del { opacity:1; }

@media (max-width:880px) {
  .layout { grid-template-columns:1fr; }
  .chat-panel { height:60vh; position:static; }
  .stat-row { grid-template-columns:1fr; }
}
