:root {
  --navy: #17324d;
  --navy-2: #22476b;
  --ink: #1b2430;
  --ink-2: #4a5666;
  --ink-3: #7c8796;
  --line: #e2e6ec;
  --line-2: #eef1f5;
  --bg: #f4f6f9;
  --card: #ffffff;
  --accent: #e8912b;
  --primary: #1f5f99;
  --primary-hover: #194f80;
  --danger: #c0392b;
  --ok: #1e8a5a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 4px 16px rgba(16, 30, 54, .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--ink-3); }
.muted { color: var(--ink-2); margin: 4px 0 0; }
.small { font-size: 12.5px; }
.dim { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 13px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Nút & ô nhập */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f6f8fb; border-color: #cfd6df; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.auth-card .btn.ghost { color: var(--ink-2); border-color: var(--line); }
.btn.danger-ghost { color: var(--danger); border-color: #f0c9c4; }
.btn.danger-ghost:hover { background: #fdf1ef; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 42px; margin-top: 8px; }
.icon-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--ink-3); font-size: 16px; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0 4px; font-size: 13px; }

input[type=text], input[type=search], input[type=password], input[type=date], input:not([type]), select, textarea {
  height: 36px; padding: 0 10px; border: 1px solid #d3d9e1; border-radius: 8px; background: #fff; outline: none; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 95, 153, .15); }
input:disabled, select:disabled { background: var(--line-2); color: var(--ink-3); }
.fld { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.fld input, .fld select { width: 100%; height: 40px; font-weight: 400; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-error { color: var(--danger); min-height: 18px; font-size: 13px; margin: 4px 0; white-space: pre-line; }

/* ---------- Đăng nhập */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 10% -10%, #23527c 0, transparent 60%), linear-gradient(160deg, #17324d, #0f2236); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 22px; margin: 18px 0 16px; }
.auth-card p.muted { margin: -6px 0 16px; line-height: 1.5; }
.auth-brand { display: flex; justify-content: center; }
.auth-brand img { width: 180px; max-width: 70%; height: auto; }

/* ---------- Thanh trên */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--navy); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.1); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: transparent; color: rgba(255,255,255,.75); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.tabs button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs button.active { color: #fff; background: rgba(255,255,255,.14); box-shadow: inset 0 -2px 0 var(--accent); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { display: flex; flex-direction: column; line-height: 1.2; margin-right: 6px; text-align: right; }
.who small { color: rgba(255,255,255,.65); font-size: 11.5px; }

main { padding: 20px 24px 40px; max-width: 1600px; margin: 0 auto; }

/* ---------- Thống kê */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; box-shadow: var(--shadow); position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--navy)); }
.stat:hover { border-color: #cdd5df; }
.stat.active { border-color: var(--c, var(--navy)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c, var(--navy)) 25%, transparent), var(--shadow); }
.stat-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-2); font-size: 13px; }
.s-all { --c: var(--navy); }
.s-coming { --c: #2f7dd1; }
.s-arrived { --c: #d9822b; }
.s-done { --c: var(--ok); }

/* ---------- Thanh lọc */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px; box-shadow: var(--shadow); }
.toolbar .search { flex: 1 1 280px; }
.toolbar .search input { width: 100%; }
.toolbar select { max-width: 220px; }
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; flex-wrap: wrap; }
.date-range input { width: 140px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

/* ---------- Bảng */
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { position: sticky; top: 0; background: #f7f9fb; text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-2);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th.sortable { cursor: pointer; color: var(--primary); }
.grid th.sortable:hover { background: #eef3f9; }
.sort-ind { font-size: 10px; margin-left: 2px; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
.grid tbody tr[data-id] { cursor: pointer; }
.grid tbody tr[data-id]:hover td { background: #f3f7fc; }
.grid tbody tr[data-id]:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.grid td.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.grid td.eta { font-weight: 600; font-variant-numeric: tabular-nums; }
.grid .row-today td { background: #fff8ec; }
.grid .row-done td { color: var(--ink-2); }
.grid .row-done td.eta { color: var(--ink-3); font-weight: 500; }
.grid.plain td { white-space: normal; }
.grid.plain tr:last-child td { border-bottom: 0; }
.empty-cell { text-align: center; color: var(--ink-3); padding: 40px 12px !important; }
.today-row td { padding: 0 !important; border-bottom: 0; background: transparent !important; cursor: default; }
.today-row span { display: flex; align-items: center; gap: 10px; color: var(--accent); font-weight: 600; font-size: 12px; padding: 6px 12px; }
.today-row span::before, .today-row span::after { content: ""; flex: 1; height: 2px; background: var(--accent); opacity: .5; }
.today-row span::before { flex: 0 0 12px; }
.table-foot { padding: 10px 14px; color: var(--ink-2); font-size: 12.5px; border-top: 1px solid var(--line-2); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.more { display: inline-block; font-family: inherit; font-size: 11px; background: var(--line-2); color: var(--ink-2); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }
.edit-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 7px; vertical-align: middle; }
.edit-dot.static { margin: 0 2px 0 6px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-coming { background: #e6f0fb; color: #1f62ab; }
.b-today { background: #fdebd3; color: #a55a0d; }
.b-arrived { background: #fff1df; color: #ae5f12; }
.b-done { background: #e3f4ec; color: #1b7a50; }
.b-nodate { background: #eef0f3; color: #5d6876; }
.b-admin { background: #ece8fb; color: #5a3fb8; }
.chip { display: inline-block; background: var(--line-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; margin: 2px 2px 2px 0; font-size: 12.5px; }

/* ---------- Modal */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 40, .5); z-index: 50; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; animation: fade .12s ease-out; }
.modal { width: 100%; max-width: 560px; background: #fff; border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.3); animation: pop .14s ease-out; }
.modal.wide { max-width: 980px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head .sub { margin-top: 6px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-body { padding: 18px 22px; }
.modal-body.narrow { max-width: 420px; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfc;
  border-radius: 0 0 14px 14px; position: sticky; bottom: 0; }
.btn-row { display: flex; gap: 8px; }

.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.field { padding: 10px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.editing { border-bottom: 0; padding: 6px 0; }
.f-label { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 4px; }
.f-value { font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; min-height: 21px; }
.f-value input, .f-value select, .f-value textarea { width: 100%; }
.req { color: var(--danger); }
.meta-line { margin-top: 14px; font-size: 12.5px; color: var(--ink-2); }
.perm-note { margin-top: 10px; padding: 10px 12px; background: #f4f6f9; border-left: 3px solid var(--ink-3); border-radius: 6px; color: var(--ink-2); font-size: 13px; }
.history { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.history summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.h-list { list-style: none; padding: 0; margin: 0 0 10px; font-size: 13px; }
.h-list > li { padding: 8px 0; border-top: 1px solid var(--line-2); line-height: 1.5; }
.h-list ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-2); }
.h-time { color: var(--ink-3); font-variant-numeric: tabular-nums; margin-right: 4px; }

/* ---------- Quản trị */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel:last-child .panel-head { border-bottom: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span2 { grid-column: 1 / -1; }
.perm-block { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.perm-block h3 { margin: 0 0 10px; font-size: 13.5px; }
.perm-block.disabled { opacity: .5; }
.checklist-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.checklist-tools input { flex: 1; height: 32px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; max-height: 240px; overflow-y: auto; padding: 4px 2px; }

/* ---------- Thông báo */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13.5px;
  transition: opacity .4s, transform .4s; max-width: 360px; }
.toast.ok { border-left: 4px solid #3ec486; }
.toast.err { border-left: 4px solid #ff6b5b; }
.toast.hide { opacity: 0; transform: translateY(6px); }

/* ---------- Màn hình nhỏ */
@media (max-width: 1000px) {
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  main { padding: 14px 16px 32px; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .userbox { width: 100%; margin-left: 0; justify-content: flex-end; }
  .who { margin-right: auto; text-align: left; }
  .field-grid, .form-grid { grid-template-columns: 1fr; }
  .toolbar select, .toolbar .search { max-width: none; flex: 1 1 100%; }
  .toolbar-actions { margin-left: 0; width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal-foot { border-radius: 0; }
  .panel-head { flex-direction: column; }
}

/* ---------- Kế hoạch làm hàng */
.plan-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.plan-head { padding: 12px 16px; display: flex; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; }
.plan-head .muted { margin: 0; font-size: 13px; }
.plan-title { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; cursor: pointer; }
.plan-title h2 { margin: 0; font-size: 16px; }
.chev { color: var(--ink-3); width: 12px; }
.plan-count { background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 9px; }
.plan-count.zero { background: var(--line); color: var(--ink-2); }
.plan-empty { padding: 4px 16px 16px; color: var(--ink-3); }
.late-text { color: var(--danger); }
.grid.compact td { padding: 8px 12px; }
.grid.compact th { position: static; }
.grid .row-late td { background: #fff4f2; }
.b-late { background: #fde4e0; color: #b03224; }

/* ---------- Ô nhập đặc biệt */
.auto-val { height: 36px; display: flex; align-items: center; padding: 0 10px; background: var(--line-2); border: 1px dashed #d3d9e1; border-radius: 8px; }
.sample-ctl { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.sample-ctl input[type=date] { flex: 1 1 140px; width: auto; }
.seg-group { display: inline-flex; border: 1px solid #d3d9e1; border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 0 11px; line-height: 34px; font-size: 13.5px; background: #fff; border-left: 1px solid #d3d9e1; }
.seg:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--primary); color: #fff; }
.seg input:focus-visible + span { box-shadow: inset 0 0 0 2px rgba(31, 95, 153, .45); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.hint.done { color: var(--ok); }

/* ---------- Nút tích V và ô bị khóa */
.f-label { display: flex; align-items: center; gap: 6px; }
.tick { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; }
.tick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.tick span { width: 18px; height: 18px; border: 1.5px solid #b9c2ce; border-radius: 4px; background: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: transparent; line-height: 1; transition: background .1s, border-color .1s; }
.tick input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick input:focus-visible + span { box-shadow: 0 0 0 3px rgba(31, 95, 153, .25); }
.tick-view { width: 16px; height: 16px; border-radius: 4px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700;
  border: 1.5px solid #cfd6df; color: transparent; text-transform: none; }
.tick-view.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.field.locked .f-value input, .field.locked .f-value select, .field.locked .f-value textarea {
  background: repeating-linear-gradient(-45deg, #f3f5f8, #f3f5f8 6px, #eceff3 6px, #eceff3 12px); cursor: not-allowed; }
.field.locked .f-label { color: #a3acb8; }
.field.locked .hint { visibility: hidden; }
.b-tvg { background: #efe7fb; color: #6a3fb8; }
.bool-ctl { height: 36px; }
.f-value .bool-ctl { width: auto; white-space: nowrap; }
.f-value .bool-ctl input[type=checkbox] { width: 18px; height: 18px; flex: none; }
.grid td .b-tvg { font-family: inherit; font-size: 11px; padding: 2px 7px; margin-left: 6px; }
.s-processing { --c: #d9822b; }
.grid th.c, .grid td.c { text-align: center; }
.plan-table .tick-view { width: 20px; height: 20px; font-size: 13px; }
.plan-table td.eta .badge { margin-left: 6px; font-weight: 600; }
.plan-export { margin-left: auto; order: 3; }
.grid .tick-view { width: 20px; height: 20px; font-size: 13px; }
.grid td.clip { max-width: 200px; }
.grid td.cust { max-width: 220px; }
.grid.compact th, .grid.compact td { padding-left: 10px; padding-right: 10px; }
.plan-table td.eta .badge { font-size: 11px; padding: 2px 7px; }
.plan-table td.clip { max-width: 170px; }
.table-card .grid th, .table-card .grid td { padding-left: 9px; padding-right: 9px; }
.table-card .grid th { white-space: normal; line-height: 1.25; }
.table-card .grid td.clip { max-width: 170px; }
.table-card .grid td.cust { max-width: 190px; }
.table-card .grid td.clip { max-width: 150px; }
.table-card .grid td.cust { max-width: 165px; }
.table-card .grid td.clip { max-width: 135px; }
.table-card .grid td.cust { max-width: 130px; }
.table-card .grid td.ckn { white-space: normal; min-width: 80px; }
.table-card .grid td.mono { font-size: 12.5px; }
.table-card .grid th, .table-card .grid td { padding-left: 8px; padding-right: 8px; }
.stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.s-tvgdang { --c: #7a4fd0; }
.s-completed { --c: #0f6f4a; }
.b-tvgdang { background: #efe7fb; color: #6a3fb8; }
.b-completed { background: #d8f0e3; color: #0f6f4a; }
.grid .row-completed td { color: var(--ink-3); }
.grid .row-tvgdang td { background: #faf7ff; }
.table-card .grid td.code { max-width: 110px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.table-card .grid td.wrap { white-space: normal; min-width: 80px; max-width: 95px; }
.table-card .grid td.code { max-width: 95px; }
.table-card .grid td.ckn { min-width: 70px; }
.table-card .grid td { font-size: 13px; }
.table-card .grid td.mono { font-size: 12px; }
.table-card .grid td.eta { font-size: 13px; }
.table-card .grid td.clip { max-width: 125px; }
.table-card .grid th, .table-card .grid td { padding-left: 7px; padding-right: 7px; }
.table-card .grid td.cust { max-width: 115px; }
/* Màu chữ theo tình trạng lô hàng */
.table-card .grid td.full { max-width: none; white-space: nowrap; }
.table-card .grid td.cont { font-size: 13px; }
.grid tr.tone-green td, .grid tr.tone-green td.eta { color: #12823f; }
.grid tr.tone-purple td, .grid tr.tone-purple td.eta { color: #7a3fc8; }
.grid tr.tone-red td, .grid tr.tone-red td.eta { color: #c62828; }
.grid tr.tone-green .dim, .grid tr.tone-purple .dim, .grid tr.tone-red .dim { color: inherit; opacity: .7; }
.table-card .grid td.full { white-space: normal; overflow-wrap: anywhere; min-width: 95px; max-width: 135px; }
.perm-note.warn { background: #fff6e8; border-left-color: var(--accent); color: #8a520c; }
/* Cùng một kiểu chữ cho bảng lô hàng và các bảng kế hoạch */
.table-card .grid td, .table-card .grid td.mono, .table-card .grid td.eta,
.plan-card .grid td, .plan-card .grid td.mono, .plan-card .grid td.eta {
  font-family: inherit; font-size: 13px; font-weight: 400;
}
.table-card .grid td.strong, .plan-card .grid td.strong { font-weight: 600; }
.plan-card.release { border-left-color: var(--ok); }
.plan-card.release .plan-count:not(.zero) { background: var(--ok); }
.f-value .cont-row { flex-wrap: nowrap; }
.f-value .cont-row input { width: auto; flex: 1 1 auto; }
.cont-msg:empty { display: none; }
/* Ô nhập số container */
.cont-list { display: flex; flex-direction: column; gap: 6px; }
.cont-row { display: flex; align-items: center; gap: 6px; }
.cont-row input { min-width: 0; text-transform: uppercase; letter-spacing: .5px; }
.cont-row.invalid input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192, 57, 43, .12); }
.cont-msg { font-size: 11.5px; color: var(--danger); white-space: nowrap; }
.cont-btn { width: 34px; height: 34px; flex: none; border: 1px solid #d3d9e1; border-radius: 8px; background: #fff; cursor: pointer; font-size: 18px; line-height: 1; color: var(--ink-2); }
.cont-btn:hover:not(:disabled) { background: #f3f6fa; }
.cont-btn.add { color: #fff; background: var(--primary); border-color: var(--primary); }
.cont-btn.add:hover { background: var(--primary-hover); }
.cont-btn:disabled { opacity: .35; cursor: default; }
.hint.bad { color: var(--danger); }
.plan-card.warn { border-left-color: var(--danger); }
.plan-card.warn .plan-count:not(.zero) { background: var(--danger); }
.warn-cell { white-space: normal !important; }
.warn-cell .badge { margin: 2px 4px 2px 0; font-weight: 600; }
.sec-mine { font-size: 13px; color: var(--ink-2); margin-left: auto; order: 2; white-space: nowrap; }
.plan-head .plan-export { margin-left: 8px; order: 3; }
.plan-head .muted { order: 4; flex-basis: 100%; }
/* Tra cứu & Xử lý phát sinh */
.panel-tools { padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.panel-tools input { width: 100%; max-width: 520px; }
.panel-head .btn-row input[type=search] { width: 280px; }
.copy { cursor: copy; border-bottom: 1px dashed #b9c2ce; }
.issue-new { padding: 14px 18px 16px; display: grid; gap: 10px; }
.issue-search { position: relative; max-width: 560px; }
.issue-search input { width: 100%; }
.issue-results { position: absolute; z-index: 30; left: 0; right: 0; top: 40px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.issue-hit { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; border: 0; background: #fff; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.issue-hit:hover { background: #f3f7fc; }
.issue-picked { padding: 9px 12px; border: 1px dashed var(--line); border-radius: 8px; background: #fafbfc; }
.issue-new textarea { width: 100%; }
.issue-actions { display: flex; align-items: center; gap: 14px; }
.issue-actions .form-error { margin: 0 auto 0 0; min-height: 0; }
.issue-table td { vertical-align: top; }
.issue-note { min-width: 260px; white-space: normal; line-height: 1.45; }
.issue-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.issue-done td { color: #12823f; }
.big-check { width: 18px; height: 18px; accent-color: var(--ok); cursor: pointer; }
/* Cập nhật ngày tàu về bằng Excel */
.eta-steps { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 10px; line-height: 1.5; }
.eta-steps li > div { margin-top: 6px; }
.file-btn { cursor: pointer; }
.eta-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.eta-table { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.eta-table th { position: sticky; top: 0; z-index: 1; }
.dim-row td { color: var(--ink-3); }
.eta-more { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.eta-more summary { cursor: pointer; font-weight: 600; }
.eta-more div { padding: 6px 0 0 16px; overflow-wrap: anywhere; }
.eta-table td.eta-cust { max-width: 150px; }

/* ===================================================================
   Giao diện điện thoại (màn hình ≤ 760px): bảng hiển thị thành thẻ
   =================================================================== */
.m-only { display: none; }
@media (max-width: 760px) {
  body { font-size: 15px; }
  main { padding: 12px 10px 40px; }

  /* Thanh trên cùng */
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 15px; }
  .brand img { width: 24px; height: 24px; }
  .userbox { width: auto; margin-left: auto; gap: 6px; }
  .who { display: none; }
  .userbox .btn.sm { height: 30px; padding: 0 9px; font-size: 12.5px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; padding: 8px 12px; flex: none; }

  /* Thẻ thống kê */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-num { font-size: 22px; }
  .stat-label { font-size: 12.5px; }

  /* Thanh lọc: chỉ hiện ô tìm kiếm + nút Bộ lọc; bấm để mở các lọc khác */
  .m-only { display: inline-flex; }
  .toolbar { padding: 10px; gap: 8px; }
  .toolbar .search { flex: 1 1 0; min-width: 0; }
  .filter-row { flex-wrap: wrap !important; }
  .filter-row > select, .filter-row > .date-range, .filter-row > .cust-pick { display: none !important; }
  .toolbar.m-open .filter-row > select, .toolbar.m-open .filter-row > .date-range, .toolbar.m-open .filter-row > .cust-pick { display: flex !important; flex: 1 1 100% !important; max-width: none; }
  .toolbar.m-open .filter-row > .date-range { flex-wrap: wrap; }
  .toolbar.m-open .filter-row > .date-range input { flex: 1 1 0; width: auto; }
  .toolbar-actions { width: 100%; margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar-actions .btn { width: 100%; }
  .toolbar-actions .btn.primary { grid-column: 1 / -1; order: -1; height: 42px; }
  input[type=text], input[type=search], input[type=password], input[type=date], input:not([type]), select, textarea { font-size: 16px; } /* tránh iPhone tự phóng to */

  /* Các khối kế hoạch / cảnh báo */
  .plan-head { padding: 10px 12px; gap: 6px 10px; }
  .plan-title h2 { font-size: 15px; }
  .sec-mine { margin-left: 0; order: 3; font-size: 13px; }
  .plan-head .plan-export { order: 2; margin-left: auto; }
  .plan-head .muted { font-size: 12.5px; order: 4; }

  /* Bảng → thẻ */
  .table-wrap { overflow: visible; }
  table.grid, table.grid tbody { display: block; width: 100%; }
  table.grid thead { display: none; }
  table.grid tbody tr { display: block; margin: 0 10px 10px; padding: 8px 12px 10px; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; box-shadow: 0 1px 2px rgba(16, 30, 54, .05); }
  .table-card table.grid tbody tr:first-child, .plan-card table.grid tbody tr:first-child, .panel table.grid tbody tr:first-child { margin-top: 10px; }
  table.grid tbody td, .table-card .grid td, .plan-card .grid td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    padding: 4px 0 !important; border: 0 !important; background: transparent !important;
    white-space: normal !important; max-width: none !important; min-width: 0 !important;
    overflow: visible; text-overflow: clip; text-align: right; font-size: 14px;
  }
  table.grid tbody td::before { content: attr(data-label); flex: none; max-width: 46%; text-align: left; color: var(--ink-3); font-size: 12.5px; font-weight: 500; line-height: 1.6; }
  table.grid tbody td.m-empty { display: none; }
  table.grid tbody td > * { max-width: 100%; }
  /* Ô đầu tiên làm tiêu đề thẻ */
  table.grid tbody tr > td:first-child { font-size: 15px; font-weight: 600; padding-bottom: 7px !important; margin-bottom: 4px;
    border-bottom: 1px dashed var(--line) !important; }
  table.grid tbody tr > td:first-child::before { font-size: 12px; }
  /* Màu nền theo tình trạng */
  table.grid tbody tr.row-late, table.grid tbody tr.row-today { background: #fff6f4; }
  table.grid tbody tr.row-today { background: #fffaf0; }
  table.grid tbody tr.row-tvgdang { background: #faf7ff; }
  table.grid tbody tr.tone-green { border-color: #b9e2c9; }
  table.grid tbody tr.tone-red { border-color: #f1c4c0; }
  table.grid tbody tr.tone-purple { border-color: #d9c8f3; }
  /* Vạch "Hôm nay" và dòng trống */
  table.grid tbody tr.today-row { border: 0; box-shadow: none; background: transparent; padding: 0; margin: 4px 10px; }
  table.grid tbody tr.today-row td { display: block; }
  table.grid tbody tr.today-row td::before, table.grid tbody td.empty-cell::before { content: none; }
  table.grid tbody tr:has(td.empty-cell) { border: 0; box-shadow: none; }
  table.grid tbody td.empty-cell { display: block; text-align: center; }
  /* Ô nhiều nội dung */
  .warn-cell { justify-content: flex-end !important; flex-wrap: wrap; }
  .warn-cell::before { flex-basis: 100% !important; max-width: none !important; }
  .warn-cell .badge { white-space: normal; text-align: left; }
  .issue-note { flex-direction: column; text-align: left !important; }
  .issue-note::before { max-width: none !important; }
  table.grid td .chip { margin: 2px 0 2px 4px; }
  table.grid td.right { justify-content: flex-end; }
  .table-foot { padding: 10px 14px; }

  /* Bảng xem trước cập nhật ngày tàu (trong cửa sổ) */
  .eta-table { max-height: none; border: 0; }
  .eta-table table.grid tbody tr { margin: 0 0 8px; }

  /* Bảng phân quyền / quản trị */
  .panel-head { padding: 12px; }
  .panel-head .btn-row { width: 100%; flex-wrap: wrap; }
  .panel-head .btn-row input[type=search], .panel-head .btn-row select { width: 100%; flex: 1 1 100%; }
  .panel-tools { padding: 10px 12px; }
  .issue-new { padding: 12px; }
  .issue-actions { flex-wrap: wrap; }
  .issue-actions .btn { width: 100%; }

  /* Cửa sổ chi tiết lô hàng toàn màn hình */
  .modal-head { padding: 14px 14px 10px; }
  .modal-body { padding: 12px 14px; }
  .modal-foot { padding: 10px 14px; flex-wrap: wrap; }
  .modal-foot .btn-row { flex: 1; justify-content: flex-end; }
  .modal-foot .btn { height: 42px; }
  .field-grid { grid-template-columns: 1fr !important; }
  .seg span { padding: 0 14px; line-height: 38px; }
  .cont-btn { width: 40px; height: 40px; }
  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
@media (max-width: 760px) {
  .tabs button { padding: 8px 10px; font-size: 14px; }
  .plan-head .sec-mine { order: 2; margin-left: 0; }
  .plan-head .plan-export { order: 3; margin-left: auto; }
  #btnEta { grid-column: 1 / -1; }
}
/* Thêm lô hàng bằng file Excel */
.import-links { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }
.import-links .link-btn { font-size: 13px; padding: 0; }
.import-links label.link-btn { cursor: pointer; }
.imp-h { margin: 14px 0 6px; font-size: 14px; }
.imp-bad td { color: var(--ink-2); }
.imp-why { color: var(--danger); font-size: 12.5px; white-space: normal !important; min-width: 220px; }
.imp-act .badge { white-space: nowrap; }
.imp-table td { white-space: normal; }
.imp-table td.imp-why { min-width: 240px; }
@media (min-width: 761px) { .imp-table td:nth-child(n+3) { max-width: 180px; } }
.table-card .grid td.note { max-width: 120px; }
/* Thêm cột Ghi chú: thu gọn để bảng vừa màn hình 1440px */
.grid td.note { white-space: normal; }
.note-clamp { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; overflow-wrap: anywhere; }
@media (min-width: 761px) {
  .table-card .grid td.note { min-width: 90px; max-width: 120px; }
  .table-card .grid td.clip { max-width: 115px; }
  .table-card .grid td.cust { max-width: 105px; }
}
@media (min-width: 761px) {
  .table-card .grid td.malo { white-space: normal; min-width: 92px; line-height: 1.5; }
  .table-card .grid td.malo .b-tvg { margin-left: 0; display: inline-block; }
  .table-card .grid td.clip.pi { max-width: 90px; }
}
@media (min-width: 761px) { .table-card .grid td.note { min-width: 80px; } .table-card .grid td.clip:not(.pi) { max-width: 110px; } }
/* Quản trị: Zalo */
.zalo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 4px 18px 18px; }
.zalo-step { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.zalo-step.wide { grid-column: 1 / -1; }
.zalo-step h3 { margin: 0 0 6px; font-size: 14px; }
.zalo-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.zalo-row input { flex: 1; min-width: 200px; }
.zalo-routes select { width: 100%; max-width: 520px; }
@media (max-width: 760px) { .zalo-grid { grid-template-columns: 1fr; padding: 4px 10px 12px; } }
/* Nút sửa riêng phần tờ khai */
.f-label .tk-edit { margin-left: 8px; font-size: 12px; font-weight: 600; }
.field.tk-editing { background: #fff8e6; border-radius: 8px; }
.zalo-diag { margin-top: 10px; }
.zalo-diag summary { cursor: pointer; font-size: 13px; color: var(--ink-2, #555); }
.zalo-diag pre { max-height: 320px; overflow: auto; background: #0f1b2d; color: #d7e3f4; padding: 10px 12px; border-radius: 8px;
  font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }
/* Vai trò Quản lý */
.b-manager { background: #e3f1ff; color: #1d5fa8; }
/* Thông tin khác của khách hàng */
.extra-block { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.extra-block h3 { margin: 0 0 4px; font-size: 14px; }
.extra-row { display: grid; grid-template-columns: minmax(140px, 220px) 1fr auto; gap: 8px; margin-bottom: 8px; align-items: start; }
.extra-row textarea { resize: vertical; min-height: 36px; font: inherit; }
@media (max-width: 760px) { .extra-row { grid-template-columns: 1fr auto; } .extra-row textarea { grid-column: 1 / 2; } }
.lk-table tr.clickable { cursor: pointer; }
.lk-table tr.clickable:hover td { background: var(--hover, #f3f7f4); }
.extra-count { display: inline-block; font-size: 11px; font-weight: 600; color: #1d5fa8; background: #e3f1ff; border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
.info-list { margin: 0; }
.info-row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.info-row.first-extra { border-top: 2px solid var(--line); margin-top: 6px; }
.info-row dt { color: var(--muted, #667); font-size: 13px; }
.info-row dd { margin: 0; display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.info-val { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 760px) { .info-row { grid-template-columns: 1fr; gap: 2px; } }
.info-sub { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 2px; padding-top: 10px; border-top: 2px solid var(--line); }
.info-sub h3 { margin: 0; font-size: 14px; }
.info-row dd textarea.extra-val { width: 100%; font: inherit; resize: vertical; min-height: 36px; }
/* Mã ĐKKD luôn hiện đủ trên 1 dòng */
.grid td.dkkd { white-space: nowrap; }
@media (max-width: 760px) { .grid td.dkkd { white-space: normal; } }
/* Lọc khách hàng: ô gõ để tìm */
.cust-pick { position: relative; display: inline-flex; width: 240px; }
.cust-pick input { width: 100%; padding-right: 28px; }
.cust-x { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted, #667); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.cust-x:hover { color: #c0392b; }
@media (max-width: 760px) { .cust-pick { width: auto; flex: 1 1 100%; } }
.table-card .grid td.ckn { white-space: nowrap; }
@media (min-width: 761px) {
  .table-card .grid td.dkkd { font-size: 12px; letter-spacing: -0.2px; }
  .table-card .grid td.clip:not(.pi) { max-width: 98px; }
  .table-card .grid td.gp { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.table-card .grid td.ckn { min-width: 0; text-align: center; }
@media (min-width: 761px) { .table-card .grid td.note { min-width: 70px; max-width: 110px; } }
/* Tra cứu hãng tàu / Forwarder */
#carrierPanel { margin-top: 16px; }
.cr-table td.cr-proc { white-space: pre-line; max-width: 520px; color: var(--ink-2, #445); font-size: 13px; }
.cr-table td.cr-phone { white-space: pre-line; min-width: 120px; }
#crForm textarea { width: 100%; font: inherit; resize: vertical; }
#crForm .fld { margin-bottom: 12px; }
.h-meta { font-size: 12px; color: var(--muted, #667); margin-bottom: 2px; }
.h-old { color: #a33; text-decoration: line-through; white-space: pre-line; }
.h-new { color: #1b7a43; white-space: pre-line; }
#crHist .h-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.eta-export-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.eta-export-row select { max-width: 320px; }
/* Cập nhật nhanh bằng file Excel: thanh ngang chọn loại cập nhật */
.qtabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--panel, #fff); overflow-x: auto; }
.qtab { border: 0; background: transparent; padding: 11px 14px; font: inherit; font-weight: 600; color: var(--muted, #667); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.qtab:hover { color: var(--ink, #222); }
.qtab.on { color: var(--brand, #1d6b47); border-bottom-color: var(--brand, #1d6b47); }
@media (max-width: 760px) { .qtabs { padding: 0 10px; } .qtab { padding: 10px 10px; } }
[hidden] { display: none !important; }

/* Kiểm dịch tự động */
.kd-box { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
.kd-head { font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.kd-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0; }
.kd-badge { margin-left: 4px; font-size: 10.5px; padding: 1px 6px; vertical-align: 1px; }
.kd-days { width: 64px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; margin: 0 4px; }
.zalo-row input.kd-days { flex: none; min-width: 0; width: 64px; }
.kd-urls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.kd-urls label { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 760px) { .kd-urls { grid-template-columns: 1fr; } }
.kd-sites input { width: 100%; min-width: 120px; }
.kd-sites td:nth-child(3) input, .kd-sites td:nth-child(4) input { min-width: 230px; }

/* Xóa nhiều lô hàng (quản trị viên) */
.btn.danger { background: var(--danger, #c0392b); border-color: var(--danger, #c0392b); color: #fff; }
.btn.danger:hover { filter: brightness(0.93); }
.btn.danger:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger-ghost.active { background: #fdf1ef; }
.sel-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: #fff4f2; border-bottom: 1px solid #f0c9c4; font-size: 14px; }
.sel-col { width: 34px; text-align: center; }
.sel-col input { width: 16px; height: 16px; cursor: pointer; }
tr.row-selected td { background: #fff1ef !important; }
.imp-warn { font-size: 12px; color: #a35a00; white-space: normal; max-width: 260px; text-align: left; margin-bottom: 4px; }
/* Bảng Zalo Bot + nhật ký gửi thu gọn */
.zb-add { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 18px 12px; }
.zb-add input { flex: 1; min-width: 200px; }
.zb-token { display: flex; gap: 6px; margin-top: 6px; }
.zb-token input { min-width: 220px; }
.zb-table td .btn.sm { margin-left: 4px; }
details.zalo-log > summary { cursor: pointer; display: flex; align-items: baseline; gap: 10px; list-style: none; }
details.zalo-log > summary::-webkit-details-marker { display: none; }
details.zalo-log > summary::before { content: '▸'; color: var(--muted, #667); }
details.zalo-log[open] > summary::before { content: '▾'; }
details.zalo-log > summary h3 { margin: 0; display: inline; }
details.zalo-log[open] > summary { margin-bottom: 8px; }
.kd-lots-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kd-lots tbody tr { cursor: pointer; }
.kd-lots tbody tr:hover { background: #f5f8fb; }
.kd-lots .nowrap { white-space: nowrap; }
.kd-lots .kd-ten-hang { min-width: 140px; max-width: 260px; }
.kd-tt { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.kd-tt-xong { background: #e3f4ea; color: #1d6b3f; }
.kd-tt-dang { background: #e8f0fb; color: #1f4e8c; }
.kd-tt-loi { background: #fdecea; color: #a1281b; }
.kd-tt-bo { background: #f1f1f1; color: #666; }

.kd-zalo-ok { color: var(--ok, #15803d); }
.kd-lots .kd-bao { margin-top: 3px; }

/* Tab Quản trị: bảng thu gọn / mở bằng cách bấm tiêu đề */
.panel.collapsible > .panel-head { cursor: pointer; user-select: none; }
.panel.collapsible > .panel-head h2::before { content: '▾'; display: inline-block; width: 18px; color: var(--ink-3); transition: transform .15s; }
.panel.collapsible.collapsed > .panel-head h2::before { transform: rotate(-90deg); }
.panel.collapsible > .panel-head:hover h2 { color: var(--accent, #1d6b47); }
.panel.collapsed > :not(.panel-head) { display: none !important; }
.panel.collapsed > .panel-head { border-bottom: 0; align-items: center; }
.panel.collapsed > .panel-head p, .panel.collapsed > .panel-head > :not(:first-child) { display: none; }

/* Kéo dãn cột: tay nắm ở mép phải tiêu đề */
.grid th .col-rz { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 3; touch-action: none; }
.grid th .col-rz::after { content: ''; position: absolute; top: 20%; bottom: 20%; left: 5px; width: 2px; border-radius: 1px; background: transparent; }
.grid th:hover .col-rz::after { background: #c9d4e0; }
.grid th .col-rz:hover::after, body.col-resizing .col-rz::after { background: var(--primary); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }
@media (max-width: 760px) { .grid th .col-rz { display: none; } }

/* Phân luồng tờ khai: Xanh / Vàng / Đỏ */
.luong-group { display: flex; flex-wrap: wrap; gap: 8px; }
.luong-tick { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-weight: 600; user-select: none; }
.luong-tick input { position: absolute; opacity: 0; pointer-events: none; }
.luong-tick .lt-box { width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 4px; display: inline-grid; place-items: center;
  font-size: 12px; line-height: 1; color: transparent; }
.luong-tick.luong-xanh { color: #15803d; } .luong-tick.luong-vang { color: #a16207; } .luong-tick.luong-do { color: #b91c1c; }
.luong-tick.luong-xanh .lt-box { border-color: #16a34a; } .luong-tick.luong-vang .lt-box { border-color: #eab308; } .luong-tick.luong-do .lt-box { border-color: #dc2626; }
.luong-tick:has(input:checked).luong-xanh { background: #dcfce7; border-color: #16a34a; }
.luong-tick:has(input:checked).luong-vang { background: #fef9c3; border-color: #eab308; }
.luong-tick:has(input:checked).luong-do { background: #fee2e2; border-color: #dc2626; }
.luong-tick:has(input:checked) .lt-box { color: #fff; }
.luong-tick.luong-xanh:has(input:checked) .lt-box { background: #16a34a; }
.luong-tick.luong-vang:has(input:checked) .lt-box { background: #eab308; }
.luong-tick.luong-do:has(input:checked) .lt-box { background: #dc2626; }
.luong-tick:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 1px; }
.luong-tick:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.luong-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.luong-badge.luong-xanh { background: #dcfce7; color: #15803d; } .luong-badge.luong-vang { background: #fef9c3; color: #a16207; } .luong-badge.luong-do { background: #fee2e2; color: #b91c1c; }
.luong-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-left: 4px; }
.luong-dot.luong-xanh { background: #16a34a; } .luong-dot.luong-vang { background: #eab308; } .luong-dot.luong-do { background: #dc2626; }

/* Kế hoạch làm hàng: lọc theo từng cột (kính lúp cạnh tên cột) */
.plan-table th .th-in { display: inline-flex; align-items: center; gap: 4px; }
.plan-table th.c .th-in { justify-content: center; }
.th-search { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px;
  background: transparent; color: var(--ink-3); cursor: pointer; flex: none; }
.th-search:hover { background: #e6ecf3; color: var(--ink); }
.th-search.on { background: var(--primary); color: #fff; }
.plan-table .pf-row th { position: static; padding: 4px 6px 8px; background: #f7f9fb; }
.plan-table .pf-row input { width: 100%; min-width: 60px; height: 28px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 400; color: var(--ink); background: #fff; }
.plan-table .pf-row input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.plan-table .pf-empty td { padding: 14px 16px; color: var(--ink-3); text-align: center; }
@media (max-width: 760px) { .plan-table .pf-row { display: none; } .th-search { display: none; } }

/* Bảng lô hàng: tiêu đề có "Chỉ KH tôi phụ trách" và "Xuất Excel" giống các bảng kế hoạch */
.table-head { align-items: center; border-bottom: 1px solid var(--line-2); }
.table-head h2 { margin: 0; font-size: 16px; }
.grid th.sortable .sort-ind:empty { display: none; }
.grid th.sortable.sort-on { background: #eef3f9; }

/* Thanh lọc: các ô lọc luôn nằm trên 1 hàng, tự co giãn theo màn hình; các nút ở hàng dưới */
.filter-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.filter-row > .search { flex: 2 1 220px; min-width: 96px; }
.filter-row > .cust-pick { flex: 1.3 1 190px; width: auto; min-width: 96px; }
.filter-row > select { flex: 1 1 150px; min-width: 88px; max-width: none; text-overflow: ellipsis; }
.filter-row > .date-range { flex: 1.6 1 400px; min-width: 392px; flex-wrap: nowrap; white-space: nowrap; gap: 6px; }
.filter-row > .date-range select { flex: 1 1 120px; min-width: 78px; max-width: 170px; }
.filter-row > .date-range input { flex: 1 1 130px; width: auto; min-width: 122px; } /* đủ hiện cả ngày/tháng/năm */
.toolbar > .toolbar-actions { flex: 1 1 100%; justify-content: flex-end; }
@media (max-width: 1100px) and (min-width: 761px) {
  .filter-row { gap: 6px; }
  .filter-row > .date-range { min-width: 336px; }
  .filter-row > .date-range .dr-lbl { display: none; } /* màn hẹp: bỏ chữ "từ / đến" cho đủ chỗ */
  .filter-row input, .filter-row select { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 760px) {
  .filter-row > .search { flex: 1 1 0; min-width: 0; }
  .toolbar.m-open .filter-row > .date-range { min-width: 0; }
  .toolbar.m-open .filter-row > .date-range select { flex: 1 1 100%; max-width: none; }
  .toolbar.m-open .filter-row > .date-range input { flex: 1 1 0; min-width: 0; }
}

/* Pop-up "Công việc cần phải hoàn thành" */
.todo-modal .modal-head h2 { color: var(--danger); letter-spacing: .02em; }
.todo-sec { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.todo-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; border: 0; background: #f7f9fb; cursor: pointer; font: inherit; font-size: 15px; text-align: left; }
.todo-head:hover { background: #eef3f9; }
.todo-sec .muted { margin: 8px 14px; font-size: 13px; }
.todo-sec .table-wrap { max-height: 300px; overflow: auto; }
.todo-table tbody tr { cursor: pointer; }
.todo-table td.clip { max-width: 220px; }
.todo-table td.todo-miss { color: var(--danger); font-size: 12.5px; white-space: normal !important; min-width: 200px; max-width: 360px; }
/* Nút thu nhỏ "CÔNG VIỆC" ở góc dưới bên phải */
.todo-pill { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px 10px 10px; border: 0; border-radius: 999px; background: var(--danger); color: #fff; font: inherit;
  font-weight: 700; font-size: 14px; letter-spacing: .03em; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.22); }
.todo-pill:hover { filter: brightness(1.08); transform: translateY(-1px); }
.todo-pill:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.todo-pill .tp-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: var(--danger); font-weight: 800; }
.todo-pill .tp-n { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.25); display: inline-grid; place-items: center; font-size: 13px; }
.todo-pill.pop { animation: todoPop .28s ease-out; }
@keyframes todoPop { from { transform: translate(-30vw, -30vh) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) { .todo-pill { right: 12px; bottom: 12px; } }
/* Ô Khách hàng trong form lô hàng: gõ hoặc chọn */
.form-cust { display: flex; width: 100%; }
.form-cust input { width: 100%; }
/* Tra cứu: dòng "Ấn vào để xem đầy đủ danh sách" dưới bảng */
.lk-more { display: block; width: 100%; padding: 10px 16px; border: 0; border-top: 1px solid var(--line-2); background: #f7f9fb;
  color: var(--primary); font: inherit; font-size: 13.5px; font-weight: 600; text-align: center; cursor: pointer; }
.lk-more:hover { background: #eef3f9; }
.lk-more[hidden] { display: none; }
/* Mã số Giấy phép kiểm dịch: chọn Mã hồ sơ / Số giấy phép */
.gp-kind { margin: 2px 0 6px; }
.gp-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #eef3f9; color: var(--ink-2); font-size: 12px; font-weight: 600; }
/* Bảng Zalo Bot: khóa kết nối cho bot */
.zb-key { margin: 14px 16px 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; }
.zb-key h3 { margin: 0 0 4px; font-size: 14px; }
/* Bảng lô hàng: dòng "Hiển thị … lô hàng" dưới tiêu đề; badge thời gian tàu về */
.table-head .table-count { order: 4; flex-basis: 100%; font-size: 13px; color: var(--ink-2); padding: 0; }
.table-head .table-count:empty { display: none; }
.grid td.eta .eta-badge { margin-top: 3px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.grid td.cust .edit-dot { margin: 0 6px 0 0; }
.f-label .gp-tick:not(.on) { display: none; } /* đang sửa: hiện V khi chọn "Không" hoặc đã điền Số giấy phép + thời hạn */

/* Bot chạy trong web (Quản trị › Kiểm dịch / Giấy phép) */
.bot-box .bot-btns { margin: 10px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.bot-box .check { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; }
.bot-nghi { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bot-nghi input[type=number] { width: 84px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; }
.bot-nghi select { height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; background: #fff; }
.bot-box .bot-nghi + p { margin: 6px 0 0; }
.bot-log { margin-top: 10px; }
.bot-log summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.bot-log pre { margin: 8px 0; max-height: 260px; overflow: auto; background: #0f1720; color: #d7e2ea; font-size: 11.5px; line-height: 1.45;
  padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bot-py { display: flex; align-items: center; gap: 6px; }
.bot-py input { flex: 1; min-width: 120px; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; }
