/* Sàn đặt xe — giao diện chung. Mobile first, tràn đầy màn hình máy tính. */
:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f8fafc; --line: #e3e8f0; --text: #0f172a; --muted: #64748b;
  --primary: #1d4ed8; --primary-2: #2563eb; --primary-soft: #e8efff; --on-primary: #fff;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fff4e0; --danger: #b91c1c; --danger-soft: #fdecec;
  --info: #0369a1; --info-soft: #e3f3fb; --accent: #6d28d9; --accent-soft: #f1eafe;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --gutter: 16px; --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #121a2c; --surface-2: #0f1626; --line: #23304a; --text: #e5eaf3; --muted: #94a3b8;
    --primary: #6d9bff; --primary-2: #86adff; --primary-soft: #1a2a4d; --on-primary: #0b1120;
    --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #fbbf24; --warn-soft: #2d2410; --danger: #f87171; --danger-soft: #331616;
    --info: #38bdf8; --info-soft: #0c2633; --accent: #b794ff; --accent-soft: #23193d; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #121a2c; --surface-2: #0f1626; --line: #23304a; --text: #e5eaf3; --muted: #94a3b8;
  --primary: #6d9bff; --primary-2: #86adff; --primary-soft: #1a2a4d; --on-primary: #0b1120;
  --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #fbbf24; --warn-soft: #2d2410; --danger: #f87171; --danger-soft: #331616;
  --info: #38bdf8; --info-soft: #0c2633; --accent: #b794ff; --accent-soft: #23193d; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); overflow-x: hidden; }
body.noscroll { overflow: hidden; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85em; } .pad { padding: 10px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.hide, [hidden] { display: none !important; }

/* Bố cục */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter); }
.brand { font-weight: 800; font-size: 1.05rem; display: flex; gap: 8px; align-items: center; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand i { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-style: normal; }
.topbar .sp { flex: 1; }
.wrap { width: 100%; padding: 16px var(--gutter) 90px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr; } .cols-3 { grid-template-columns: 1fr; } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } :root { --gutter: 24px; } }
@media (min-width: 1280px) { .cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } :root { --gutter: 32px; } }
.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .gap { gap: 10px; }
.stack > * + * { margin-top: 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.tight { padding: 12px; }
.card h2, .card h3 { display: flex; align-items: center; gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.warn b { color: var(--warn); } .stat.danger b { color: var(--danger); } .stat.ok b { color: var(--ok); }

/* Nút */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 11px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: .88rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled, .btn.busy { opacity: .55; cursor: progress; }
.icon-btn { position: relative; border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; min-width: 44px; min-height: 44px; color: var(--text); }
.icon-btn.has::after { content: attr(data-count); position: absolute; top: 4px; right: 2px; background: var(--danger); color: #fff; font-size: .7rem; border-radius: 99px; padding: 0 5px; min-width: 18px; }

/* Form */
.form { display: grid; gap: 12px; }
.form label, label.f { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; min-width: 0; }
.form label small { font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; min-width: 0; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }
label.check input { width: 20px; min-height: 20px; height: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 8px 12px; cursor: pointer; user-select: none; background: var(--surface); font-weight: 500; }
.chip input { display: none; }
.chip:has(input:checked), .chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg label { margin: 0; padding: 10px 6px; text-align: center; cursor: pointer; font-weight: 600; border-right: 1px solid var(--line); background: var(--surface); flex-direction: row !important; justify-content: center; }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--primary); color: var(--on-primary); }
.ac-wrap { position: relative; }
.ac-list { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; }
.ac-list:empty { display: none; }
.ac-list button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--text); cursor: pointer; }
.ac-list button:hover { background: var(--primary-soft); }

/* Nhãn trạng thái */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.alert { border-radius: 12px; padding: 12px 14px; background: var(--info-soft); color: var(--text); border: 1px solid transparent; }
.alert.warn { background: var(--warn-soft); } .alert.danger { background: var(--danger-soft); } .alert.ok { background: var(--ok-soft); }

/* Bảng -> thẻ trên điện thoại */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { background: var(--surface-2); font-size: .8rem; color: var(--muted); position: sticky; top: 0; cursor: pointer; white-space: nowrap; user-select: none; }
table.t tr:hover td { background: var(--surface-2); }
table.t tr.urgent td:first-child { box-shadow: inset 3px 0 var(--danger); }
@media (max-width: 899px) {
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { border-bottom: 8px solid var(--bg); padding: 8px 4px; }
  table.t.cards td { border: 0; padding: 4px 10px; display: flex; gap: 10px; justify-content: space-between; }
  table.t.cards td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; flex: 0 0 38%; }
  table.t.cards td[data-l=""]::before { display: none; }
  .table-wrap { border: 0; background: transparent; }
}

/* Thẻ cuốc */
.trip { display: grid; gap: 8px; }
.trip .route { font-weight: 700; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.trip .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .88rem; }
.trip .money { font-size: 1.25rem; font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; }
.trip.urgent { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; }
.list { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; min-height: 44px; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav button { border: 0; background: transparent; padding: 8px 2px 6px; font: inherit; font-size: .72rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-height: 56px; }
.bottomnav button span { font-size: 1.25rem; }
.bottomnav button.on { color: var(--primary); }

/* Hộp thoại, thông báo */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(2,6,23,.5); display: flex; align-items: flex-end; justify-content: center; }
.modal { position: relative; background: var(--surface); width: 100%; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { .modal-wrap { align-items: center; } .modal { width: min(560px, 92vw); border-radius: 18px; padding: 24px; } .modal.wide { width: min(1100px, 96vw); } }
.modal-x { position: absolute; top: 8px; right: 10px; border: 0; background: transparent; font-size: 1.6rem; cursor: pointer; color: var(--muted); min-width: 44px; min-height: 44px; }
#toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: 80px; display: grid; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.toast { background: #0f172a; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast.err { background: #b91c1c; } .toast.warn { background: #b45309; } .toast.ok { background: #166534; }
.toast.out { opacity: 0; transform: translateY(10px); }
#offline { display: none; position: sticky; top: 0; z-index: 60; background: var(--danger); color: #fff; padding: 8px var(--gutter); font-size: .88rem; font-weight: 600; }
#offline.show { display: block; }
.notif-list { display: grid; gap: 8px; max-height: 60vh; overflow: auto; margin-bottom: 12px; }
.notif { border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; }
.notif.unread { background: var(--primary-soft); } .notif.urgent { border-color: var(--danger); }

.map { height: 260px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); z-index: 0; }
@media (min-width: 900px) { .map.tall { height: calc(100vh - 140px); min-height: 480px; position: sticky; top: 76px; } }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.price-lines { width: 100%; font-size: .9rem; } .price-lines td { padding: 3px 0; } .price-lines td:last-child { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar > input, .toolbar > select { width: auto; flex: 1 1 160px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.side { display: grid; gap: 16px; }
@media (min-width: 1100px) { .split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; } }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .d { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 74px; padding: 4px; font-size: .75rem; overflow: hidden; }
.cal .d.today { border-color: var(--primary); }
.cal .ev { background: var(--primary-soft); color: var(--primary); border-radius: 5px; padding: 1px 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.off { background: var(--warn-soft); color: var(--warn); } .cal .ev.bad { background: var(--danger-soft); color: var(--danger); }
details > summary { cursor: pointer; font-weight: 600; }
.gantt { display: grid; gap: 6px; }
.gantt .lane { display: grid; grid-template-columns: 150px 1fr; gap: 8px; align-items: center; }
.gantt .bar { position: relative; height: 34px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--line); overflow: hidden; }
.gantt .blk { position: absolute; top: 3px; bottom: 3px; border-radius: 6px; background: var(--primary); color: var(--on-primary); font-size: .7rem; padding: 2px 4px; overflow: hidden; white-space: nowrap; cursor: pointer; }
.gantt .blk.off { background: var(--warn); } .gantt .blk.bad { background: var(--danger); }
@media (max-width: 700px) { .gantt .lane { grid-template-columns: 1fr; } }
@media print { .topbar, .bottomnav, .toolbar, .pager, .btn, #offline { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
