/* Fun Work · Hệ thống quản lý — bản mẫu
   Nguyên tắc: sáng, đơn giản, chữ lớn, nút to (≥ 48px), dùng một tay trên điện thoại. */

:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F2F4F7;
  --line: #E4E7EC;
  --line-2: #D0D5DD;
  --ink: #101828;
  --text: #1D2939;
  --muted: #667085;
  --faint: #98A2B3;

  --brand: #E1251B;          /* đỏ VU Cargo — chỉ dùng làm điểm nhấn thương hiệu */
  --yellow: #F6BE00;         /* vàng VU Cargo — nút Quét */

  --ok: #067647;   --ok-bg: #ECFDF3;   --ok-line: #ABEFC6;
  --warn: #B54708; --warn-bg: #FFFAEB; --warn-line: #FEDF89;
  --bad: #B42318;  --bad-bg: #FEF3F2;  --bad-line: #FECDCA;
  --info: #175CD3; --info-bg: #EFF8FF; --info-line: #B2DDFF;
  --tm: #6941C6;   --tm-bg: #F4F3FF;   --tm-line: #D9D6FE;
  --vc: #0E7090;   --vc-bg: #ECFDFF;   --vc-line: #A5F0FC;

  --r: 14px;
  --r-sm: 10px;
  --r-lg: 20px;
  --sh: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-lg: 0 16px 40px -12px rgba(16, 24, 40, .25);
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #E7E9EE;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.lg { width: 26px; height: 26px; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; background: var(--bg); position: relative; box-shadow: 0 0 0 1px var(--line); }
@media (max-width: 560px) { body { background: var(--bg); } .app { box-shadow: none; } }

/* ---------- Thanh trên ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 58px; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 8px; background: rgba(255,255,255,.94); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { flex: 1; min-width: 0; margin: 0 0 0 4px; font-size: 18px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandmark { display: flex; align-items: center; gap: 8px; margin-left: 6px; flex: 1; min-width: 0; }
.brandmark .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.02em; }
.brandmark b { font-size: 16px; font-weight: 800; color: var(--ink); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:active { background: var(--surface-2); }
.role-chip { display: flex; align-items: center; gap: 8px; max-width: 46%; height: 40px; padding: 0 12px 0 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink); }
.role-chip span.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 12px; font-weight: 800; color: #fff; background: var(--ink); }
.avatar.de { background: #344054; }
.avatar.vn { background: var(--brand); }
.demo-strip { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 12px; font-weight: 600; color: #7A5A00; background: #FFF8DB; border-bottom: 1px solid #F5E3A3; }

main { padding: 16px 16px calc(var(--nav-h) + 36px + var(--safe-b)); outline: none; }
main.has-sticky { padding-bottom: calc(var(--nav-h) + 120px + var(--safe-b)); }

/* ---------- Khối cơ bản ---------- */
.hello { margin: 2px 2px 14px; }
.hello h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.hello p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.section-title:first-child { margin-top: 2px; }
.section-title a, .section-title button { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 700; color: var(--info); text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--sh); }
.card + .card { margin-top: 10px; }
.card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; color: var(--ink); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.top { align-items: flex-start; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.strong { font-weight: 800; color: var(--ink); }
.nowrap { white-space: nowrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { font-family: var(--mono); font-weight: 700; letter-spacing: .02em; color: var(--ink); }
.num { font-variant-numeric: tabular-nums; }
.mt0 { margin-top: 0 !important; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; border: 0; }
.hidden { display: none !important; }

/* KPI & lối tắt */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { display: block; width: 100%; padding: 12px 14px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); cursor: pointer; }
.kpi .v { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .v small { font-size: 14px; font-weight: 700; color: var(--muted); margin-left: 2px; }
.kpi .l { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi.bad { border-color: var(--bad-line); background: var(--bad-bg); } .kpi.bad .v { color: var(--bad); }
.kpi.warn { border-color: var(--warn-line); background: var(--warn-bg); } .kpi.warn .v { color: var(--warn); }
.kpi.ok .v { color: var(--ok); }
.actions-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); font-size: 13px; font-weight: 700; color: var(--ink); text-align: center; cursor: pointer; line-height: 1.25; }
.action .ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); }
.action.primary .ic { background: var(--ink); color: #fff; }
.action:active, .kpi:active, .item:active { transform: scale(.99); }

a.kpi, a.action, a.chip { text-decoration: none; color: inherit; }
.legend i { font-style: normal; }
.search-wrap { position: relative; }
.search-wrap .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search-wrap .input { padding-left: 44px; }
.ex-btn { width: 100%; background: none; border: 0; text-align: left; cursor: pointer; padding-left: 0; padding-right: 0; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid #D6BBFB; border-top-color: #6941C6; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 14px; margin-bottom: 12px; }
.tabs a { flex: 1; height: 40px; display: grid; place-items: center; border-radius: 10px; font-size: 13px; font-weight: 800; color: var(--muted); text-decoration: none; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.big-code { font-family: var(--mono); font-size: 30px; font-weight: 800; letter-spacing: .03em; color: var(--ink); line-height: 1.1; }
.diffbox { margin-top: 10px; padding: 12px 14px; border-radius: 13px; font-weight: 700; font-size: 15px; }
.diffbox.ok { background: var(--ok-bg); color: var(--ok); }
.diffbox.bad { background: var(--bad-bg); color: var(--bad); }
.diffbox.idle { background: var(--surface-2); color: var(--muted); }
.bc-mini { display: block; width: 100%; max-width: 260px; height: 46px; margin-top: 8px; }
a.action { color: var(--ink); }
.legend .lvl { margin-right: 2px; }

/* Danh sách */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh); }
.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; text-decoration: none; }
.item:first-child { border-top: 0; }
.item .t { font-weight: 700; color: var(--ink); }
.item .s { font-size: 13px; color: var(--muted); margin-top: 1px; }
.item .chev { color: var(--faint); }
.item.static { cursor: default; }
.ic-box { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink); flex: none; }

/* Huy hiệu trạng thái */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge.tm { background: var(--tm-bg); color: var(--tm); border-color: var(--tm-line); }
.badge.vc { background: var(--vc-bg); color: var(--vc); border-color: var(--vc-line); }
.badge.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge.lg { height: 30px; padding: 0 12px; font-size: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 18px; border: 1px solid transparent; border-radius: 13px; font-size: 16px; font-weight: 800; cursor: pointer; user-select: none; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.ok { background: #079455; color: #fff; }
.btn.danger { background: #D92D20; color: #fff; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.soft { background: var(--surface-2); color: var(--ink); }
.btn.yellow { background: var(--yellow); color: var(--ink); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; font-weight: 700; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.link-btn { border: 0; background: none; padding: 0; color: var(--info); font-weight: 700; cursor: pointer; font-size: 14px; }

/* Biểu mẫu */
.field { display: block; margin-top: 16px; }
.field:first-child { margin-top: 0; }
.label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.label .req { color: var(--bad); }
.input { width: 100%; height: 54px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 13px; background: #fff; color: var(--ink); font: inherit; font-size: 17px; font-weight: 600; outline: none; -webkit-appearance: none; appearance: none; }
textarea.input { height: auto; min-height: 84px; padding: 12px 14px; line-height: 1.4; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 42px; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(16, 24, 40, .08); }
.input.big { height: 64px; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.input.code { font-family: var(--mono); letter-spacing: .04em; }
.input.err { border-color: var(--bad); box-shadow: 0 0 0 4px rgba(217, 45, 32, .1); }
.input.lowconf { border-color: #F79009; background: var(--warn-bg); }
.input::placeholder { color: var(--faint); font-weight: 500; }
.input-wrap { position: relative; }
.input-wrap .suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 800; pointer-events: none; }
.input-wrap .input { padding-right: 52px; }
.input-action { display: flex; gap: 8px; }
.input-action .input { flex: 1; min-width: 0; }
.input-action .btn { height: 54px; flex: none; }
.hint { margin: 6px 2px 0; font-size: 13px; color: var(--muted); }
.hint.err { color: var(--bad); font-weight: 600; }
.hint.warn { color: var(--warn); font-weight: 600; }
.dims { display: grid; grid-template-columns: 1fr 18px 1fr 18px 1fr; gap: 4px; align-items: center; }
.dims .x { text-align: center; color: var(--faint); font-weight: 800; }
.dims .input { text-align: center; padding: 0 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 15px; }
.seg button { height: 46px; padding: 0 6px; border: 0; border-radius: 11px; background: transparent; font-size: 14px; font-weight: 800; color: var(--muted); cursor: pointer; line-height: 1.15; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.seg.kind button { height: 60px; font-size: 22px; letter-spacing: .02em; }
.seg.kind button small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0; opacity: .85; }
.seg.kind button.on[data-v="TM"] { background: var(--tm); color: #fff; }
.seg.kind button.on[data-v="VC"] { background: var(--vc); color: #fff; }
.seg.wrap2 { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: #fff; font-size: 14px; font-weight: 700; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.hold.on { background: #D92D20; border-color: #D92D20; }
.chip .n { font-size: 12px; opacity: .75; }
.filters { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: none; height: 36px; }
.radio-card { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 13px; background: #fff; text-align: left; cursor: pointer; }
.radio-card + .radio-card { margin-top: 8px; }
.radio-card .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; margin-top: 1px; display: grid; place-items: center; }
.radio-card.on { border-color: var(--ink); background: #FCFCFD; }
.radio-card.on .dot { border-color: var(--ink); }
.radio-card.on .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }

/* Ảnh */
.photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px; text-align: center; font-size: 11px; line-height: 1.2; font-weight: 700; color: var(--muted); cursor: pointer; overflow: hidden; }
.photo.filled { border: 0; padding: 0; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 4px; font-size: 10px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.6)); }

/* Thông báo */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); font-size: 14px; }
.alert .i { margin-top: 1px; }
.alert b { color: inherit; }
.alert.bad { background: var(--bad-bg); border-color: var(--bad-line); color: #912018; }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #93370D; }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #085D3A; }
.alert.info { background: var(--info-bg); border-color: var(--info-line); color: #1849A9; }
.hold-banner { border-radius: var(--r); padding: 14px; background: #D92D20; color: #fff; }
.hold-banner .h { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; }
.hold-banner p { margin: 6px 0 0; font-size: 14px; opacity: .95; }

/* Bảng thông số */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 10px; border-radius: 12px; background: var(--surface-2); }
.stat .v { font-size: 19px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; font-weight: 600; color: var(--muted); }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }

/* Timeline hành trình */
.timeline { position: relative; margin: 2px 0 0 4px; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 10px; width: 2px; background: var(--line); }
.tl { position: relative; padding-bottom: 14px; }
.tl:last-child { padding-bottom: 0; }
.tl::before { content: ""; position: absolute; left: -23px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--line-2); box-sizing: border-box; }
.tl.done::before { background: #12B76A; border-color: #12B76A; }
.tl.now::before { background: var(--ink); border-color: var(--ink); box-shadow: 0 0 0 4px rgba(16,24,40,.12); }
.tl.hold::before { background: #D92D20; border-color: #D92D20; box-shadow: 0 0 0 4px rgba(217,45,32,.15); }
.tl .tt { font-weight: 700; color: var(--ink); font-size: 14px; }
.tl .tm { font-size: 12px; color: var(--muted); }
.tl.future .tt { color: var(--faint); font-weight: 600; }

/* Các bước của lô */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; font-weight: 600; color: var(--faint); }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); background: #fff; display: grid; place-items: center; flex: none; }
.steps li.done { color: var(--text); }
.steps li.done .dot { background: #12B76A; border-color: #12B76A; color: #fff; }
.steps li.now { color: var(--ink); font-weight: 800; }
.steps li.now .dot { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(16,24,40,.1); }
.steps li.now .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }

/* 4 chốt tạo tem */
.gate { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.gate:first-child { border-top: 0; padding-top: 2px; }
.gate .st { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; }
.gate.ok .st { background: var(--ok-bg); color: var(--ok); }
.gate.no .st { background: var(--bad-bg); color: var(--bad); }
.gate.wait .st { background: var(--surface-2); color: var(--muted); }
.gate .gt { font-weight: 800; color: var(--ink); }
.gate .gd { font-size: 13px; color: var(--muted); margin-top: 2px; }
.gate.no .gd { color: var(--bad); font-weight: 600; }

/* Agent */
.agent-card { border: 1px solid #D6BBFB; background: linear-gradient(180deg, #FAF5FF, #fff 60%); }
.agent-head { display: flex; align-items: center; gap: 10px; }
.agent-head .ic-box { background: #6941C6; color: #fff; }
.conf { display: inline-block; min-width: 40px; padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 800; text-align: center; }
.conf.hi { background: var(--ok-bg); color: var(--ok); }
.conf.lo { background: #FEF0C7; color: var(--warn); }
.ex-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.ex-row:first-child { border-top: 0; }
.ex-row .k { width: 92px; flex: none; color: var(--muted); font-weight: 700; font-size: 13px; }
.ex-row .v { flex: 1; min-width: 0; font-weight: 700; color: var(--ink); }

/* Quét mã */
.scan-view { position: relative; height: 210px; border-radius: 18px; background: #0B0F17; overflow: hidden; display: grid; place-items: center; color: #98A2B3; font-size: 13px; font-weight: 600; }
.scan-view .frame { position: absolute; inset: 36px 44px; border: 2px solid rgba(255,255,255,.55); border-radius: 14px; }
.scan-view .laser { position: absolute; left: 52px; right: 52px; top: 44px; height: 2px; background: #F04438; box-shadow: 0 0 14px #F04438; animation: laser 1.5s ease-in-out infinite alternate; }
.scan-view .txt { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; }
@keyframes laser { from { top: 44px; } to { top: 164px; } }
.pick-list .item { padding: 10px 12px; }

/* Thanh điều hướng dưới */
.nav { position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 560px; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255,255,255,.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--faint); text-decoration: none; cursor: pointer; }
.nav a.on { color: var(--ink); }
.nav a.fab .b { width: 60px; height: 60px; margin-top: -28px; border-radius: 19px; display: grid; place-items: center; background: var(--yellow); color: var(--ink); box-shadow: 0 10px 22px -8px rgba(181, 140, 0, .9), 0 0 0 5px #fff; }
.nav a.fab { color: var(--ink); }

/* Thanh nút dính đáy */
.sticky-actions { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b)); width: 100%; max-width: 560px; padding: 14px 16px 12px; display: flex; gap: 10px; background: linear-gradient(180deg, rgba(244,245,247,0), var(--bg) 26%); }
.sticky-actions .btn { flex: 1; }

/* Bảng trượt từ dưới */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(16, 24, 40, .45); animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 560px; max-height: 90dvh; overflow: auto; padding: 8px 16px calc(20px + var(--safe-b)); background: #fff; border-radius: 22px 22px 0 0; animation: up .22s ease-out; overscroll-behavior: contain; }
.sheet .handle { width: 42px; height: 5px; margin: 4px auto 12px; border-radius: 3px; background: var(--line-2); }
.sheet h2 { margin: 2px 0 4px; font-size: 19px; font-weight: 800; color: var(--ink); }
.sheet .sub { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Thông báo nhanh */
.toast { position: fixed; z-index: 70; left: 50%; bottom: calc(var(--nav-h) + 20px + var(--safe-b)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 13px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 700; box-shadow: var(--sh-lg); animation: up .2s ease-out; }
.toast.bad { background: #B42318; }
.toast.ok { background: #067647; }

/* Ma trận quyền */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
table.matrix { border-collapse: separate; border-spacing: 0; min-width: 780px; width: 100%; font-size: 12.5px; }
table.matrix th, table.matrix td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; }
table.matrix th:first-child, table.matrix td:first-child { position: sticky; left: 0; z-index: 1; min-width: 168px; text-align: left; background: #fff; border-right: 1px solid var(--line); font-weight: 600; color: var(--ink); }
table.matrix thead th { background: var(--surface-2); font-size: 11.5px; font-weight: 800; color: var(--ink); vertical-align: bottom; line-height: 1.2; }
table.matrix thead th:first-child { background: var(--surface-2); }
table.matrix .me { background: #FFF8DB !important; }
table.matrix tr.hard td { background: #FEF3F2; }
table.matrix tr.hard td:first-child { background: #FEF3F2; color: var(--bad); font-weight: 800; }
.lvl { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 4px; border-radius: 6px; font-size: 12px; font-weight: 800; }
.lvl.D { background: var(--ink); color: #fff; }
.lvl.S { background: var(--info-bg); color: var(--info); }
.lvl.X { background: var(--surface-2); color: var(--muted); }
.lvl.R { background: var(--warn-bg); color: var(--warn); }
.lvl.N { color: var(--line-2); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Tem in sẵn */
.label-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.lbl { display: flex; flex-direction: column; gap: 3px; padding: 7px 9px 8px; border: 1.5px solid #111; border-radius: 8px; background: #fff; color: #000; font-size: 10px; line-height: 1.2; overflow: hidden; }
.lbl .top { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 9px; letter-spacing: .04em; }
.lbl .top .wh { background: #000; color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.lbl .lc { font-family: var(--mono); font-size: 18px; font-weight: 800; letter-spacing: .03em; text-align: center; line-height: 1.1; }
.lbl .bc { display: block; width: 100%; height: 34px; }
.lbl .f { display: flex; align-items: flex-end; gap: 4px; font-weight: 800; font-size: 11px; }
.lbl .f .ln { flex: 1; border-bottom: 1.2px solid #000; height: 13px; }
.lbl .f .u { font-weight: 600; font-size: 9px; }
.lbl .tmvc { display: flex; gap: 10px; justify-content: center; margin-top: 2px; font-weight: 800; font-size: 13px; }
.lbl .tmvc span { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 22px; border: 1.5px solid #000; border-radius: 50%; }

/* Bản mẫu "sắp có" */
.soon { opacity: .75; }
.empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.empty .ic-box { margin: 0 auto 10px; width: 52px; height: 52px; border-radius: 16px; }

@media (min-width: 420px) {
  .photos { gap: 10px; }
}

@media print {
  @page { size: A4; margin: 8mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 194mm; }
  .label-sheet { grid-template-columns: repeat(2, 95mm); gap: 4mm; }
  .lbl { height: 66mm; break-inside: avoid; border-radius: 3mm; padding: 3mm 4mm; font-size: 3.2mm; }
  .lbl .lc { font-size: 7mm; }
  .lbl .bc { height: 14mm; }
  .lbl .f { font-size: 4mm; }
  .lbl .f .ln { height: 6mm; }
  .lbl .tmvc { font-size: 5mm; }
  .lbl .tmvc span { width: 16mm; height: 8mm; }
}

/* ---------- Camera quét mã ---------- */
.cam-box { position: relative; aspect-ratio: 4 / 3; max-height: 52dvh; width: 100%; border-radius: 18px; background: #0B0F17; overflow: hidden; }
.cam-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-frame { position: absolute; left: 8%; right: 8%; top: 30%; bottom: 30%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.28); }
.cam-msg { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.6); padding: 0 12px; }
.cam-log { margin-top: 10px; max-height: 26dvh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.cam-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.cam-row.ok { background: var(--ok-bg); color: var(--ok); }
.cam-row.bad { background: var(--bad-bg); color: var(--bad); }
.cam-row span { color: var(--text); font-weight: 600; }
.ai-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; background: #F4EBFF; color: #6941C6; }
.ai-pill.sim { background: var(--surface-2); color: var(--muted); }

/* ---------- Tem 1/8 A4 (105 × 74,25 mm) ---------- */
.tem { width: 105mm; height: 74.25mm; box-sizing: border-box; padding: 4mm 5mm 3.5mm; display: flex; flex-direction: column; gap: 1.4mm; background: #fff; color: #000; font-family: "Be Vietnam Pro", system-ui, sans-serif; overflow: hidden; outline: .2mm dashed #c8c8c8; outline-offset: -.1mm; }
.tem .t1 { display: flex; justify-content: space-between; align-items: center; font-size: 3mm; font-weight: 800; letter-spacing: .03em; }
.tem .t1 .wh { background: #000; color: #fff; padding: .5mm 2.2mm; border-radius: 1mm; font-size: 3.4mm; }
.tem svg.bc { display: block; width: 100%; height: 15mm; }
.tem .cd { text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 800; font-size: 7.2mm; line-height: 1; letter-spacing: .05em; }
.tem .rw { display: flex; gap: 3mm; align-items: flex-end; font-weight: 800; font-size: 4.4mm; }
.tem .rw .f { display: flex; align-items: flex-end; gap: 1.4mm; flex: 1; min-width: 0; }
.tem .rw .ln { flex: 1; border-bottom: .35mm solid #000; height: 6.5mm; }
.tem .rw .u { font-size: 3mm; font-weight: 600; }
.tem .ck { display: flex; gap: 5mm; align-items: center; font-weight: 800; font-size: 4.6mm; }
.tem .ck .o { display: inline-flex; align-items: center; justify-content: center; width: 15mm; height: 7.5mm; border: .45mm solid #000; border-radius: 50%; }
.tem .ck .nt { flex: 1; display: flex; align-items: flex-end; gap: 1.4mm; font-size: 3.2mm; font-weight: 700; }
.tem-sheet { width: 210mm; display: grid; grid-template-columns: 105mm 105mm; grid-auto-rows: 74.25mm; background: #fff; }
.tem-preview { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
@media screen { .tem-preview .tem-sheet { zoom: var(--z, .44); } .tem-preview.one .tem { zoom: var(--z1, .85); } }
@media print {
  .print-area.tem-print { width: 210mm; }
  .print-area.tem-print.thermal { width: 105mm; }
  .tem-print .tem { outline: none; }
  .tem-print .tem-sheet { break-after: page; }
  .tem-print.thermal .tem { break-after: page; }
}

#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block !important; }
  body.printing #print-root.print-area { position: static; width: auto; }
  body.printing { background: #fff; }
}

/* ---------- Chạy thật: đăng nhập PIN, màn chụp liên tục ---------- */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 8px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; margin-top: 12px; }
.pin-pad button { height: 64px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-size: 24px; font-weight: 800; color: var(--ink); cursor: pointer; }
.pin-pad button:active { background: var(--surface-2); }
.cap-cam { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 56dvh; border-radius: 18px; overflow: hidden; background: #0B0F17; }
.cap-cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cap-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cap-flash.go { animation: capflash .25s ease-out; }
@keyframes capflash { from { opacity: .8; } to { opacity: 0; } }
.cap-bar { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.cap-shot { width: 76px; height: 76px; flex: none; border-radius: 50%; border: 5px solid var(--ink); background: var(--yellow); color: var(--ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 16px -6px rgba(0,0,0,.4); }
.cap-shot:active { transform: scale(.94); }
.cap-strip { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; min-height: 8px; scrollbar-width: none; }
.cap-strip img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: none; }
.cap-save { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); min-height: 20px; }
.cap-save:empty { display: none; }

/* ---------- Phần 4 (17/10/2026): trang chủ theo nghiệp vụ key + bố cục máy tính ----------
   Kho B/F/H + CEO: giao diện điện thoại ở mọi cỡ màn hình.
   Vai trò ưu tiên máy tính (body.role-desk): từ 1024px có menu trái, nội dung rộng; nhỏ hơn vẫn là giao diện điện thoại. */
.side { display: none; }
.home { display: grid; gap: 18px; }
.home > section > .section-title:first-child { margin-top: 0; }
.task-n { display: inline-grid; place-items: center; min-width: 38px; height: 32px; padding: 0 10px; box-sizing: border-box; border-radius: 10px; background: var(--surface-2); color: var(--ink); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.task-n.bad { background: var(--bad-bg); color: var(--bad); }
.task-n.warn { background: var(--warn-bg); color: var(--warn); }
.task-n.ok { background: var(--ok-bg); color: var(--ok); }
.task-n.zero { background: transparent; color: var(--faint); font-weight: 700; }
.item.task.later .t { color: var(--muted); }
.list.alerts .ic-box { background: var(--bad-bg); color: var(--bad); }

@media (min-width: 1024px) {
  body.role-desk .app { max-width: none; display: grid; grid-template-columns: 264px minmax(0, 1fr); grid-template-rows: auto auto 1fr; box-shadow: none; }
  body.role-desk .side { display: flex; flex-direction: column; grid-column: 1; grid-row: 1 / span 3; align-self: start; position: sticky; top: 0; height: 100dvh; overflow-y: auto; padding: 16px 12px 24px; box-sizing: border-box; background: var(--surface); border-right: 1px solid var(--line); }
  body.role-desk .topbar, body.role-desk .demo-strip, body.role-desk main { grid-column: 2; }
  body.role-desk .topbar { padding: 0 24px; }
  body.role-desk .topbar .role-chip, body.role-desk .topbar .brandmark .logo { display: none; }
  body.role-desk .nav { display: none; }
  body.role-desk main { width: 100%; max-width: 960px; box-sizing: border-box; padding: 24px 32px 56px; }
  body.role-desk main.wide { max-width: 1280px; }
  body.role-desk main.has-sticky { padding-bottom: 128px; }
  body.role-desk .sticky-actions { left: 264px; transform: none; bottom: 0; width: min(960px, calc(100vw - 264px)); max-width: none; padding: 14px 32px 16px; box-sizing: border-box; }
  body.role-desk .toast { left: calc(264px + (100vw - 264px) / 2); bottom: 28px; }
  body.role-desk .sheet-backdrop { align-items: center; }
  body.role-desk .sheet { max-width: 620px; max-height: 86dvh; border-radius: 20px; padding-bottom: 20px; }
  body.role-desk .sheet .handle { display: none; }
  body.role-desk .kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  body.role-desk .actions-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  body.role-desk .home { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; gap: 22px 24px; }
  body.role-desk .home > section { grid-column: 1 / -1; }
  body.role-desk .home > .h-tasks { grid-column: 1; }
  body.role-desk .home > .h-alerts { grid-column: 2; }
  body.role-desk .home.no-alerts > .h-tasks { grid-column: 1 / -1; }
  /* Menu trái */
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
  .side-brand .logo { width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: -.02em; }
  .side-brand b, .side-role b { display: block; font-size: 15px; font-weight: 800; color: var(--ink); }
  .side-brand span, .side-role .grow span { display: block; font-size: 12px; color: var(--muted); }
  .side-role { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); text-align: left; cursor: pointer; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a, .side-scan { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; text-align: left; cursor: pointer; box-sizing: border-box; }
  .side-nav a:hover, .side-scan:hover { background: var(--surface-2); }
  .side-nav a.on { background: var(--ink); color: #fff; }
  .side-nav a.on .badge { background: rgba(255, 255, 255, .16); color: #fff; border-color: transparent; }
  .side-sec { margin: 14px 10px 4px; font-size: 11px; font-weight: 800; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
  .side-sec:empty { margin: 10px; border-top: 1px solid var(--line); }
}
@media print {
  .side { display: none !important; }
  body.role-desk .app { display: block !important; }
}
/* Thẻ duyệt thanh toán: nút Từ chối / Duyệt xuống dòng trên điện thoại hẹp (sửa tràn ngang ở 390px, 17/10) */
.pay-actions { flex-wrap: wrap; row-gap: 8px; }
.pay-actions > .row { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Phần 5 (17/10/2026): CEO — lưới phân hệ + kiểu gọn trên điện thoại ---------- */
.mod-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .mod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mod-card { display: block; min-width: 0; padding: 10px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); color: var(--ink); text-decoration: none; }
.mod-card.later { opacity: .75; }
.mod-head { display: flex; align-items: center; gap: 6px; min-height: 24px; font-size: 13.5px; font-weight: 800; line-height: 1.2; }
.mod-head .grow { min-width: 0; }
.mod-head .chev { color: var(--faint); }
.mod-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.mod-stats .ms { min-width: 0; }
.mod-stats .ms b { display: block; font-size: 18px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mod-stats .ms b small { margin-left: 1px; font-size: 11px; font-weight: 700; color: var(--muted); }
.mod-stats .ms span { display: block; margin-top: 2px; font-size: 12px; line-height: 1.2; color: var(--muted); }
.mod-stats .ms.bad b { color: var(--bad); }
.mod-stats .ms.warn b { color: var(--warn); }
.mod-stats .ms.ok b { color: var(--ok); }

/* CEO trên điện thoại: gọn hơn kho để xem nhiều thông tin trên một màn hình (chữ ≥ 12px, vùng bấm ≥ 44px) */
@media (max-width: 1023.98px) {
  body.role-ceo main { padding-top: 12px; padding-left: 12px; padding-right: 12px; }
  body.role-ceo .hello { margin: 0 2px 8px; }
  body.role-ceo .hello h2 { font-size: 19px; }
  body.role-ceo .hello p { font-size: 13px; }
  body.role-ceo .home { gap: 10px; }
  body.role-ceo .section-title { margin: 12px 2px 6px; font-size: 12px; }
  body.role-ceo .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  body.role-ceo .kpi { padding: 8px 9px; }
  body.role-ceo .kpi .v { font-size: 20px; }
  body.role-ceo .kpi .v small { font-size: 11px; }
  body.role-ceo .kpi .l { margin-top: 2px; font-size: 12px; line-height: 1.25; }
  body.role-ceo .item { min-height: 44px; padding: 7px 12px; gap: 10px; box-sizing: border-box; }
  body.role-ceo .item .ic-box { width: 32px; height: 32px; border-radius: 10px; }
  body.role-ceo .item .t { font-size: 14px; }
  body.role-ceo .item .s { font-size: 12px; }
  body.role-ceo .task-n { height: 26px; min-width: 32px; font-size: 15px; }
  body.role-ceo .actions-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  body.role-ceo .action { padding: 9px 4px 8px; gap: 6px; font-size: 12px; }
  body.role-ceo .action .ic { width: 36px; height: 36px; border-radius: 11px; }
  body.role-ceo .card { padding: 11px 12px; }
}
@media (min-width: 1024px) {
  body.role-desk .mod-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
  body.role-desk .mod-card { padding: 14px 16px; }
  body.role-desk .mod-head { font-size: 15px; }
  body.role-desk .mod-stats .ms b { font-size: 20px; }
}
