/* ============================================================================
 * GIAO DIỆN MỚI VIOLA (/moi/) — khung chung + Lên đơn + Cập nhật đơn cũ
 * Theo bản vẽ giao-dien-moi v8. CHỈ là phần nhìn: mọi class do app.js tự sinh
 * (payment-row, discount-row, done-prod, hist-item...) được tạo kiểu lại ở đây,
 * app.js giữ nguyên nên nghiệp vụ không đổi.
 * ========================================================================== */
/* Font nạp bằng thẻ <link> trong từng trang (xem head) — dùng @import ở đây làm trình
   duyệt phải tải xong CSS này rồi mới biết đường tải font, chậm thêm ~0,3-0,8s mỗi lần mở. */

:root {
  --primary: #ef5b2a;
  --primary-hover: #d94b1d;
  --primary-soft: #fff0e9;
  --primary-border: #ffc8b1;
  --page: #f8f6f3;
  --surface: #ffffff;
  --surface-soft: #f3f0ec;
  --surface-strong: #e8e3dd;
  --ink: #27231f;
  --ink-soft: #6e6862;
  --ink-faint: #958d85;
  --rule: #e2ddd7;
  --rule-soft: #eeeae6;
  --sidebar: #132334;
  --sidebar-hover: #1c344a;
  --sidebar-text: #b6c2cd;
  --sidebar-title: #ff9a70;
  --overlay: rgba(19, 35, 52, 0.54);
  --success: #208a55;
  --success-soft: #e8f6ef;
  --warning: #bd6d0b;
  --warning-strong: #955206;
  --warning-soft: #fff0d8;
  --danger: #c93e32;
  --danger-soft: #fcecea;
  --neutral: #74777d;
  --neutral-soft: #ececef;
  --info: #2e6fb3;
  --info-soft: #eaf3fc;
  --r-input: 6px;
  --r-control: 8px;
  --r-card: 12px;
  --shadow-card: 0 1px 2px rgba(39, 35, 31, .04), 0 8px 24px rgba(39, 35, 31, .05);
  --shadow-modal: 0 24px 48px rgba(39, 35, 31, .22);
  --sidebar-w: 248px;
  --topbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page); color: var(--ink); font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 14px; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, label[for], input[type="checkbox"] { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tabular, .sum-row b, .dp-amt, .done-line b, .price-cell, .disc-amt { font-variant-numeric: tabular-nums; }

/* ---------------- Khung ---------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: var(--r-control); background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 16px; flex: none;
}
.brand-name { color: #fff; font-weight: 800; font-size: 14px; line-height: 1.25; }
.brand-subtitle { font-size: 12px; color: var(--sidebar-text); }
#brandSub { display: none; }
.nav-group { margin-top: 12px; }
.nav-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-title); padding: 8px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border-radius: var(--r-control);
  color: var(--sidebar-text); font-weight: 500; background: none; text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.is-active { background: var(--primary); color: #fff; font-weight: 700; }
.nav-ico { width: 16px; text-align: center; flex: none; opacity: .9; }
.nav-tag { margin-left: auto; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, .12); color: #fff; padding: 0 8px; border-radius: 999px; line-height: 20px; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .1); display: grid; gap: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: rgba(248, 246, 243, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 12px; padding: 0 24px;
}
.topbar-spacer { flex: 1; }
.menu-toggle { display: none; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-control); width: 36px; height: 36px; font-size: 18px; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--neutral-soft); color: var(--neutral); white-space: nowrap; }
.conn.ok { background: var(--success-soft); color: var(--success); }
.conn.connecting { background: var(--warning-soft); color: var(--warning); }
.conn.err { background: var(--danger-soft); color: var(--danger); }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-hover); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
#userBadge { font-weight: 600; color: var(--ink); }
.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }
.backdrop { display: none; }

/* ---------------- Tiêu đề trang ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.page-head h1 { margin: 4px 0; font-size: 24px; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.page-sub { margin: 0; color: var(--ink-soft); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Nút ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 16px;
  border-radius: var(--r-control); font-weight: 600; border: 1px solid transparent; background: var(--surface-soft); color: var(--ink);
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-strong); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.soft { background: var(--primary-soft); color: var(--primary-hover); border-color: var(--primary-border); }
.btn.soft:hover { background: #ffe3d6; }
.btn.ghost { background: var(--surface); border-color: var(--rule); }
.btn.ghost:hover { background: var(--surface-soft); }
.btn.confirm {
  width: 100%; min-height: 48px; margin-top: 16px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(239, 91, 42, .25);
}
.btn.confirm:hover { background: var(--primary-hover); }
.btn.confirm:disabled { background: var(--surface-strong); color: var(--ink-faint); box-shadow: none; }
.confirm-note { text-align: center; font-size: 12px; color: var(--ink-faint); margin-top: 8px; }
.row-del {
  width: 32px; height: 32px; flex: none; border-radius: var(--r-control); border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink-soft); display: inline-grid; place-items: center; font-weight: 700;
}
.row-del:hover { background: var(--danger-soft); border-color: #f2c6c1; color: var(--danger); }

/* ---------------- Thẻ ---------------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; gap: 12px; padding: 16px 16px 0; }
.step-num {
  width: 32px; height: 32px; border-radius: var(--r-control); background: var(--primary-soft); color: var(--primary-hover);
  display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none;
}
.card-title { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }
.card-body { padding: 16px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 12px; line-height: 24px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--primary-hover); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }

/* ---------------- Ô nhập ---------------- */
.field { display: grid; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label, .field-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.req { color: var(--primary); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--r-input); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(239, 91, 42, .14); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); flex: none; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid2:last-child { margin-bottom: 0; }
.grid2 > .field { margin-bottom: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field.grid2 > div { display: grid; gap: 4px; min-width: 0; }
.customer-row { display: flex; gap: 8px; }
.customer-row input { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: var(--success); min-height: 16px; }
.hint:empty { min-height: 0; }
.hint.err { color: var(--warning-strong); }
.check-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-control);
  background: var(--surface-soft); font-weight: 600;
}
.check-row small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.check-row:has(input:checked) { background: var(--success-soft); border-color: #bfe3cf; }
.divider { height: 1px; background: var(--rule); margin: 16px 0; }

/* ---------------- Lên đơn: bố cục ---------------- */
.order-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.order-side { position: sticky; top: calc(var(--topbar-h) + 16px); }

/* thêm dịch vụ */
.add-line { display: flex; gap: 8px; align-items: flex-end; }
.add-line .grow { flex: 1; min-width: 0; }
.qty { display: flex; align-items: center; border: 1px solid var(--rule); border-radius: var(--r-input); overflow: hidden; background: var(--surface); height: 40px; }
.qty button { width: 32px; height: 100%; background: var(--surface-soft); border: 0; font-weight: 700; }
.qty button:hover { background: var(--surface-strong); }
.qty input { width: 48px !important; min-height: 0 !important; height: 100%; border: 0 !important; border-radius: 0 !important; text-align: center; padding: 0 !important; box-shadow: none !important; }

/* bảng dòng dịch vụ */
.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--rule); border-radius: var(--r-control); }
table.lines { width: 100%; border-collapse: collapse; min-width: 560px; }
table.lines th { background: var(--surface-soft); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); padding: 8px 12px; text-align: left; }
table.lines td { padding: 12px; border-top: 1px solid var(--rule-soft); vertical-align: middle; }
table.lines .r { text-align: right; }
table.lines .c { text-align: center; }
table.lines tr.empty td { text-align: center; color: var(--ink-faint); padding: 24px; }
.svc-name { font-weight: 600; }
.svc-group { font-size: 12px; color: var(--ink-faint); }
.base-price { color: var(--ink-soft); white-space: nowrap; }
.line-qty { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; }
.line-qty button { width: 24px; height: 24px; border-radius: 999px; background: var(--surface-soft); border: 0; font-weight: 700; }
.line-qty span { min-width: 16px; text-align: center; font-weight: 700; }
.price-in { width: 132px !important; min-height: 36px !important; text-align: right; font-weight: 700; }
.price-in.edited { border-color: var(--primary-border) !important; background: var(--primary-soft) !important; color: var(--primary-hover); }
.line-meta { margin-top: 8px; }
.meta-field { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.meta-field.on { color: var(--primary-hover); font-weight: 600; }
.meta-sel { min-height: 28px !important; padding: 2px 8px !important; font-size: 12px; width: auto !important; }

/* ---------------- Thanh toán ---------------- */
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; }
.sum-row span { color: var(--ink-soft); }
.sum-row b { font-weight: 700; }
.sum-row.total {
  background: var(--primary); color: #fff; border-radius: var(--r-control); padding: 12px 16px; margin: 12px 0 4px;
}
.sum-row.total span { color: #fff; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 12px; }
.sum-row.total b { font-size: 20px; }
.sum-row.remain { border-top: 1px dashed var(--rule); margin-top: 8px; padding-top: 12px; }
.sum-row.remain b { color: var(--warning); font-size: 16px; }
.discount-row, .payment-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.disc-label { flex: 1 1 140px; }
.disc-val { flex: 0 1 120px; text-align: right; }
.disc-amt { flex: 1 0 100%; text-align: right; font-size: 12px; color: var(--primary-hover); font-weight: 600; margin-top: -4px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-input); overflow: hidden; height: 40px; }
.seg button { width: 36px; background: var(--surface); border: 0; font-weight: 700; color: var(--ink-soft); }
.seg button.on { background: var(--primary); color: #fff; }
.pay-method-sel { flex: 1 1 140px; }
.pay-amt { flex: 1 1 120px; text-align: right; font-weight: 700; }
.btn-add-discount, .btn-add-payment { width: 100%; border-style: dashed; }

/* ---------------- Hộp thoại ---------------- */
.modal-bg { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 16px; z-index: 60; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-modal); padding: 24px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h3 { margin: 0 0 16px; font-size: 20px; font-weight: 800; }
.modal-note { font-size: 12px; color: var(--ink-soft); background: var(--info-soft); border-radius: var(--r-control); padding: 8px 12px; margin: 12px 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.modal.done { text-align: center; max-width: 480px; }
.done-icon { width: 56px; height: 56px; margin: 0 auto 8px; border-radius: 999px; background: var(--success-soft); display: grid; place-items: center; font-size: 28px; }
.done-code { display: inline-block; font-weight: 800; color: var(--primary-hover); background: var(--primary-soft); padding: 4px 12px; border-radius: 999px; margin-bottom: 16px; }
.done-info, .done-lines { text-align: left; border: 1px solid var(--rule); border-radius: var(--r-control); padding: 4px 12px; margin-bottom: 12px; }
.done-info-row, .done-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; }
.done-info-row + .done-info-row, .done-line + .done-line { border-top: 1px solid var(--rule-soft); }
.done-info-row span, .done-line span { color: var(--ink-soft); }
.done-line.strong b { font-size: 16px; }
.done-line.remain b { color: var(--warning); }
.done-products { text-align: left; margin-bottom: 12px; }
.done-prod { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--rule-soft); }
.dp-name { flex: 1; min-width: 0; font-weight: 600; }
.dp-qty { color: var(--ink-soft); font-weight: 600; }
.dp-km { color: var(--primary-hover); font-style: normal; font-size: 12px; }
.dp-amt { font-weight: 700; white-space: nowrap; }

/* ---------------- Cập nhật đơn cũ ---------------- */
#modalUpdate { position: static; inset: auto; background: none; display: block; padding: 0; overflow: visible; z-index: auto; }
#modalUpdate[hidden] { display: none !important; }
html.mo-cap-nhat #viewLenDon { display: none !important; }
html.mo-cap-nhat #modalUpdate[hidden] { display: block !important; }
#modalUpdate > .modal { max-width: none; box-shadow: none; background: none; padding: 0; max-height: none; overflow: visible; border-radius: 0; }
#modalUpdate > .modal > h3 { display: none; }
.update-search { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.update-customer-orders { display: grid; gap: 8px; margin-top: 8px; }
.update-order-item {
  display: grid; gap: 2px; text-align: left; padding: 12px; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-control); border-left: 3px solid var(--primary);
}
.update-order-item:hover { background: var(--primary-soft); }
.update-order-item .muted { color: var(--ink-faint); font-size: 12px; }
.update-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; margin-top: 16px; }
.update-side { position: sticky; top: calc(var(--topbar-h) + 16px); }
.order-head { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; }
.order-head .done-info-row { padding: 0; gap: 8px; border: 0 !important; }
.update-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.update-col { min-width: 0; }
.update-col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 8px; }
#updateLines .done-prod { flex-wrap: wrap; }
#updateLines .row-del[title^="Đổi"] { color: var(--primary-hover); border-color: var(--primary-border); background: var(--primary-soft); }
#updateNewLinesBody .done-prod { background: var(--primary-soft); border-radius: var(--r-control); padding: 8px; border: 0; margin-top: 8px; }
.hist-wrap { border: 1px solid var(--rule); border-radius: var(--r-control); padding: 8px; margin-bottom: 8px; }
.hist-item { display: flex; width: 100%; align-items: center; gap: 12px; background: none; border: 0; text-align: left; padding: 4px; border-radius: var(--r-input); }
.hist-item:hover { background: var(--surface-soft); }
.hist-main { flex: 1; min-width: 0; }
.hist-time { font-size: 12px; color: var(--ink-soft); }
.hist-amt { font-weight: 700; }
.hist-print { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-control); background: var(--primary-soft); }
.pay-row select, .pay-row input { min-height: 36px !important; }
#updatePaidFullMsg { background: var(--success-soft); color: var(--success) !important; border-radius: var(--r-control); padding: 12px !important; }
.update-totals .sum-row { padding: 4px 0; }
#updateRemain { color: var(--warning) !important; }
#updatePaid { color: var(--success) !important; }

/* ---------------- Thông báo ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: var(--r-control); box-shadow: var(--shadow-modal); font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); }

/* ---------------- Màn hình nhỏ ---------------- */
@media (max-width: 1180px) {
  .order-layout, .update-layout { grid-template-columns: minmax(0, 1fr); }
  .order-side, .update-side { position: static; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 35; }
  .menu-toggle { display: grid; place-items: center; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .update-search, .update-2col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .topbar-user #userBadge { display: none; }
  .conn { padding: 4px 8px; }
  .btn-refresh-text { display: none; }
  .customer-row { flex-wrap: wrap; }
  .customer-row input { flex: 1 0 100%; }
  .customer-row .btn { flex: 1 0 auto; }
  body #vlAiFabWrap #vlAiFab img { height: 72px; }
  /* bảng dịch vụ thành thẻ trên điện thoại (không phải cuộn ngang) */
  .table-wrap { border: 0; overflow: visible; }
  table.lines { min-width: 0; }
  table.lines thead { display: none; }
  table.lines tbody, table.lines tr, table.lines td { display: block; }
  table.lines tr:not(.empty) {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center;
    padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-control); margin-bottom: 8px;
  }
  table.lines td { padding: 0; border: 0; text-align: left !important; }
  table.lines tr:not(.empty) td:first-child { grid-column: 1 / -1; }
  table.lines td:nth-child(2)::before { content: "Đơn giá "; color: var(--ink-faint); font-size: 12px; }
  table.lines td:nth-child(4) { display: flex; align-items: center; gap: 8px; }
  table.lines td:nth-child(4) { min-width: 0; }
  table.lines td:nth-child(4)::before { content: "Thành tiền"; color: var(--ink-faint); font-size: 12px; white-space: nowrap; }
  table.lines td:nth-child(4) .price-in { flex: 1; min-width: 0; width: 100% !important; }
  .disc-label { flex: 1 0 100%; }
  .disc-val { flex: 1 1 auto; }

  .add-line { flex-wrap: wrap; }
  .add-line .grow { flex: 1 0 100%; }
  .add-line .btn { flex: 1; }
  .page-head h1 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ============ MÀN LÀM VIỆC GỌN (Thức chốt 17/09/2026 — MacBook 13") ============
 * Áp cho MỌI màn bảng / làm việc: thanh trên 1 hàng (tên màn + tìm + nút), bộ lọc ẩn sau "⚙ Bộ lọc",
 * thẻ số 1 dải mỏng, bảng lấp hết phần còn lại của màn hình. Màn mới làm sau dùng lại các lớp này. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.thanh-tren { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.thanh-tren h1 { margin: 0 4px 0 0; font-size: 19px; font-weight: 800; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.thanh-tren .field { margin: 0; }
.thanh-tren input, .thanh-tren select { height: 36px; min-height: 36px !important; }
.thanh-tren .tt-tim { flex: 1 1 220px; min-width: 180px; }
.thanh-tren .btn { white-space: nowrap; min-height: 36px; }
.thanh-tren .chip { min-height: 30px; padding: 0 10px; font-size: 12px; }
.tt-dem { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-left: 6px; padding: 0 4px; border-radius: 999px; background: var(--warning); color: #fff; font-size: 10px; font-weight: 800; }
.tt-dem[hidden] { display: none; }
[data-bo-loc].is-active { border-color: var(--warning); color: var(--warning-strong); }
.tt-bo-loc { margin-bottom: 10px; }
.tt-bo-loc-trong { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 10px 12px; }
.tt-bo-loc-trong .field { margin: 0; min-width: 160px; }
.dt-stats.so-gon { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.thanh-tren .dt-stats.so-gon { margin: 0; gap: 6px; }
.thanh-tren .dt-stats.so-gon .stat { padding: 4px 10px; }
.dt-stats.so-gon .stat { display: flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 10px; }
.dt-stats.so-gon .stat-label { font-size: 12px; }
.dt-stats.so-gon .stat .stat-value, .dt-stats.so-gon .stat-main .stat-value { font-size: 15px; }
.dt-stats.so-gon .stat-sub { font-size: 11px; }
.content.man-bang { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h)); padding: 12px 20px; }
.man-bang > .dt-table-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.man-bang .dt-table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; }
@media (max-width: 560px) {
  .content.man-bang { display: block; height: auto; padding: 12px; }
  .thanh-tren .tt-tim { flex-basis: 100%; }
}

/* Cập nhật đơn cũ gọn: tên màn + 2 ô tìm trên 1 hàng, thẻ bớt đệm */
.content:has(#modalUpdate:not([hidden])) { padding: 12px 20px; }
#modalUpdate .update-thanh-tren .update-search { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 12px; }
#modalUpdate .update-thanh-tren h1 { margin: 0; font-size: 19px; font-weight: 800; white-space: nowrap; line-height: 40px; }
#modalUpdate .update-thanh-tren .field { margin: 0; }
#modalUpdate .update-thanh-tren [data-go] { min-height: 40px; }
#modalUpdate .update-layout { margin-top: 10px; gap: 12px; }
#modalUpdate .card + .card { margin-top: 10px; }
#modalUpdate .card-header { padding: 10px 14px 0; }
#modalUpdate .card-body { padding: 10px 14px; }
@media (max-width: 1100px) {
  #modalUpdate .update-thanh-tren .update-search { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #modalUpdate .update-thanh-tren h1, #modalUpdate .update-thanh-tren [data-go] { display: none; }
}
@media (max-width: 560px) { #modalUpdate .update-thanh-tren .update-search { grid-template-columns: minmax(0, 1fr); } }

/* Dải nhắc trên bản làm thử (thu.thammyviola.com) */
.ban-thu { position: sticky; top: 0; z-index: 100; background: repeating-linear-gradient(45deg, #b4262a, #b4262a 12px, #9c1f23 12px, #9c1f23 24px); color: #fff; font-size: 12px; font-weight: 700; text-align: center; padding: 4px 12px; letter-spacing: .02em; }

/* ===== Ô NHẬP NỘI DUNG CHĂM SÓC (cham-soc-ca.js dùng chung cho màn Khách hàng + màn CSKH) ===== */
.cs-nhap { margin-top: 10px; }
.cs-nhap-thanh { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.cs-nhap-thanh .kh-tai-nut { flex: 0 0 auto; }
.cs-nhap-thanh .btn.primary { margin-left: auto; }
.cs-moc-chon { flex: 0 0 auto; min-width: 140px; max-width: 190px; padding: 5px 8px; border: 1px solid var(--border, #e5e8ef); border-radius: 7px; background: #fff; font: inherit; font-size: 13px; }
/* Ô nhập nội dung chăm sóc TO lại để soát nội dung AI đọc cho dễ (Thức nhắc 22/09/2026) */
.cs-nhap textarea { width: 100%; min-height: 240px; max-height: 70vh; padding: 10px 12px; border: 1px solid var(--border, #e5e8ef); border-radius: 8px; font: inherit; font-size: 14px; line-height: 1.55; resize: vertical; }
/* ảnh chờ lưu: hiện thu nhỏ, bấm ✕ để bỏ */
.cs-tep-anh { position: relative; display: inline-block; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border, #e5e8ef); background: var(--surface-2, #f1f2f6); }
.cs-tep-anh img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cs-tep-anh button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; line-height: 18px; padding: 0; cursor: pointer; }
.cs-tep-anh button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.cs-tep-ds { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.cs-tep { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2, #f1f2f6); font-size: 11.5px; color: var(--text-2, #5b6270); }
.cs-tep button { border: 0; background: transparent; color: var(--text-3, #8b93a3); cursor: pointer; font-size: 11px; padding: 0; }

/* Kho ảnh + so sánh gộp vào cuối khối chăm sóc (18/09/2026, bỏ tab Hình ảnh riêng) */
.cs-kho-anh { margin-top: 14px; border-top: 1px solid var(--border, #e5e8ef); padding-top: 10px; }
.cs-kho-anh > summary { cursor: pointer; font-weight: 500; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
.cs-kho-anh > summary::-webkit-details-marker { display: none; }
.cs-kho-anh > summary::before { content: '▸'; color: var(--text-3, #8b93a3); }
.cs-kho-anh[open] > summary::before { content: '▾'; }
.cs-so-sanh-dau { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 6px; }

/* ===== NHÃN MÀU DÙNG CHUNG cho MỌI bảng (chuyển từ khach-hang.css, 18/09/2026) =====
 * Một giá trị luôn ra một màu ở mọi màn (xem public/moi/nhan.js). */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-alt); color: var(--ink-soft); font-size: 11px; font-weight: 800;
  white-space: nowrap; line-height: 1.4;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: none; }
/* Nhãn nằm trong ô bảng: dài quá thì rút gọn "…" chứ không tràn đè cột bên cạnh (Thức 22/09/2026:
 * "dài thì ẩn bớt chữ cũng được vì nhân viên biết"). Rê chuột vào nhãn xem đủ chữ. */
.chip-chu { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
td .chip { max-width: min(150px, 100%); vertical-align: middle; }
.chip.t-xong     { background: #e7f6ec; color: #17794a; }
.chip.t-lich     { background: #eaf3fc; color: #1f6fb2; }
.chip.t-dangchay { background: #fff0e9; color: #c2521b; }
.chip.t-canlam   { background: #fff4d9; color: #9a6608; }
.chip.t-tre      { background: #fdeaea; color: #b4262a; }
.chip.t-nhat     { background: #ececef; color: #5f6070; }
.chip.t-nong     { background: #ffe9e2; color: #cf4318; }
.chip.t-am       { background: #fff7df; color: #9d7708; }
.chip.t-nguoi    { background: #edf5f8; color: #3c7b90; }
.chip.t-ten1 { background: #e8f0ff; color: #2a55a8; }
.chip.t-ten2 { background: #eaf7ee; color: #2a7a4e; }
.chip.t-ten3 { background: #f6ecff; color: #7241a8; }
.chip.t-ten4 { background: #fff0f3; color: #ab2f53; }
.chip.t-ten5 { background: #e6f6f7; color: #1f7a80; }
.chip.t-ten6 { background: #fdf0e3; color: #a35f12; }
.chip.t-ten7 { background: #eef0f5; color: #4a5470; }
.chip.t-ten8 { background: #f0f7dd; color: #5a7314; }

/* ===== THANH CUỘN LUÔN NHÌN THẤY (Thức chốt 18/09/2026) =====
 * Quy tắc chung: bảng nào phải kéo ngang mới xem hết cột thì PHẢI có thanh cuộn nhìn thấy được,
 * không để người dùng đoán là kéo được (macOS mặc định giấu thanh cuộn). Áp dụng cho mọi khung
 * cuộn của bảng danh sách — màn mới sau này chỉ cần đặt lớp .dt-table-wrap là có sẵn. */
.dt-table-wrap, .kh-bang-wrap, .cs-list .dt-table-wrap { scrollbar-width: thin; scrollbar-color: #b9bfcc #eef0f4; }
.dt-table-wrap::-webkit-scrollbar, .kh-bang-wrap::-webkit-scrollbar { height: 12px; width: 12px; }
.dt-table-wrap::-webkit-scrollbar-track, .kh-bang-wrap::-webkit-scrollbar-track { background: #eef0f4; border-radius: 8px; }
.dt-table-wrap::-webkit-scrollbar-thumb, .kh-bang-wrap::-webkit-scrollbar-thumb { background: #b9bfcc; border-radius: 8px; border: 3px solid #eef0f4; }
.dt-table-wrap::-webkit-scrollbar-thumb:hover, .kh-bang-wrap::-webkit-scrollbar-thumb:hover { background: #8b93a3; }

/* ===== THANH TAB TRONG MÀN (dùng chung: Chăm sóc KH, Quản trị, Báo cáo) ===== */
.cs-tabs { display: inline-flex; gap: 2px; background: var(--surface-2, #f1f2f6); border-radius: 8px; padding: 2px; }
.cs-tab { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; font: inherit; font-size: 13px; color: var(--text-2, #5b6270); cursor: pointer; white-space: nowrap; }
.cs-tab:hover { color: var(--text-1, #1d2330); }
.cs-tab.is-on { background: #fff; color: var(--text-1, #1d2330); font-weight: 500; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }

/* Ô bảng rút gọn 1 dòng, rê chuột xem đủ (dùng chung mọi màn — chuyển từ cham-soc.css 21/09/2026)
 * Nhớ kèm th { width: 1px } cho cột đó, vì max-width trên <td> bị trình duyệt bỏ qua. */
.o-gon { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.cs-tep-loi { display: grid; place-items: center; width: 100%; height: 100%; font-size: 10px; color: var(--text-3, #8b93a3); }

/* Khung xem ảnh dùng chung (23/09/2026): xoay · phóng to · kéo · chuyển ảnh. KHÔNG có nút tải xuống. */
#violaXemAnh { position: fixed; inset: 0; z-index: 10000; background: rgba(18,16,14,.93); display: flex; align-items: center; justify-content: center; overflow: hidden; }
#violaXemAnh[hidden] { display: none; }
#violaXemAnh img { max-width: 94vw; max-height: calc(100vh - 80px); transform-origin: center; transition: transform .12s ease-out; user-select: none; background: #fff; border-radius: 6px; }
.xa-thanh { position: fixed; top: 0; left: 0; right: 0; height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 13px; }
.xa-ten { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.xa-so { opacity: .75; }
.xa-nut { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.xa-nut button, .xa-chuyen { border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; border-radius: 8px;
  width: 34px; height: 32px; font-size: 16px; line-height: 1; cursor: pointer; }
.xa-nut button:hover, .xa-chuyen:hover { background: rgba(255,255,255,.28); }
.xa-ti { min-width: 46px; text-align: center; opacity: .9; font-variant-numeric: tabular-nums; }
.xa-chuyen { position: fixed; top: 50%; transform: translateY(-50%); width: 42px; height: 64px; font-size: 26px; }
.xa-truoc { left: 10px; } .xa-sau { right: 10px; }

/* ---- Bộ lọc chọn trường (24/09/2026): chỉ hiện ô của trường đang cần lọc ---- */
.loc-bo { display: grid; gap: 10px; }
.loc-o { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; }
.loc-o:empty { display: none; }
.loc-mot label { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.loc-bo-mot { border: 0; background: none; cursor: pointer; font-size: 13px; line-height: 1;
  color: var(--ink-faint, #8a8a8a); padding: 2px 4px; border-radius: 6px; }
.loc-bo-mot:hover { color: var(--danger, #c0392b); background: var(--surface-2, #f3f4f6); }
.loc-thanh { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.loc-them { max-width: 220px; }
@media (max-width: 560px) { .loc-them { max-width: 100%; flex: 1 1 auto; } }
/* trong khung "⚙ Bộ lọc" của màn Chăm sóc: phần chọn trường chiếm trọn hàng, mấy ô tích
   "cách xem" (ca đã huỷ / thùng rác) xuống hàng dưới cho khỏi chen ngang */
.tt-bo-loc-trong > #csLocO, .kh-bo-loc-trong > #khLocO { flex: 1 1 100%; min-width: 0; }
.cs-xem-them { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px 22px;
  padding-top: 8px; border-top: 1px dashed var(--line, #e6ded8); }
.cs-xem-them .check-row { margin: 0; }
.cs-xem-them[hidden] { display: none; }   /* display:flex ở trên đè mất thuộc tính hidden nếu không có dòng này */
