/* ==========================================================================
   Tối ưu UX/UI màn đơn hàng (nạp CUỐI CÙNG trong index.html để ghi đè).
   - Font Be Vietnam Pro: thiết kế cho tiếng Việt, dấu không bị trộn font.
   - Bảng đơn 14px, tiêu đề 12.5px, số canh đều (tabular-nums).
   - Dòng đơn 11 cột (app.js → orderRowHTML), có ảnh + tên sản phẩm.
   ========================================================================== */
:root {
  --ux-font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --ux-text: #1f2733;
  --ux-muted: #667385;
  --ux-line: #e4e8ee;
  --ux-row-hover: #f6f9fd;
  --ux-row-selected: #edf4ff;
  --ux-accent: #2867d5;
}
html body, body button, body input, body select, body textarea, body .order-detail-panel, body .order-detail-panel * {
  font-family: var(--ux-font) !important;
}
body { color: var(--ux-text); -webkit-font-smoothing: antialiased; }

/* ---- Tab trạng thái: một hàng cuộn ngang, tab = 0 mờ đi ---- */
#ordersView #statusTabs {
  display: flex !important; flex-wrap: nowrap !important; gap: 8px !important;
  overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin;
}
#ordersView #statusTabs button {
  flex: none !important; width: auto !important; min-width: 0 !important;
  height: 38px !important; padding: 0 12px !important; gap: 10px !important;
  border-radius: 10px !important; font-size: 13.5px !important; font-weight: 500 !important;
  display: inline-flex !important; align-items: center !important; justify-content: space-between !important;
  white-space: nowrap;
}
#ordersView #statusTabs button b {
  font-size: 12.5px !important; font-weight: 700 !important; min-width: 24px; height: 22px;
  border-radius: 11px; display: inline-grid; place-items: center; padding: 0 7px; font-variant-numeric: tabular-nums;
}
#ordersView #statusTabs button.is-zero { opacity: .45; }
#ordersView #statusTabs button.is-zero:hover { opacity: 1; }
#ordersView #statusTabs button.selected { font-weight: 700 !important; }

/* ---- Thẻ tổng & ô tìm kiếm ---- */
#ordersView .order-range-summary article strong { font-size: 22px !important; font-variant-numeric: tabular-nums; }
#ordersView .order-range-summary article span { font-size: 13px !important; }
#ordersView #orderSearch { font-size: 14px !important; height: 42px !important; }
#ordersView .filters button { font-size: 13.5px !important; }

/* ---- Bảng đơn ---- */
#ordersView .table-wrap table { width: 100% !important; min-width: 1240px !important; table-layout: auto !important; border-collapse: separate !important; border-spacing: 0 !important; }
#ordersView .table-wrap table thead th {
  position: sticky; top: 0; z-index: 2; background: #f3f6fa !important;
  font-size: 12.5px !important; font-weight: 600 !important; color: #4d5a6b !important;
  text-transform: none !important; letter-spacing: 0 !important; text-align: left !important;
  height: 44px !important; padding: 0 12px !important; white-space: nowrap; border-bottom: 1px solid var(--ux-line) !important;
}
#ordersView .table-wrap tr.ux-row > td {
  font-size: 14px !important; color: var(--ux-text) !important; height: auto !important;
  padding: 12px !important; vertical-align: middle !important; text-align: left !important;
  border-top: 1px solid var(--ux-line) !important; white-space: normal !important; font-variant-numeric: tabular-nums;
}
#ordersView .table-wrap tr.ux-row:hover > td { background: var(--ux-row-hover); }
#ordersView .table-wrap tr.ux-row.order-row-selected > td { background: var(--ux-row-selected); }
#ordersView .table-wrap tr.ux-row.order-row-expanded > td { background: #f8fafc; border-bottom: 0 !important; }

/* Độ rộng 11 cột (ghi đè quy tắc 14 cột cũ trong order-management.css / ui-polish.css) */
#ordersView .table-wrap table thead th:nth-child(1), #ordersView .table-wrap tr.ux-row > td:nth-child(1) { width: 40px !important; min-width: 40px; text-align: center !important; padding: 0 4px !important; }
#ordersView .table-wrap table thead th:nth-child(2), #ordersView .table-wrap tr.ux-row > td:nth-child(2) { width: 44px !important; min-width: 44px; text-align: center !important; padding: 0 4px !important; }
#ordersView .table-wrap table thead th:nth-child(3), #ordersView .table-wrap tr.ux-row > td:nth-child(3) { width: 140px !important; min-width: 140px; }
#ordersView .table-wrap table thead th:nth-child(4), #ordersView .table-wrap tr.ux-row > td:nth-child(4) { width: auto !important; min-width: 280px; }
#ordersView .table-wrap table thead th:nth-child(5), #ordersView .table-wrap tr.ux-row > td:nth-child(5) { width: 170px !important; min-width: 150px; }
#ordersView .table-wrap table thead th:nth-child(6), #ordersView .table-wrap tr.ux-row > td:nth-child(6) { width: 160px !important; min-width: 150px; }
#ordersView .table-wrap table thead th:nth-child(7), #ordersView .table-wrap tr.ux-row > td:nth-child(7) { width: 160px !important; min-width: 160px; }
#ordersView .table-wrap table thead th:nth-child(8), #ordersView .table-wrap tr.ux-row > td:nth-child(8) { width: 110px !important; }
#ordersView .table-wrap table thead th:nth-child(9), #ordersView .table-wrap tr.ux-row > td:nth-child(9) { width: 76px !important; text-align: center !important; }
#ordersView .table-wrap table thead th:nth-child(10), #ordersView .table-wrap tr.ux-row > td:nth-child(10) { width: 104px !important; min-width: 104px; text-align: center !important; }
#ordersView .table-wrap table thead th:nth-child(11), #ordersView .table-wrap tr.ux-row > td:nth-child(11) { width: 60px !important; text-align: center !important; }

/* Cột Đơn hàng */
.ux-order { display: grid; gap: 2px; }
.ux-order .ux-sub { flex-wrap: nowrap; white-space: nowrap; }
.ux-order .ux-order-id { font-size: 15px !important; font-weight: 700 !important; color: var(--ux-accent) !important; text-align: left; padding: 0 !important; letter-spacing: .2px; }
.ux-sub { font-size: 12.5px; color: var(--ux-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ux-age { font-size: 11.5px; font-weight: 600; border-radius: 6px; padding: 1px 6px; background: #eef1f5; color: #4d5a6b; }
.ux-age.warn { background: #fff3df; color: #9a5a00; }
.ux-age.late { background: #fdecec; color: #c93632; }
.ux-chip { font-size: 11.5px !important; font-weight: 600 !important; border-radius: 6px !important; padding: 1px 6px !important; background: #eef4ff !important; color: var(--ux-accent) !important; border: 0 !important; height: auto !important; }

/* Cột Sản phẩm */
.ux-product { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ux-product img, .ux-noimg { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; background: #f1f4f8; border: 1px solid var(--ux-line); }
.ux-noimg { display: grid; place-items: center; font-size: 11px; color: var(--ux-muted); }
.ux-product > div { min-width: 0; display: grid; gap: 3px; }
.ux-title { font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ux-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-meta { font-size: 13px; color: #3d4757; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ux-meta b { font-weight: 700; color: var(--ux-text); }
.ux-more { color: #b45309; font-weight: 600; }
.ux-custom { font-size: 12.5px; color: var(--ux-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 460px; }

/* Cột Khách hàng */
.ux-customer { display: grid !important; gap: 2px; text-align: left !important; padding: 0 !important; background: none !important; border: 0 !important; height: auto !important; cursor: pointer; }
.ux-customer b { font-size: 14px; font-weight: 600; color: var(--ux-text); }
.ux-customer small { font-size: 12.5px; color: var(--ux-muted); }
.ux-customer:hover b { color: var(--ux-accent); text-decoration: underline; }

/* Cột Trạng thái */
.ux-status { display: grid; gap: 4px; justify-items: start; }
.ux-status small { font-size: 12px; color: var(--ux-muted); }
.ux-status .ux-track { color: #0e7490; font-weight: 600; }
#ordersView .table-wrap .order-status { font-size: 12.5px !important; font-weight: 600 !important; padding: 5px 10px !important; border-radius: 999px !important; white-space: nowrap; line-height: 1.2; }
.order-status.new-order { color: #1d4ed8 !important; background: #e8efff !important; }
.order-status.fulfilled, .order-status.shipped { color: #12824c !important; background: #e8f8ef !important; }
.order-status.cancelled { color: #6b7280 !important; background: #f1f2f4 !important; }

/* Cột Tiền */
.ux-money { display: grid; gap: 4px; }
.ux-money > div { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; white-space: nowrap; }
.ux-money span { font-size: 12px; color: var(--ux-muted); white-space: nowrap; }
.ux-money b { font-size: 14px; font-weight: 700; white-space: nowrap; }
.ux-money em { font-size: 12px; font-style: normal; color: #b45309; white-space: nowrap; }

/* Thao tác & pill */
.ux-actions { display: grid !important; gap: 4px !important; }
.ux-actions { gap: 3px !important; }
.ux-actions .order-mini-action { font-size: 12px !important; height: 24px !important; min-height: 0 !important; line-height: 1 !important; padding: 0 8px !important; white-space: nowrap !important; width: 100% !important; }
#ordersView .table-wrap tr.ux-row .order-control-pill { font-size: 12.5px !important; height: 30px !important; min-width: 48px; width: auto !important; padding: 0 10px !important; white-space: nowrap !important; }
#ordersView .order-expand { width: 32px !important; height: 32px !important; }

/* Phân trang & thanh chọn */
#orderPagination { font-size: 13.5px !important; }
#ordersView .order-selection-bar { font-size: 14px !important; }

@media (max-width: 1100px) {
  .ux-custom { max-width: 260px; }
  #ordersView .table-wrap table thead th:nth-child(4), #ordersView .table-wrap tr.ux-row > td:nth-child(4) { min-width: 260px; }
}

/* Tiền: thực nhận + lợi nhuận (app.js → orderEconomics) */
.ux-money { gap: 2px !important; }
.ux-money span { font-size: 11.5px !important; }
.ux-money b { font-size: 13px !important; }
.ux-money .ux-net { color: #3d4757; font-weight: 600; }
.ux-profit-line { border-top: 1px dashed var(--ux-line); padding-top: 2px; }
.ux-profit.pos { color: #12824c; }
.ux-profit.low { color: #b45309; }
.ux-profit.neg { color: #c93632; }
#ordersView .order-range-summary { display: grid !important; grid-template-columns: repeat(4, minmax(180px, 1fr)) !important; gap: 12px !important; max-width: 1100px; }
.ux-profit-total { color: #12824c; }
.ux-profit-total.neg { color: #c93632; }
@media (max-width: 900px) { #ordersView .order-range-summary { grid-template-columns: 1fr 1fr !important; } }

/* Nút "Gửi đơn sẵn sàng" trên hàng bộ lọc: CSS chung .filters button đặt nền trắng → chữ trắng bị ẩn. */
#ordersView .filters #sendReady { background: #e8590c !important; color: #fff !important; border: 1px solid #e8590c !important; font-weight: 600 !important; padding: 0 14px !important; }
#ordersView .filters #sendReady:hover { background: #c94c0a !important; }
#ordersView .filters #sendReady:disabled { background: #e5e8ed !important; border-color: #e5e8ed !important; color: #8a94a3 !important; cursor: not-allowed; }

/* Ô chọn shop trên hàng bộ lọc (app.js → renderShopFilter) */
#ordersView .ux-shop-filter { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 4px 0 12px; border: 1px solid var(--ux-line); border-radius: 8px; background: #fff; font-size: 13.5px; font-weight: 600; color: #3d4757; }
#ordersView .ux-shop-filter span { white-space: nowrap; }
#ordersView .ux-shop-filter select { height: 32px; border: 0; background: transparent; font-size: 13.5px; font-weight: 500; color: var(--ux-text); max-width: 260px; cursor: pointer; padding: 0 6px; }
#ordersView .ux-shop-filter select:focus { outline: 2px solid var(--ux-accent); outline-offset: 1px; border-radius: 6px; }
#ordersView .ux-shop-filter.active { border-color: var(--ux-accent); background: #eef4ff; }
#ordersView .ux-shop-filter.active span { color: var(--ux-accent); }

/* ==========================================================================
   Chi tiết đơn (mở dòng đơn) — bố cục THẺ 3 cột thay cho bảng 6 cột chật chội.
   Trái: sản phẩm + file PNG | Giữa: SKU/biến thể + cá nhân hoá + ảnh listing
   Phải: số lượng → xưởng (cost center) → tracking & ghi chú.
   Chỉ đổi CSS: HTML/chức năng giữ nguyên (app.js → orderItemDetails).
   ========================================================================== */
#ordersView .order-detail-panel { padding: 12px 16px 16px !important; overflow: visible !important; background: #f4f6fa !important; }
#ordersView .order-detail-panel > table { display: block !important; width: 100% !important; min-width: 0 !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; table-layout: auto !important; overflow: visible !important; }
#ordersView .order-detail-panel > table > thead { display: none !important; }
#ordersView .order-detail-panel > table > tbody { display: grid !important; gap: 12px !important; }
#ordersView .order-detail-panel > table > tbody > tr {
  display: grid !important;
  grid-template-columns: minmax(290px, 1fr) minmax(300px, 1.2fr) minmax(330px, 1.05fr);
  grid-template-areas: "a b d" "a c e" "a c f";
  grid-template-rows: auto auto 1fr;
  background: #fff !important; border: 1px solid #e1e7ef !important; border-radius: 12px !important; overflow: hidden !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
#ordersView .order-detail-panel > table > tbody > tr > td {
  display: block !important; width: auto !important; min-width: 0 !important; height: auto !important;
  padding: 14px 16px !important; border: 0 !important; background: #fff !important; text-align: left !important;
  vertical-align: top !important; white-space: normal !important; font-size: 13px !important;
}
#ordersView .order-detail-panel > table > tbody > tr:hover > td { background: #fff !important; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(1) { grid-area: a; border-right: 1px solid #edf0f5 !important; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(2) { grid-area: b; border-right: 1px solid #edf0f5 !important; padding-bottom: 6px !important; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(3) { grid-area: c; border-right: 1px solid #edf0f5 !important; padding-top: 6px !important; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(4) { grid-area: d; background: #fafbfd !important; padding-bottom: 8px !important; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(5) { grid-area: e; background: #fafbfd !important; border-top: 1px solid #edf0f5 !important; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(6) { grid-area: f; background: #fafbfd !important; border-top: 1px solid #edf0f5 !important; }
/* Tiêu đề nhỏ cho từng khối (thay hàng tiêu đề bảng đã ẩn) */
#ordersView .order-detail-panel > table > tbody > tr > td::before {
  display: block; margin-bottom: 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #8390a3;
}
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(1)::before { content: "Sản phẩm"; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(2)::before { content: "SKU & biến thể"; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(3)::before { content: "Cá nhân hoá & ảnh listing"; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(4)::before { content: "Số lượng"; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(5)::before { content: "Xưởng (cost center)"; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(6)::before { content: "Tracking & ghi chú"; }

/* Trái: sản phẩm */
#ordersView .order-detail-panel .detail-product { display: grid !important; grid-template-columns: 76px minmax(0, 1fr) !important; gap: 12px !important; min-width: 0 !important; }
#ordersView .order-detail-panel .detail-image-button, #ordersView .order-detail-panel .detail-image-empty { width: 76px !important; height: 76px !important; border-radius: 10px !important; overflow: hidden !important; }
#ordersView .order-detail-panel .detail-image-button img { width: 100% !important; height: 100% !important; object-fit: cover !important; }
#ordersView .order-detail-panel .detail-product-meta > b { font-size: 13.5px !important; line-height: 1.4 !important; color: var(--ux-text) !important; -webkit-line-clamp: 3 !important; }
#ordersView .order-detail-panel .detail-product-meta dl { gap: 5px !important; margin-top: 10px !important; }
#ordersView .order-detail-panel .detail-product-meta dl > div { grid-template-columns: 88px minmax(0, 1fr) !important; font-size: 12.5px !important; }
#ordersView .order-detail-panel .png-form { margin-top: 14px !important; min-width: 0 !important; }

/* Giữa: SKU / biến thể / cá nhân hoá */
#ordersView .order-detail-panel .detail-stack { gap: 6px !important; font-size: 13px !important; line-height: 1.45 !important; }
#ordersView .order-detail-panel .detail-stack > div { display: grid !important; grid-template-columns: 120px minmax(0, 1fr) !important; gap: 8px !important; align-items: baseline; }
#ordersView .order-detail-panel .detail-stack b { margin: 0 !important; color: #5b6778 !important; font-weight: 600 !important; }
#ordersView .order-detail-panel .detail-stack strong, #ordersView .order-detail-panel .detail-stack span { color: var(--ux-text) !important; font-weight: 600 !important; overflow-wrap: anywhere !important; }
#ordersView .order-detail-panel .detail-sku > div:first-child strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace !important; font-size: 12.5px !important; }
#ordersView .order-detail-panel .detail-customization .listing-gallery { display: block !important; margin: 6px 0 4px !important; }
#ordersView .order-detail-panel .listing-gallery > b { display: block !important; margin-bottom: 8px !important; font-size: 12.5px !important; color: #5b6778 !important; }
#ordersView .order-detail-panel .listing-gallery > div { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)) !important; gap: 6px !important; max-width: 480px !important; }
#ordersView .order-detail-panel .listing-gallery a { width: auto !important; height: auto !important; aspect-ratio: 1 / 1; border-radius: 8px !important; }

/* Phải: số lượng (1 hàng ngang) */
#ordersView .order-detail-panel .detail-qty { display: grid !important; grid-template-columns: 84px minmax(0, 1fr) 64px !important; gap: 10px !important; align-items: end !important; font-size: 12px !important; color: #5b6778 !important; }
#ordersView .order-detail-panel .detail-qty label { gap: 4px !important; }
#ordersView .order-detail-panel .detail-qty input, #ordersView .order-detail-panel .qty-stepper, #ordersView .order-detail-panel .qty-ok { height: 36px !important; }
#ordersView .order-detail-panel .qty-stepper { display: grid !important; grid-template-columns: 34px minmax(0, 1fr) 34px !important; }
#ordersView .order-detail-panel .qty-ok { width: 100% !important; border-radius: 8px !important; }

/* Phải: xưởng / cost center — nhãn trái, ô chọn phải, đủ rộng */
#ordersView .order-detail-panel .cost-center-fields { gap: 8px !important; }
#ordersView .order-detail-panel .cost-center-fields label { grid-template-columns: 104px minmax(0, 1fr) !important; gap: 10px !important; font-size: 12.5px !important; }
#ordersView .order-detail-panel .cost-center-fields label > span { color: #5b6778 !important; font-weight: 600 !important; }
#ordersView .order-detail-panel .cost-center-fields select { width: 100% !important; min-width: 0 !important; height: 36px !important; font-size: 13px !important; text-overflow: ellipsis; }
#ordersView .order-detail-panel .fulfill-name { display: grid !important; grid-template-columns: 104px minmax(0, 1fr) auto !important; gap: 10px !important; align-items: center !important; }
#ordersView .order-detail-panel .fulfill-name > span { display: contents !important; }
#ordersView .order-detail-panel .fulfill-name b { color: #5b6778 !important; font-weight: 600 !important; font-size: 12.5px !important; }
#ordersView .order-detail-panel .fulfill-name em {
  display: block !important; min-width: 0 !important; font-style: normal !important; font-family: ui-monospace, SFMono-Regular, Consolas, monospace !important;
  font-size: 12.5px !important; color: var(--ux-text) !important; background: #eef2f7 !important; border-radius: 6px !important; padding: 6px 8px !important;
  white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; word-break: normal !important;
}
#ordersView .order-detail-panel .copy-fulfill { height: 32px !important; padding: 0 12px !important; white-space: nowrap !important; }

/* Phải: tracking & ghi chú */
#ordersView .order-detail-panel .detail-tracking { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
#ordersView .order-detail-panel .detail-tracking input, #ordersView .order-detail-panel .detail-tracking select { width: 100% !important; height: 36px !important; font-size: 13px !important; }
#ordersView .order-detail-panel .detail-tracking select, #ordersView .order-detail-panel .detail-tracking textarea, #ordersView .order-detail-panel .detail-tracking .detail-update { grid-column: 1 / -1 !important; }
#ordersView .order-detail-panel .detail-tracking textarea { width: 100% !important; min-height: 64px !important; height: 64px !important; font-size: 13px !important; resize: vertical !important; }
#ordersView .order-detail-panel .detail-tracking .detail-update { height: 38px !important; width: 100% !important; border-radius: 8px !important; font-weight: 600 !important; }

@media (max-width: 1150px) {
  #ordersView .order-detail-panel > table > tbody > tr { grid-template-columns: 1fr 1fr; grid-template-areas: "a b" "a c" "d e" "f f"; }
  #ordersView .order-detail-panel > table > tbody > tr > td:nth-child(3) { border-right: 0 !important; }
  #ordersView .order-detail-panel > table > tbody > tr > td:nth-child(4), #ordersView .order-detail-panel > table > tbody > tr > td:nth-child(5) { border-top: 1px solid #edf0f5 !important; }
}
@media (max-width: 760px) {
  #ordersView .order-detail-panel > table > tbody > tr { grid-template-columns: 1fr; grid-template-areas: "a" "b" "c" "d" "e" "f"; }
  #ordersView .order-detail-panel > table > tbody > tr > td { border-right: 0 !important; border-top: 1px solid #edf0f5 !important; }
}

/* Khối Xưởng (khớp thật từ API) + Tracking (API) + ghi chú tay (app.js → vendorMatchHTML / vendorTrackingHTML / noteFormHTML) */
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(5)::before { content: "Xưởng & sản phẩm in"; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(6)::before { content: "Tracking & ghi chú"; }
.vm-box { display: grid; gap: 10px; }
.vm-list { display: grid; gap: 6px; margin: 0; }
.vm-list > div { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; align-items: baseline; font-size: 13px; }
.vm-list dt { color: #5b6778; font-weight: 600; font-size: 12.5px; }
.vm-list dd { margin: 0; color: var(--ux-text); min-width: 0; overflow-wrap: anywhere; }
.vm-list code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; background: #eef2f7; border-radius: 6px; padding: 2px 6px; }
.vm-sub { color: #5b6778; font-size: 12.5px; }
.vm-src { display: inline-block; font-size: 11.5px; font-weight: 600; color: #12824c; background: #e8f8ef; border-radius: 999px; padding: 2px 8px; }
.vm-missing { color: #b45309; font-weight: 600; }
.vm-empty { margin: 0; color: #5b6778; font-size: 13px; }
.vm-map { justify-self: start; height: 34px; border: 1px solid #2867d5; border-radius: 8px; background: #fff; color: #2867d5; padding: 0 14px; font: 600 13px var(--ux-font); cursor: pointer; }
.vm-map:hover { background: #eef4ff; }
.vt-box { display: grid; gap: 10px; }
.vt-none { margin: 0; font-size: 12.5px; color: #5b6778; line-height: 1.5; }
.vt-api { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid #d7e7dc; border-radius: 10px; background: #f3fbf6; }
.vt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.vt-track { display: grid; gap: 6px; }
.vt-track > span { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.vt-track code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; font-weight: 600; background: #fff; border: 1px solid #d7e7dc; border-radius: 6px; padding: 3px 8px; }
.vt-copy { height: 28px; border: 1px solid var(--ux-line); border-radius: 6px; background: #fff; padding: 0 10px; font: 600 12px var(--ux-font); cursor: pointer; }
.vt-wait { font-size: 12.5px; color: #5b6778; }
.note-form { display: grid; gap: 8px; }
.note-form .nf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note-form input, .note-form textarea { width: 100%; min-width: 0; border: 1px solid var(--ux-line); border-radius: 8px; padding: 0 10px; font: 13px var(--ux-font); background: #fff; }
.note-form input { height: 36px; }
.note-form textarea { min-height: 64px; padding: 8px 10px; resize: vertical; }
.note-form input:focus, .note-form textarea:focus { outline: 2px solid #2867d5; outline-offset: -1px; }
.note-form .nf-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-form .nf-foot small { font-size: 12px; color: #7a8592; }
.note-form .nf-foot button { height: 36px; border: 0; border-radius: 8px; background: #2867d5; color: #fff; padding: 0 20px; font: 600 13px var(--ux-font); cursor: pointer; }
.note-form .nf-foot button:disabled { opacity: .5; cursor: wait; }

/* Đơn nhiều sản phẩm: liệt kê ở dòng đơn + dải tóm tắt + đánh số thẻ (app.js → itemSummary) */
.ux-count { display: inline-block; margin-left: 2px; font-size: 11px; font-weight: 700; color: #b45309; background: #fff3df; border-radius: 6px; padding: 1px 6px; }
.ux-items { list-style: none; margin: 3px 0 0; padding: 0; display: grid; gap: 2px; }
.ux-items li { font-size: 12.5px; color: #3d4757; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.45; }
.ux-items li b { color: var(--ux-text); font-weight: 700; }
.ux-it-custom, .ux-it-title { color: #667385; }
.ux-n { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-right: 5px; border-radius: 50%; background: #e8efff; color: #1d4ed8; font-size: 10.5px; font-weight: 700; vertical-align: 1px; }
.ux-ok { margin-left: 5px; color: #12824c; font-weight: 700; }
.items-overview { display: grid; gap: 8px; margin: 0 0 12px; padding: 10px 14px; border: 1px solid #f3d9a8; border-radius: 10px; background: #fffaf0; }
.items-overview > b { font-size: 13px; color: #8a5300; }
.items-overview > div { display: flex; flex-wrap: wrap; gap: 8px; }
.io-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 34px; padding: 0 12px; border: 1px solid #e5d3b3; border-radius: 8px; background: #fff; font: 500 13px var(--ux-font); color: var(--ux-text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.io-chip:hover { border-color: #2867d5; }
.io-chip em { margin-left: 8px; font-style: normal; font-size: 12px; font-weight: 700; color: #c93632; }
.io-chip.ok em { color: #12824c; }
#ordersView .order-detail-panel > table > tbody > tr > td:nth-child(1)::before { content: attr(data-pos); color: #1d4ed8; }
#ordersView .order-detail-panel > table > tbody > tr.io-flash { box-shadow: 0 0 0 3px #93b4f3 !important; transition: box-shadow .3s; }

/* Hạn D+1: nhãn ở dòng đơn + thanh lọc (app.js → slaBadge / renderSlaBar) */
.sla-badge { display: inline-flex; align-items: center; width: fit-content; margin-bottom: 4px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; line-height: 1.5; white-space: nowrap; }
.sla-badge.sla-overdue { background: #fde8e8; color: #b42318; }
.sla-badge.sla-today { background: #fff1e0; color: #b45309; }
.sla-badge.sla-tomorrow { background: #fef9c3; color: #854d0e; }
.sla-badge.sla-later { background: #eef2f7; color: #5b6778; font-weight: 600; }
#ordersView tr.ux-row.sla-row-overdue > td:first-child { box-shadow: inset 4px 0 0 #d92d20; }
#ordersView tr.ux-row.sla-row-today > td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.sla-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.sla-bar[hidden] { display: none !important; }
.sla-title { font-size: 13px; font-weight: 700; color: var(--ux-text, #1f2733); margin-right: 2px; }
.sla-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 1px solid #dfe3ea; border-radius: 8px; background: #fff; font: 600 13px var(--ux-font, inherit); color: #3d4757; cursor: pointer; }
.sla-chip b { min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 12px; text-align: center; }
.sla-chip.sla-overdue b { background: #fde8e8; color: #b42318; }
.sla-chip.sla-today b { background: #fff1e0; color: #b45309; }
.sla-chip.sla-tomorrow b { background: #fef9c3; color: #854d0e; }
.sla-chip:hover { border-color: #2867d5; }
.sla-chip.selected { border-color: #2867d5; background: #eef4ff; color: #1d4ed8; box-shadow: 0 0 0 1px #2867d5 inset; }
.sla-sort { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 12.5px; color: #5b6778; }
.sla-sort > span { margin-right: 4px; }
.sla-sort button { height: 30px; padding: 0 10px; border: 1px solid #dfe3ea; border-radius: 7px; background: #fff; font: 600 12.5px var(--ux-font, inherit); color: #3d4757; cursor: pointer; }
.sla-sort button.selected { background: #1f2733; border-color: #1f2733; color: #fff; }
@media (max-width: 720px) { .sla-sort { margin-left: 0; } }

/* Nút copy mã đơn cạnh mã đơn (app.js → orderRowHTML / .ux-copy-id) */
.ux-id-row { display: inline-flex; align-items: center; gap: 4px; }
.ux-copy-id { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #7a8592; cursor: pointer; }
.ux-copy-id:hover { background: #eef4ff; border-color: #c9d8f5; color: #2867d5; }
.ux-copy-id:focus-visible { outline: 2px solid #2867d5; outline-offset: 1px; }
.ux-copy-id.copied { background: #e8f8ef; border-color: #b7e4c7; color: #12824c; }
#ordersView .ux-copy-id { width: 26px !important; height: 26px !important; min-height: 0 !important; min-width: 0 !important; padding: 0 !important; }

/* Ô vận hành trang Orders (app.js → renderOpsCards): bấm để lọc, bấm lại để bỏ lọc */
#ordersView .order-range-summary { grid-template-columns: repeat(5, minmax(150px, 1fr)) !important; max-width: 1400px; }
#ordersView .order-range-summary .ops-card { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; align-items: center; height: auto; min-height: 0; padding: 11px 14px; border: 1px solid #e1e7ef; border-radius: 10px; background: #fff; text-align: left; font: inherit; cursor: pointer; box-shadow: none; }
#ordersView .order-range-summary .ops-card:hover { border-color: #2867d5; }
#ordersView .order-range-summary .ops-card.selected { border-color: #2867d5; background: #eef4ff; box-shadow: 0 0 0 1px #2867d5 inset; }
#ordersView .order-range-summary .ops-card span { color: #667386; font-size: 13px !important; font-weight: 700; }
#ordersView .order-range-summary .ops-card strong { font-size: 22px !important; font-variant-numeric: tabular-nums; color: #1d2735; }
#ordersView .order-range-summary .ops-card small { grid-column: 1 / -1; color: #929baa; font-size: 11px; }
#ordersView .order-range-summary .ops-overdue strong { color: #b42318; }
#ordersView .order-range-summary .ops-design strong { color: #b45309; }
#ordersView .order-range-summary .ops-shipping strong { color: #1d4ed8; }
@media (max-width: 1100px) { #ordersView .order-range-summary { grid-template-columns: repeat(3, minmax(140px, 1fr)) !important; } }
@media (max-width: 720px) { #ordersView .order-range-summary { grid-template-columns: 1fr 1fr !important; } }

/* Etsy Orders Cost: dòng độ đầy đủ dưới ô số liệu, bấm để lọc bảng */
.report-metric .cost-link { display: inline; height: auto; min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: #2867d5; font: inherit; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.report-metric .cost-link.selected { color: #1d2735; font-weight: 700; text-decoration: none; }

/* Cost Centers → Chi phí cố định (fixed-costs.js) */
.fc-page { max-width: 1200px; }
.fc-hint { margin: 4px 0 14px; color: #5b6778; font-size: 13px; line-height: 1.5; }
.fc-empty { padding: 24px 4px; color: #5b6778; }
.fc-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; }
.fc-toolbar label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: #5b6778; }
.fc-toolbar input { height: 36px; padding: 0 10px; border: 1px solid #dfe3ea; border-radius: 8px; font: inherit; }
.fc-toolbar button, .fc-form button, .fc-actions button { height: 36px; padding: 0 12px; border: 1px solid #dfe3ea; border-radius: 8px; background: #fff; font: 600 13px inherit; cursor: pointer; }
.fc-form button.primary { background: #2867d5; border-color: #2867d5; color: #fff; }
.fc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.fc-cards article { display: grid; gap: 2px; padding: 11px 14px; border: 1px solid #e1e7ef; border-radius: 10px; background: #fff; }
.fc-cards span { color: #667386; font-size: 12px; font-weight: 700; }
.fc-cards strong { font-size: 20px; color: #1d2735; font-variant-numeric: tabular-nums; }
.fc-cards small { color: #929baa; font-size: 11px; }
.fc-form { display: grid; grid-template-columns: 150px minmax(180px, 2fr) 130px 80px 160px minmax(140px, 1.5fr) auto auto; gap: 8px; margin-bottom: 12px; }
.fc-form input, .fc-form select { height: 36px; padding: 0 10px; border: 1px solid #dfe3ea; border-radius: 8px; font: inherit; min-width: 0; }
.fc-actions { white-space: nowrap; }
.fc-actions button { height: 30px; margin-left: 4px; }
.fc-actions button.danger { color: #b42318; }
.report-metric .neg { color: #b42318; }
@media (max-width: 900px) { .fc-form { grid-template-columns: 1fr 1fr; } }

/* Hộp thoại nhập sao kê Etsy (etsy-statement.js) */
.es-dialog { width: min(560px, calc(100vw - 32px)); }
.es-dialog .es-hint { margin: 6px 0; color: #5b6778; font-size: 13px; }
.es-dialog .es-shop { display: grid; gap: 6px; margin: 10px 0; font-weight: 600; }
.es-dialog .es-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13.5px; }
.es-dialog .es-table th { padding: 8px 0 4px; text-align: left; color: #1f2733; }
.es-dialog .es-table td { padding: 4px 0; border-bottom: 1px solid #eef1f5; }
.es-dialog .es-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.es-dialog .es-status { min-height: 18px; font-weight: 600; }

/* Lãi theo kỳ (Hôm nay · Hôm qua · 7 ngày) — Etsy Orders Cost */
.period-profit { margin: 4px 0 14px; }
.period-profit .pr-cards { display: grid; grid-template-columns: repeat(3, minmax(200px, 1fr)); gap: 12px; }
.period-profit .pr-card { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid #e1e7ef; border-radius: 12px; background: #fff; }
.period-profit .pr-card > span { color: #667386; font-size: 13px; font-weight: 700; }
.period-profit .pr-card > strong { font-size: 24px; font-variant-numeric: tabular-nums; color: #157347; }
.period-profit .pr-card > small { color: #929baa; font-size: 11px; margin-bottom: 6px; }
.period-profit .neg { color: #b42318; }
.period-profit dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin: 0; font-size: 12.5px; }
.period-profit dt { color: #667386; }
.period-profit dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.period-profit dd em { color: #b45309; font-style: normal; font-size: 11.5px; }
.period-profit .pr-days { margin-top: 10px; }
.period-profit .pr-days summary { cursor: pointer; font-weight: 700; color: #2867d5; font-size: 13px; }
.period-profit .pr-note { margin: 6px 0 0; color: #929baa; font-size: 11.5px; }
@media (max-width: 760px) { .period-profit .pr-cards { grid-template-columns: 1fr; } }

/* Hộp thoại link upload theo shop (upload-links.js) */
.ul-dialog { width: min(900px, calc(100vw - 32px)); }
.ul-dialog .ul-hint { margin: 6px 0 10px; color: #5b6778; font-size: 13.5px; }
.ul-dialog .ul-err { color: #b42318; font-weight: 600; }
.ul-dialog .ul-muted { color: #929baa; }
.ul-dialog .ul-list { display: grid; gap: 10px; }
.ul-dialog .ul-row { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid #e1e7ef; border-radius: 10px; }
.ul-dialog .ul-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ul-dialog .ul-link { display: flex; gap: 6px; }
.ul-dialog .ul-link input { flex: 1; min-width: 180px; height: 32px; padding: 0 8px; border: 1px solid #dfe3ea; border-radius: 7px; font: 12.5px ui-monospace, monospace; color: #1d2735; background: #f7f9fc; }
.ul-dialog button { height: 32px; padding: 0 10px; border: 1px solid #dfe3ea; border-radius: 7px; background: #fff; font: 600 12.5px inherit; cursor: pointer; white-space: nowrap; }
.ul-dialog .ul-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ul-dialog .ul-danger { color: #b42318; }

/* Ảnh listing: ảnh 2 có link tải; ảnh khác rê chuột phóng to */
#ordersView .order-detail-panel .listing-gallery > div { grid-template-columns: repeat(auto-fill, 52px) !important; }
#ordersView .order-detail-panel .listing-gallery .lg-pick { position: relative; padding: 0 !important; border: 0 !important; background: none !important; }
#ordersView .order-detail-panel .listing-gallery .lg-pick.picked { outline: 2px solid #34c759; outline-offset: 1px; cursor: pointer; }
#ordersView .order-detail-panel .listing-gallery .lg-pick.locked img { opacity: .55; }
#ordersView .order-detail-panel .listing-gallery .lg-pick i { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%; background: #34c759; color: #fff; font: 700 10px/16px system-ui; text-align: center; font-style: normal; }
#ordersView .order-detail-panel .listing-gallery .lg-zoom, #ordersView .order-detail-panel .listing-gallery .lg-link { display: block; width: 52px !important; height: 52px !important; border-radius: 8px !important; overflow: visible; cursor: zoom-in; }
#ordersView .order-detail-panel .listing-gallery .lg-link { cursor: pointer; }
#ordersView .order-detail-panel .listing-gallery .lg-zoom img, #ordersView .order-detail-panel .listing-gallery .lg-link img { width: 52px !important; height: 52px !important; border-radius: 8px !important; }
#ordersView .order-detail-panel .listing-gallery .lg-link { position: relative; outline: 2px solid #0071e3; outline-offset: 1px; }
#ordersView .order-detail-panel .listing-gallery .lg-link i { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%; background: #0071e3; color: #fff; font: 700 10px/16px system-ui; text-align: center; font-style: normal; }
.lg-preview { position: fixed; z-index: 9999; pointer-events: none; padding: 6px; background: #fff; border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.lg-preview[hidden] { display: none; }
.lg-preview img { display: block; width: 100%; height: auto; border-radius: 10px; }
.copy-sku { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: 6px; padding: 0; vertical-align: middle; border: 1px solid #d2d2d7; border-radius: 6px; background: #fff; color: #6e6e73; cursor: pointer; }
.copy-sku:hover { border-color: #0071e3; color: #0071e3; background: #f0f6ff; }
.copy-sku svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Tracking → Etsy: icon copy + trạng thái đã/chưa add */
.trk-copy { display: inline-grid !important; place-items: center; width: 22px !important; height: 22px !important; min-height: 0 !important; flex: 0 0 auto; margin-left: 4px; padding: 0; vertical-align: middle; border: 1px solid #d2d2d7; border-radius: 6px; background: #fff; color: #6e6e73; cursor: pointer; }
.trk-copy:hover { border-color: #0071e3; color: #0071e3; background: #f0f6ff; }
.trk-copy.done { border-color: #a7e3bd; color: #12824c; background: #e8f8ef; }
.trk-copy svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.etsy-trk { display: inline-block; margin: 4px 0 0 4px; padding: 1px 8px; border-radius: 999px; font: 600 11px/18px -apple-system, Inter, sans-serif; white-space: nowrap; }
.etsy-trk.ok { color: #12824c; background: #e8f8ef; }
.etsy-trk.todo { color: #b45309; background: #fff4e5; }
.etsy-trk-undo { margin-left: 6px; padding: 0; border: 0; background: none; color: #86868b; font-size: 11px; text-decoration: underline; cursor: pointer; }
#statusTabs .trk-tab b { background: #fff4e5; color: #b45309; }

/* Copy địa chỉ khách */
.addr-copy { display: inline-flex !important; align-items: center; gap: 4px; width: auto !important; height: 24px !important; min-height: 0 !important; margin-top: 4px; padding: 0 8px !important; border: 1px solid #d2d2d7; border-radius: 6px; background: #fff; color: #6e6e73; font: 500 11.5px/1 -apple-system, Inter, sans-serif; cursor: pointer; }
.addr-copy:hover { border-color: #0071e3; color: #0071e3; background: #f0f6ff; }
.addr-copy svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Link 2 ảnh đã chọn gửi khách */
#ordersView .order-detail-panel .lg-links { display: grid; gap: 6px; margin-top: 10px; padding: 10px; border-radius: 10px; background: #f0faf3; }
#ordersView .order-detail-panel .lg-links > div { display: grid !important; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 8px; }
#ordersView .order-detail-panel .lg-links span { color: #12824c; font-weight: 600; font-size: 12px; white-space: nowrap; }
#ordersView .order-detail-panel .lg-links a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; text-decoration: none !important; }
.lg-link-copy { height: 26px !important; padding: 0 10px !important; border: 1px solid #a7e3bd; border-radius: 6px; background: #fff; color: #12824c; font: 600 11.5px -apple-system, Inter, sans-serif; cursor: pointer; }
.lg-link-copy.all { justify-self: start; background: #34c759; border-color: #34c759; color: #fff; }
#ordersView .order-detail-panel .listing-gallery .lg-links a { display: block !important; width: auto !important; height: auto !important; aspect-ratio: auto !important; border: 0 !important; border-radius: 0 !important; background: none !important; overflow: hidden !important; color: #0071e3 !important; }
#ordersView .order-detail-panel .listing-gallery .lg-links .lg-link-copy { min-height: 0 !important; height: 26px !important; width: auto !important; }
