/* Norvix Autobot dashboard. Bố cục: thanh bên trái là các mục, thanh trên hiện gói và token, nội dung một cột rộng tối đa 1120px.
   Ưu tiên người mới: mỗi trang có một câu giải thích, nút chính luôn ở góc phải tiêu đề, trạng thái trống có hướng dẫn. */
:root {
  --bg: #f3f5fa; --surface: #ffffff; --surface-2: #f6f8fc; --ink: #0f1a2c; --muted: #5a687f; --faint: #8893a7; --line: #e4e8f0;
  --accent: #1f5eff; --accent-ink: #ffffff; --accent-soft: #e9efff; --mark: #ffd84d;
  --ok: #10875a; --ok-soft: #e2f5ec; --warn: #a76300; --warn-soft: #fff2d9; --bad: #c33550; --bad-soft: #fde8ec;
  --shadow: 0 1px 2px rgba(16, 27, 45, .05), 0 8px 24px rgba(16, 27, 45, .06);
  --shadow-sm: 0 1px 2px rgba(16, 27, 45, .04), 0 2px 8px -2px rgba(16, 27, 45, .05);
  --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --body: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --r: 14px; --tabbar: 0px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0b1220; --surface: #121b2e; --surface-2: #0f1727; --ink: #e5ecfa; --muted: #98a6bf; --faint: #6f7d95; --line: #24324c;
  --accent: #5b8cff; --accent-ink: #06122b; --accent-soft: #172543; --mark: #f2c14e;
  --ok: #4fd69a; --ok-soft: #10302a; --warn: #f2b84e; --warn-soft: #382a0f; --bad: #ff7d92; --bad-soft: #3b1822;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-sm: none; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121b2e; --surface-2: #0f1727; --ink: #e5ecfa; --muted: #98a6bf; --faint: #6f7d95; --line: #24324c;
  --accent: #5b8cff; --accent-ink: #06122b; --accent-soft: #172543; --mark: #f2c14e;
  --ok: #4fd69a; --ok-soft: #10302a; --warn: #f2b84e; --warn-soft: #382a0f; --bad: #ff7d92; --bad-soft: #3b1822;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-sm: none; color-scheme: dark }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -.01em; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--faint); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 8px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; }
.btn[disabled], .btn.busy { opacity: .55; cursor: progress; }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.fb { background: #1877f2; border-color: #1877f2; color: #fff; }

/* Ô nhập */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 13.5px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-size: 15px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.err { color: var(--bad); font-size: 13.5px; }
.err:empty { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.form { display: grid; gap: 14px; }
.g2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions.end { justify-content: flex-end; }

/* Công tắc */
.sw { position: relative; width: 44px; height: 26px; flex: none; border-radius: 99px; border: 0; background: var(--line); cursor: pointer; transition: background .15s; padding: 0; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.sw[aria-checked="true"] { background: var(--ok); }
.sw[aria-checked="true"]::after { transform: translateX(18px); }
.sw[disabled] { opacity: .5; cursor: not-allowed; }

/* Khung */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; padding: 4px 10px 14px; }
.logo img { height: 27px; width: auto; display: block; }
.logo span { font-weight: 600; letter-spacing: .02em; }
.logo .lg-d { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo .lg-l { display: none; } :root:not([data-theme="light"]) .logo .lg-d { display: block; } }
:root[data-theme="dark"] .logo .lg-l { display: none; } :root[data-theme="dark"] .logo .lg-d { display: block; }
.nav { display: grid; gap: 2px; }
.nav .grp { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 14px 10px 4px; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14.5px; transition: background .12s, color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; padding: 14px 10px 0; font-size: 12.5px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.side .foot a { color: var(--faint); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .menu, .top .mlogo, .tabbar { display: none; }
.mlogo img { height: 24px; width: auto; display: block; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.pill b { font-weight: 600; }
.top .me { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.content { width: 100%; max-width: 1160px; margin: 0 auto; padding: 28px max(20px, env(safe-area-inset-right, 0px)) calc(64px + var(--tabbar)) max(20px, env(safe-area-inset-left, 0px)); display: grid; gap: 18px; align-content: start; }
.head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; }
.head p { color: var(--muted); margin-top: 4px; max-width: 640px; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); padding-top: max(18px, env(safe-area-inset-top, 0px)); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(5, 10, 20, .45); z-index: 40; }
  .top .mlogo { display: block; }
  .app:not(:has(.tabbar)) .top .menu { display: inline-flex; }
  .app:not(:has(.tabbar)) { --tabbar: 0px; }
  .top .hide-sm { display: none; }
  .top { top: env(safe-area-inset-top, 0px); background: color-mix(in srgb, var(--surface) 90%, transparent); }
  .side .logo { padding-left: 10px; }
  /* Thanh dưới cho điện thoại: 4 mục chính + Thêm. */
  :root { --tabbar: 64px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-top: 1px solid var(--line); padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px)); }
  .tabbar a, .tabbar button { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 60px; padding: 6px 2px; border: 0; background: none; color: var(--faint); font-size: 11.5px; font-weight: 600; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar span:not(.badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar [aria-current="page"], .tabbar [data-on] { color: var(--accent); }
  .tabbar [aria-current="page"]::before, .tabbar [data-on]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 10.5px; padding: 0 5px; }
  .toasts { bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px; }
  .toast { max-width: none; }
}

/* Thẻ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; box-shadow: var(--shadow-sm); }
.card > .ch { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.card > .ch p { color: var(--muted); font-size: 13.5px; width: 100%; margin-top: -4px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .ch { padding: 18px 20px 0; }
.stat .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-family: var(--display); font-size: 28px; letter-spacing: -.01em; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .s { font-size: 13px; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.warn i { background: var(--warn); } .bar.bad i { background: var(--bad); } .bar.ok i { background: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--accent-soft); color: var(--accent); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.banner { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: var(--r); background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* Hướng dẫn bắt đầu */
.steps { display: grid; gap: 10px; }
.step { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); text-decoration: none; color: var(--ink); }
.step .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; background: var(--surface); border: 2px solid var(--line); color: var(--muted); }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step { transition: border-color .15s, background .15s; }
@media (hover: hover) { a.step:not(.done):hover { border-color: var(--accent); background: var(--surface); } }
.step.done { padding-block: 8px; background: transparent; border-style: dashed; }
.step.done b { color: var(--muted); font-weight: 500; }
.step.done small, .step.done .go { display: none; }
.step.done .dot { width: 24px; height: 24px; border-width: 0; }
.step.done .dot svg { width: 13px; height: 13px; }
.step > div { min-width: 0; flex: 1; } .step small { display: block; color: var(--muted); font-size: 13px; }
.step .go { color: var(--accent); font-weight: 600; font-size: 13.5px; white-space: nowrap; }

/* Bảng, danh sách */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.list { display: grid; }
.item { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item > .grow { flex: 1; min-width: 0; }
.item small { display: block; color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 36px 16px; display: grid; gap: 10px; justify-items: center; }
.empty .ic { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty .ic svg { width: 26px; height: 26px; }
.empty p { color: var(--muted); max-width: 420px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 13px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button small { color: var(--ok); font-weight: 700; margin-left: 4px; }
details.adv { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
details.adv summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
details.adv[open] summary { margin-bottom: 12px; }
ol.how { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
ol.how b { color: var(--ink); }
.copy { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; min-width: 0; }
.copy code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13.5px; }

/* Gói */
.plans { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .plans { grid-template-columns: minmax(0, 1fr); } }
.plan { border: 1.5px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 10px; align-content: start; background: var(--surface); }
.plan.cur { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan .price { font-family: var(--display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan .price small { font-family: var(--body); font-size: 13.5px; font-weight: 500; color: var(--muted); }
.plan ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: grid; gap: 3px; }
.packs { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .packs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 340px) { .packs { grid-template-columns: minmax(0, 1fr); } }
.pack { border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 4px; }
.pack .v { font-family: var(--display); font-size: 20px; font-weight: 700; }

/* Hội thoại */
.chat { display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 560px; }
.chat .ls { border-right: 1px solid var(--line); overflow-y: auto; max-height: 72vh; }
.chat .ls button { all: unset; box-sizing: border-box; display: grid; gap: 2px; width: 100%; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat .ls button:hover, .chat .ls button[aria-current="true"] { background: var(--surface-2); }
.chat .ls button:focus-visible { outline: 3px solid var(--mark); outline-offset: -3px; }
.chat .ls .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 14px; }
.chat .ls small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat .pane { display: flex; flex-direction: column; min-width: 0; }
.chat .ph { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 58vh; background: var(--surface-2); }
.bub { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bub.customer { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bub.bot, .bub.staff { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bub.staff { background: var(--ink); color: var(--surface); }
.bub .who { display: block; font-size: 11.5px; opacity: .75; margin-bottom: 2px; }
.compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.compose textarea { min-height: 44px; height: 44px; }
@media (max-width: 860px) { .chat { grid-template-columns: minmax(0, 1fr); } .chat.has-sel .ls { display: none; } .chat:not(.has-sel) .pane { display: none; } .chat .ls { max-height: none; border-right: 0; } }

/* Biểu đồ */
.chart svg { width: 100%; height: auto; display: block; }
.chart .gl { stroke: var(--line); }
.chart .ax { fill: var(--faint); font-size: 11px; font-family: var(--body); }
.chart rect.b { fill: var(--accent); }
.chart rect.b:hover { fill: color-mix(in srgb, var(--accent) 75%, var(--ink)); }

/* Hộp thoại, thông báo */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(5, 10, 20, .5); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: min(560px, 100%); background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: grid; gap: 16px; padding: 22px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.wide { width: min(760px, 100%); }
.modal .mh { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 8px; }
.modal .x svg { width: 22px; height: 22px; }
.toasts { position: fixed; z-index: 200; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); max-width: 360px; animation: tin .2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.qrbox { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
.qrbox img { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
@media (max-width: 560px) { .qrbox { grid-template-columns: minmax(0, 1fr); } .qrbox img { max-width: 260px; justify-self: center; } }
dl.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: sp .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
.skel { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border: 1px solid var(--line); }
@keyframes sk { to { background-position: -200% 0; } }

/* Đăng nhập, đăng ký */
.auth { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth .pitch { background: var(--accent); color: var(--accent-ink); padding: 48px max(24px, env(safe-area-inset-left, 0px)); display: grid; align-content: center; gap: 18px; }
.auth .pitch h2 { font-size: 30px; max-width: 420px; }
.auth .pitch ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 420px; }
.auth .pitch li { display: flex; gap: 10px; align-items: flex-start; }
.auth .pitch li::before { content: ""; flex: none; width: 18px; height: 18px; margin-top: 3px; border-radius: 50%; background: color-mix(in srgb, var(--accent-ink) 25%, transparent); box-shadow: inset 0 0 0 5px var(--accent); }
.auth .pitch .logo { color: var(--accent-ink); padding: 0; } .auth .pitch .logo .lg-l { display: none; } .auth .pitch .logo .lg-d { display: block; background: #06122b; padding: 6px 10px; border-radius: 10px; box-sizing: content-box; }
.auth .box { display: grid; align-content: center; justify-items: center; padding: 40px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
.auth .box > div { width: min(420px, 100%); display: grid; gap: 18px; }
.auth .alt { text-align: center; font-size: 14px; color: var(--muted); }
.alogo { display: none !important; padding: 0 !important; }
@media (max-width: 860px) { .auth { grid-template-columns: minmax(0, 1fr); } .auth .pitch { display: none; } .alogo { display: flex !important; margin-bottom: 8px; }
  .auth { background: radial-gradient(60% 40% at 90% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%), var(--bg); }
  .auth .box { align-content: start; padding-top: max(40px, env(safe-area-inset-top, 0px)); } }
.backup { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; background: var(--surface-2); border-radius: 10px; padding: 12px; }
.step .dot svg { width: 16px; height: 16px; }
.chat #back { display: none; }
@media (max-width: 860px) { .chat #back { display: inline-flex; } }
/* Bảng trên điện thoại: mỗi dòng thành một thẻ nhỏ, không phải vuốt ngang. */
@media (max-width: 620px) {
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0; text-align: left !important; }
  table.stack td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: 12.5px; font-weight: 400; }
  table.stack td.full { grid-column: 1 / -1; }
  table.stack td.full .actions { justify-content: flex-start !important; }
}

/* Đăng bài: chọn kiểu ảnh và thư viện ảnh sản phẩm */
.modes { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.modes label { position: relative; display: grid; gap: 4px; align-content: start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); font-size: 13px; color: var(--muted); }
.modes label b { color: var(--ink); font-size: 14px; display: flex; gap: 7px; align-items: center; }
.modes label b svg, .photos .add svg { width: 20px; height: 20px; flex: none; }
.modes input { position: absolute; opacity: 0; pointer-events: none; }
.modes label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modes label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 980px) { .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px) { .modes { grid-template-columns: minmax(0, 1fr); } }
.photos { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); background: var(--surface-2); padding: 0; cursor: pointer; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.photos .ph .n { position: absolute; top: 6px; left: 6px; min-width: 24px; height: 24px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: none; place-items: center; padding: 0 6px; }
.photos .ph[aria-pressed="true"] .n { display: grid; }
.photos .ph .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 99px; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.photos .add { aspect-ratio: 1; border-radius: 12px; border: 2px dashed var(--line); background: var(--surface); color: var(--muted); display: grid; place-items: center; align-content: center; gap: 4px; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; padding: 6px; }
.photos .add:hover { border-color: var(--accent); color: var(--accent); }
.gallery { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface-2); }

/* Điện thoại: chữ đủ lớn để iOS không phóng to khi bấm ô nhập, nút chính rộng hết hàng, hộp thoại trượt từ dưới lên. */
@media (max-width: 620px) {
  h1 { font-size: 22px; }
  .content { padding-top: 18px; gap: 14px; }
  .card { padding: 16px; border-radius: 16px; }
  .card.flush > .ch { padding: 14px 16px 0; }
  .head { align-items: stretch; }
  .head > .actions { width: 100%; }
  .head > .actions > .btn { flex: 1; }
  .head > .btn { width: 100%; }
  input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input:not([type]), select, textarea { font-size: 16px; min-height: 46px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 36px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .g4 > .card.stat, .g4 > .stat.card { padding: 14px; }
  .stat .v { font-size: 22px; }
  .stat .k, .stat .s { font-size: 12.5px; }
  .modal-wrap { place-items: end center; padding: 0; }
  .modal, .modal.wide { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); animation: sheet .22s ease-out; }
  .modal::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -8px 0 -4px; }
  .modal .actions.end { flex-direction: column-reverse; align-items: stretch; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; min-height: 36px; }
  .step { padding: 12px; gap: 12px; }
  .step .go { font-size: 13px; }
  .msgs { max-height: none; min-height: 50vh; }
  .chat .ls { max-height: none; }
  .compose { position: sticky; bottom: var(--tabbar); background: var(--surface); }
}
@media (max-width: 340px) { .g4 { grid-template-columns: minmax(0, 1fr); } }
@keyframes sheet { from { transform: translateY(24px); opacity: .4; } }
