:root {
  --bg: #f5f6f8; --panel: #fff; --line: #e3e6ea; --text: #1d2329; --muted: #6b7580;
  --accent: #e8590c; --accent-2: #fff1e8; --ok: #2b8a3e; --ok-bg: #ebfbee; --warn-bg: #fff9db; --warn: #8a6d00; --err: #c92a2a; --err-bg: #fff5f5;
  --shop: #e7f0ff;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); height: 100vh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
h1 { font-size: 17px; margin: 0; white-space: nowrap; }
#page-select { width: auto; max-width: 260px; margin: 0; padding: 5px 8px; }
.badge { background: var(--warn-bg); color: var(--warn); border-radius: 99px; padding: 2px 10px; font-size: 12px; }
.tabs-nav { margin-left: auto; display: flex; gap: 4px; }
.tab-btn { border: none; background: transparent; padding: 8px 14px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.tab-btn:hover { background: #f1f3f5; }
.tab-btn.active { background: var(--accent-2); color: var(--accent); }
main.tab { flex: 1; min-height: 0; }
main.tab[hidden] { display: none; }
.grid3 { display: grid; grid-template-columns: 280px 1fr 420px; }
.col { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; min-height: 0; }
.col-title { position: sticky; top: 0; z-index: 1; background: var(--panel); padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pad { padding: 14px; }
.muted { color: var(--muted); }
.small, button.small { font-size: 12px; }
button.small { padding: 3px 8px; }
button.danger { color: var(--err); border-color: var(--err-bg); }
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--err); }

/* ---- Thanh công cụ (hàng loạt, dashboard) ---- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.toolbar label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.toolbar input[type=number] { width: 70px; margin: 0; }
.toolbar input[type=date] { width: auto; margin: 0; }
.small-note { margin: 8px 16px; font-size: 12px; }
.range-picker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-picker input[type=date] { width: auto; margin: 0; padding: 4px 6px; }
.range-picker .seg button { padding: 4px 10px; font-size: 13px; }
.pad-x { padding: 8px 14px; border-bottom: 1px solid var(--line); }
label.exclude-done { margin-bottom: 6px; font-size: 13px; align-items: flex-start; }
label.exclude-done input { margin-top: 3px; }
/* Ước tính tiền AI */
.ai-est { padding: 0 16px 12px; }
.ai-est-main { background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 16px; }
.ai-est-nums { display: flex; gap: 28px; flex-wrap: wrap; margin: 6px 0; }
.ai-est-nums > div { display: flex; flex-direction: column; }
.ai-est-nums b { font-size: 24px; font-variant-numeric: tabular-nums; }
.ai-est-nums small { color: var(--muted); font-size: 12px; }
.ai-card h4 { margin: 14px 0 6px; font-size: 13px; }
.ai-card .tbl tr.cur { background: var(--accent-2); }
label.ai-mode { align-items: flex-start; margin-bottom: 8px; }
label.ai-mode input { margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai-tag { font-size: 11px; color: var(--muted); }

/* Hộp cấu hình quét */
dialog.modal { border: none; border-radius: 12px; padding: 18px 20px; width: min(520px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(0,0,0,.35); }
dialog.modal h3 { margin: 0 0 6px; }
dialog.modal .sc-rows { margin: 8px 0; }
dialog.modal .sc-rows select { width: auto; margin: 0; padding: 3px 6px; }
dialog.modal .sc-sum { background: var(--accent-2); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }

/* Bộ lọc thẻ dạng thả xuống */
.tag-filter { display: flex; flex-direction: column; gap: 4px; }
.toolbar.sub { flex-direction: row; align-items: center; padding-top: 6px; padding-bottom: 6px; }
.toolbar.sub label.exclude-done { margin: 0; }
.tf-drop { position: relative; }
.tf-drop > summary { list-style: none; display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; background: #fff; color: var(--text); font-size: 13px; max-width: 100%; }
.tf-drop > summary::-webkit-details-marker { display: none; }
.tf-drop > summary::after { content: "▾"; color: var(--muted); margin-left: 4px; }
.tf-drop[open] > summary { border-color: var(--accent); }
.tf-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.tf-panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 280px; max-height: 340px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 6px; }
.tf-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 4px; margin: 0; font-weight: 400; }
.tf-row select { width: 110px; margin: 0; padding: 3px 6px; }
.tf-foot { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; text-align: right; }
.tf-has { color: var(--ok); font-weight: 600; } .tf-not { color: var(--err); font-weight: 600; }
.conv-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.tag-chip.mini { font-size: 11px; padding: 0 6px; }

/* ---- Lên hàng loạt ---- */
#tab-hang-loat:not([hidden]) { display: flex; flex-direction: column; }
.grid-bulk { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr) 420px; border-top: 1px solid var(--line); }
.bl-list { list-style: none; margin: 0; padding: 0; }
.bl-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.bl-item:hover { background: #fafbfc; }
.bl-item.active { background: var(--accent-2); }
.bl-item input.pick { width: auto; margin-top: 3px; }
.bl-main { flex: 1; min-width: 0; }
.bl-item .reasons { margin: 4px 0 0; padding-left: 18px; color: var(--warn); font-size: 12px; }
.bl-actions { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); }
#bl-other .bl-item { cursor: default; }
.bl-item input.ppick { width: auto; margin-top: 3px; }
.snip1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details summary { cursor: pointer; color: var(--muted); }
.msgs { display: flex; flex-direction: column; gap: 6px; }
#bl-chat { border-top: 1px dashed var(--line); max-height: 45vh; overflow: auto; }

/* ---- Dashboard ---- */
.dash { overflow: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi.good .kpi-value { color: var(--ok); }
.kpi.warn .kpi-value { color: var(--warn); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.section-title { font-size: 15px; margin: 8px 16px 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 6px 12px; }
.seg button.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl .num { text-align: right; }
.tbl tfoot td { font-weight: 600; border-bottom: none; }
.tbl tbody tr:hover { background: #fafbfc; }
.bar-col { width: 30%; }
.bar { display: block; height: 10px; background: var(--ok); border-radius: 0 4px 4px 0; min-width: 0; }
.cfg-pages { list-style: none; margin: 0 0 10px; padding: 0; }
.cfg-pages li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cfg-pages li .actions { flex-wrap: nowrap; }
.tag-box { margin: 10px 0; }
.tbl.tags td input { width: auto; margin: 0; }
.tag-chip { display: inline-block; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--c); color: var(--text); font-size: 12px; }
.tag-chip::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 5px; }

#conv-list { list-style: none; margin: 0; padding: 0; }
#conv-list li.conv { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#conv-list li.conv:hover { background: #fafbfc; }
#conv-list li.conv.active { background: var(--accent-2); }
.conv .top { display: flex; gap: 6px; align-items: baseline; }
.conv .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .time { color: var(--muted); font-size: 12px; }
.conv .snip { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .name::before { content: "● "; color: var(--accent); }
.tag-done { background: var(--ok-bg); color: var(--ok); font-size: 11px; border-radius: 4px; padding: 0 6px; }

#msgs.msgs { display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 80%; padding: 7px 11px; border-radius: 12px; background: #f1f3f5; white-space: pre-wrap; word-break: break-word; }
.msg.shop { align-self: flex-end; background: var(--shop); }
.msg .at { display: block; font-size: 11px; color: var(--muted); }

form label { display: block; margin-bottom: 10px; font-weight: 500; }
form label small { display: block; font-weight: 400; color: var(--muted); }
input, textarea, select { width: 100%; font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; margin-top: 3px; background: #fff; color: inherit; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.summary { margin: 0 0 10px; font-style: italic; color: var(--muted); }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; }
.warn ul { margin: 4px 0 0; padding-left: 18px; }
.prev { background: var(--ok-bg); color: var(--ok); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; }
fieldset.mode { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px 0; margin: 0 0 8px; }
fieldset.mode label.check { margin-bottom: 8px; }
.warn-box { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 14px; }
.prev ul { margin: 4px 0 0; padding-left: 18px; }
.prev small { color: var(--muted); }
.items-head { display: flex; justify-content: space-between; align-items: center; font-weight: 500; margin-bottom: 4px; }
.item { display: grid; grid-template-columns: 1fr 64px 84px 28px; gap: 6px; align-items: center; margin-bottom: 8px; }
.item input { margin: 0; }
.item .line { text-align: right; font-variant-numeric: tabular-nums; }
.item .hint { grid-column: 1 / -1; color: var(--muted); margin-top: -4px; }
.item.bad .prod { border-color: var(--err); background: var(--err-bg); }
.item.bad .hint { color: var(--err); }
.total { text-align: right; margin: 8px 0 12px; font-size: 15px; }
.err { background: var(--err-bg); color: var(--err); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
.ok-box { background: var(--ok-bg); color: var(--ok); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button { font: inherit; border-radius: 6px; padding: 7px 14px; cursor: pointer; border: 1px solid var(--line); background: #fff; color: inherit; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:disabled { opacity: .6; cursor: wait; }
button.ghost { background: transparent; }
button.ghost.del { padding: 4px; border: none; color: var(--muted); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Giao diện v2: thẻ bo góc, bóng nhẹ, cột theo bước, font tiếng Việt
   ===================================================================== */
:root {
  --bg: #f3f4f7; --panel: #fff; --line: #e7e9ee; --line-2: #f0f1f4; --text: #1b2230; --muted: #6a7384;
  --accent: #e8590c; --accent-2: #fff3eb; --accent-3: #ffd8c2;
  --ok: #2f8a46; --ok-bg: #eaf7ee; --warn: #8a6400; --warn-bg: #fff8e1; --err: #c62828; --err-bg: #fdeeee;
  --lane-pending: #6c7a93; --lane-ok: #2f8a46; --lane-manual: #d08a00; --lane-edit: #e8590c;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .05);
  --radius: 12px;
}
body { font-family: "Be Vietnam Pro", system-ui, "Segoe UI", Roboto, sans-serif; font-size: 14px; }
header { padding: 10px 18px; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(0,0,0,.02); gap: 14px; }
h1 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h1::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-2); }
#page-select { border-radius: 8px; font-weight: 500; }
.tabs-nav { background: #f1f2f5; padding: 3px; border-radius: 10px; }
.tab-btn { padding: 7px 16px; border-radius: 8px; font-weight: 600; }
.tab-btn.active { background: #fff; color: var(--accent); box-shadow: var(--shadow); }
.tab-btn:hover:not(.active) { background: rgba(255,255,255,.6); }

input, textarea, select { border-radius: 8px; border-color: var(--line); transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
button { border-radius: 8px; transition: background .15s, box-shadow .15s, transform .05s; font-weight: 500; }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { box-shadow: 0 1px 2px rgba(232, 89, 12, .25), 0 3px 10px rgba(232, 89, 12, .18); }
button.primary:hover:not(:disabled) { background: #d44f08; }
button.primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button.ghost { border-color: var(--line); background: #fff; }
button.ghost:hover { background: #f6f7f9; }

/* Bước (số tròn) */
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.step.sm { width: 18px; height: 18px; font-size: 11px; margin-right: 6px; vertical-align: 1px; }

/* ---- Lên hàng loạt ---- */
#tab-hang-loat:not([hidden]) { display: flex; flex-direction: column; padding: 12px; gap: 12px; }
.scanbar { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.scanbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scanbar-row.sub { font-size: 13px; padding-left: 32px; gap: 16px; }
.scanbar .cond { background: var(--line-2); border-radius: 8px; padding: 3px 10px; }
.grid-bulk { border-top: none; gap: 12px; grid-template-columns: 230px minmax(230px, 1fr) minmax(230px, 1fr) minmax(600px, 2fr); }
.lane { border: none; border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; border-top: 3px solid var(--lane-color, var(--line)); }
.lane > .bl-list, .lane > .edit-split { flex: 1; overflow: auto; min-height: 0; }
.lane-pending { --lane-color: var(--lane-pending); }
.lane-ok { --lane-color: var(--lane-ok); }
.lane-manual { --lane-color: var(--lane-manual); }
.lane-edit { --lane-color: var(--lane-edit); }
.lane-pending .step { background: var(--lane-pending); }
.lane-ok .step { background: var(--lane-ok); }
.lane .col-title { position: static; font-size: 13.5px; }
.count { display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 4px; border-radius: 99px; background: var(--line-2); color: var(--text); font-size: 12px; text-align: center; }
.lane-ok .count { background: var(--ok-bg); color: var(--ok); }
.lane-manual .count { background: var(--warn-bg); color: var(--warn); }
.bl-item { border-bottom: 1px solid var(--line-2); border-left: 3px solid transparent; padding: 10px 12px; transition: background .12s; }
.bl-item:hover { background: #fafbfc; }
.bl-item.active { background: var(--accent-2); border-left-color: var(--accent); }
.bl-item.compact { padding: 7px 10px; gap: 8px; }
.bl-item.compact .line1 { display: flex; justify-content: space-between; gap: 6px; }
.bl-item.compact .line1 b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-item .reasons { color: var(--warn); }
.bl-actions { position: static; border-top: 1px solid var(--line-2); background: #fcfcfd; }
.bl-actions button { width: 100%; padding: 9px 12px; }
details.other summary { font-size: 13px; }
.ai-tag { display: inline-block; margin-top: 3px; padding: 0 6px; border-radius: 6px; background: var(--line-2); }
.edit-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 38%); }
.edit-split > #bl-edit { overflow: auto; min-height: 0; }
.chat-side { border-left: 1px solid var(--line-2); background: #fafbfc; overflow: auto; min-height: 0; display: flex; flex-direction: column; }
.chat-head { position: sticky; top: 0; background: #fafbfc; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-2); z-index: 1; }
#bl-chat { border-top: none; max-height: none; }
.msg { border-radius: 14px; font-size: 13.5px; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.msg.shop { background: #e9f1ff; }

/* Form đơn trong cột Sửa đơn */
.order-form label { font-size: 13px; }
.order-form .total { background: var(--line-2); border-radius: 8px; padding: 8px 12px; }
.order-form .actions button[type=submit] { flex: 1; padding: 9px 14px; }
.ok-box { border: 1px solid #cfe9d6; }
.warn, .warn-box { border: 1px solid #f3e2a6; }
.prev { border: 1px solid #cfe9d6; }

/* ---- Dashboard ---- */
.kpi, .card { border: none; box-shadow: var(--shadow); border-radius: var(--radius); }
.kpi-value { font-size: 28px; }
.ai-est-main { border: none; box-shadow: var(--shadow); border-left: 4px solid var(--accent); }
.scanbar .seg, .toolbar .seg { background: #fff; }
.seg { border-radius: 8px; }
.seg button.active { background: var(--accent); color: #fff; }

/* Hộp cấu hình quét */
dialog.modal .sc-h { margin: 14px 0 6px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }
.sc-pos { display: flex; flex-wrap: wrap; gap: 6px; }
label.chip-check { margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; cursor: pointer; background: #fff; }
label.chip-check:has(input:checked) { border-color: var(--accent); background: var(--accent-2); color: var(--accent); font-weight: 600; }

/* Kho: nút to hiện số kg */
.wh-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; transition: border-color .15s, background .15s; }
.wh-box.heavy { border-color: var(--lane-manual); background: var(--warn-bg); }
.wh-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.wh-note { color: var(--warn); font-weight: 600; font-size: 12.5px; }
.wh-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
label.wh { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; padding: 10px 6px 8px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; text-align: center; font-weight: 400; transition: border-color .12s, box-shadow .12s; }
label.wh input { position: absolute; opacity: 0; pointer-events: none; }
label.wh .wh-kg { font-size: 22px; font-weight: 700; line-height: 1.1; }
label.wh .wh-kg small { font-size: 12px; font-weight: 600; margin-left: 1px; color: var(--muted); }
label.wh .wh-name { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
label.wh:hover { border-color: var(--accent-3); }
label.wh:has(input:checked) { border-color: var(--accent); background: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-2); }
label.wh:has(input:checked) .wh-kg { color: var(--accent); }
label.discount input { max-width: 200px; }

/* Lọc nội bộ cột Đủ điều kiện + nhãn trên đơn */
.lane-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line-2); background: #fcfcfd; }
.lane-filter label.chip-check { font-size: 12.5px; padding: 3px 10px; }
.lane-filter label.chip-check input { width: auto; margin: 0 4px 0 0; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badges span { font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.badge-muted { background: var(--line-2); color: var(--muted); }
.badge-heavy { background: #fff1e0; color: #b35400; font-weight: 600; }

/* ---- Xử lý đơn (giao hàng) ---- */
#tab-xu-ly:not([hidden]) { display: flex; flex-direction: column; padding: 12px; gap: 12px; }
#tab-xu-ly .scanbar-row.sub { padding-left: 0; }
#xl-q { width: 260px; margin-left: auto; }
.grid-ship > .lane[hidden] { display: none; }
#xl-kinds[hidden] { display: none; }
#xl-kinds .chip-toggle { padding: 2px 10px; font-size: 12px; }
.sh-hint { font-size: 12px; color: var(--err); font-weight: 600; margin-top: 2px; }
/* ---- Đăng nhập / nhân viên ---- */
.me-box { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; }
.me-box[hidden] { display: none; }
.login-wrap { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.login-wrap[hidden] { display: none; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.login-card h2 { margin: 0; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; }
.login-card label[hidden] { display: none; }
.login-card button { padding: 10px; margin-top: 4px; }
body.locked > header, body.locked > main { visibility: hidden; }
.tab-btn[hidden] { display: none; }
.staff-tbl td { vertical-align: top; }
.staff-perm-row { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.staff-perm-row .check, .staff-perms .check { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 13px; }
.staff-perm-row input, .staff-perms input { width: auto; margin: 0; }
.staff-perms { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 6px 0; }
.staff-acts { white-space: nowrap; }
.staff-acts button { padding: 3px 8px; font-size: 12px; }
.staff-form { border-top: 1px solid var(--line-2); margin-top: 12px; padding-top: 8px; }
.audit-card { grid-column: 1 / -1; }
.audit-filter { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 8px; }
.audit-filter label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.audit-filter input[type=date], .audit-filter select { width: auto; margin: 0; }
.audit-filter input[type=search] { width: 260px; margin: 0; }
.audit-scroll { max-height: 480px; overflow: auto; }
.audit-tbl { font-size: 12.5px; }
.audit-tbl td { vertical-align: top; }
.audit-tbl .nowrap { white-space: nowrap; }
.audit-detail { max-width: 560px; word-break: break-word; color: var(--muted); }
.audit-tbl tr.audit-bad td { background-color: var(--err-bg); }
/* ---- Thêm tiền quảng cáo ---- */
.qc-card { margin: 12px 16px 16px; }
.qc-tbl td { vertical-align: top; }
.qc-tbl tr.qc-day td { border-top: 2px solid var(--line); }
.qc-tbl tr.qc-done { color: var(--muted); }
.qc-tbl input[type=checkbox] { width: auto; margin: 0; }
.qc-tbl .qc-cost { width: 120px; text-align: right; margin: 0; padding: 3px 6px; }
.qc-tbl .qc-cost.qc-manual { border-color: var(--lane-manual); background: var(--warn-bg); }
.qc-actions { margin-top: 12px; align-items: center; }
.qc-res { padding-left: 18px; }
.ok-text { color: var(--ok); }
/* ---- Thống kê ---- */
.pf-card { margin: 12px 16px 0; }
.pf-kpis { padding: 4px 0 12px; }
.pf-scroll { overflow-x: auto; }
.pf-tbl { min-width: 720px; font-size: 13.5px; }
.pf-tbl th { white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.pf-tbl td:first-child, .pf-tbl th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 200px; }
.pf-tbl tr.pf-page { cursor: pointer; font-weight: 600; }
.pf-tbl tr.pf-page:hover td { background-color: #fafbfc; }
.pf-tbl tr.pf-page td:first-child::before { content: '▸ '; color: var(--muted); }
.pf-tbl tr.pf-page.open td:first-child::before { content: '▾ '; }
.pf-tbl tr.pf-prod td { color: var(--text); font-weight: 400; background-color: #fcfcfd; }
.pf-tbl tr.pf-prod td:first-child { padding-left: 24px; background-color: #fcfcfd; }
.pf-tbl tfoot td { font-weight: 700; }
.pf-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pf-head h3 { margin: 0; }
.pf-filter { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.pf-filter select { width: auto; min-width: 220px; margin: 0; font-weight: 500; }
.pf-tbl tr.pf-total td { background-color: #f6f7f9; border-top: 2px solid var(--line); font-weight: 700; font-size: 14px; }
.pf-tbl tr.pf-day td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pf-sp-btn { margin-top: 12px; }
/* Thanh màu trong ô (giống màn Thống kê POS): --w độ dài, --c màu cột */
.pf-tbl td.pf-bar { background-image: linear-gradient(90deg, var(--c) 0 var(--w), transparent var(--w)); background-repeat: no-repeat; background-size: calc(100% - 8px) 70%; background-position: 4px center; }
.pf-tbl td.neg { color: var(--err); font-weight: 600; }
.pf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.pf-tbl tr.pf-shop td { font-weight: 700; border-bottom: 2px solid var(--line); }
.pf-tbl .pf-sp { padding: 1px 8px; font-size: 11.5px; margin-left: 6px; font-weight: 500; }
.pf-tbl tr.pf-sprow td { background-color: #f7f9fc; }
.pf-tbl tr.pf-sprow td:first-child { background-color: #f7f9fc; }
.pf-tbl .neg { color: var(--err); }
.pf-tbl .pos { color: var(--ok); }
.pf-tbl th.fx { color: var(--accent); }
.tk-sub { margin: 16px 16px 0; font-size: 15px; }
.tk-note { margin: 10px 16px 0; }
.tk-grid { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.bar.bar-bad { background: var(--err); opacity: .75; }
@media (max-width: 700px) { .tk-grid { grid-template-columns: 1fr; } .tk-grid .tbl { font-size: 12.5px; } }
.grid-ship.cols-2 { grid-template-columns: 1fr 1fr; }
.grid-ship.cols-3 { grid-template-columns: 1.1fr 1.1fr 1fr; }
.xl-lanes { display: inline-flex; gap: 6px; }
.chip-toggle { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.chip-toggle b { font-weight: 600; margin-left: 2px; }
.chip-toggle.on { background: var(--accent-2); border-color: var(--accent-3); color: var(--accent); }
.chip-toggle.on::before { content: '✓ '; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--line); }
.copy:hover { color: var(--accent); border-bottom-color: var(--accent); }
.copy.copied { color: var(--ok); border-bottom-color: var(--ok); }
.xl-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.xl-tag select { width: auto; min-width: 140px; }
#xl-notify.on { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-tag { background: #e8f0fc; color: #2f6fd0; font-size: 11px; padding: 1px 7px; }
.badge-overdue { background: var(--err); color: #fff; font-size: 11.5px; font-weight: 700; }
.sh-item.overdue { background: var(--err-bg); border-left-color: var(--err); }
.lane-arrived .sh-item.overdue .sh-label { color: var(--err); }
.sh-notes { margin-top: 6px; }
.sh-notes ul { list-style: none; margin: 0 0 4px; padding: 0; font-size: 12px; }
.sh-notes li { padding: 2px 0; }
.sh-notes li time { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.sh-notes li:first-child { font-weight: 600; color: var(--ok); }
.sh-note-form { display: flex; gap: 6px; }
.sh-note-form input { flex: 1; min-width: 0; padding: 4px 8px; font-size: 12.5px; }
.sh-note-form button { padding: 3px 10px; font-size: 12px; }
.sh-quick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sh-quick .chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 1px 9px; font-size: 11.5px; color: var(--muted); }
.sh-quick .chip:hover { border-color: var(--accent); color: var(--accent); }
.grid-ship { flex: 1; min-height: 0; display: grid; gap: 12px; grid-template-columns: minmax(280px, 1.3fr) minmax(240px, 1fr) minmax(240px, 1fr) minmax(220px, .9fr); }
.lane-issue { --lane-color: var(--err); }
.lane-issue .count { background: var(--err-bg); color: var(--err); }
.lane-out { --lane-color: var(--accent); }
.lane-out .count { background: var(--accent-2); color: var(--accent); }
.lane-arrived { --lane-color: #2f6fd0; }
.lane-arrived .count { background: #e8f0fc; color: #2f6fd0; }
.lane-rest { --lane-color: var(--lane-pending); }
.sh-item { display: block; cursor: default; }
.sh-item.new { background: #fffbea; border-left-color: var(--lane-manual); }
.sh-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sh-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-label { font-weight: 600; font-size: 13px; margin-top: 3px; }
.lane-issue .sh-label { color: var(--err); }
.lane-out .sh-label { color: var(--accent); }
.lane-arrived .sh-label { color: #2f6fd0; }
.sh-reason { font-size: 12.5px; color: var(--text); }
.sh-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.sh-meta a { color: inherit; }
.sh-items { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-item details { margin-top: 4px; font-size: 12px; }
.sh-item details summary { cursor: pointer; color: var(--muted); }
.sh-ev { list-style: none; margin: 4px 0 0; padding: 0 0 0 10px; border-left: 2px solid var(--line); }
.sh-ev li { margin: 0 0 4px; }
.sh-ev time { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.sh-actions { display: flex; gap: 6px; margin-top: 6px; }
.sh-actions button { padding: 3px 10px; font-size: 12px; }
.badge-new { background: var(--lane-manual); color: #fff; font-weight: 700; font-size: 11px; padding: 1px 7px; }
.badge-fail { background: var(--err-bg); color: var(--err); font-weight: 600; font-size: 11px; padding: 1px 7px; }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--err); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* Màn hình hẹp: xếp dọc */
@media (max-width: 1400px) {
  .grid-bulk { grid-template-columns: 220px minmax(220px, 1fr) minmax(220px, 1fr) minmax(480px, 1.6fr); }
  .edit-split { grid-template-columns: 1fr; }
  .chat-side { border-left: none; border-top: 1px solid var(--line-2); max-height: 320px; }
}
@media (max-width: 1100px) {
  body { height: auto; }
  #tab-hang-loat:not([hidden]) { padding: 8px; }
  .grid-bulk, .grid-ship, .grid-ship.cols-2, .grid-ship.cols-3 { grid-template-columns: 1fr; }
  #tab-xu-ly:not([hidden]) { padding: 8px; }
  #xl-q { width: 100%; margin-left: 0; }
  .lane { max-height: none; }
  .lane > .bl-list { max-height: 50vh; }
  .tabs-nav { margin-left: 0; width: 100%; overflow-x: auto; }
}
.warn-text { color: var(--warn); font-weight: 600; }
