:root {
  --bg: #f4f6fb; --card: #fff; --ink: #141a26; --muted: #647089; --line: #e2e7f0;
  --brand: #2b59ff; --ok: #0a8f5b; --pending: #c47d16; --danger: #c0392b; --chip: #eef2fb;
  --amberbg: #fff7e8; --okbg: #e9f8f0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1221; --card: #121a2b; --ink: #e8edf7; --muted: #90a0bd; --line: #223048;
    --brand: #5b7cff; --chip: #1b2740; --amberbg: #2a2110; --okbg: #0f2a1e;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
#app { max-width: 680px; margin: 0 auto; padding: 14px 16px calc(40px + env(safe-area-inset-bottom)); }
.muted { color: var(--muted); }
.sr { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* big, touch-first controls */
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; min-height: 52px; padding: 12px 18px; font-weight: 600; transition: transform .06s; }
button:active, .btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn-ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn-sm { min-height: 44px; padding: 9px 14px; border-radius: 11px; font-size: 15px; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.full { width: 100%; }

input, select { font: inherit; width: 100%; min-height: 54px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label { font-size: 13px; color: var(--muted); display: block; margin: 12px 2px 6px; }
.amount-in { font-size: 30px; font-weight: 800; text-align: left; letter-spacing: -.5px; }

header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 8px; }
h1 { font-size: 21px; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 12px 0; }

/* segmented toggle */
.seg { display: flex; gap: 6px; background: var(--chip); padding: 5px; border-radius: 14px; }
.seg button { flex: 1; min-height: 46px; border: none; background: transparent; color: var(--muted); border-radius: 10px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button.on.paid { color: var(--ok); }
.seg button.on.pending { color: var(--pending); }

/* month-to-date count banner */
.monthbar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; margin: 10px 0 2px; }
.monthbar .big { font-size: 26px; font-weight: 800; letter-spacing: -.5px; color: var(--brand); margin-right: 4px; }

/* category drill-down path */
.drill { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 2px; font-size: 14px; }
.drill .mini { min-height: 34px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--chip); border: 1px solid var(--line); }

/* currency switcher */
.curbar { display: flex; gap: 8px; margin: 10px 0 2px; flex-wrap: wrap; }
.cur { min-height: 40px; padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); background: var(--card); }
.cur.on { background: var(--ink); color: var(--bg); border-color: transparent; }
.cursel { width: auto; min-width: 88px; min-height: 54px; font-weight: 700; }
.bizsel { margin: 12px 0 2px; font-weight: 600; }

/* by-business breakdown */
.bizrow { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line); }
.bizrow:first-of-type { border-top: none; }
.bizrow .bn { font-weight: 700; font-size: 15px; }
.bizrow .pd { font-weight: 800; font-size: 16px; color: var(--ok); letter-spacing: -.3px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.tile .k { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tile .v { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.5px; }
.tile.pending { background: var(--amberbg); } .tile.pending .v { color: var(--pending); }
.tile.paid { background: var(--okbg); } .tile.paid .v { color: var(--ok); }

/* monthly bars */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; margin-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; }
.bar .seg2 { border-radius: 4px 4px 0 0; }
.bar .p { background: var(--ok); } .bar .q { background: var(--pending); opacity: .85; }
.bar .lb { font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px; }

/* filter chips */
.chips { display: flex; gap: 8px; margin: 2px 0 8px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 16px; min-height: 42px; font-size: 14px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--brand); color: #fff; border-color: transparent; }

/* order rows */
.order { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 0; }
.order .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.order .num { font-size: 13px; color: var(--muted); font-weight: 700; }
.order .amt { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.pending { background: var(--amberbg); color: var(--pending); }
.badge.paid { background: var(--okbg); color: var(--ok); }
.badge.cancelled { background: var(--chip); color: var(--muted); text-decoration: line-through; }
.order .meta { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 600; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.center { min-height: 74vh; display: flex; flex-direction: column; justify-content: center; gap: 12px; max-width: 360px; margin: 0 auto; text-align: center; }
.hide { display: none; }
