/* Hệ giao diện theo XeNhà: nền trắng, chữ/điểm nhấn xanh dương kiểu Zalo, thẻ bo 14px, thanh tab dưới */
:root {
  --bg: #ffffff; --surface: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-ink: #ffffff; --accent-soft: #eaf1ff;
  --good: #15803d; --good-soft: #dcf2e3; --warn: #b45309; --warn-soft: #fdeeda; --bad: #dc2626; --bad-soft: #fde8e8;
  --cargo: #3b5bdb; --cargo-soft: #eaf0ff;
  --tint-1: #eef4ff; --tint-2: #f4effb; --tint-3: #fdf6e7; --tint-4: #ecf8f0;
  --hero-from: #eef4ff; --hero-to: #ffffff;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --surface: #111a2b; --ink: #e6edf7; --muted: #8fa0b8; --line: #1f2a3d;
  --accent: #60a5fa; --accent-ink: #0b1a33; --accent-soft: #15233d;
  --good: #4ade80; --good-soft: #12301c; --warn: #fbbf24; --warn-soft: #33260d; --bad: #f87171; --bad-soft: #331214;
  --cargo: #93a8ff; --cargo-soft: #18213d;
  --tint-1: #13213a; --tint-2: #1f1a2e; --tint-3: #29220f; --tint-4: #13261a;
  --hero-from: #0f1a2e; --hero-to: #0b1220; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px); -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; border: none; border-radius: 10px; color: inherit; background: none; }
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; width: 100%; font-size: 16px; /* ≥16px để iPhone không tự phóng to khi gõ */
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
input[type="range"] { accent-color: var(--accent); padding: 0; border: none; background: transparent; }
textarea { resize: vertical; }
h1, h2, h3 { font-weight: 800; }

.boot { padding: 40px; text-align: center; color: var(--muted); }
#root { min-height: 100dvh; }
.app { max-width: 560px; margin: 0 auto; padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
.page { padding: 12px 14px 28px; max-width: 560px; margin: 0 auto; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); max-width: 560px; margin: 0 auto;
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; min-width: 0; }
.title-block { flex: 1; min-width: 0; }
/* Màn Tin: dòng số người dùng / nhắc gia hạn xuống hàng riêng, rộng hết thanh trên */
.feed-top { flex-wrap: wrap; row-gap: 2px; }
.topbar-line { flex-basis: 100%; display: flex; flex-direction: column; gap: 2px; }
.title-block h1 { margin: 0; }
/* "Số lượng người dùng app: x người" — số to, đậm, màu nhấn */
.user-count { font-size: 14px; color: var(--muted); line-height: 1.35; font-weight: 600; }
.user-count b { color: var(--accent); font-size: 1.45em; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.welcome-hero .user-count { margin-top: 10px; font-size: 16px; background: var(--surface); border: 1.5px solid var(--accent-soft); border-radius: 999px; padding: 6px 16px; box-shadow: 0 2px 10px rgba(37, 99, 235, .12); }
.welcome-hero .user-count b { font-size: 1.6em; }
.trial-warn { text-align: left; font-size: 12.5px; line-height: 1.35; color: var(--muted); padding: 0; border-radius: 0; }
.trial-warn i { color: var(--bad); opacity: .8; }
.trial-warn b { color: var(--accent); font-weight: 800; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabbar button {
  flex: 1 1 0; max-width: 140px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; white-space: nowrap;
}
.tabbar button.active { color: var(--accent); }
.tabbar .ticon { font-size: 21px; line-height: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.strong { font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.accent { color: var(--accent); }
.ink { color: var(--ink); }
.center { text-align: center; }
.right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.left { text-align: left; }
.bad-text { color: var(--bad); font-weight: 700; }
.warn-text { color: var(--warn); font-weight: 700; }
.fade { opacity: .55; }
.wide { width: 100%; display: block; }
.section-title { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }
.footnote { margin-top: 16px; }

/* Nút */
.btn { padding: 10px 16px; font-weight: 700; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn.wide { display: flex; }
.btn-accept { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-small { padding: 6px 12px; font-size: 14px; min-height: 34px; white-space: nowrap; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: default; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px 0; }
.chip { background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 600; border-radius: 999px; padding: 5px 12px; white-space: nowrap; border: 1px solid transparent; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.soft { background: var(--bg); color: var(--muted); border-color: var(--line); font-weight: 500; }
.chip-row { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }

/* Nút phân đoạn (Tất cả / Khách / Hàng …) */
.seg { display: flex; gap: 8px; margin-bottom: 10px; }
.seg button { flex: 1; padding: 8px 6px; font-size: 15px; font-weight: 700; color: var(--muted); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; white-space: nowrap; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.login-card .seg { gap: 6px; }
.seg.scroll { overflow-x: auto; scrollbar-width: none; }
.seg.scroll button { flex: 0 0 auto; padding: 8px 12px; }
.subnav { padding: 10px 14px 0; max-width: 560px; margin: 0 auto; }

/* Thẻ tin */
.msg-head { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.msg-src { flex: 1 1 160px; min-width: 0; display: flex; flex-direction: column; }
.msg-group { font-weight: 700; color: var(--accent); font-size: 14px; overflow-wrap: anywhere; }
.msg-sender { color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; background: var(--line); color: var(--muted); }
.badge.cat-passenger, .badge.good { background: var(--good-soft); color: var(--good); }
.badge.cat-cargo { background: var(--cargo-soft); color: var(--cargo); }
.badge.cat-mixed, .badge.new { background: var(--accent-soft); color: var(--accent); }
.badge.cat-unknown, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.route { font-size: 17px; font-weight: 800; margin: 8px 0 2px; overflow-wrap: anywhere; }
.msg-content { margin: 6px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; font-size: calc(16px * var(--msg-scale, 1)); max-height: 16em; overflow: auto; }
.msg-bold .msg-content { font-weight: 700; }
.msg-actions { display: flex; gap: 8px; margin-top: 8px; }
.msg-actions .btn { flex: 1 1 0; min-width: 0; min-height: 48px; font-size: 16px; white-space: nowrap; padding: 10px 12px; }
.msg-actions .btn-accept { flex-grow: 2.2; }
.card.lead.is-read { opacity: .62; }
.card.lead.is-read .route { font-weight: 700; }
.status-row { margin: 2px 0 10px; }
.feed-toolbar + input[type="search"] { margin-bottom: 8px; }
.newcount {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 64px); left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; padding: 8px 16px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.empty { text-align: center; color: var(--muted); padding: 44px 16px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* Biểu mẫu, công tắc */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); }
.field label > input, .field label > textarea, .field label > select { margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { padding: 8px 0; font-weight: 600; cursor: pointer; }
.setting { padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.setting:last-child { border-bottom: 0; }
.setting-label { font-weight: 600; }
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; background: #fff; border-radius: 999px; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { left: 22px; }
form.card > input, form.card > textarea, form.card > .pw-wrap { margin-bottom: 10px; }
/* Ô mật khẩu có nút 👁 ẩn/hiện */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 40px; font-size: 19px; line-height: 1; border-radius: 8px; }
.pw-eye:hover, .pw-eye:focus-visible { background: var(--accent-soft); }
.remember { padding: 2px 0; font-weight: 600; font-size: 15px; }
.remember small { font-weight: 400; font-size: 13px; }

/* Thông báo */
.banner { display: block; border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; font-size: 14px; font-weight: 500; background: var(--accent-soft); color: var(--ink); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.good { background: var(--good-soft); color: var(--good); }
button.banner { font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); z-index: 90;
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #b91c1c; }
.toast.good { background: #15803d; }

/* Hộp thoại */
.overlay { position: fixed; inset: 0; z-index: 70; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet {
  background: var(--surface); color: var(--ink); border-radius: 18px; padding: 20px 18px 14px; width: 100%; max-width: 420px;
  max-height: calc(100dvh - 32px); overflow: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.sheet-icon { font-size: 40px; line-height: 1; text-align: center; }
.sheet h3 { margin: 0; font-size: 18px; text-align: center; }
.sheet p { margin: 0 0 6px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.sheet-actions .btn { flex: 1 1 140px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.secret { background: var(--bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 15px; overflow-wrap: anywhere; user-select: all; }
.pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.key-box { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.key-box > div { align-self: stretch; }

/* Màn chào / đăng nhập */
.welcome {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 56px 16px 32px; gap: 14px; position: relative;
  background: linear-gradient(180deg, var(--hero-from), var(--hero-to) 420px, var(--bg) 900px);
}
.welcome > * { width: 100%; max-width: 440px; }
.theme-toggle {
  position: absolute; top: 12px; right: 12px; width: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 7px 12px; font-size: 13.5px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.welcome-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.app-logo { border-radius: 22%; box-shadow: 0 6px 18px rgba(37, 99, 235, .25); }
.welcome-hero h1 { margin: 8px 0 0; font-size: 32px; color: var(--accent); letter-spacing: -.01em; }
.welcome-hero p { margin: 0; color: var(--muted); }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.05);
}
.login-card .seg { margin-bottom: 4px; }
.agree-card {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; cursor: pointer; background: var(--accent-soft);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; line-height: 1.5;
}
.agree-card.on { border-color: var(--accent); }
.agree-card a { font-weight: 600; }
.btn-login { width: 100%; padding: 14px; font-size: 18px; font-weight: 800; background: var(--accent); color: var(--accent-ink); border-radius: 12px; }
.btn-login:disabled { opacity: .35; cursor: not-allowed; }
.welcome-hint { text-align: center; font-size: 13.5px; margin: -4px 0 0; }
.install-btn { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); border-radius: 12px; padding: 12px; font-weight: 700; font-size: 15.5px; margin: 10px 0; }
.welcome-h2 { text-align: center; font-size: 21px; margin: 22px 0 4px; }
.features { display: flex; flex-direction: column; gap: 12px; }
.feature { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 18px; border: 1px solid var(--line); }
.feature-ill { flex-shrink: 0; width: 56px; height: 56px; border-radius: 16px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 30px; }
.feature h3 { margin: 0 0 3px; font-size: 16.5px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.welcome-free { text-align: center; margin-top: 8px; }
.welcome-foot { text-align: center; font-size: 12px; line-height: 1.6; }

/* Điều khoản */
.terms { min-height: 100dvh; background: var(--bg); }
.terms-body { max-width: 760px; margin: 0 auto; padding: 8px 18px 120px; line-height: 1.65; }
.terms-body h1 { font-size: 26px; margin: 14px 0 0; }
.terms-body h2 { font-size: 21px; margin: 30px 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.terms-body h3 { font-size: 16.5px; margin: 20px 0 6px; }
.terms-body ul { padding-left: 22px; }
.terms-intro { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.terms-note { background: var(--warn-soft); border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.terms-agreebar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; }
.terms-agreebar .btn { width: 100%; max-width: 440px; }

/* Gói dịch vụ, thanh toán */
.plan-card { padding: 16px; }
.plan-name { font-weight: 800; font-size: 17px; }
.plan-price { font-size: 26px; font-weight: 800; color: var(--accent); margin: 2px 0; }
.plan-price .muted { font-size: 14px; font-weight: 500; }
.plan-price.small-price { font-size: 19px; }
.plan-note { color: var(--good); font-size: 13.5px; font-weight: 600; }
.plan-perks { list-style: none; padding: 0; margin: 8px 0 12px; }
.plan-perks li { padding: 3px 0; font-size: 14.5px; }
.qr-pay { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 8px 0 12px; }
.qr-pay img { width: 240px; max-width: 80%; height: auto; border-radius: 14px; background: #fff; padding: 8px; }
.info-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; }
.countdown { font-variant-numeric: tabular-nums; }

/* Tài khoản */
.profile .avatar { width: 48px; height: 48px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.linkcard { width: 100%; text-align: left; }
.link-icon { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.ref-link { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: 13.5px; overflow-wrap: anywhere; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat-tiles.three { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat-tile { text-align: center; margin-bottom: 0; width: 100%; }
button.stat-tile { cursor: pointer; }
.stat-tile.warn { background: var(--warn-soft); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; }
.three .stat-num { font-size: 22px; }
.contact-phone { font-size: 20px; font-weight: 800; color: var(--accent); letter-spacing: .02em; }
.contact-actions { display: flex; gap: 8px; margin-top: 8px; }
.contact-actions .btn { flex: 1 1 0; }

/* Quản trị */
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 3px 10px; font-size: 14px; margin: 8px 0; }
.kv > span:nth-child(odd) { color: var(--muted); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding-top: 2px; }
.user-card[data-expiry="soon"] { border-color: var(--warn); background: var(--warn-soft); }
.user-card[data-expiry="expired"] { border-color: var(--bad-soft); }

/* Hướng dẫn */
.guide summary { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; list-style: none; }
.guide summary::-webkit-details-marker { display: none; }
.guide-list { padding-left: 20px; margin: 8px 0 0; }
.guide-list li { margin: 6px 0; }

@media (max-width: 360px) {
  .msg-actions { flex-direction: column; }
  .kv { grid-template-columns: 1fr; }
  .stat-tiles.three .stat-num { font-size: 18px; }
}

/* Nút bật/tắt ở thanh trên màn Tin (Đọc, chuông) — nền trắng viền xám như XeNhà */
.toggle { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.toggle.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
