:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #475569;
  --line: #e2e8f0;
  --line-2: #eef2f6;
  --field: #cbd5e1;
  --accent: #0b7a5b;
  --accent-ink: #075e46;
  --accent-soft: #e6f4ee;
  --warn: #b45309;
  --warn-ink: #7c2d12;
  --warn-soft: #fef3c7;
  --warn-line: #f5c77e;
  --danger: #b91c1c;
  --radius: 16px;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* shell */
.app { display: flex; min-height: 100dvh; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding: 20px 20px 104px; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.main.wide { max-width: 1180px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(72px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-around; z-index: 20; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; min-height: 48px; text-decoration: none; font-size: 11px; color: var(--muted); }
.tab[aria-current='page'] { color: var(--accent); font-weight: 600; }
.tab-fab { width: 56px; height: 56px; border-radius: 28px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; margin-top: -18px; box-shadow: 0 6px 16px rgba(11, 122, 91, 0.35); }
.tab-fab:hover { color: #fff; }
@media (min-width: 960px) {
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 4px; width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); padding: 24px 16px; position: sticky; top: 0; height: 100dvh; }
  .main { padding: 28px 32px 48px; }
  .side-link { min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-radius: 10px; color: var(--ink-2); font-size: 14px; text-decoration: none; }
  .side-link[aria-current='page'] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-weight: 700; font-size: 17px; }
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* building blocks */
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.accent { border: 2px solid var(--accent); }
.card.warn { border-color: var(--warn-line); }
.hero { background: var(--accent); color: #fff; border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.hero .big { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
/* Ad label and notes next to "Mở thẻ này": not smaller than the button text (Luật Quảng cáo Điều 19 khoản 2). */
.ad-note { margin: 0; font-size: 14px; color: var(--ink-2); }
.strong { font-weight: 600; }
.money { font-weight: 700; color: var(--accent); white-space: nowrap; }
.warn-text { color: var(--warn); font-weight: 600; }
.chip { display: inline-flex; align-items: center; font-size: 12px; border-radius: 999px; padding: 5px 10px; background: var(--line-2); color: var(--ink-2); }
.chip.ok { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; }
.chip.on-dark { background: rgba(255, 255, 255, 0.16); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.warn > span { background: var(--warn); }
.bar.lg { height: 10px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.list > * + * { border-top: 1px solid var(--line-2); }
.li { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; }
.li .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* controls */
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--field); background: var(--surface); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); cursor: pointer; }
.btn:hover { color: var(--ink); background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { color: #fff; background: #1e293b; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 15px; border-radius: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); position: relative; cursor: pointer; text-decoration: none; }
.icon-btn.plain { border: 0; background: none; }
.dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 5px; background: var(--danger); border: 2px solid #fff; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { min-height: 44px; border: 1px solid var(--field); border-radius: 12px; padding: 10px 12px; font-size: 15px; background: var(--surface); color: var(--ink); width: 100%; }
textarea.input { resize: vertical; line-height: 1.5; }
.input.amount { font-size: 22px; font-weight: 700; min-height: 52px; }
.pill { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--field); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.pill[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; background: #e9edf2; padding: 4px; border-radius: 12px; }
.segmented button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.segmented button[aria-selected='true'] { background: var(--surface); }
.switch { width: 52px; height: 32px; border-radius: 16px; border: 0; background: var(--field); padding: 3px; display: flex; justify-content: flex-start; flex-shrink: 0; cursor: pointer; }
.switch[aria-checked='true'] { background: var(--accent); justify-content: flex-end; }
.switch > span { width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25); }
.note { background: var(--line-2); border-radius: 12px; padding: 10px 12px; font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.note.ok { background: var(--accent-soft); color: var(--accent-ink); }
.note.warn { background: var(--warn-soft); color: var(--warn-ink); }
.header-back { display: flex; align-items: center; gap: 4px; }
.header-back h1 { font-size: 20px; }

/* specific */
.cc { min-height: 160px; border-radius: 18px; background: #1e293b; color: #fff; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; }
.rank { width: 28px; height: 28px; border-radius: 14px; background: var(--line-2); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bubble { max-width: 88%; border-radius: 18px; padding: 12px 14px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.composer { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 8px; background: var(--bg); padding: 8px 0; }
@media (min-width: 960px) { .composer { bottom: 0; } }
.composer .input { border-radius: 24px; min-height: 48px; }
.composer .send { width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
.datebox { width: 48px; text-align: center; display: flex; flex-direction: column; }
.datebox b { font-size: 18px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 8px; }
table.data td { padding: 10px 8px; border-top: 1px solid var(--line-2); vertical-align: top; }
dialog { border: 0; border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); }
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog form, .dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
.toast.err { background: var(--danger); }
.login { max-width: 420px; margin: 0 auto; padding: 64px 24px 32px; min-height: 100dvh; display: flex; flex-direction: column; gap: 28px; }
.login h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.5px; }
.check { width: 28px; height: 28px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.skeleton { background: linear-gradient(90deg, #eef2f6, #f8fafc, #eef2f6); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 16px; min-height: 80px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.card.row { flex-direction: row; align-items: center; }
a.pill { color: var(--ink); }
a.pill[aria-pressed='true'] { color: #fff; }
.btn.link.danger { color: var(--danger); }
.row > svg, .note > svg { flex-shrink: 0; }

/* Public "Chọn thẻ" page */
.public { min-height: 100dvh; }
.public-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.spend-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .spend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.owned-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.conds { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
