/* Trang quản lý + trang tra cứu — dùng chung token với style.css */
body.admin, body.page-sub { padding-bottom: 0; background: var(--bg-soft); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .82rem; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn--danger { color: var(--err); border-color: #FECACA; }
.btn--danger:hover { background: #FEF2F2; }

/* Trạng thái */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; background: var(--bg-soft); color: var(--muted); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status--moi { background: #FEF3C7; color: #B45309; }
.status--da_xac_nhan { background: var(--blue-50); color: var(--blue); }
.status--dang_chay { background: #EDE9FE; color: #6D28D9; }
.status--hoan_thanh { background: #DCFCE7; color: #15803D; }
.status--da_huy { background: #F1F5F9; color: #64748B; }

.detail { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; margin: 0 0 16px; font-size: .94rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--blue), var(--blue-700)); }
.login__box { width: min(400px, 100%); padding: 32px 28px; text-align: center; }
.login__box .field { text-align: left; margin-top: 20px; }
.login__mark { margin: 0 auto 12px; width: 56px; height: 56px; font-size: 1.8rem; }
.login h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login .form-error { margin-bottom: 12px; text-align: left; }

/* ---------- Khung ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 24px; background: var(--blue); color: #fff; }
.topbar .brand__mark { width: 36px; height: 36px; }
.topbar__title { padding-left: 16px; border-left: 1px solid rgba(255, 255, 255, .25); font-weight: 600; opacity: .9; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; opacity: .9; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; animation: pulse 1.8s infinite; }
.live.is-off i { background: #F87171; animation: none; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 24px; }
.alert { margin-bottom: 16px; padding: 12px 16px; border-radius: 12px; background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; font-size: .92rem; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { padding: 16px 18px; border-radius: var(--r); background: #fff; border: 1px solid var(--line); }
.stat span { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat b { display: block; margin-top: 4px; font-size: 1.6rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat--warn b { color: #B45309; }
.stat--ok b { color: #15803D; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.toolbar__right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: #fff; border: 1px solid var(--line); overflow-x: auto; max-width: 100%; }
.seg button { flex: none; border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--blue); color: #fff; }
.seg i { font-style: normal; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, .07); font-size: .75rem; }
.seg button.on i { background: rgba(255, 255, 255, .2); }
.search { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: .9rem; width: 240px; }
.search--sel { width: auto; }
.search:focus { outline: none; border-color: var(--blue); }

/* không dùng overflow:hidden ở đây — nó làm tiêu đề dính (sticky) lệch xuống đè dòng đầu */
.table-card { box-shadow: none; }
.tbl th:first-child { border-top-left-radius: var(--r-lg); }
.tbl th:last-child { border-top-right-radius: var(--r-lg); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { position: sticky; top: 64px; z-index: 1; padding: 11px 12px; background: #F8FAFD; border-bottom: 1px solid var(--line); text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: #F8FAFD; }
.tbl tbody tr.is-new { animation: flash 2.4s ease; }
.tbl tbody tr.is-sel { background: var(--blue-50); }
@keyframes flash { 0%, 40% { background: #FEF3C7; } 100% { background: transparent; } }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .ma { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--blue); }
.tbl .sub { display: block; font-size: .8rem; color: var(--muted); }
.tbl .route { max-width: 340px; }
.tbl .route span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .route span::before { display: inline-block; width: 16px; font-weight: 800; }
.tbl .route .a::before { content: "A"; color: var(--ok); }
.tbl .route .b::before { content: "B"; color: var(--err); }
.tbl .soon { color: #B45309; font-weight: 700; }
.tbl .act { white-space: nowrap; text-align: right; }
.tbl .act .btn { min-height: 32px; padding: 0 10px; font-size: .82rem; }
.empty { padding: 40px; text-align: center; color: var(--muted); margin: 0; }

/* ---------- Bảng chi tiết ---------- */
.drawer { position: fixed; z-index: 80; top: 0; right: 0; bottom: 0; width: min(460px, 100%); display: flex; flex-direction: column; background: #fff; box-shadow: -20px 0 40px -20px rgba(0, 0, 0, .3); transform: translateX(100%); transition: transform .22s ease; }
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer__x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--bg-soft); font-size: 1.1rem; cursor: pointer; }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.dflow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.dflow button { min-height: 42px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; font-size: .88rem; cursor: pointer; }
.dflow button:hover { border-color: var(--blue); }
.dflow button.on { border-color: transparent; }
.dflow button.on.s-moi { background: #FEF3C7; color: #B45309; }
.dflow button.on.s-da_xac_nhan { background: var(--blue); color: #fff; }
.dflow button.on.s-dang_chay { background: #6D28D9; color: #fff; }
.dflow button.on.s-hoan_thanh { background: var(--ok); color: #fff; }
.dflow button.on.s-da_huy { background: #64748B; color: #fff; }
.dquick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.dh { font-size: .95rem; margin: 20px 0 8px; }
.hist { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.hist li { position: relative; padding: 0 0 12px 18px; color: var(--muted); }
.hist li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.hist li b { color: var(--ink); }
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(10, 30, 68, .35); }

/* ---------- Tra cứu đơn ---------- */
.page-sub .header__inner { justify-content: space-between; }
.header__back { min-height: 40px; }
.track { min-height: calc(100vh - var(--header-h)); }
.track__form { padding: 22px; margin-bottom: 20px; }
.track__form .form-error { margin-top: 12px; }
.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; font-size: .86rem; color: var(--muted); }
.track__result { padding: 22px; }
.track__head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.track__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.timeline { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 22px; padding: 0; counter-reset: b; }
.timeline li { position: relative; padding-top: 30px; text-align: center; font-size: .82rem; color: var(--muted); }
.timeline li::before { counter-increment: b; content: counter(b); position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 2px solid var(--line); font-weight: 800; font-size: .75rem; }
.timeline li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.timeline li:first-child::after { display: none; }
.timeline li b { display: block; color: inherit; }
.timeline li span { font-size: .74rem; }
.timeline li.done { color: var(--ink); }
.timeline li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.timeline li.done::after { background: var(--ok); }
.timeline li.now::before { box-shadow: 0 0 0 5px rgba(22, 163, 74, .18); }
.timeline li.is-cancel::before { content: "✕"; background: #64748B; border-color: #64748B; }
.timeline:has(.is-cancel) { grid-template-columns: 1fr 1fr; }

/* ---------- Mobile cho trang quản lý ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .toolbar__right { margin-left: 0; width: 100%; }
  .search { flex: 1; width: auto; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar__title, .live #liveText, #btnThongBao { display: none; }
  .wrap { padding: 14px 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat b { font-size: 1.3rem; }
  .toolbar__right { flex-wrap: wrap; }
  .table-card { background: none; border: 0; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { margin-bottom: 10px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
  .tbl td { padding: 3px 0; border: 0; }
  .tbl td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .8rem; }
  .tbl .r { text-align: left; }
  .tbl .route { max-width: none; }
  .tbl .act { text-align: left; padding-top: 8px; }
  .detail { grid-template-columns: 90px 1fr; }
  .timeline li b { font-size: .74rem; }
}

/* ---------- Nhãn phụ, cảnh báo, chia sẻ vị trí, ghi đơn ---------- */
.tag { display: inline-block; margin: 4px 4px 0 0; padding: 2px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); font-size: .74rem; font-weight: 700; white-space: nowrap; }
.tag--err { background: #FEE2E2; color: #B91C1C; }
.tag--warn { background: #FEF3C7; color: #B45309; }
.dwarn { margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; font-size: .88rem; font-weight: 600; }
.dwarn p { margin: 0; }
.dwarn p + p { margin-top: 6px; }
.share.is-on { background: #16A34A; border-color: #16A34A; color: #fff; }
.share.is-on::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.modal--form { width: min(560px, calc(100% - 24px)); }
.modal--form form { padding: 20px 20px 4px; max-height: calc(100dvh - 48px); overflow-y: auto; }
.modal--form h2 { font-size: 1.2rem; margin-bottom: 14px; }
.modal--form .field { margin-bottom: 10px; }
.modal--form .modal__actions { padding: 8px 0 16px; grid-template-columns: 1fr 1fr; }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 600; font-size: .92rem; }
.check input { width: 18px; height: 18px; }
@media (max-width: 760px) {
  #btnTaoDon { flex: 1 0 100%; min-height: 46px; font-size: 1rem; }
}

/* ---------- Tra cứu: tài xế đang tới ---------- */
.driver { margin-bottom: 14px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.driver__eta { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; background: var(--blue); color: #fff; }
.driver__eta b { font-size: 1.6rem; font-weight: 800; color: var(--yellow); white-space: nowrap; }
.driver__eta span { font-weight: 600; }
.driver__eta.is-wait { background: var(--bg-soft); color: var(--ink); }
.driver__eta.is-wait b { color: var(--blue); font-size: 1.1rem; }
.driver__row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.driver__av { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--yellow); font-size: 1.4rem; flex: none; }
.driver__who { flex: 1; min-width: 0; }
.driver__who b { display: block; }
.driver__who span { font-size: .86rem; color: var(--muted); font-family: ui-monospace, Consolas, monospace; letter-spacing: .03em; }
.track__map { height: 300px; margin-bottom: 18px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #E8EEF6; }
.car-mk { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); font-size: 1.3rem; }

/* ---------- Thanh chia sẻ vị trí (to, dễ bấm cho tài xế) ---------- */
.sharebar { display: flex; align-items: center; gap: 14px; width: 100%; margin-bottom: 16px; padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--r); background: #fff; text-align: left; cursor: pointer; }
.sharebar__ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--bg-soft); font-size: 1.3rem; flex: none; }
.sharebar__t { flex: 1; min-width: 0; }
.sharebar__t b { display: block; font-size: 1rem; }
.sharebar__t small { display: block; color: var(--muted); font-size: .82rem; }
.sharebar__sw { position: relative; width: 52px; height: 30px; border-radius: 999px; background: #CBD5E1; flex: none; transition: background .2s; }
.sharebar__sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.sharebar.is-on { border-color: #16A34A; background: #F0FDF4; }
.sharebar.is-on .sharebar__ic { background: #16A34A; animation: pulse 1.6s infinite; }
.sharebar.is-on .sharebar__sw { background: #16A34A; }
.sharebar.is-on .sharebar__sw::after { transform: translateX(22px); }
.track__again { width: 100%; margin: 4px 0 16px; }
@media (max-width: 760px) {
  .topbar .brand__text { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px; }
  .stat span { font-size: .7rem; line-height: 1.3; }
  .stat b { font-size: 1.05rem; }
}
.login__help { margin: 14px 0 0; font-size: .9rem; }

/* ---------- Thẻ bật thông báo đẩy ---------- */
.pushcard { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 14px 16px; border-radius: var(--r); background: #FFFBEB; border: 2px solid #FCD34D; }
.pushcard__ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--yellow); font-size: 1.3rem; flex: none; }
.pushcard__t { flex: 1; min-width: 0; }
.pushcard__t b { display: block; }
.pushcard__t small { display: block; color: #92400E; font-size: .84rem; }
.pushcard.is-on { background: #F0FDF4; border-color: #86EFAC; }
.pushcard.is-on .pushcard__ic { background: #16A34A; }
.pushcard.is-on .pushcard__t small { color: #166534; }
@media (max-width: 760px) { .pushcard { flex-wrap: wrap; } .pushcard .btn { width: 100%; min-height: 46px; } }

/* Phân trang + nút xóa đơn */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 14px; border-top: 1px solid var(--line); font-size: .88rem; color: var(--muted); }
.pager button[disabled] { opacity: .4; cursor: default; }
.btn--del { margin-top: 18px; width: 100%; background: #fff; color: #B91C1C; border: 1.5px solid #FCA5A5; }
.btn--del:hover { background: #FEF2F2; }
