/* =====================================================================
   XPRINT — lớp CSS duy nhất bên cạnh theme DevExtreme.
   Giao diện = theme DevExtreme Fluent (dx.xprint.light/dark.css, dựng từ
   design-system/theme/). File này CHỈ chứa thứ DevExtreme không có sẵn:
   khung trang, tiêu đề trang, nhãn trạng thái, thẻ số liệu.
   Luật: design-system/MASTER.md
   ===================================================================== */

/* ---------- Token: đúng bảng màu của theme Fluent Blue ---------- */
:root {
  --xp-canvas:   #fafafa;   /* nền trang (thẻ dx-card nền trắng nổi lên) */
  --xp-surface:  #ffffff;   /* = nền dx-card / widget Fluent light */
  --xp-border:   #e0e0e0;   /* = viền dx-card Fluent light */
  --xp-ink:      #242424;   /* = chữ Fluent light */
  --xp-muted:    #707070;
  --xp-accent:   #0f6cbd;   /* = nút default Fluent light */
  --xp-success:  #107c10;   /* = nút success Fluent */
  --xp-warning:  #f0ad4e;   /* = toast warning */
  --xp-danger:   #d13438;   /* = nút danger Fluent */
  --xp-hover:    rgba(0, 0, 0, 0.04);
  --xp-header-h: 56px;
  --xp-radius:   4px;       /* = bo góc mặc định của theme (khung tự vẽ dùng chung) */
}
html[data-theme="dark"] {
  --xp-canvas:   #1f1f1f;
  --xp-surface:  #292929;   /* = nền dx-card / widget Fluent dark */
  --xp-border:   #616161;   /* = viền dx-card Fluent dark */
  --xp-ink:      #ffffff;
  --xp-muted:    #adadad;
  --xp-accent:   #479ef5;   /* = nút default Fluent dark */
  --xp-hover:    rgba(255, 255, 255, 0.05);
}

/* ---------- Nền ---------- */
html, body.dx-viewport { height: 100%; margin: 0; }
body.dx-viewport { background: var(--xp-canvas); color: var(--xp-ink); }

/* ---------- Khung: thanh đầu trang (dxToolbar) + menu bên cố định (dxTreeView) ---------- */
.x-shell { display: flex; flex-direction: column; height: 100vh; }
.x-header {
  flex: 0 0 var(--xp-header-h);
  display: flex; align-items: center;
  background: var(--xp-surface);
  border-bottom: 1px solid var(--xp-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  position: relative; z-index: 2;
}
.x-header .dx-toolbar { background: transparent; padding: 0 8px; }
.x-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; white-space: nowrap; color: inherit !important; text-decoration: none !important; }
.x-brand img { width: 28px; height: 28px; }
.x-body { flex: 1 1 auto; min-height: 0; display: flex; }
/* Menu bên: mặc định ẩn, nút ☰ mở ĐÈ lên nội dung ở mọi bề ngang (không đẩy nội dung ⇒ các màn không phải dựng lại) */
.x-side { position: fixed; top: var(--xp-header-h); bottom: 0; left: 0; z-index: 1500; width: 250px;
  background: var(--xp-surface); border-right: 1px solid var(--xp-border); overflow-y: auto;
  transform: translateX(-100%); transition: transform .2s; }
body.x-side-open .x-side { transform: none; box-shadow: 2px 0 8px var(--xp-border); }
.x-side-backdrop { display: none; }
body.x-side-open .x-side-backdrop { display: block; position: fixed; inset: var(--xp-header-h) 0 0 0; z-index: 1400; background: var(--xp-hover); }
.x-nav { background: var(--xp-surface); }
.x-nav .dx-treeview-item { padding-top: 9px; padding-bottom: 9px; white-space: nowrap; }
/* dxTreeView dựng mục có url thành <a>; giữ màu theme kể cả khi màn cũ nạp Bootstrap (a { color:#007bff }) */
.x-nav a.dx-item-url, .x-nav a.dx-item-url:hover { color: inherit; text-decoration: none; }
.x-nav .dx-treeview-node.x-nav-active > .dx-treeview-item { color: var(--xp-accent); background: var(--xp-hover); box-shadow: inset 3px 0 0 var(--xp-accent); }
.x-content { flex: 1 1 auto; min-width: 0; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }
.x-main { flex: 1 0 auto; padding: 24px 28px 40px; }
.x-footer { padding: 14px 28px; color: var(--xp-muted); font-size: 12px; border-top: 1px solid var(--xp-border); }
@media (max-width: 767.98px) { .x-main { padding: 16px; } }

/* ---------- Trang ---------- */
/* Thanh đầu trang = một khung riêng (anh Kiệt chốt 29/09/2026, theo mẫu CRM của DevExtreme):
   tên màn bên trái; nút Thêm, ô chọn trạng thái/lọc, ⟳, Chọn cột, ô tìm bên phải — cùng một hàng, màn hẹp tự xuống dòng.
   Bảng đứng riêng một khung bên dưới (.x-grid-card). */
.x-page-head {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  margin-bottom: 16px; padding: 12px 16px;
  background: var(--xp-surface); border: 1px solid var(--xp-border); border-radius: var(--xp-radius);
}
.x-page-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--xp-muted); }   /* nhãn nhỏ trong nội dung (vd Branding) */
.x-page-head .x-page-title { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }   /* typography Fluent phóng h2 lên 36px */
.x-page-sub { margin-top: 2px; color: var(--xp-muted); font-size: 13px; }
.x-page-actions { flex: 1 1 auto; display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; min-width: 0; }
.x-page-actions > * { flex: none; }   /* nút, nhóm nút, ô khoảng ngày giữ nguyên cỡ; chỉ ô chọn + ô tìm co giãn */
.x-page-actions > .x-list-filter { flex: 0 1 210px; min-width: 150px; }
.x-page-actions > .x-list-search { flex: 0 1 200px; min-width: 160px; }   /* ô tìm ngắn như mẫu CRM (anh Kiệt chốt 30/09/2026) */
/* Vạch ngăn giữa các nút icon (⟳ | Chọn cột), như mẫu CRM của DevExtreme */
.x-page-actions > .x-sep { width: 1px; height: 20px; background: var(--xp-border); }
/* Màn rộng: cả cụm một hàng, các ô co lại trước khi xuống dòng; không đủ chỗ thì cả cụm xuống dưới tên màn */
@media (min-width: 1200px) { .x-page-actions { flex-wrap: nowrap; min-width: auto; } }
@media (max-width: 767.98px) {
  .x-page-head { align-items: stretch; }
  .x-page-actions { justify-content: flex-start; }
  .x-page-actions > .x-list-filter { flex: 1 1 45%; }
  .x-page-actions > .x-list-search { flex: 1 1 180px; min-width: 0; }
  .x-page-actions > .x-sep { display: none; }
}

/* Thẻ nội dung = dx-card của DevExtreme + khoảng đệm chuẩn */
.dx-card.x-block { padding: 16px; margin-bottom: 16px; }
.x-block-title { font-size: 16px; font-weight: 500; margin: 0 0 12px; }

/* ---------- Nhãn trạng thái (DevExtreme không có) ---------- */
.x-status {
  display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap;
  background: color-mix(in srgb, var(--xp-status, var(--xp-muted)) 15%, transparent);
  color: color-mix(in srgb, var(--xp-status, var(--xp-muted)) 85%, var(--xp-ink));
}
.x-status--ok     { --xp-status: var(--xp-success); }
.x-status--warn   { --xp-status: var(--xp-warning); }
.x-status--danger { --xp-status: var(--xp-danger); }
.x-status--info   { --xp-status: var(--xp-accent); }
.x-status--muted  { --xp-status: var(--xp-muted); }

/* Cụm nút thao tác cuối dòng bảng */
.x-row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }

/* ---------- Thẻ số liệu: 4 → 2 → 1 cột ---------- */
.x-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.x-stat { padding: 16px; border-top: 3px solid var(--xp-stat, var(--xp-border)) !important; }
.x-stat-head { display: flex; justify-content: space-between; align-items: center; color: var(--xp-muted); }
.x-stat-head .dx-icon { font-size: 18px; color: var(--xp-stat, var(--xp-muted)); }
.x-stat-value { font-size: 34px; font-weight: 300; line-height: 1.1; margin-top: 10px; }
.x-stat-note { margin-top: 6px; font-size: 12px; color: var(--xp-stat, var(--xp-muted)); }
.x-stat--accent { --xp-stat: var(--xp-accent); }
.x-stat--ok     { --xp-stat: var(--xp-success); }
.x-stat--warn   { --xp-stat: var(--xp-warning); }
.x-stat--danger { --xp-stat: var(--xp-danger); }
.x-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.x-panels > .dx-card { margin-bottom: 0; min-width: 0; }
.x-stat--link { cursor: pointer; }
.x-stat--link:hover { background: var(--xp-hover); }
.x-stat-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
/* Thẻ có biểu đồ nhỏ: số bên trái, dxSparkline / dxBullet bên phải */
.x-stat-body { display: flex; align-items: flex-end; gap: 12px; }
.x-stat-body > .x-grow { flex: 1 1 auto; min-width: 0; }
.x-stat-spark { flex: 0 0 45%; height: 52px; min-width: 0; }
.x-stat-spark:empty { display: none; }
/* Thanh hạn mức mảnh 6px */
.x-quota-bar { height: 6px; overflow: hidden; line-height: 0; }
.x-quota-bar .dx-progressbar, .x-quota-bar .dx-trackbar-wrapper { display: block; }
.x-quota-bar .dx-progressbar::before { display: none; }   /* theme chèn ::before để căn giữa dọc — đẩy thanh ra khỏi khung 6px */
.x-clamp-1 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-pre { white-space: pre-wrap; word-break: break-word; font-family: Consolas, "Courier New", monospace; font-size: 12px;
  max-height: 360px; overflow: auto; margin: 0; padding: 10px; background: var(--xp-canvas); border: 1px solid var(--xp-border); border-radius: var(--xp-radius); }
.x-detail .x-kv dd { display: flex; align-items: center; gap: 4px; }
.x-detail .x-kv dd .dx-button { flex: 0 0 auto; }
.x-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.x-stat-foot .x-stat-note { margin-top: 0; }
@media (max-width: 991.98px) { .x-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .x-stats { grid-template-columns: 1fr; } }

/* ---------- Dashboard: hàng điều khiển, khối "Cần xử lý", biểu đồ ---------- */
.dx-card.x-block.x-block--danger { border-left: 3px solid var(--xp-danger) !important; }
.dx-card.x-block.x-block--warn   { border-left: 3px solid var(--xp-warning) !important; }
.x-alert-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--xp-border); }
.x-alert-row:first-of-type { border-top: 0; }
.x-alert-row .x-grow { flex: 1 1 auto; min-width: 0; }
.x-alert-row a { color: var(--xp-accent); text-decoration: none; white-space: nowrap; }
@media (max-width: 575.98px) {
  .x-alert-row { flex-wrap: wrap; align-items: flex-start; }
  .x-alert-row .x-grow { flex-basis: calc(100% - 100px); }
}
.x-chart { height: 300px; }
/* Danh sách nhãn — giá trị (màn Tình trạng hệ thống) */
.x-kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.x-kv > dt { color: var(--xp-muted); }
.x-kv > dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.x-kv a { color: var(--xp-accent); text-decoration: none; }
/* Hai khối ngang hàng, luôn chia đôi (không để khối lẻ); màn hẹp xếp dọc */
.x-panels--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 991.98px) { .x-panels--2 { grid-template-columns: 1fr; } }
.x-block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.x-block-head .x-block-title { margin: 0; }
.x-block-head a { color: var(--xp-accent); text-decoration: none; white-space: nowrap; }

/* Thanh đầu chật (x-ui.js fitPageHead): c1 = nhóm nút chọn thành ô chọn; c2 = nút có chữ chỉ còn icon */
.x-choice .x-choice-narrow, .x-page-head--c1 .x-choice-wide { display: none; }
.x-page-head--c1 .x-choice-narrow { display: block; }
.x-page-actions > .x-choice { flex: none; }
.x-page-head--c1 .x-page-actions > .x-choice { flex: 0 1 170px; min-width: 130px; }
.x-page-head--c2 .x-page-actions .dx-button-has-text.dx-button-has-icon .dx-button-text { display: none; }
/* Chỉ còn icon: bỏ khoảng cách bên phải icon (dành cho chữ), đệm 6px = nút icon của Fluent cỡ thường → vuông, icon giữa, cùng cỡ nút ⟳ */
.x-page-head--c2 .x-page-actions .dx-button-has-text.dx-button-has-icon .dx-button-content { padding: 6px; }
.x-page-head--c2 .x-page-actions .dx-button-has-text.dx-button-has-icon .dx-icon { margin: 0; }

/* Vùng kéo thả tệp (Nhập mẫu .repx): bấm để chọn hoặc thả tệp vào */
.x-dropzone { border: 2px dashed var(--xp-border); padding: 24px 16px; text-align: center; cursor: pointer; color: var(--xp-ink); }
.x-dropzone:hover, .x-dropzone.x-dropzone--over { border-color: var(--xp-accent); background: var(--xp-hover); }
.x-dropzone .dx-icon { font-size: 28px; color: var(--xp-accent); display: block; margin: 0 auto 8px; }

/* Kéo tệp vào cả trang (Mẫu in): lớp phủ báo "thả để nhập"; không bắt chuột để sự kiện kéo vẫn tới trang */
.x-page-drop { position: fixed; inset: 0; z-index: 3000; pointer-events: none; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--xp-canvas) 85%, transparent); outline: 3px dashed var(--xp-accent); outline-offset: -12px;
  font-size: 18px; color: var(--xp-ink); text-align: center; }
.x-page-drop[hidden] { display: none; }
.x-page-drop .dx-icon { font-size: 40px; color: var(--xp-accent); display: block; margin: 0 auto 12px; }

/* Khung bảng: bảng sát viền khung (không đệm), thanh chọn nhiều dòng (nếu có) tự đệm */
/* Bảng danh sách (anh Kiệt chốt 30/09/2026, theo mẫu DevExtreme): khung bao đầu bảng + các dòng, thanh phân trang nằm NGOÀI khung
   trên nền trang. Vỏ .x-grid-card chỉ còn là chỗ chứa (không nền, không bóng); khung vẽ trên đầu bảng / thân bảng / thanh thao tác hàng loạt. */
.dx-card.x-grid-card { padding: 0; margin-bottom: 16px; background: transparent; box-shadow: none; border: 0; overflow: visible; }
.dx-card.x-grid-card .dx-datagrid { background: transparent; }
.dx-card.x-grid-card .dx-datagrid-header-panel { display: none; }   /* bảng trong khung không dùng thanh công cụ riêng (nút nằm ở khung đầu trang) */
.dx-card.x-grid-card .dx-datagrid-headers {
  background: var(--xp-surface); border: 1px solid var(--xp-border); border-radius: var(--xp-radius) var(--xp-radius) 0 0; overflow: hidden;
}
.dx-card.x-grid-card .dx-datagrid-rowsview {
  background: var(--xp-surface); border: 1px solid var(--xp-border); border-top: 0; border-radius: 0 0 var(--xp-radius) var(--xp-radius); overflow: hidden;
}
.dx-card.x-grid-card .dx-datagrid-pager { padding: 12px 0 0; border-top: 0; }
.x-grid-card > .x-grid-bulk[hidden] { display: none; }
.x-grid-card > .x-grid-bulk {
  margin: 0; padding: 10px 16px; background: var(--xp-surface);
  border: 1px solid var(--xp-border); border-bottom: 0; border-radius: var(--xp-radius) var(--xp-radius) 0 0;
}
.x-grid-card > .x-grid-bulk:not([hidden]) ~ * .dx-datagrid-headers { border-radius: 0; }   /* thanh hàng loạt đang hiện thì nó giữ góc bo trên */
/* Bỏ đường kẻ dọc: ô giữ chỗ của cột cố định (cột nút bên phải) được DevExtreme vẽ viền trái/phải */
.dx-datagrid .dx-pointer-events-none { border-left: 0 !important; border-right: 0 !important; }

/* ---------- Form (dxForm) gửi về máy chủ: hàng nút cuối form ---------- */
.x-form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.x-muted { color: var(--xp-muted); }

/* ---------- Bộ lọc dạng form (dxForm / editor) ---------- */
.x-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.x-filters .x-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.x-filters .x-field--grow { flex: 1 1 220px; }
.x-filters .x-field-label { font-size: 12px; color: var(--xp-muted); }

/* ---------- Che giao diện tới khi site.js dựng xong khung ---------- */
.dx-cloak { visibility: hidden; }

/* ---------- Trang tràn khung (Designer/Viewer): không đệm, cao bằng vùng nội dung ---------- */
.x-content > .x-main { min-height: 0; }
.x-main--full { flex: 1 1 auto; padding: 0; overflow: hidden; height: 100%; }

/* ---------- Trang đăng nhập / quên mật khẩu / đặt lại / khởi tạo (Views/Auth/_AuthLayout) ---------- */
.x-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; box-sizing: border-box; }
.x-auth-card { width: 100%; max-width: 400px; padding: 32px 28px; box-sizing: border-box; }
.x-auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 16px; font-weight: 600; }
.x-auth-brand img { max-height: 40px; max-width: 180px; object-fit: contain; }
.x-auth-card .x-page-title { margin-bottom: 4px; }
.x-auth-card .x-page-sub { margin-bottom: 20px; }
.x-auth-card .x-field { margin-bottom: 14px; }
.x-auth-row { display: flex; justify-content: space-between; align-items: center; }
.x-auth-links { margin-top: 16px; text-align: center; }
.x-auth-tools { position: fixed; top: 8px; right: 12px; display: flex; gap: 4px; z-index: 2; }
.x-auth-done { text-align: center; padding: 8px 0; }
.x-auth-done .dx-icon { font-size: 40px; color: var(--xp-accent); }
.x-auth-done .x-page-title { font-size: 20px; margin-top: 8px; }
.x-auth-done .dx-icon.x-auth-done--warn { color: var(--xp-warning); }

/* ---------- Trang xem bản in (Views/Print/Viewer): dải thương hiệu bên TRÁI + trình xem (anh Kiệt chốt 29/09/2026) ----------
   Thanh trên cũ ăn chiều cao khung giấy; dải trái tận dụng bề ngang thừa của trang dọc A4.
   --x-brand / --x-brand-text: màu thương hiệu của KHÁCH (dữ liệu, đã kiểm ở máy chủ); không có thì theo màu nhấn của theme. */
.x-viewer { display: flex; height: 100vh; }
.x-viewer-rail {
  flex: 0 0 176px; min-width: 0; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 12px; padding: 16px 12px;
  background: var(--xp-surface); border-right: 1px solid var(--xp-border);
  border-left: 4px solid var(--x-brand, var(--xp-accent));
}
.x-viewer-logo img { display: block; max-width: 100%; max-height: 64px; object-fit: contain; }
.x-viewer-company { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.x-viewer-title { font-size: 13px; color: var(--xp-muted); overflow-wrap: anywhere; }
.x-viewer-hint { font-size: 12px; margin-top: -6px; text-align: center; }
.x-viewer-rail .dx-button { width: 100%; }
.x-viewer-close { margin-top: auto; }
.x-viewer--brand .x-viewer-print.dx-button { background-color: var(--x-brand); border-color: var(--x-brand); color: var(--x-brand-text); }
.x-viewer--brand .x-viewer-print.dx-button .dx-icon { color: var(--x-brand-text); }
.x-viewer--brand .x-viewer-print.dx-button.dx-state-hover { filter: brightness(0.92); }
.x-viewer-main { flex: 1 1 auto; min-width: 0; position: relative; }
@media (max-width: 700px) {
  .x-viewer { flex-direction: column; }
  .x-viewer-rail { flex: none; flex-direction: row; align-items: center; gap: 8px; padding: 8px; border-left: 0; border-right: 0; border-top: 3px solid var(--x-brand, var(--xp-accent)); border-bottom: 1px solid var(--xp-border); }
  .x-viewer-logo img { max-height: 32px; max-width: 120px; }
  .x-viewer-rail > :first-child { flex: 1 1 auto; min-width: 0; }
  .x-viewer-company { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .x-viewer-close .dx-button-text { display: none; }
  .x-viewer-title, .x-viewer-hint { display: none; }
  .x-viewer-rail .dx-button { width: auto; }
  .x-viewer-close { margin-top: 0; }
  .x-viewer-main { flex: 1 1 auto; min-height: 0; }
}

/* ---------- Tab Thương hiệu (màn Khách hàng): xem trước thu nhỏ đúng bố cục trang xem bản in ---------- */
.x-brand-preview { display: flex; height: 230px; border: 1px solid var(--xp-border); background: var(--xp-canvas); overflow: hidden; }
.x-brand-preview .x-viewer-rail { flex-basis: 140px; padding: 12px 10px; gap: 8px; }
.x-brand-preview .x-viewer-logo img { max-height: 40px; }
.x-brand-preview-page { flex: 1 1 auto; display: flex; justify-content: center; padding: 16px; }
.x-brand-preview-page > div { width: 150px; background: var(--xp-surface); border: 1px solid var(--xp-border); padding: 14px 12px; box-sizing: border-box; display: flex; flex-direction: column; gap: 6px; }
.x-brand-preview-page > div > span { display: block; height: 6px; background: var(--xp-border); }
.x-brand-swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.x-brand-swatch { width: 28px; height: 28px; border: 2px solid var(--xp-surface); outline: 1px solid var(--xp-border); cursor: pointer; padding: 0; }
.x-brand-swatch.is-on { outline: 2px solid var(--xp-ink); }
.x-brand-logo { display: flex; align-items: center; justify-content: center; min-height: 72px; padding: 12px; border: 1px dashed var(--xp-border); cursor: pointer; text-align: center; }
.x-brand-logo img { max-height: 56px; max-width: 100%; object-fit: contain; }
.x-brand-logo.is-over { border-color: var(--xp-accent); background: var(--xp-hover); }
