:root {
  --red: #c62424; --red-d: #a51d1d; --navy: #00467f; --ink: #1c1f26; --muted: #6b7280; --line: #e7e8ec;
  --bg: #f4f5f7; --card: #fff; --green: #15803d; --amber: #b45309; --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Be Vietnam Pro", system-ui, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 9px; padding: 8px 14px; font: 600 13.5px "Be Vietnam Pro", sans-serif;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f8f8fa; text-decoration: none; }
.btn.wide { width: 100%; justify-content: center; padding: 11px; }
.link { border: 0; background: none; color: var(--navy); cursor: pointer; font: 500 13px "Be Vietnam Pro", sans-serif; padding: 0; }
input, select { font: 14px "Be Vietnam Pro", sans-serif; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
input:focus, select:focus { outline: 2px solid #f3b4b4; border-color: var(--red); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card label { display: block; font-weight: 500; margin: 14px 0; }
.login-card input { display: block; width: 100%; margin-top: 6px; font-size: 16px; padding: 10px 12px; }
.msg { min-height: 20px; color: var(--red); margin: 4px 0 10px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.brand b { display: block; font-size: 15px; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }
.brand.big { margin-bottom: 8px; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: #374151; font-weight: 500; }
.side nav a:hover { background: #f6f6f8; text-decoration: none; }
.side nav a.on { background: #fdecec; color: var(--red); }
.side svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-note { font-size: 12px; color: var(--muted); background: #fff7e6; border: 1px solid #f5d79e; border-radius: 9px; padding: 8px 10px; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.me b { display: block; }
.me small { display: block; color: var(--muted); margin-bottom: 4px; }

.main { padding: 22px 28px 60px; min-width: 0; }
.page-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-h .btn { margin-left: auto; }
.back { font-size: 20px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.cnt { background: #eef0f3; color: #4b5563; border-radius: 999px; font-size: 12px; padding: 1px 8px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 8px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { color: var(--muted); font-size: 12.5px; display: block; }
.kpi b { font-size: 24px; display: block; margin: 2px 0; }
.kpi small { color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); }
.tile:hover { border-color: var(--red); text-decoration: none; }
.tile span { font-size: 12.5px; color: var(--muted); display: block; }
.tile b { font-size: 22px; display: block; }
.tile small { color: var(--muted); font-size: 12px; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cols2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[name=q] { flex: 1; min-width: 240px; }
.filters .dt { display: flex; align-items: center; gap: 6px; color: var(--muted); }

.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 6px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafafb; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.tbl tr[data-href] { cursor: pointer; }
.tbl tr[data-href]:hover td { background: #fbfbfc; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl.kv td:first-child { color: var(--muted); width: 45%; }
.tbl.kv td:last-child { text-align: right; }
.card .tbl td { padding: 7px 4px; }
.thumb { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; background: #eef0f3; display: inline-block; vertical-align: middle; }
tr.locked td { opacity: .6; }
.warn-t { color: var(--amber); }
.ok-t { color: var(--green); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 14px 0; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: #eef0f3; color: #4b5563; }
.s-quote { background: #f3e8ff; color: #7e22ce; }
.s-wait { background: #fff4e5; color: var(--amber); }
.s-dep { background: #fef3c7; color: #92400e; }
.s-bought { background: #e0f2fe; color: #0369a1; }
.s-sent { background: #e0e7ff; color: #4338ca; }
.s-jp { background: #e8f0fb; color: var(--navy); }
.s-fly { background: #efe9fd; color: #6d28d9; }
.s-done { background: #e6f6ec; color: var(--green); }
.s-cancel { background: #fdecec; color: var(--red); }

.prod { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f1f3; }
.prod img, .prod .thumb { width: 64px; height: 64px; border-radius: 9px; object-fit: cover; flex: none; }
.prod a { font-weight: 500; word-break: break-all; }
.note { background: #fafafb; border-radius: 9px; padding: 8px 10px; margin: 10px 0 0; }
.hist { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.hist li { padding: 6px 0; border-bottom: 1px solid #f0f1f3; }
.hist li span { display: block; }
.lines { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f1f3; }
.lines small { display: block; color: var(--muted); font-size: 12px; }
.lines b { white-space: nowrap; }
.plus { color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.empty.small { padding: 12px 4px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; }

@media (max-width: 1100px) { .cols3 { grid-template-columns: 1fr; } .cols2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 10px; }
  .side nav { flex-direction: row; overflow-x: auto; order: 3; flex: 1 1 100%; min-width: 0; }
  .side nav a { flex: 0 0 auto; white-space: nowrap; }
  .side-note { display: none; }
  .me { margin: 0 0 0 auto; border: 0; padding: 0; text-align: right; }
  .main { padding: 14px 12px 40px; }
}

.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.subtabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.subtabs a:hover { color: var(--ink); text-decoration: none; }
.subtabs a.on { color: var(--red); border-bottom-color: var(--red); }
.form label { display: block; font-weight: 500; margin: 0 0 12px; }
.form input { display: block; width: 100%; margin-top: 5px; }
.form .btn { margin-top: 4px; }
h3.sep { margin-top: 20px; }
.switch-row { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.switch-row input { width: 16px; height: 16px; accent-color: var(--green); }
details.more { margin-top: 14px; }
details.more summary { cursor: pointer; color: var(--muted); }
.howto { margin: 0; padding-left: 20px; }
.howto li { margin: 6px 0; }

.ql-note { background: #eef5fc; border: 1px solid #cfe0f3; color: #1e3a5f; border-radius: 9px; padding: 8px 12px; font-size: 13px; margin: 0 0 14px; }
.warn-box { background: #fff7e6; border: 1px solid #f5d79e; border-radius: 9px; padding: 8px 12px; font-size: 13px; margin: 12px 0 0; }
.kpi b small { font-size: 13px; color: var(--muted); font-weight: 500; }
.route-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.sep { margin-top: 14px; }

.rate-row { margin-bottom: 4px; }
.rate-big { font-size: 30px; font-weight: 700; margin: 4px 0 6px; }
.rate-big small { font-size: 14px; color: var(--muted); font-weight: 500; }
.fix-form { display: flex; gap: 8px; align-items: center; }
.fix-form input { width: 120px; font-size: 18px; font-weight: 600; }

/* bản sửa thử (chưa ghi quanly) */
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
h3 .btn.sm { margin-left: auto; }
.draft-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #f5f0ff; border: 1px solid #ddd0fb; border-radius: 9px; padding: 8px 12px; margin: 0 0 14px; font-size: 13px; }
.test-v { color: #6d28d9; font-weight: 600; }
.tbl.test-t td { background: #faf7ff; }
.tbl.edit input { width: 100%; min-width: 80px; text-align: right; padding: 6px 8px; }
.edit-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.tbl-h { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 4px; }
tr.edit-row td { background: #faf7ff; }
.cust-edit-f { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.cust-edit-f label { font-size: 12.5px; color: var(--muted); }
.cust-edit-f input { display: block; width: 130px; margin-top: 3px; }
.q-form select { display: block; width: 100%; margin-top: 5px; }
.q-dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.q-tbl td { vertical-align: top; }
.q-diff { background: #f5f0ff; color: #6d28d9; font-weight: 600; }
.q-strong td { font-weight: 700; border-top: 1px solid var(--line); }
.cols2.q-cols { grid-template-columns: 1fr 1.4fr; }
@media (max-width: 1100px) { .cols2.q-cols { grid-template-columns: 1fr; } }
.page-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.route-f { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; }
.route-f label { font-weight: 500; font-size: 13px; }
.route-f input, .route-f select { display: block; width: 100%; margin-top: 4px; }
.route-f .wide { grid-column: 1 / -1; }
.new-route { border-color: #ddd0fb; }
h3 .btn.sm + .btn.sm { margin-left: 0; }
.kpi b.small-b { font-size: 14px; }

/* thao tác kho thử */
.pk-bar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.pkg-t td:first-child, .pkg-t th:first-child { width: 28px; }
.nowrap { white-space: nowrap; }
.pk-edit { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.pk-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted, #667); }
.pk-edit input:not([type=checkbox]), .pk-edit select { min-width: 0; width: 160px; }
.pk-edit .q-dims input { width: 60px; }
.scan-f { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.scan-f input[name=code] { flex: 1 1 260px; font-size: 18px; padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; }
.bag-act .bag-act-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.bag-act h3 .btn { float: right; }
#scanMany { width: 100%; margin: 8px 0; font-family: ui-monospace, Menlo, monospace; }
@media (max-width: 640px) { .pk-edit input:not([type=checkbox]), .pk-edit select { width: 100%; } .pk-edit label { flex: 1 1 100%; } }
.bag-act-row .scan-f { flex: 1 1 420px; }
.role-boxes { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.role-boxes label { flex-direction: row !important; align-items: center; gap: 6px !important; color: inherit !important; }
.pk-edit .full { flex: 1 1 100%; }

/* chọn khách khi tạo đơn */
.cust-pick { position: relative; display: flex; max-width: 420px; margin-top: 6px; }
.cust-pick input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cust-pick > button { width: 42px; border: 1px solid var(--line); border-left: 0; border-radius: 0 9px 9px 0; background: #fff; cursor: pointer; font-size: 15px; }
.cust-pick > button:hover { background: #f6f6f8; }
.cust-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; max-height: 280px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; }
.cust-list > div { padding: 8px 10px; }
.cust-list button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; font: inherit; }
.cust-list button:hover { background: #f6f6f8; }
.ql-note.live-note { background: #fdecec; border-color: #f3b4b4; color: #7a1d1d; }
.ql-note.warn-note { background: #fff6e0; border-color: #f1d48a; color: #6b4e00; }
.ql-note .btn { margin-left: 8px; }
.home-link { display: block; margin: 10px 0 4px; padding: 7px 10px; border-radius: 8px; background: #eef5fc; color: #1e3a5f; font-size: 13px; font-weight: 600; text-decoration: none; }
.home-link:hover { background: #dcebf9; }
@media (max-width: 760px) { .home-link { margin: 0; } }
.vn-list { list-style: none; padding: 0; margin: 6px 0 10px; }
.vn-list li { padding: 6px 0; border-bottom: 1px solid var(--line, #e5e9ef); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.np-prod span { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fix-log { border-top: 1px solid var(--line, #e5e7eb); padding: 8px 0; }
.fix-log:first-of-type { border-top: 0; }
/* khách báo nạp tiền (11/11/2026) */
.nav-cnt { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 6px; border-radius: 999px; background: #d62828; color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.nap-card { display: flex; gap: 16px; align-items: flex-start; }
.nap-img img { width: 140px; max-height: 240px; object-fit: contain; border-radius: 8px; border: 1px solid #e5e7eb; background: #f8f9fb; }
.nap-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
.nap-amt { font-size: 20px; }
.nap-ai { padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.nap-ai small { display: block; color: #6b7280; margin-top: 2px; }
.nap-ai.ok { background: #e9f7ee; }
.nap-ai.warn { background: #fff6e0; }
.nap-do { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.nap-do label { margin: 0; }
.nap-do input { width: 160px; }
.nap-auto { display: block; margin: 8px 0 14px; }
.nap-auto input { width: auto; display: inline; margin-right: 6px; }
@media (max-width: 640px) { .nap-card { flex-direction: column; } .nap-img img { width: 100%; } }

/* hạng ký quỹ (13/11/2026) */
.hang-kv{display:flex;flex-wrap:wrap;gap:6px 18px;margin:6px 0}
.hang-card h3 .badge{margin-left:6px}
.hang-f{margin-top:8px}

/* (14/11/2026) xuất bao ở danh sách + đấu giá & mặc cả */
.bag-out { margin-top: 4px; white-space: nowrap; }
.dg-item { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px; }
.dg-item img, .dg-noimg { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #f3f4f6; }
.dg-noimg { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.dg-body { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.dg-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.dg-title { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.dg-kv { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.dg-kv b { color: var(--ink); }
.dg-act { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.dg-in { width: 90px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; }
.dg-ja { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.dg-ja code { background: #f6f7f9; padding: 4px 8px; border-radius: 6px; white-space: pre-wrap; flex: 1 1 260px; }
@media (max-width: 560px) { .dg-item { grid-template-columns: 52px 1fr; gap: 10px; } .dg-item img, .dg-noimg { width: 52px; height: 52px; } }
.dg-clean { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dg-del { margin-left: auto; }

/* hộp chat chung (17/11/2026) */
.chat-wrap{display:grid;grid-template-columns:minmax(260px,360px) 1fr;gap:12px;align-items:start}
.chat-list{padding:0;max-height:75vh;overflow:auto}
.chat-row{display:block;padding:10px 12px;border-bottom:1px solid #eee;color:inherit;text-decoration:none}
.chat-row:hover{background:#f7f8fa}.chat-row.on{background:#e8f1ff}.chat-row.unread .chat-last{color:#111;font-weight:600}
.chat-row-top{display:flex;flex-wrap:wrap;gap:4px;align-items:center}
.chat-last{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px}
.chat-back{display:none}
.chat-box{max-height:55vh;min-height:200px;overflow:auto;display:flex;flex-direction:column;gap:6px;margin-bottom:8px}
.chat-msg{max-width:85%;padding:6px 10px;border-radius:10px;background:#f6f6ee;align-self:flex-end}
.chat-msg.khach{background:#f1f3f5;align-self:flex-start}.chat-msg.nhanvien{background:#e3f0ff}
.chat-text{white-space:pre-wrap;word-break:break-word}
.chat-draft{border:1px dashed #c9b458;border-radius:8px;padding:8px;margin-bottom:8px;display:grid;gap:6px}
.chat-draft textarea,.chat-send textarea{width:100%;box-sizing:border-box}
.chat-send{display:flex;gap:6px}.chat-send textarea{flex:1}
@media (max-width:760px){.chat-wrap{grid-template-columns:1fr}.chat-wrap.has-t .chat-list{display:none}.chat-wrap:not(.has-t) .chat-pane{display:none}.chat-back{display:inline-flex}}
