/* autoReply — hệ thiết kế theo ui-ux-pro-max: "Ride Hailing / Transportation"
   Minimalism + glass nhẹ (chỉ thanh điều hướng/sheet), nền tối kiểu bản đồ đêm + xanh tuyến đường,
   màu trạng thái luôn kèm chữ/icon, vùng chạm ≥ 44px, chữ Be Vietnam Pro tự host. */

/* ---------- font ---------- */
@import url("/fonts/fonts.css");

/* ---------- token ---------- */
:root {
  color-scheme: dark;
  --bg: #0F172A; --surface: #192134; --surface-2: #10182B; --surface-3: #232E47;
  --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .16);
  --text: #F8FAFC; --muted: #94A3B8;
  /* cam "theo dõi chuyến" (skill: Logistics accent). Nền nút #C2410C để chữ trắng đạt 5.2:1 */
  --primary: #C2410C; --primary-hover: #9A3412; --on-primary: #FFFFFF; --primary-soft: rgba(234, 88, 12, .18); --primary-text: #FDBA74; --accent: #F97316;
  --info-soft: rgba(37, 99, 235, .2); --info-text: #93C5FD;
  /* biểu đồ: bảng màu tham chiếu dataviz, ô 1 xanh (Tay) + ô 2 cam (Auto), đã chạy validate_palette ở cả 2 nền */
  --series-1: #3987e5; --series-2: #d95926; --series-err: #e66767; --grid: rgba(255, 255, 255, .08);
  --success: #22C55E; --success-soft: rgba(34, 197, 94, .16); --success-text: #86EFAC;
  --warn: #F59E0B; --warn-soft: rgba(245, 158, 11, .16); --warn-text: #FCD34D;
  --danger: #DC2626; --danger-soft: rgba(220, 38, 38, .18); --danger-text: #FCA5A5;
  --glass: rgba(15, 23, 42, .78); --scrim: rgba(2, 6, 23, .64);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);

  --fs: 22px;                                  /* cỡ chữ thẻ cuốc, chỉnh trong Cài đặt */
  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-full: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --tap: 44px;
  --ease: cubic-bezier(.2, .8, .2, 1); --t: 180ms;
  --z-nav: 20; --z-sheet: 40; --z-toast: 100;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
/* bản sáng: theo hệ thống (auto) hoặc chọn tay trong Cài đặt */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F1F5F9; --surface: #FFFFFF; --surface-2: #F8FAFC; --surface-3: #E2E8F0;
  --border: #E2E8F0; --border-strong: #CBD5E1; --text: #0F172A; --muted: #475569;
  --primary-soft: #FFEDD5; --primary-text: #C2410C; --info-soft: #DBEAFE; --info-text: #1D4ED8;
  --series-1: #2a78d6; --series-2: #eb6834; --series-err: #e34948; --grid: #E2E8F0;
  --success-soft: #DCFCE7; --success-text: #15803D; --warn-soft: #FEF3C7; --warn-text: #B45309;
  --danger-soft: #FEE2E2; --danger-text: #B91C1C;
  --glass: rgba(255, 255, 255, .82); --scrim: rgba(15, 23, 42, .45);
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .08);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #F1F5F9; --surface: #FFFFFF; --surface-2: #F8FAFC; --surface-3: #E2E8F0;
    --border: #E2E8F0; --border-strong: #CBD5E1; --text: #0F172A; --muted: #475569;
    --primary-soft: #FFEDD5; --primary-text: #C2410C; --info-soft: #DBEAFE; --info-text: #1D4ED8;
  --series-1: #2a78d6; --series-2: #eb6834; --series-err: #e34948; --grid: #E2E8F0;
    --success-soft: #DCFCE7; --success-text: #15803D; --warn-soft: #FEF3C7; --warn-text: #B45309;
    --danger-soft: #FEE2E2; --danger-text: #B91C1C;
    --glass: rgba(255, 255, 255, .82); --scrim: rgba(15, 23, 42, .45);
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .08);
  }
}

/* ---------- nền ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
body.no-nav { padding-bottom: env(safe-area-inset-bottom); }
main { max-width: 600px; margin: 0 auto; padding: var(--s3) var(--s4) var(--s4); }
body.no-nav main, body.admin main { padding-top: calc(var(--s3) + env(safe-area-inset-top)); }
h1 { font-size: 26px; line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; line-height: 1.35; margin: 0; font-weight: 600; }
h3 { font-size: 15px; margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary-text); text-underline-offset: 3px; }
small, .muted { color: var(--muted); }
small { font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--primary-soft); }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 16px; height: 16px; } .ic.lg { width: 28px; height: 28px; } .ic.xl { width: 48px; height: 48px; stroke-width: 1.5; }

/* ---------- bố cục ---------- */
.stack { display: grid; gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.mt { margin-top: var(--s3); } .mt-lg { margin-top: var(--s6); }
.center { text-align: center; }
.full { width: 100%; }

/* thanh đầu trang */
.app-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 52px; margin-bottom: var(--s2); }
.eyebrow { color: var(--primary-text); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin: var(--s6) 0 var(--s2); }
.section-title h2 { font-size: 15px; color: var(--muted); font-weight: 600; }

/* ---------- thẻ ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--shadow); }
.card + .card { margin-top: var(--s3); }
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.card-head .ic { color: var(--primary-text); }
.list { padding: 0 var(--s4); }
.list > * + * { border-top: 1px solid var(--border); }

/* ---------- nút ---------- */
button, .btn { font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--r); min-height: var(--tap); padding: 0 var(--s4); display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  background: var(--surface-3); color: var(--text); text-decoration: none; touch-action: manipulation;
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), transform var(--t) var(--ease), opacity var(--t); }
button:hover, .btn:hover { border-color: var(--border-strong); }
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary { background: var(--primary); color: var(--on-primary); }
.primary:hover { background: var(--primary-hover); border-color: transparent; }
.tonal { background: var(--primary-soft); color: var(--primary-text); }
.danger { background: var(--danger-soft); color: var(--danger-text); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { background: var(--surface-3); color: var(--text); }
.icon-btn { width: var(--tap); padding: 0; flex: none; }
.lg-btn { min-height: 56px; font-size: 17px; border-radius: var(--r-lg); }
.busy { pointer-events: none; opacity: .7; }

/* ---------- ô nhập ---------- */
input[type=text], input[type=search], input[type=time], textarea, select {
  font: inherit; font-size: 16px; width: 100%; min-height: var(--tap); padding: 10px 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r); transition: border-color var(--t);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field { display: grid; gap: 6px; margin-top: var(--s4); }
.field > label, label.field-label { font-size: 14px; font-weight: 600; }
.field .help { font-size: 13px; color: var(--muted); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 42px; }
input[type=range] { width: 100%; height: var(--tap); accent-color: var(--primary); cursor: pointer; }

/* công tắc */
.switch { position: relative; display: inline-flex; width: 52px; height: var(--tap); flex: none; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: relative; width: 52px; height: 30px; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r-full); transition: background-color var(--t); }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 2px; top: 2px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--t) var(--ease); }
.switch input:checked + span { background: var(--primary); border-color: var(--primary); }
.switch input:checked + span::before { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* dòng cài đặt */
.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; min-height: 60px; }
.setting .label { display: grid; gap: 2px; }
.setting .label b { font-weight: 600; }

/* điều khiển phân đoạn */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.segmented button { min-height: 40px; background: transparent; color: var(--muted); font-size: 14px; border-radius: var(--r-sm); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- huy hiệu / trạng thái ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text); white-space: nowrap; }
.tag .ic { width: 14px; height: 14px; }
.tag.blue { background: var(--info-soft); color: var(--info-text); }
.tag.accent { background: var(--primary-soft); color: var(--primary-text); }
.tag.green { background: var(--success-soft); color: var(--success-text); }
.tag.warn { background: var(--warn-soft); color: var(--warn-text); }
.tag.red { background: var(--danger-soft); color: var(--danger-text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.dot.ok.live { animation: pulse 2s var(--ease) infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.ok-text { color: var(--success-text); font-weight: 600; } .bad-text { color: var(--danger-text); font-weight: 600; } .warn-text { color: var(--warn-text); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s2) 0 var(--s4); border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.pill.plain { padding: 0 var(--s4); }

/* hộp trạng thái kết nối */
.status { display: flex; align-items: center; gap: var(--s3); }
.status .grow b { display: block; }

/* ---------- thẻ cuốc ---------- */
.ride { position: relative; overflow: hidden; animation: enter 240ms var(--ease) both; }
.ride::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.ride .text { font-size: var(--fs); font-weight: 700; line-height: 1.35; word-break: break-word; }
.ride .meta { display: flex; justify-content: space-between; gap: var(--s2); margin: var(--s3) 0; font-size: 14px; color: var(--muted); }
.ride .meta .ic { width: 16px; height: 16px; }
.ride .meta span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ride .meta b { color: var(--text); font-weight: 600; }
.ride .actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: var(--s3); margin-top: var(--s4); }
.ride.taken { opacity: .6; }
.ride.taken::before { background: var(--warn); }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

/* trạng thái trống */
.empty { display: grid; justify-items: center; gap: var(--s2); text-align: center; padding: var(--s8) var(--s4); }
.empty .ic.xl { color: var(--muted); margin-bottom: var(--s2); }
.empty p { max-width: 32ch; }

/* ---------- nhóm ---------- */
.group { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; object-fit: cover; background: var(--primary-soft); color: var(--primary-text);
  display: grid; place-items: center; font-weight: 700; }
.group .name { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.check:has(input:disabled) { opacity: .4; cursor: not-allowed; }
.check { display: grid; justify-items: center; gap: 2px; min-width: var(--tap); font-size: 12px; color: var(--muted); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; margin: 0; }

/* ---------- bộ từ khóa ---------- */
.set { display: grid; gap: 6px; padding: var(--s3) 0; }
.set > .row { gap: var(--s2); }
.set .route span { word-break: break-word; }
.set .name { font-weight: 600; }
.route { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.route .ic { width: 14px; height: 14px; }
.result { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2) 0; font-size: 14px; border-top: 1px dashed var(--border); }
.result .ic { margin-top: 2px; }

/* chip */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s3); max-height: 260px; overflow: auto; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--primary-soft); color: var(--primary-text); border-radius: var(--r-full);
  padding: 2px 2px 2px 12px; font-size: 14px; font-weight: 600; }
.chip button { min-height: 32px; width: 32px; padding: 0; background: transparent; color: inherit; border-radius: 50%; }

/* lịch sử */
.history-item { padding: var(--s3) 0; display: grid; gap: 4px; }

/* ---------- điều hướng dưới (glass) ---------- */
#tabs { position: fixed; z-index: var(--z-nav); bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)); background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); border-top: 1px solid var(--border); }
#tabs button { flex-direction: column; gap: 2px; min-height: 56px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; border-radius: var(--r); }
#tabs button .ic { width: 24px; height: 24px; }
#tabs button.on { color: var(--primary-text); background: var(--primary-soft); }
#tabs button:hover { border-color: transparent; color: var(--text); }
@media (min-width: 640px) { #tabs { max-width: 600px; margin: 0 auto 12px; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); } }

/* ---------- sheet / popup ---------- */
#modal { position: fixed; inset: 0; z-index: var(--z-sheet); background: var(--scrim); display: grid; align-items: end; justify-items: center;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade 160ms ease-out both; }
#modal .box { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--s5) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  animation: sheet-up 240ms var(--ease) both; }
#modal .box::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: -8px auto var(--s4); }
@media (min-width: 640px) {
  #modal { align-items: center; padding: var(--s4); }
  #modal .box { border-radius: var(--r-lg); }
  #modal .box::before { display: none; }
}
#modal dl { display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); margin: var(--s4) 0; }
#modal dt { color: var(--muted); font-size: 14px; } #modal dd { margin: 0; font-weight: 600; word-break: break-word; }
.sheet-head { display: flex; align-items: center; gap: var(--s3); }
.sheet-head .badge-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success-text); flex: none; }
.rank { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--surface-2); font-weight: 600; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s5); }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }

/* toast */
#toast { position: fixed; z-index: var(--z-toast); top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  max-width: min(92vw, 480px); padding: 12px 18px; border-radius: var(--r); background: var(--text); color: var(--bg);
  font-weight: 600; font-size: 15px; text-align: center; box-shadow: var(--shadow); animation: toast-in 200ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- đăng nhập QR ---------- */
.login { min-height: calc(100dvh - 40px); display: grid; align-content: center; gap: var(--s5); }
.login .logo { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--primary); color: #fff; margin: 0 auto; }
.qr-frame { width: 264px; max-width: 100%; aspect-ratio: 1; margin: 0 auto; padding: 12px; background: #fff; border-radius: var(--r-lg); display: grid; place-items: center; }
.qr { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.steps { display: grid; gap: var(--s3); counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { display: flex; gap: var(--s3); align-items: flex-start; counter-increment: s; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: 13px; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- trang admin ---------- */
body.admin { padding-bottom: var(--s8); }
body.admin main { max-width: 1240px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s3); }
.stat { display: grid; gap: 4px; }
.stat .k { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
#users tbody tr { cursor: pointer; transition: background-color var(--t); }
#users tbody tr:hover, #users tbody tr:focus-visible { background: var(--primary-soft); }
#logs td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
#logs .detail { word-break: break-word; min-width: 260px; color: var(--muted); }
#logs pre { white-space: pre-wrap; margin: 6px 0 0; font-size: 12px; }
#logs summary { cursor: pointer; }
tr.lv-error td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.lv-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.filters { display: grid; grid-template-columns: 180px 1fr; gap: var(--s3); }
@media (max-width: 720px) { .filters { grid-template-columns: 1fr; } }

/* ---------- giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* tiện ích nhỏ (CSP cấm style="" inline) */
.justify-center { justify-content: center; }
.right { text-align: right; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; flex: none; }
.status .grow small { display: block; }
button, .btn, .tag, #tabs button { white-space: nowrap; }
.ride .text { white-space: pre-line; }
.ride .meta b { white-space: nowrap; }
.card > .field:first-child, .box > .field:first-child { margin-top: 0; }
#users td:nth-child(2) { white-space: nowrap; }

/* ---------- thanh trạng thái trên cùng (glass, dính khi cuộn) ---------- */
#topbar { position: sticky; top: 0; z-index: var(--z-nav); background: var(--glass); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 600px; margin: 0 auto; display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s4); min-height: 56px; }
.top-status { line-height: 1.25; }
.top-status b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-status small { font-size: 12px; }
.topbar-inner .pill { min-height: 40px; padding-left: var(--s3); font-size: 13px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; margin-bottom: var(--s3); }

/* ---------- thẻ cuốc gọn, giá + giờ nổi bật ---------- */
.stack.tight { gap: var(--s2); }
.ride { padding: var(--s3) var(--s4) var(--s3) calc(var(--s4) + 2px); }
.ride-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: 2px; }
.big-time { display: inline-flex; align-items: center; gap: 6px; font-size: calc(var(--fs) * 1.1); font-weight: 700; color: var(--info-text); }
.big-time .ic { width: .9em; height: .9em; }
.big-price { font-size: calc(var(--fs) * 1.45); font-weight: 800; line-height: 1; color: var(--success-text); letter-spacing: -.02em; }
.big-price small { font-size: .55em; font-weight: 700; margin-left: 1px; color: inherit; }
.ride .text { font-size: calc(var(--fs) * .82); font-weight: 600; line-height: 1.4; }
.ride .tags { margin-top: 6px; }
.ride .meta { margin: 6px 0 0; font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ride .meta .grow { min-width: 0; }
.ride .actions { margin-top: var(--s3); gap: var(--s2); }
.ride .actions button { min-height: 48px; font-size: 16px; }
.empty.compact { padding: var(--s6) var(--s4); }
.section-title h2 { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- mục thu gọn (details) ---------- */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details .chev { color: var(--muted); transition: transform var(--t) var(--ease); }
details[open] .chev { transform: rotate(90deg); }
.setting .label b { display: inline-flex; align-items: center; gap: 6px; }
details.adv { padding-top: 0; padding-bottom: var(--s2); }
details.adv[open] { padding-bottom: var(--s4); }
.sub-block { padding: var(--s3) 0; border-top: 1px solid var(--border); }
.list-flat > * + * { border-top: 1px solid var(--border); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#testBox[open] { padding-bottom: var(--s4); }

/* ---------- biểu đồ admin ---------- */
.charts { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--s3); }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .s1 { fill: var(--series-1); } .chart .s2 { fill: var(--series-2); } .chart .s-err { fill: var(--series-err); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--primary-soft); fill-opacity: .5; }
.chart-box { position: relative; }
.legend { display: flex; gap: var(--s4); font-size: 13px; color: var(--muted); margin-bottom: var(--s2); }
.legend span, .tip span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); } .sw.s-err { background: var(--series-err); }
.tip { position: absolute; top: 0; transform: translate(-50%, -100%); z-index: 5; pointer-events: none; display: grid; gap: 2px;
  min-width: 120px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 13px; box-shadow: var(--shadow); white-space: nowrap; }
#claimsTable table { margin-top: var(--s2); }

/* ---------- bảng chi tiết user ---------- */
#modal .box.wide { max-width: 720px; }
.box .stats .stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s3); }
.box .stats .v { font-size: 22px; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s2); }
.card.flat.list { background: var(--surface-2); }

/* ---------- admin màn hẹp (điện thoại, tablet dọc): bảng → thẻ, không cuộn ngang ---------- */
@media (max-width: 900px) {
  body.admin main { padding-left: var(--s3); padding-right: var(--s3); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat .v { font-size: 24px; }
  #users thead, #logs thead { display: none; }
  #users tbody tr, #logs tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
  #users tbody td, #logs tbody td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; }
  #users tbody td::before, #logs tbody td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  #users td:nth-child(1) { display: none; }
  #users td:nth-child(2), #logs td.detail { grid-column: 1 / -1; }
  #users td:nth-child(2)::before { display: none; }
  #users td:nth-child(2) b { font-size: 16px; }
  #logs td.detail { min-width: 0; }
  tr.lv-error td:first-child, tr.lv-warn td:first-child { box-shadow: none; }
  #logs tr.lv-error { box-shadow: inset 3px 0 0 var(--danger); }
  #logs tr.lv-warn { box-shadow: inset 3px 0 0 var(--warn); }
  #logs tbody tr:has(.empty) { display: block; }
}
#modal[data-shown], #modal[data-shown] .box { animation: none; }
.section-title { flex-wrap: wrap; } .section-title h2 { white-space: nowrap; }

/* log trong bảng chi tiết user */
.log-item { display: grid; gap: 4px; padding: var(--s3) 0; }
.log-item .detail { font-size: 13px; color: var(--muted); word-break: break-word; }
.log-item pre { white-space: pre-wrap; margin: 4px 0 0; font-size: 12px; }
.log-item.lv-error { box-shadow: inset 3px 0 0 var(--danger); padding-left: var(--s3); }
.log-item.lv-warn { box-shadow: inset 3px 0 0 var(--warn); padding-left: var(--s3); }
.log-item { gap: 2px; padding: var(--s2) 0; } .log-item .row { gap: var(--s2); }
