:root {
  --bg: #f2f5f4; --card: #ffffff; --ink: #0e1d19; --muted: #66756f; --line: #e3e9e6;
  --accent: #0f766e; --accent-ink: #ffffff;
  --inc: #0a9d58; --inc-bg: #e3f6ec; --exp: #e0393e; --exp-bg: #fdeaea;
  --shadow: 0 1px 2px rgba(15, 40, 32, .06), 0 6px 18px rgba(15, 40, 32, .06);
  --r: 18px; --tab-h: 64px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1412; --card: #14211e; --ink: #e8f1ee; --muted: #8aa098; --line: #223530;
    --accent: #2dd4bf; --accent-ink: #052e2a;
    --inc: #34d399; --inc-bg: #10352b; --exp: #fb7185; --exp-bg: #3a1a20;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; }
b { font-weight: 650; }
small { color: var(--muted); }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; position: relative; }
#view { padding: calc(var(--sat) + 16px) 16px calc(var(--tab-h) + var(--sab) + 36px); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px;
  height: calc(var(--tab-h) + var(--sab)); padding-bottom: var(--sab);
  display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); z-index: 20; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; color: var(--muted); height: 100%; justify-content: center; }
.tab .ti { font-size: 21px; filter: grayscale(1); opacity: .75; }
.tab.on { color: var(--accent); font-weight: 650; }
.tab.on .ti { filter: none; opacity: 1; }
.mic-fab { width: 66px; height: 66px; border-radius: 50%; margin: -26px auto 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(15,118,110,.45); border: 4px solid var(--bg); }
.mic-fab:active { transform: scale(.94); }

/* ---------- typography/blocks ---------- */
h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 4px 8px; font-weight: 650; }
h3 { margin: 0; font-size: 18px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.top small { display: block; }
.btn { background: var(--accent); color: var(--accent-ink); padding: 11px 16px; border-radius: 12px; font-weight: 650; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--exp-bg); color: var(--exp); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { display: block; width: 100%; text-align: center; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; }
.hero { padding: 18px; background: linear-gradient(135deg, #0f766e, #115e59); color: #fff; }
.hero small { color: rgba(255,255,255,.75); }
.hero .big { font-size: 38px; font-weight: 750; letter-spacing: -.03em; margin: 2px 0 12px; font-variant-numeric: tabular-nums; }
.hero .pair { display: flex; gap: 10px; }
.hero .pair > div { flex: 1; background: rgba(255,255,255,.14); border-radius: 12px; padding: 8px 12px; }
.hero .pair b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.grid3 .card { padding: 10px 12px; }
.grid3 b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.grid3 small { font-size: 12px; }
.pos { color: var(--inc); } .neg { color: var(--exp); }

/* ---------- ride app cards ---------- */
.rides { display: grid; gap: 10px; }
.ride { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.ride .ico { width: 44px; height: 44px; }
.ride .nm { font-weight: 650; }
.ride .tot { text-align: right; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.ride .sub { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px dashed var(--line); padding-top: 10px; }
.ride .sub small { flex: 1; }
.ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; }

/* ---------- rows ---------- */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--bg); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dayhead { display: flex; justify-content: space-between; align-items: baseline; margin: 20px 6px 8px; }
.dayhead b { font-size: 15px; } .dayhead span { font-size: 13px; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- stats ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 9px 8px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg button.on.inc { color: var(--inc); } .seg button.on.exp { color: var(--exp); }
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 14px 0; }
.monthnav button { width: 42px; height: 42px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; }
.monthnav b { font-size: 17px; }
.bar-row { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-top { display: flex; align-items: center; gap: 10px; }
.bar-top .nm { flex: 1; font-weight: 600; }
.bar-top .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-top .p { width: 44px; text-align: right; color: var(--muted); font-size: 13px; }
.track { height: 8px; background: var(--line); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.fill { height: 100%; border-radius: 99px; }
.bar-sub { display: flex; gap: 14px; margin-top: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.bar-sub b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: auto; display: block; }
.chart .gi { fill: var(--inc); } .chart .ge { fill: var(--exp); opacity: .85; }
.chart text { fill: var(--muted); font-size: 9px; text-anchor: middle; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.table th, .table td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.set-row:last-child { border-bottom: 0; }
.set-row .txt { flex: 1; } .set-row small { display: block; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: .15s; }
.switch.on { background: var(--accent); } .switch.on::after { left: 23px; }
.tips { font-size: 14px; color: var(--muted); } .tips li { margin: 6px 0; } .tips code { background: var(--line); padding: 1px 6px; border-radius: 6px; color: var(--ink); }

/* ---------- sheet / toast ---------- */
#backdrop { position: fixed; inset: 0; background: rgba(5, 15, 12, .5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
#sheet { position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; z-index: 40;
  background: var(--card); border-radius: 24px 24px 0 0; padding: 18px 18px calc(var(--sab) + 20px);
  transform: translate(-50%, 105%); transition: transform .25s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
body.sheet-open #backdrop { opacity: 1; pointer-events: auto; }
body.sheet-open #sheet { transform: translate(-50%, 0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.x { width: 34px; height: 34px; border-radius: 50%; background: var(--line); }
label.l { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 2px 6px; }
.field { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); outline: none; }
.field:focus { border-color: var(--accent); }
.amount { font-size: 30px; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 99px; background: var(--bg); border: 1.5px solid var(--line); font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.quick { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.quick button { flex: 1; min-width: 56px; padding: 8px 0; border-radius: 10px; background: var(--bg); border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; }
.actions { display: flex; gap: 10px; margin-top: 20px; }
.actions .btn { flex: 1; padding: 14px; font-size: 17px; }
.notice { background: var(--exp-bg); color: var(--exp); padding: 10px 12px; border-radius: 12px; font-size: 14px; margin-bottom: 8px; }
.notice.ok { background: var(--inc-bg); color: var(--inc); }
.heard { font-style: italic; color: var(--muted); margin: 0 0 4px; font-size: 14px; }

.voice { text-align: center; padding-bottom: 6px; }
.mic-big { width: 96px; height: 96px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin: 10px auto 14px; }
.mic-big.live { animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(15,118,110,.55); } 80%, 100% { box-shadow: 0 0 0 30px rgba(15,118,110,0); } }
.transcript { min-height: 56px; font-size: 22px; font-weight: 650; margin: 8px 0 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 16px; }
.vform { display: flex; gap: 8px; margin-top: 8px; }
.vform .field { flex: 1; }

#toast { position: fixed; left: 50%; top: calc(var(--sat) + 12px); transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: #10231e; color: #fff; padding: 12px 16px; border-radius: 14px; z-index: 60; max-width: min(92vw, 520px); width: max-content;
  display: flex; align-items: center; gap: 14px; transition: .2s; box-shadow: 0 8px 30px rgba(0,0,0,.35); font-size: 15px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { color: #5eead4; font-weight: 700; white-space: nowrap; }

/* ---------- tài khoản ---------- */
[hidden] { display: none !important; }
body.locked .tabbar { display: none; }
body.locked #view { padding-bottom: 40px; }
.auth { max-width: 380px; margin: 0 auto; padding-top: 7vh; text-align: center; }
.auth-logo { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 16px; display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(135deg, #14998d, #0b4f4a); box-shadow: 0 10px 30px rgba(15,118,110,.35); }
.auth-sub { color: var(--muted); margin: 8px 0 8px; }
.auth-form { text-align: left; margin-top: 10px; }
.auth-foot { margin-top: 22px; }
.avatar { background: var(--line); font-weight: 750; color: var(--ink); }
.avatar.adm { background: var(--accent); color: var(--accent-ink); }
.tag { font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 99px; background: var(--inc-bg); color: var(--inc); vertical-align: 2px; }
.tag.off { background: var(--exp-bg); color: var(--exp); }
.seg button:disabled { opacity: .5; }

/* ---------- v3: hoàn tác, thông báo, ví, nguồn tiền, mục xổ chi tiết ---------- */
.top-actions { display: flex; gap: 6px; align-items: center; }
.ib { position: relative; width: 40px; height: 40px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 19px; display: grid; place-items: center; }
.ib:disabled { opacity: .35; box-shadow: none; }
.ib.plus { background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 22px; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--exp); color: #fff; font: 700 11px/18px sans-serif; font-style: normal; text-align: center; }
.title-back { display: flex; align-items: center; gap: 10px; }
.back { display: inline-block; margin: -4px 0 8px; padding: 6px 12px 6px 6px; color: var(--accent); font-weight: 650; font-size: 16px; }
.mv { color: var(--muted); }
.subnote { color: var(--muted); font-size: 13px; margin: 8px 4px; }
.subnote b { color: var(--ink); }
.rv { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.seg.hours { grid-auto-columns: auto; width: auto; flex: none; }
.seg.hours button { padding: 7px 9px; font-size: 14px; }

.bar-row { padding: 0; }
.bar-head { display: block; width: 100%; text-align: left; padding: 10px 14px; }
.bar-head:active { background: var(--bg); }
.chev { color: var(--muted); font-size: 13px; margin-left: 4px; width: 14px; text-align: center; }
.items { padding: 2px 14px 10px; display: grid; gap: 2px; }
.item { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: baseline; text-align: left; padding: 7px 8px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.item .it-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.item .it-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ride { display: block; }
.ride-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; }
.ride .sub { margin-top: 10px; }
.ride .items { padding: 10px 0 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card.bal b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.card.bal.wide { text-align: center; }
.card.bal .flow { font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.wal { display: block; }
.wal.low { box-shadow: 0 0 0 2px var(--exp), var(--shadow); }
.wal-top { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.wal-top .nm { display: flex; flex-direction: column; }
.wal-top .tot { font-weight: 750; font-size: 20px; font-variant-numeric: tabular-nums; }
.wal-sub { display: block; margin-top: 8px; }
.wal-sub b { color: var(--ink); }
.wal-btns { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
.wal-total { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.wal-total b { font-size: 18px; font-variant-numeric: tabular-nums; }
.wb-edit { padding: 4px 14px 14px; }
.wb-edit .l { margin-top: 6px; }
.hint-box { margin: 8px 2px 0; padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 14px; color: var(--muted); }
.hint-box b { color: var(--ink); }
.hint-box b.neg { color: var(--exp); }

.ncard { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; margin-top: 12px; border-left: 5px solid var(--muted); }
.ncard.good { border-left-color: var(--inc); } .ncard.warn { border-left-color: var(--exp); } .ncard.info { border-left-color: var(--accent); }
.ncard.new { outline: 2px solid var(--accent); }
.n-head { display: flex; align-items: center; gap: 8px; } .n-head b { flex: 1; }
.n-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--bg); font-size: 14px; }
.n-msg { margin: 8px 0 6px; font-weight: 600; }
.n-lines { margin: 0 0 8px; padding-left: 18px; font-size: 14px; color: var(--muted); } .n-lines li { margin: 3px 0; white-space: pre-wrap; }
.chips + .ncard { margin-top: 14px; }
/* quảng cáo (gói miễn phí) & thông báo của chủ ứng dụng */
.ad { display: block; width: 100%; margin: 16px 0 4px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--card); text-align: left; color: var(--muted); }
.ad small { display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; opacity: .7; margin-bottom: 2px; }
.ad span { color: var(--ink); font-weight: 600; font-size: 14px; }
.banner { display: block; width: 100%; margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 14px; text-align: left; }
.banner.info { background: var(--inc-bg); color: var(--inc); font-weight: 600; }
button.switch { border: 0; padding: 0; }

/* đăng nhập Google / Apple */
.or { display: flex; align-items: center; gap: 10px; margin: 22px 0 14px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.g-box { display: flex; justify-content: center; min-height: 44px; }
.btn-apple { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; padding: 12px; border-radius: 99px; background: #000; color: #fff; font-weight: 600; font-size: 15px; }
