:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f1;
  --border: #dfe5e3;
  --text: #15201d;
  --text-2: #4a5754;
  --muted: #74817d;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d7efec;
  --in: #15803d;
  --in-soft: #dcf3e3;
  --out: #c2410c;
  --out-soft: #fbe5d9;
  --pribadi: #2563eb;
  --pribadi-soft: #dfe8fd;
  --usaha: #a16207;
  --usaha-soft: #fbefd0;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 4px 16px rgba(16, 24, 22, .05);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #161f1d; --surface-2: #1d2826; --border: #2a3633;
    --text: #e8efed; --text-2: #b7c3c0; --muted: #8a9893;
    --brand: #2bb3a5; --brand-ink: #062320; --brand-soft: #143a36;
    --in: #4ade80; --in-soft: #143323; --out: #fb923c; --out-soft: #3a2316;
    --pribadi: #7aa2ff; --pribadi-soft: #1b2847; --usaha: #f2c14e; --usaha-soft: #3a2f12;
    --danger: #f87171; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #161f1d; --surface-2: #1d2826; --border: #2a3633;
  --text: #e8efed; --text-2: #b7c3c0; --muted: #8a9893;
  --brand: #2bb3a5; --brand-ink: #062320; --brand-soft: #143a36;
  --in: #4ade80; --in-soft: #143323; --out: #fb923c; --out-soft: #3a2316;
  --pribadi: #7aa2ff; --pribadi-soft: #1b2847; --usaha: #f2c14e; --usaha-soft: #3a2f12;
  --danger: #f87171; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
[hidden] { display: none !important; }

/* Layout */
.app { min-height: 100vh; display: flex; }
main { flex: 1; min-width: 0; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.sidebar { display: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.topbar h1 { font-size: 1.35rem; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.page { display: none; animation: fade .2s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (min-width: 900px) {
  .sidebar { display: flex; flex-direction: column; gap: 10px; width: 240px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; }
  .brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
  .brand small { display: block; color: var(--muted); font-size: .78rem; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .side-nav button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; border-radius: 10px; cursor: pointer; color: var(--text-2); text-align: left; }
  .side-nav button:hover { background: var(--surface-2); }
  .side-nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .bottomnav, .add-top { display: none !important; }
  main { padding: 0 32px 40px; }
}

/* Bottom nav (mobile) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); padding: 4px 0; cursor: pointer; }
.bottomnav button.active { color: var(--brand); font-weight: 600; }
.bottomnav .nav-mic { width: 62px; height: 62px; margin: -26px auto 0; border-radius: 50%; background: var(--brand); color: var(--brand-ink); justify-content: center; box-shadow: 0 6px 18px rgba(15, 118, 110, .4); border: 4px solid var(--bg); }
.bottomnav .nav-mic svg { width: 28px; height: 28px; }
.add-top { color: var(--brand); }

/* Cards & buttons */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn svg { width: 20px; height: 20px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
.link { border: 0; background: none; color: var(--brand); cursor: pointer; font-weight: 600; padding: 4px; }
.install-btn { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; }
.tag.pribadi { background: var(--pribadi-soft); color: var(--pribadi); }
.tag.usaha { background: var(--usaha-soft); color: var(--usaha); }

/* Home */
.greet { margin: 0 0 12px; color: var(--text-2); }
.wallets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 2px; }
.wallets .card { margin-bottom: 12px; }
.total-card { grid-column: 1 / -1; background: linear-gradient(135deg, #0f766e, #115e59); color: #fff; border: 0; }
.total-card .label { opacity: .85; font-size: .85rem; }
.total-card .muted { color: rgba(255, 255, 255, .78); }
.big { display: block; font-size: 1.9rem; margin: 2px 0; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mid { display: block; font-size: 1.15rem; margin: 8px 0 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.wallet-card { cursor: pointer; border-top: 4px solid var(--pribadi); }
.wallet-card.usaha { border-top-color: var(--usaha); }
.io { display: flex; flex-direction: column; font-size: .8rem; gap: 1px; }
.io .in, .amt.in { color: var(--in); }
.io .out, .amt.out { color: var(--out); }
.profit { display: block; margin-top: 6px; font-size: .8rem; font-weight: 600; color: var(--text-2); }
@media (min-width: 640px) {
  .wallets { grid-template-columns: 1.3fr 1fr 1fr; }
  .total-card { grid-column: auto; }
}

.voice-card { display: grid; grid-template-columns: auto 1fr; gap: 14px 18px; align-items: center; }
.voice-help b { display: block; margin-bottom: 2px; }
.voice-help p { margin: 0 0 8px; font-size: .88rem; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button { border: 1px dashed var(--border); background: var(--surface-2); border-radius: 999px; padding: 5px 11px; font-size: .8rem; cursor: pointer; color: var(--text-2); }
.examples button:hover { border-color: var(--brand); color: var(--brand); }
.quick { grid-column: 1 / -1; display: flex; gap: 8px; }
.quick input { flex: 1; min-width: 0; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.mic-big { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 22px rgba(15, 118, 110, .35); transition: transform .15s; position: relative; }
.mic-big:hover { transform: scale(1.04); }
.mic-big svg { width: 34px; height: 34px; }
.mic-big.listening { background: var(--out); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194, 65, 12, .5); } 100% { box-shadow: 0 0 0 22px rgba(194, 65, 12, 0); } }

.section-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 10px; }
.list-card { padding: 4px 0; }

/* Transaction list */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx { display: flex; align-items: center; gap: 12px; padding: 11px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.tx:last-child { border-bottom: 0; }
.tx:hover { background: var(--surface-2); }
.tx .ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 1.1rem; }
.tx .ico.in { background: var(--in-soft); color: var(--in); }
.tx .ico.out { background: var(--out-soft); color: var(--out); }
.tx .ico.tf { background: var(--brand-soft); color: var(--brand); }
.tx .info { flex: 1; min-width: 0; }
.tx .desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .meta { font-size: .78rem; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* History */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type=search] { flex: 1 1 220px; }
.filters select { width: auto; flex: 0 1 auto; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-size: .86rem; color: var(--text-2); font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.type button.on[data-v=out] { color: var(--out); }
.seg.type button.on[data-v=in] { color: var(--in); }
.seg.type button.on[data-v=tf] { color: var(--brand); }
.seg.wallet button.on[data-v=pribadi] { color: var(--pribadi); }
.seg.wallet button.on[data-v=usaha] { color: var(--usaha); }
.hist-sum { display: flex; gap: 16px; flex-wrap: wrap; font-size: .88rem; margin: 0 4px 12px; }
.hist-sum b { font-variant-numeric: tabular-nums; }
.day-head { display: flex; justify-content: space-between; padding: 10px 16px 6px; font-size: .8rem; font-weight: 700; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.group { padding: 0; overflow: hidden; }

/* Report */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat span { font-size: .8rem; color: var(--muted); display: block; }
.stat b { font-size: 1.25rem; font-variant-numeric: tabular-nums; display: block; margin-top: 2px; overflow-wrap: anywhere; }
.stat small { font-size: .76rem; color: var(--muted); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--text-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.in { background: var(--in); } .sw.out { background: var(--out); }
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; display: block; stroke: none; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .bar-in { fill: var(--in); }
.chart .bar-out { fill: var(--out); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: var(--surface-2); opacity: .6; }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: .78rem; padding: 7px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 3; }
.two-col { display: grid; gap: 14px; }
@media (min-width: 760px) { .two-col { grid-template-columns: 1fr 1fr; } .two-col .card { margin-bottom: 0; } }
.catrow { margin-bottom: 10px; }
.catrow .top { display: flex; justify-content: space-between; font-size: .86rem; gap: 8px; }
.catrow .top b { font-variant-numeric: tabular-nums; }
.catrow .barbg { height: 8px; background: var(--surface-2); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.catrow .bar { height: 100%; border-radius: 4px; background: var(--out); }
.catrow .bar.in { background: var(--in); }

/* Settings */
.form-grid { display: grid; gap: 12px; }
.form-grid h3 { margin: 0; }
.form-grid label { display: grid; gap: 6px; font-size: .88rem; font-weight: 600; }
.form-grid p { margin: 0; }
.switch { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px !important; font-weight: 500 !important; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-btn { min-height: 44px; display: flex; justify-content: center; }
.btn.google-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 22px; border-radius: 999px;
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 600; }
.btn.google-btn:hover { background: #f8faff; }
.sheet-info { margin: 0; color: var(--text-2); }
.sheet-info.bad { color: var(--danger); }
a.btn { text-decoration: none; color: inherit; }
.help { margin: 0; padding-left: 18px; color: var(--text-2); font-size: .88rem; display: grid; gap: 6px; }

/* Dialogs */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--text); width: min(560px, 100%); max-height: 92vh; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.sheet::backdrop { background: rgba(8, 15, 13, .55); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; max-width: 100%; border-radius: 20px 20px 0 0; max-height: 94vh; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.sheet-foot .btn.primary { flex: 1; }
.spacer { flex: 1; }
#voiceDialog .sheet-foot .btn { flex: 1; }
.listen { display: flex; flex-direction: column; align-items: center; padding: 8px 18px 4px; text-align: center; }
.listen .mic-big { width: 88px; height: 88px; }
#listenStatus { margin: 12px 0 4px; }
.transcript { min-height: 1.5em; font-size: 1.1rem; font-weight: 600; margin: 0 0 8px; }
#voiceDialog .quick { padding: 0 18px 12px; }
.answer { margin: 0 18px 12px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--text); font-weight: 600; }
#drafts { padding: 0 18px 8px; display: grid; gap: 12px; }
.draft { border: 1px solid var(--border); border-radius: 14px; padding: 12px; position: relative; }
.draft .rm { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; }
.draft-note { font-size: .8rem; color: var(--muted); margin: 0 0 8px; padding-right: 24px; }
.editor { display: grid; gap: 10px; }
#editBody { padding: 4px 18px 14px; }
.editor .segs { display: flex; flex-wrap: wrap; gap: 8px; }
.editor label { display: grid; gap: 4px; font-size: .8rem; color: var(--text-2); font-weight: 600; }
.editor .amount-input { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.editor .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor .warn { color: var(--danger); font-size: .8rem; font-weight: 600; }
.tf-hint { font-size: .85rem; color: var(--text-2); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 11px 14px 11px 16px; border-radius: 12px; display: flex; gap: 14px; align-items: center; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100% - 32px); font-size: .9rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--brand-soft); font-weight: 700; cursor: pointer; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

@media (max-width: 420px) {
  .voice-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .examples { justify-content: center; }
  .quick { width: 100%; }
  .big { font-size: 1.6rem; }
}

/* Sinkronisasi */
.sync-btn { position: relative; }
.sync-btn::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 2px var(--surface); }
.sync-btn[data-s="ok"]::after { background: var(--in); }
.sync-btn[data-s="sync"]::after { background: var(--usaha); }
.sync-btn[data-s="offline"]::after, .sync-btn[data-s="err"]::after { background: var(--out); }
.auth-msg { color: var(--text-2); }
.auth-msg.bad { color: var(--danger); }
