:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eaefec;
  --text: #17201b;
  --muted: #5f6b65;
  --line: #dde3df;
  --accent: #1f6f54;
  --accent-soft: #d8ebe3;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --bar: #2a8a68;
  --pos: #12804f;
  --neg: #c8312a;
  --warn: #9a6200;
  --notice-bg: #fbefd2;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --radius: 16px;
  --tabs-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412;
    --surface: #1a201d;
    --surface-2: #232a26;
    --text: #e8eeea;
    --muted: #9aa8a0;
    --line: #2c3530;
    --accent: #4cc497;
    --accent-soft: #1e3a2f;
    --on-accent: #08130e;
    --danger: #f2827a;
    --bar: #4cc497;
    --pos: #4cc497;
    --neg: #ff8a80;
    --warn: #f2c66d;
    --notice-bg: #3a2f14;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; border: 0; background: none; }

#app {
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }
.view.scroll { overflow-y: auto; padding: 0 16px 24px; gap: 12px; -webkit-overflow-scrolling: touch; }

/* ---------- Nhập ---------- */
#view-add { padding: 10px 16px 12px; gap: 10px; }
.add-head { display: flex; justify-content: space-between; align-items: center; }
.pill {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; background: var(--surface-2);
  font-size: 15px; font-weight: 600; overflow: hidden;
}
.pill::after { content: "▾"; font-size: 11px; color: var(--muted); }
.pill.past { background: #f6e3b4; color: #5a3d00; }
@media (prefers-color-scheme: dark) { .pill.past { background: #4a3a12; color: #f6e3b4; } }
.pill input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.today-total { color: var(--muted); font-size: 15px; }
.today-total b { color: var(--text); font-variant-numeric: tabular-nums; }

.amount-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; min-height: 0; }
.amount {
  font-size: clamp(40px, 13vw, 60px); font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap;
}
.amount .cur { font-size: .5em; margin-left: 6px; color: var(--muted); font-weight: 600; }
.amount.empty { color: var(--muted); }
.amount.shake { animation: shake .35s; }
@keyframes shake { 25%{transform:translateX(-8px)} 50%{transform:translateX(8px)} 75%{transform:translateX(-4px)} }
.note {
  width: 100%; max-width: 360px; text-align: center; padding: 8px 12px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 15px;
}
.note:focus { outline: none; border-color: var(--line); background: var(--surface); }
.note::placeholder { color: var(--muted); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }

.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 2px 8px; border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; transition: transform .08s, background .15s;
}
.cat .ci { font-size: 24px; line-height: 1; }
.cat:active { transform: scale(.94); }
.cats.ready .cat { border-color: var(--accent); background: var(--accent-soft); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  height: clamp(50px, 7.5dvh, 62px); border-radius: 14px; background: var(--surface-2);
  font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; transition: transform .06s, background .1s;
  user-select: none;
}
.key:active { transform: scale(.95); background: var(--line); }
.key.fn { font-size: 20px; color: var(--muted); }

/* ---------- Tháng ---------- */
.top-nav { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 4px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.top-nav h1 { font-size: 20px; margin: 0; flex: 1; text-align: center; }
#view-more .top-nav h1 { text-align: left; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; font-size: 28px; line-height: 1; color: var(--accent); }
.icon-btn:disabled { color: var(--line); cursor: default; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.summary .label { color: var(--muted); font-size: 14px; }
.summary .big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.summary .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.bar-name { font-size: 14.5px; }
.bar-val { font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-val small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.bar-track { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--bar); min-width: 3px; transition: width .3s; }

.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 600; padding: 12px 0 4px; border-bottom: 1px solid var(--line); }
.day-head:first-child { padding-top: 0; }
.entry { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .ei { font-size: 20px; width: 28px; text-align: center; }
.entry .et { flex: 1; min-width: 0; }
.entry .en { font-size: 15px; }
.entry .enote { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .ea { font-variant-numeric: tabular-nums; font-weight: 600; }
.entry .del { width: 36px; height: 36px; border-radius: 10px; color: var(--muted); font-size: 18px; }
.entry .del:hover { color: var(--danger); background: var(--surface-2); }
.empty-state { color: var(--muted); text-align: center; padding: 16px 0; font-size: 14.5px; }

/* ---------- Cài đặt ---------- */
.muted { color: var(--muted); font-size: 14.5px; margin: 0 0 12px; }
.small { font-size: 13px; }
.center { text-align: center; }
.btn-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn-row .btn { flex: 1; margin-top: 0; }
.btn {
  display: flex; justify-content: center; align-items: center; width: 100%;
  min-height: 46px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2);
  font-weight: 600; font-size: 15px; text-align: center; cursor: pointer;
}
.btn + .btn, .btn + .muted { margin-top: 8px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: #fff; }

/* ---------- Thanh tab ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; max-width: 173px; height: var(--tabs-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.tab .ti { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 10px);
  width: min(92vw, 480px); z-index: 20;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #1d2621; color: #eef3f0; padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 15px;
}
@media (prefers-color-scheme: dark) { .toast { background: #e8eeea; color: #101412; } }
.toast button { color: #7fe0b8; font-weight: 700; padding: 4px 6px; }
@media (prefers-color-scheme: dark) { .toast button { color: #1f6f54; } }

/* ---------- Màu lời/lỗ ---------- */
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
b small, .a-right small { font-weight: 500; opacity: .85; }
.small { font-size: 13px; }

/* ---------- Splash & đăng nhập ---------- */
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); z-index: 50; text-align: center; color: var(--muted); }
.splash .btn { margin-top: 12px; width: auto; display: inline-flex; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: #1f6f54; color: #fff; font-size: 38px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 24px) 16px 24px; }
.auth-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.auth-box .logo { align-self: center; }
.auth-box h1 { text-align: center; margin: 0 0 6px; font-size: 24px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.demo-note { font-size: 13px; background: var(--notice-bg); color: var(--warn); padding: 10px 12px; border-radius: 10px; margin: 0; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); font-weight: 600; min-width: 0; }
.field input, .field select {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 16px; font-weight: 500;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-error { color: var(--neg); font-size: 14px; margin: 0; min-height: 0; }
.form-error:empty { display: none; }
.calc { font-size: 14.5px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.calc:empty { display: none; }
.cur-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.notice { background: var(--notice-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 8px 0 0; }

/* Segmented control */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 38px; border-radius: 9px; font-weight: 600; font-size: 14.5px; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.mini { display: inline-flex; }
.seg.mini button { min-height: 30px; padding: 0 14px; font-size: 13.5px; }
.side-seg button.active[data-v="buy"] { background: var(--pos); color: #fff; }
.side-seg button.active[data-v="sell"] { background: var(--neg); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button, .chip-input { min-height: 36px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--text); border: 1px solid transparent; }
.chips button.active { background: var(--accent); color: var(--on-accent); }
.chip-input { width: 76px; text-align: center; border-color: var(--line); background: var(--surface); }

/* ---------- Thẻ & danh sách ---------- */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14.5px; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; text-align: right; }
.summary .kv:first-of-type { margin-top: 8px; }
.list-card { padding-top: 6px; padding-bottom: 6px; }
.list-card h2 { margin-top: 10px; }
details.list-card > summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--muted); font-size: 15px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; }
.badge.coin { background: #fdf0d5; color: #8a5a00; }
.badge.stock { background: #dde9fb; color: #1d4f91; }
@media (prefers-color-scheme: dark) { .badge.coin { background: #3d3115; color: #f2c66d; } .badge.stock { background: #1b2c45; color: #9cc2f5; } }
.asset { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.asset:last-child { border-bottom: 0; }
.a-main { min-width: 0; }
.a-sub { font-size: 13px; color: var(--muted); font-weight: 400; }
.a-right { text-align: right; font-variant-numeric: tabular-nums; font-size: 14.5px; flex-shrink: 0; }
.side-tag { font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 6px; flex-shrink: 0; }
.side-tag.buy { background: color-mix(in srgb, var(--pos) 15%, transparent); color: var(--pos); }
.side-tag.sell { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.price-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.link-btn { color: var(--accent); font-weight: 700; font-size: 13px; padding: 6px 4px; }
.small-btn { width: auto; min-height: 36px; padding: 6px 14px; font-size: 14px; }
.month-inline { display: flex; align-items: center; justify-content: space-between; margin: -6px 0 6px; }
.month-inline h2 { margin: 0; color: var(--text); font-size: 17px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-grid .wide { grid-column: 1 / -1; }
.stat-grid .label { font-size: 13px; color: var(--muted); }
.stat-grid b { font-variant-numeric: tabular-nums; font-size: 17px; }
.big2 { font-size: 26px !important; }
.sub-h { font-size: 15px; color: var(--muted); margin: 18px 0 4px; }
.quote-form { display: flex; gap: 8px; align-items: flex-end; margin: 14px 0 8px; }
.quote-form .field { flex: 1; }
.quote-form .btn { width: auto; margin: 0; }
.btn.sell-btn { background: var(--neg); color: #fff; }
.btn-row { flex-wrap: wrap; }
.card .btn-row { margin-top: 10px; margin-bottom: 0; }
.highlight { border-color: var(--accent); }

/* Biểu đồ */
.chart { width: 100%; height: auto; display: block; }
.chart .zero-line { stroke: var(--line); stroke-width: 1; }
.chart .pos-bar { fill: var(--pos); }
.chart .neg-bar { fill: var(--neg); }
.chart .bar-label { font-size: 9px; text-anchor: middle; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .axis-label { font-size: 10px; text-anchor: middle; fill: var(--muted); }
.chart .axis-label.sel { fill: var(--text); font-weight: 700; }

/* Tiết kiệm */
.saving .s-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.saving .s-amount { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 6px 0 8px; }
.saving.matured { border-color: var(--warn); }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); border-radius: 3px; }
.s-dates { font-size: 13px; color: var(--muted); margin: 6px 0 6px; }

/* Tài khoản */
.profile { display: flex; gap: 14px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.p-info b { font-size: 17px; }
.mode-badge { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.mode-badge.local { background: var(--notice-bg); color: var(--warn); }

/* ---------- Bảng trượt ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--bg);
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(30%); opacity: .6; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -8px; background: var(--bg); padding: 4px 0; z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet-head .icon-btn { font-size: 20px; color: var(--muted); }
body.sheet-open { overflow: hidden; }
@media (min-width: 600px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 20px; } }

/* Thanh tab 5 mục */
.tab { max-width: 110px; font-size: 11px; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn-row > .btn { margin: 0 !important; }
/* Toast: phía dưới (trên thanh tab); riêng màn Nhập để ở trên cùng cho khỏi che bàn phím số */
.toast { top: auto; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); }
body[data-view="add"] .toast, body:not([data-view]) .toast { top: calc(env(safe-area-inset-top) + 10px); bottom: auto; }

/* ===== v3: thu nhập, ngân sách, tài sản, cài đặt ===== */
.stack { display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.flow3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.flow3 .label { font-size: 13px; color: var(--muted); }
.flow3 b { font-size: 17px; font-variant-numeric: tabular-nums; display: block; word-break: break-word; }
.summary .sub + .sub { margin-top: 2px; }
.entry-btn { width: 100%; text-align: left; color: inherit; cursor: pointer; }
.entry-btn .en, .entry-btn .enote, .block { display: block; }
.entry-btn:hover .en { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.list-hint { margin: 6px 0 0; }
.bar-track { position: relative; overflow: visible; }
.bar-track .bar-fill { border-radius: 5px; }
.bar-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); margin-top: -2px; }
.bar-row.budget.near .bar-fill { background: var(--warn) !important; }
.bar-row.budget.over .bar-fill { background: var(--neg) !important; }
.bar-row.budget.near .bar-note { color: var(--warn); }
.bar-row.budget.over .bar-note { color: var(--neg); font-weight: 600; }
.pace { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--text); opacity: .75; }
.bar-row.income .bar-fill { background: var(--pos) !important; }
.kind-seg button { min-width: 56px; }
.kind-seg button.active[data-kind="in"] { background: var(--pos); color: #04210f; }
#view-add[data-kind="in"] .amount:not(.empty) { color: var(--pos); }
.today-total { margin: 0; font-size: 13.5px; }
.cats.many .cat { padding: 7px 2px 6px; font-size: 12px; }
.cats.many .cat .ci { font-size: 20px; }
.inline-field { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.inline-field span { flex: 1; color: var(--text); font-weight: 500; font-size: 15px; }
.inline-field input { width: 150px !important; flex: none; text-align: right; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; cursor: pointer; }
.switch-row input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.cat-rows { display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: grid; grid-template-columns: 52px 1fr 36px 36px 36px; gap: 6px; align-items: center; }
.cat-row input { min-height: 42px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px; width: 100%; }
.cat-row .cat-icon { text-align: center; padding: 6px 2px; font-size: 20px; }
.cat-row.is-hidden { opacity: .55; }
.icon-btn.sm { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }
.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice-list .btn { justify-content: flex-start; padding-left: 16px; font-size: 16px; }
.side-seg.four button { font-size: 12.5px; line-height: 1.15; padding: 4px; white-space: normal; }
.side-seg button.active[data-v="bonus"], .side-seg button.active[data-v="cashdiv"] { background: var(--accent); color: var(--on-accent); }
.side-tag.bonus, .side-tag.cashdiv { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.chart .nw-bar { fill: var(--bar); opacity: .7; }
.chart .nw-bar.sel { opacity: 1; }
.nw-bars { margin: 12px 0 4px; }
.sub-h + .chart { margin-top: 6px; }

/* ===== v3.1: tiền tệ, ảnh đại diện ===== */
.add-head { gap: 8px; }
.add-head .kind-seg { margin-left: auto; }
.cur-btn { font-weight: 700; padding: 7px 12px; }
.cur-btn::after { content: "⇄"; font-size: 12px; }
.cur-note { font-size: 12.5px; line-height: 1.5; margin-top: 6px; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.colored { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.25); }
.avatar-btn { position: relative; border-radius: 50%; flex: none; padding: 0; }
.avatar-edit { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 12px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.avatar-preview { display: flex; justify-content: center; padding: 6px 0 2px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 12px; font-size: 22px; background: var(--surface-2); border: 2px solid transparent; }
.emoji-grid button.active { border-color: var(--accent); background: var(--accent-soft); }
.color-row { display: flex; flex-wrap: wrap; gap: 10px; }
.color-row button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; box-shadow: 0 0 0 1px rgba(255,255,255,.35) inset; }
.color-row button.active { border-color: var(--text); }
.tab-avatar { display: flex; height: 24px; align-items: center; }
.tab-avatar .avatar { border: 1.5px solid currentColor; }
.mode-badge.admin { margin-left: 4px; background: rgba(255, 200, 90, 0.2); color: var(--warn); }
@media (max-width: 360px) { .emoji-grid { grid-template-columns: repeat(6, 1fr); } .cur-btn { padding: 7px 9px; } }
.amount { display: flex; align-items: baseline; justify-content: center; }
.amount.prefix .cur { order: -1; margin: 0 6px 0 0; }
.emoji-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.emoji-grid button { min-width: 0; padding: 0; font-size: clamp(16px, 5vw, 22px); }
.flow3 b { font-size: clamp(13.5px, 4.1vw, 17px); white-space: nowrap; }
@media (max-width: 360px) { .emoji-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* Logo đồng xu vàng ở màn chờ & đăng nhập */
.logo-img { width: 72px; height: 72px; border-radius: 18px; display: block; align-self: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

/* Chọn tiền tệ dạng sổ xuống */
.cur-btn { position: relative; overflow: hidden; }
.cur-btn::after { content: "▾"; font-size: 11px; color: var(--muted); }
.cur-btn select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.cur-select { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 15px; }
.cur-select option, .cur-select optgroup { color: #17201b; background: #fff; }

/* ===== Chạm trên điện thoại =====
   - touch-action: manipulation → tắt "chạm 2 lần để phóng to" (nguyên nhân màn hình bị phóng to/giật khi bấm nhanh),
     đồng thời bỏ độ trễ ~300ms của cú chạm. Vẫn giữ được thao tác chụm 2 ngón để phóng to khi cần.
   - Không cho bôi chọn chữ trên nút khi chạm liên tiếp (gây nhấp nháy vùng chọn màu xanh).
   - Ô nhập ≥ 16px: iPhone tự phóng to trang khi chạm vào ô nhập có chữ nhỏ hơn 16px. */
html, body { touch-action: manipulation; }
button, .key, .cat, .tab, .pill, .seg, .chips, .btn, .entry-btn, .asset, label.btn, .cur-btn, .icon-btn {
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
#keypad, #cats, .amount-wrap .amount, .tabs { -webkit-user-select: none; user-select: none; }
input, select, textarea, .note, .chip-input, .cur-select { font-size: 16px !important; }
/* Phím bấm: chỉ hiệu ứng nhấn rất ngắn, không chuyển động nền → không nhấp nháy khi bấm dồn */
.key, .cat { transition: transform .05s ease-out !important; will-change: transform; }
