:root {
  --bg: #f4f6f8; --card: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #0f766e; --brand-dark: #115e59; --brand-soft: #ccfbf1;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2; --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 12px; --nav-h: 60px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; }
h1 { font-size: 1.35rem; margin: 0 0 10px; } h2 { font-size: 1.1rem; margin: 18px 0 8px; } h3 { font-size: 1rem; margin: 12px 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .85rem; }
.big { font-size: 1.25rem; font-weight: 700; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.center { text-align: center; }

.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; padding-top: max(10px, env(safe-area-inset-top)); }
.logo { color: #fff; font-weight: 800; font-size: 1.1rem; }
.top-right { display: flex; gap: 10px; align-items: center; }
.top-right a { color: #fff; position: relative; font-size: 1.3rem; }
.badge-dot { position: absolute; top: -4px; right: -8px; background: #f59e0b; color: #111; border-radius: 10px; font-size: .7rem; font-weight: 700; padding: 0 5px; min-width: 16px; text-align: center; line-height: 16px; }
.top-right .who { font-size: .85rem; opacity: .95; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { max-width: 720px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + 24px); }
.loading { color: var(--muted); padding: 30px; text-align: center; }

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 20; }
.bottom-nav:empty { display: none; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: .72rem; gap: 2px; }
.bottom-nav a .ic { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--brand); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.card.clickable { cursor: pointer; } .card.clickable:active { background: #f9fafb; }
.card .title { font-weight: 700; font-size: 1.02rem; }
.route { font-weight: 800; font-size: 1.1rem; }
.route .arrow { color: var(--brand); margin: 0 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; min-height: 44px; text-align: center; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.lg { font-size: 1.1rem; min-height: 52px; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.warn { background: var(--warn); border-color: var(--warn); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.actions.inline { flex-direction: row; flex-wrap: wrap; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 4px; color: #374151; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; min-height: 44px; }
.field textarea { min-height: 80px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.check input { width: 22px; height: 22px; margin-top: 2px; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #e5e7eb; color: #374151; white-space: nowrap; }
.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(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); }

.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; border: 1px solid transparent; }
.banner.ok { background: var(--ok-soft); border-color: #86efac; } .banner.warn { background: var(--warn-soft); border-color: #fcd34d; }
.banner.bad { background: var(--bad-soft); border-color: #fca5a5; } .banner.info { background: var(--info-soft); border-color: #93c5fd; }
.banner.brand { background: var(--brand-soft); border-color: #5eead4; }
.banner .title { font-weight: 800; margin-bottom: 4px; }

.cap { height: 10px; background: #e5e7eb; border-radius: 6px; overflow: hidden; margin: 6px 0; }
.cap > div { height: 100%; background: var(--brand); }
.cap.full > div { background: var(--bad); }

.stops { list-style: none; padding: 0; margin: 8px 0; }
.stops li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; position: relative; }
.stops li .dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--brand); background: #fff; flex: none; margin-top: 5px; }
.stops li.arrived .dot { background: var(--ok); border-color: var(--ok); }
.stops li .stop-name { font-weight: 700; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 10px 12px; margin-left: 6px; }
.timeline li.hot { border-left-color: var(--bad); } .timeline li.good { border-left-color: var(--ok); } .timeline li.brand { border-left-color: var(--brand); }
.timeline .when { font-size: .78rem; color: var(--muted); }
.timeline img { max-width: 100%; border-radius: 8px; margin-top: 6px; max-height: 260px; }

.pkg { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.pkg .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 92vw; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: #fff; width: 100%; max-width: 720px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }

.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1 / 1; max-height: 60vh; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 15%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 200px rgba(0,0,0,.35); }
.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.scan-actions button { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 6px; font-weight: 700; min-height: 54px; }
.scan-actions button.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.result { border-radius: var(--radius); padding: 12px; margin-top: 10px; }
.result.ok { background: var(--ok-soft); } .result.bad { background: var(--bad-soft); } .result.warn { background: var(--warn-soft); }
.photo-preview { max-width: 100%; max-height: 200px; border-radius: 8px; display: block; margin-top: 6px; }
.stat { display: inline-block; margin-right: 12px; font-size: .85rem; color: var(--muted); }
.stat b { color: var(--text); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th, table.tbl td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll-x { overflow-x: auto; }
.empty { color: var(--muted); text-align: center; padding: 24px 10px; }
@media (min-width: 640px) { .actions { flex-direction: row; flex-wrap: wrap; } .actions .btn { flex: 1; } }

/* ---------- dòng lộ trình nằm ngang ---------- */
.tl { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 0 2px; }
.tl-track { display: flex; align-items: flex-start; min-width: max-content; padding: 0 4px; }
.tl-node { width: 128px; flex: none; text-align: center; position: relative; }
.tl-node.act { cursor: pointer; } .tl-node.act:active { opacity: .7; }
.tl-node .ic { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 30px; line-height: 1; position: relative; z-index: 1; }
.tl-node .ic .pin { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 3px solid #cbd5e1; align-items: center; justify-content: center; font-size: 15px; }
.tl-node.done .ic .pin { border-color: var(--ok); background: var(--ok-soft); }
.tl-node.target .ic .pin { border-color: var(--warn); background: var(--warn-soft); }
.tl-node.end .ic .pin { border-color: #111827; }
.tl-node.finished .ic .pin { border-color: var(--ok); background: var(--ok-soft); }
.tl-node .lbl { font-weight: 800; font-size: .88rem; margin-top: 2px; line-height: 1.2; }
.tl-node .sub { font-size: .74rem; color: var(--muted); line-height: 1.3; padding: 0 4px; }
.tl-node .sub.addr { color: #374151; }
.tl-node .sub.ok { color: var(--ok); font-weight: 700; }
.tl-node .tap { font-size: .68rem; color: var(--brand); margin-top: 2px; }
.tl-seg { flex: 1; min-width: 34px; height: 44px; position: relative; }
.tl-seg::before { content: ''; position: absolute; left: -34px; right: -34px; top: 21px; height: 3px; background: repeating-linear-gradient(90deg, #cbd5e1 0 10px, transparent 10px 18px); }
.tl-seg.done::before { background: var(--ok); }
.tl-seg.active::before { background: repeating-linear-gradient(90deg, var(--brand) 0 12px, transparent 12px 20px); animation: tl-march 0.9s linear infinite; }
@keyframes tl-march { from { background-position: 0 0; } to { background-position: 20px 0; } }
.tl-truck { display: inline-block; font-size: 32px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); transform: scaleX(-1); }
.tl-truck.moving { animation: tl-bob 0.6s ease-in-out infinite; }
@keyframes tl-bob { 0%, 100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-3px); } }
.tl.compact .tl-node { width: 96px; }
.tl.compact .tl-node .ic { height: 36px; font-size: 24px; }
.tl.compact .tl-truck { font-size: 26px; }
.tl.compact .tl-node .ic .pin { width: 24px; height: 24px; font-size: 12px; border-width: 2px; }
.tl.compact .tl-seg { height: 36px; min-width: 20px; } .tl.compact .tl-seg::before { top: 17px; left: -26px; right: -26px; }
.tl.compact .tl-node .lbl { font-size: .8rem; } .tl.compact .tl-node .sub { font-size: .68rem; }
.tl-next { margin-top: 8px; }
.info-list div { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.info-list div b { display: inline-block; min-width: 110px; color: #374151; }

/* ---------- bảng 10 chỗ xe máy ---------- */
.slot { border-left: 5px solid #cbd5e1; }
.slot.available { border-left-color: var(--ok); }
.slot.busy { border-left-color: var(--warn); }
.slot.off { opacity: .8; }
.slot.empty { border-style: dashed; background: transparent; }
.tl-node.ret .ic .pin { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; }
.tl-seg.return::before { background: repeating-linear-gradient(90deg, #99f6e4 0 6px, transparent 6px 12px); }
.tl-seg.return.active::before { background: repeating-linear-gradient(90deg, var(--brand) 0 12px, transparent 12px 20px); animation: tl-march 0.9s linear infinite; }

/* ---------- ghim vị trí Google Maps ---------- */
.loc { margin-bottom: 12px; }
.loc-tools { margin-bottom: 6px; }
.loc-map { position: relative; margin-top: 6px; }
.loc-map iframe { width: 100%; height: 180px; border: 1px solid var(--line); border-radius: 10px; display: block; }
.loc-map .loc-clear { position: absolute; right: 8px; top: 8px; background: #fff; }
.pac-container { z-index: 60; font-family: inherit; }

/* ---------- khai hàng bằng ảnh + danh mục ---------- */
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.quick button { border: 1px solid var(--brand); background: #fff; color: var(--brand-dark); border-radius: 999px; padding: 8px 12px; font-weight: 600; font-size: .9rem; min-height: 40px; }
.quick button:active { background: var(--brand-soft); }
.p-photo-box { width: 84px; height: 84px; flex: none; border: 2px dashed #cbd5e1; border-radius: 10px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .78rem; color: var(--muted); cursor: pointer; overflow: hidden; background: #f9fafb; line-height: 1.15; }
.p-photo-box img { width: 100%; height: 100%; object-fit: cover; }
.p-sizes button { padding: 5px 10px; font-size: .82rem; }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.thumb.ph { display: flex; align-items: center; justify-content: center; background: #f3f4f6; font-size: 24px; }
.lot-photo { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin: 6px 0; display: block; }
.pkg { align-items: center; }
.card.dim { opacity: .6; }

/* ---------- hai vai trò, hai màu: chủ hàng xanh ngọc, chủ xe cam ---------- */
body.role-driver { --brand: #c2410c; --brand-dark: #9a3412; --brand-soft: #ffedd5; }
body.role-admin { --brand: #4338ca; --brand-dark: #312e81; --brand-soft: #e0e7ff; }
.role-chip { background: rgba(255,255,255,.22); color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 999px; padding: 2px 9px; font-size: .72rem; font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.role-chip.big-chip { background: var(--brand); border-color: var(--brand); font-size: .8rem; padding: 4px 12px; }
.role-card { border-left: 6px solid var(--brand); }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.role-pick button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text); min-height: 110px; }
.role-pick button .ic { font-size: 30px; line-height: 1; }
.role-pick button .small { color: var(--muted); text-align: center; line-height: 1.2; }
.role-pick button.active { border-color: var(--brand); background: var(--brand-soft); }
.role-pick button.active b { color: var(--brand-dark); }

/* ---------- nút Góp ý nổi ---------- */
.fab { position: fixed; right: 12px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 30; background: #fff; color: var(--brand-dark); border: 2px solid var(--brand); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: .9rem; box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer; }
.fab:active { background: var(--brand-soft); }
.fab.install { right: auto; left: 12px; background: var(--brand); color: #fff; }

/* chế độ chụp ảnh cửa hàng: ?shot=1 ẩn nút nổi */
.shot .fab, .shot .toast { display: none !important; }
