/* NEW-189 — "Giao diện mới": khung ERP 2 tầng (js/shell_erp.js). CHỈ dựng ở site crm (khung duy nhất từ NEW-212 / NEW-213) ⇒ mọi luật nằm dưới
   .shell.erp / .erp-* — menu dọc NEW-73 không bị ảnh hưởng. Màu = token --rail-* / --tb-* / --sb-* (app.css, cả sáng lẫn tối); không hex lẻ,
   không gradient, không bóng phát sáng. Desktop: [cột phân hệ 72 px | cột menu 248 px | thanh trên 48 px + .main cuộn riêng].
   Ngưỡng của thanh trên theo CHỖ THỰC CÓ của nó (container query "erptop" = màn − 72 px cột phân hệ − 248 px cột menu nếu đang mở), không theo cả
   màn: < 1120 px đường dẫn bỏ nhóm; < 1040 px ô tìm + chip "Lưu trữ VN" chỉ biểu tượng; < 800 px BU / vai trò vào nút "⋯" (như dưới 900 px).
   Dưới 900 px (màn): cột phân hệ + cột menu thành ngăn kéo trượt (☰), BU / vai trò vào "⋯". Không cuộn ngang ở 320 px. */

/* ---- khung ---- */
.shell.erp { --shell-top: 48px; }   /* chiều cao thanh trên (form_view.css .fv-chat, chatter dính) */
.erp-side { display: flex; flex: none; min-height: 0; position: relative; z-index: 30; }
.erp-side a { text-decoration: none; color: inherit; }
.erp-side .ic, .erp-top .ic { flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.erp-side :focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ---- tầng 1: cột phân hệ ---- */
.erp-rail { width: 72px; flex: none; min-height: 0; display: flex; flex-direction: column; align-items: center; background: var(--rail-bg); color: var(--rail-ink); }
.erp-rail :focus-visible { outline-color: var(--rail-strong); }
.erp-rail .erp-mod.on:focus-visible { outline-color: var(--rail-on-ink); }   /* ô phân hệ đang chọn nền sáng ⇒ vòng focus màu chữ của ô (≥ 3:1) */
.erp-logo { display: block; margin: 10px 0 6px; border-radius: 8px; flex: none; }
.erp-logo img { display: block; width: 36px; height: 36px; border-radius: 8px; }
/* NEW-201: #erpMods = ghim (.erp-pins) · ô tạm (.erp-tmp, sau vạch --rail-line) · Workplace (đáy). KHÔNG cuộn ẩn: màn thấp ⇒ fitRail() gập ghim cuối
   (hidden + .fold) vào Workplace; chỉ khi cả nút bắt buộc cũng không đủ chỗ (< ~230 px) mới cuộn, thanh cuộn MỎNG nhìn thấy (.scroll). */
.erp-mods { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; overflow: hidden; padding: 4px; overscroll-behavior: contain; }
.erp-mods.scroll { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--rail-soon-icon) transparent; }
.erp-pins, .erp-tmp { flex: none; display: flex; flex-direction: column; }
.erp-tmp { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--rail-line); }
.erp-mod { position: relative; width: 100%; min-height: 48px; margin: 0 0 2px; padding: 6px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; border-radius: 8px; background: none; color: var(--rail-ink); cursor: pointer; font: 500 12px/1.25 var(--font); text-align: center; }
.erp-mod[hidden], .erp-mod.fold { display: none; }   /* .erp-mod display:flex thắng [hidden] của trình duyệt */
.erp-mod .ic { width: 21px; height: 21px; }
.erp-mod-t { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.2; }   /* MỘT dòng (fitRail đo ô một dòng); chữ dài ⇒ "…", tên đủ ở title */
.erp-mod:hover { background: var(--rail-hover); color: var(--rail-strong); }
.erp-mod.cur:not(.on) { background: var(--rail-hover); }
.erp-mod.on, .erp-mod.on:hover { background: var(--rail-on-bg); color: var(--rail-on-ink); }
.erp-mod.on .ic { color: var(--rail-on-ink); }
.erp-mod.on .erp-mod-t { font-weight: 700; letter-spacing: -.02em; }   /* đậm không đẩy "Marketing" ra "Marketin/g" */
.erp-mod .erp-ext-g { position: absolute; top: 6px; right: 9px; width: 12px; height: 12px; }   /* Chat: link thẻ mới */
.erp-wp-btn { flex: none; margin: auto 0 0; }   /* luôn ở đáy cột, không gập; chữ "Workplace" một dòng (không ngắt "Workplac/e") */
.erp-wp-btn .erp-mod-t { overflow: visible; text-overflow: clip; letter-spacing: -.02em; }
.erp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sb-dot); flex: none; }
.erp-dot[hidden] { display: none; }
/* Số việc THẬT (/my-work) trên nút phân hệ / Workplace: chữ --rail-av-ink trên --rail-dot — viền 2 px màu nền tách khỏi biểu tượng */
.erp-cnt { position: absolute; top: 2px; left: calc(50% + 2px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--rail-dot); color: var(--rail-av-ink);
  font: 600 12px/18px var(--font); font-variant-numeric: tabular-nums; text-align: center; box-shadow: 0 0 0 2px var(--rail-bg); }
.erp-cnt[hidden] { display: none; }
.erp-mod.on .erp-cnt { box-shadow: 0 0 0 2px var(--rail-on-bg); }
.erp-rail-foot { flex: none; width: 100%; display: flex; justify-content: center; padding: 8px 0 12px; border-top: 1px solid var(--rail-line); }
.erp-av { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 8px; background: var(--rail-av-bg); color: var(--rail-av-ink);
  font: 700 13px/1 var(--font); cursor: pointer; padding: 0; }
.erp-user .umenu-pop { top: auto; bottom: 0; left: calc(100% + 8px); right: auto; z-index: 50; }

/* ---- tầng 2: cột menu nhóm ---- */
.erp-panel { width: 248px; flex: none; min-height: 0; display: flex; flex-direction: column; background: var(--sb-bg); color: var(--sb-ink); border-right: 1px solid var(--sb-border); }
.erp-ph { flex: none; display: flex; align-items: flex-start; gap: 8px; padding: 12px 8px 6px 16px; }
.erp-ph-t { flex: 1; min-width: 0; }
.erp-ph-t small { display: block; font: 600 12px/1.3 var(--font); color: var(--brand); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.erp-ph-t b { display: block; margin-top: 2px; font-size: 17px; line-height: 1.3; color: var(--sb-strong); overflow-wrap: anywhere; }
.erp-tag { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.erp-ib { width: 36px; height: 36px; flex: none; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--sb-icon);
  cursor: pointer; font: 700 16px/1 var(--font); text-decoration: none; position: relative; }
.erp-ib .ic { width: 18px; height: 18px; }
.erp-ib:hover { background: var(--sb-hover); color: var(--sb-strong); }
.erp-filter { flex: none; display: flex; align-items: center; gap: 6px; height: 36px; margin: 2px 12px 8px; padding: 0 10px; border: 1px solid var(--sb-border); border-radius: 8px;
  background: var(--sb-field); color: var(--sb-muted); }
.erp-filter .ic { width: 16px; height: 16px; }
.erp-filter:focus-within { border-color: var(--brand); }
.erp-filter input { flex: 1; min-width: 0; height: 32px; padding: 0; border: 0; outline: 0; background: none; color: var(--sb-ink); font-size: 14px; box-shadow: none; }
.erp-filter input::placeholder { color: var(--sb-muted); opacity: 1; }
.erp-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 8px 12px; overscroll-behavior: contain; }
.erp-grp { margin-top: 4px; }
.erp-gh { width: 100%; min-height: 32px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: 6px; background: none; cursor: pointer;
  color: var(--sb-muted); font: 600 12px/1.3 var(--font); text-transform: uppercase; letter-spacing: .03em; text-align: left; }
.erp-gh > span:first-child { flex: 1; min-width: 0; }
.erp-gh .ic { width: 14px; height: 14px; transition: transform .15s ease-out; }
.erp-grp.closed > .erp-gh .ic { transform: rotate(-90deg); }
.erp-grp.closed > .erp-items { display: none; }
.erp-gh:hover { background: var(--sb-hover); color: var(--sb-strong); }
.erp-grp.has-on > .erp-gh { color: var(--sb-group-on); }
.erp-it { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: 8px; color: var(--sb-ink); font-size: 14px; line-height: 1.3; }
.erp-it .ic { width: 18px; height: 18px; color: var(--sb-icon); }
.erp-it-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.erp-it:hover { background: var(--sb-hover); color: var(--sb-strong); }
.erp-it.on, .erp-it.on:hover { background: var(--sb-active); color: var(--sb-active-ink); font-weight: 600; }
.erp-it.on .ic { color: var(--sb-active-ink); }
.erp-it.on .erp-dot { box-shadow: 0 0 0 2px var(--sb-active-ink); }
.erp-it.on:focus-visible { outline-color: var(--sb-active-ink); outline-offset: -4px; }   /* nền mục đang mở = màu thương hiệu ⇒ vòng trắng bên trong */
.erp-empty { margin: 8px; font-size: 14px; line-height: 1.5; color: var(--sb-muted); }
.erp-pfoot { flex: none; padding: 6px 8px; border-top: 1px solid var(--sb-border); }
.erp-cust { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px; border-radius: 8px; color: var(--sb-muted); font-size: 14px; }
.erp-cust .ic { width: 16px; height: 16px; }
.erp-cust:hover { background: var(--sb-hover); color: var(--sb-strong); }
@media (pointer: coarse) {
  .erp-it, .erp-gh, .erp-cust, .erp-pop-act, .erp-bell-it { min-height: 44px; }
  .erp-ib, .erp-av-top, .erp-av { width: 44px; height: 44px; }
  .erp-logo { padding: 4px; margin: 6px 0 2px; }   /* ảnh 36 px + 4 px mỗi bên = vùng bấm 44 px */
  .erp-top .gsearch, .erp-chip, .erp-bu { height: 44px; }
}
@media (min-width: 900px) { .shell.erp.sub-off .erp-panel { display: none; } }

/* ---- thanh trên ---- */
.erp-top { flex: none; height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 8px; position: relative; z-index: 25;
  background: var(--tb-bg); color: var(--tb-ink); border-bottom: 1px solid var(--tb-border); }
.erp-top :focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.erp-top .erp-ib { color: var(--tb-muted); }
.erp-top .erp-ib:hover { background: var(--tb-hover); color: var(--tb-ink); }
.erp-burger, .erp-more, .erp-av-top { display: none !important; }
.erp-crumb { flex: 0 1 auto; min-width: 0; overflow: hidden; }   /* co sau ô tìm (ô tìm co nhanh gấp 4) */
.erp-crumb ol { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; white-space: nowrap; font-size: 14px; color: var(--tb-muted); min-width: 0; }
.erp-crumb li { flex: 0 4 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* hẹp: nhóm / phân hệ co trước, mục đang mở giữ chữ */
.erp-crumb li + li::before { content: "›"; margin-right: 6px; color: var(--tb-muted); }
.erp-crumb .erp-c-cur { flex: 0 1 auto; min-width: min(5em, 100%); color: var(--tb-ink); font-weight: 600; }
.erp-crumb .erp-c-it { flex-shrink: 1; min-width: min(4em, 45%); }
.erp-crumb a { color: var(--brand-dark); text-decoration: none; }   /* NEW-192: link đứng riêng (đường dẫn) không gạch chân; rê / focus ⇒ gạch chân */
.erp-crumb a:hover, .erp-crumb a:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
.erp-tsp { flex: 1 1 auto; min-width: 8px; }
.erp-top .gsearch { flex: 0 4 300px; width: auto; min-width: 150px; max-width: 320px; height: 34px; margin: 0; background: var(--tb-field); border-color: var(--tb-border); color: var(--tb-muted); }
.erp-top .gsearch:hover { border-color: var(--btn-border); background: var(--tb-field); }
.erp-top .gsearch:focus-visible { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: 1px; }
.erp-top .gsearch kbd { background: var(--tb-bg); border-color: var(--tb-border); color: var(--tb-muted); }
.erp-top .gsearch-text { font-size: 14px; }
.erp-tools { flex: none; display: flex; align-items: center; gap: 6px; }
.erp-bu { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 2px 0 8px; border: 1px solid var(--tb-border); border-radius: 6px; background: var(--tb-bg); color: var(--tb-muted); }
.erp-bu .ic { width: 15px; height: 15px; }
.erp-bu select { height: 32px; max-width: 170px; padding: 0 2px; border: 0; background: none; color: var(--tb-ink); font: 600 14px var(--font); cursor: pointer; box-shadow: none; min-height: 0; }
.erp-bu select:disabled { cursor: not-allowed; color: var(--tb-muted); }
.erp-bu.na { border-style: dashed; }
.erp-bu.na select { color: var(--tb-muted); font-weight: 500; }
.erp-pw { position: relative; flex: none; }
.erp-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; height: 34px; padding: 0 8px; border: 1px solid var(--tb-border); border-radius: 6px;
  background: var(--tb-bg); color: var(--tb-ink); font: 500 14px var(--font); cursor: pointer; }
.erp-chip .ic { width: 15px; height: 15px; color: var(--tb-muted); }
.erp-chip:hover { background: var(--tb-hover); }
.erp-chip-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erp-vn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 6px; background: var(--ok-soft); color: var(--ok-text);
  font-size: 12px; font-weight: 600; white-space: nowrap; cursor: default; }
.erp-vn .ic { width: 15px; height: 15px; }
.erp-bell .erp-dot { position: absolute; top: 7px; right: 7px; box-shadow: 0 0 0 2px var(--tb-bg); }
.erp-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 320px; max-width: calc(100vw - 16px); max-height: min(70vh, 480px); overflow: auto; padding: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); text-align: left; }
.erp-pop[hidden] { display: none; }
.erp-pop-h { padding: 6px 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.erp-pop-msg { margin: 6px 8px 10px; font-size: 14px; color: var(--muted); }
.erp-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 4px 8px 8px; font-size: 14px; }
.erp-kv dt { color: var(--muted); }
.erp-kv dd { margin: 0; overflow-wrap: anywhere; }
.erp-pop-act { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 8px; border: 0; border-radius: 6px; background: none; color: var(--ink);
  font: inherit; text-decoration: none; text-align: left; cursor: pointer; }
.erp-pop-act .ic { width: 16px; height: 16px; color: var(--muted); }
.erp-pop-act:hover, .erp-pop-act:focus-visible { background: var(--hover); }
.erp-bell-list { list-style: none; margin: 0 0 4px; padding: 0; }
.erp-bell-it { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px; border-radius: 6px; color: var(--ink); font-size: 14px; text-decoration: none; }
.erp-bell-it:hover, .erp-bell-it:focus-visible { background: var(--hover); }
.erp-bell-t { flex: 1; min-width: 0; }
.erp-bell-n { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.erp-bell-it.hot .erp-bell-n { color: var(--accent-text); }
.erp-av-top { width: 36px; height: 36px; border-radius: 8px; background: var(--rail-av-bg) !important; color: var(--rail-av-ink) !important; font: 700 13px/1 var(--font); }
@media (pointer: coarse) { .erp-av-top { width: 44px; height: 44px; } }

/* Ngưỡng theo chỗ thực có của thanh trên (cột menu mở / gập đổi chỗ này) — đo bằng Chromium với chip vai trò dài nhất ("Đang xem như … · …", 260 px) */
.erp-top { container: erptop / inline-size; }
@container erptop (min-width: 1280px) { .erp-bu select { max-width: 220px; } }
@container erptop (max-width: 1119px) { .erp-crumb .erp-c-grp { display: none; } }   /* đường dẫn gọn: Phân hệ › Mục */
@container erptop (max-width: 1039px) {
  .erp-top .gsearch { flex: none; width: 36px; min-width: 0; padding: 0; justify-content: center; }
  .erp-top .gsearch-text, .erp-top .gsearch-kbd { display: none; }
  .erp-vn { padding: 0 9px; }
  .erp-vn > span { display: none; }
}
@media (pointer: coarse) { @container erptop (max-width: 1039px) { .erp-top .gsearch { width: 44px; } } }
@container erptop (max-width: 799px) {   /* BU + vai trò vào "⋯" (như dưới 900 px) — đường dẫn không bị ép về 0 px, "?" không bị đẩy ra ngoài */
  .erp-top .erp-more { display: grid !important; }
  .erp-tools { display: none; position: absolute; right: 6px; top: calc(100% + 4px); z-index: 5; width: min(320px, calc(100vw - 12px)); flex-direction: column; align-items: stretch;
    gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
  .erp-tools.open { display: flex; }
  .erp-tools .erp-bu { height: 40px; }
  .erp-tools .erp-bu select { flex: 1; min-width: 0; max-width: none; height: 38px; }
  .erp-tools .erp-chip { width: 100%; max-width: none; height: 40px; }
  .erp-tools .erp-pop { position: static; width: auto; max-width: none; margin-top: 6px; box-shadow: none; }
}
/* Trình duyệt chưa có container query (Safari < 16, Chrome < 105): ngưỡng theo cả màn như bản đầu */
@supports not (container-type: inline-size) {
  @media (min-width: 1600px) { .erp-bu select { max-width: 220px; } }
  @media (max-width: 1439px) { .erp-crumb .erp-c-grp { display: none; } }
  @media (max-width: 1179px) {
    .erp-top .gsearch { flex: none; width: 36px; min-width: 0; padding: 0; justify-content: center; }
    .erp-top .gsearch-text, .erp-top .gsearch-kbd { display: none; }
    .erp-vn { padding: 0 9px; }
    .erp-vn > span { display: none; }
  }
}

/* ---- < 900 px: ngăn kéo trượt (cột phân hệ + cột menu), BU / vai trò vào "⋯" ---- */
@media (max-width: 899px) {
  .erp-side { position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(320px, 92vw); transform: translateX(-100%); visibility: hidden;
    transition: transform .18s ease-out, visibility 0s linear .18s; }
  .erp-side.open { transform: none; visibility: visible; transition: transform .18s ease-out; box-shadow: var(--shadow-pop); }
  .erp-panel { width: auto; flex: 1 1 auto; min-width: 0; border-right: 0; }
  .erp-top { padding: 0 6px 0 4px; gap: 4px; }
  .erp-burger, .erp-more, .erp-av-top { display: grid !important; }
  .erp-subt, .erp-vn, .erp-help { display: none !important; }
  .erp-crumb .erp-c-mod, .erp-crumb .erp-c-grp { display: none; }
  .erp-crumb .erp-c-it::before { display: none; }
  .erp-tools { display: none; position: absolute; right: 6px; top: calc(100% + 4px); z-index: 5; width: min(320px, calc(100vw - 12px)); flex-direction: column; align-items: stretch;
    gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
  .erp-tools.open { display: flex; }
  .erp-tools .erp-bu { height: 40px; }
  .erp-tools .erp-bu select { flex: 1; min-width: 0; max-width: none; height: 38px; }
  .erp-tools .erp-chip { width: 100%; max-width: none; height: 40px; }
  .erp-tools .erp-pop { position: static; width: auto; max-width: none; margin-top: 6px; box-shadow: none; }
}
@media (max-width: 760px) {
  .erp-top { position: sticky; top: 0; z-index: 30; }
  body.va-on .erp-top { top: var(--va-h, 40px); }
  .erp-filter input, .erp-bu select { font-size: 16px; }   /* iOS không phóng to khi chạm ô */
}
@media (pointer: coarse) { .erp-tools .erp-bu, .erp-tools .erp-chip { height: 44px; } .erp-tools .erp-bu select { height: 42px; } }   /* "⋯" trên màn chạm */
@media (prefers-reduced-motion: reduce) { .erp-side, .erp-side.open, .erp-gh .ic, .erp-wp, .erp-wp-bg { transition: none; } }

/* ---- NEW-201: nút ghim phân hệ đang mở (đầu cột menu) ---- */
.erp-pincur[aria-pressed="true"] { color: var(--brand); }
.erp-pincur[aria-pressed="true"] .ic, .erp-wp-pin[aria-pressed="true"] .ic { fill: currentColor; }   /* đã ghim = ghim TÔ ĐẶC (đổi hình, không chỉ màu) */

/* ---- NEW-201: Workplace (hộp thoại mọi phân hệ). Token: nền --surface, ô viền --line, rê --hover, kẻ --line-2, chữ --ink / mô tả --muted, biểu tượng + ghim
   --brand, "Sắp có" / "Mở thẻ mới" = .erp-tag (--surface-2 / --muted), "Đang mở" = --brand-soft / --brand-dark, số việc = --err / --on-err, nền phủ --scrim.
   Đo contrast.py 09/11 (sáng / tối): --muted/--surface 6,7 / 7,4 · --muted/--hover 6,0 / 6,5 · --muted/--surface-2 6,1 / 6,9 · --brand/--surface 12,4 / 5,9
   (ghim, biểu tượng, vòng focus) · --brand/--hover 11,1 / 5,2 · --brand-dark/--brand-soft 13,3 / 7,5 · --on-err/--err 5,9 / 8,2 · --ink/--surface 20,8 / 15,9 ·
   --err/--surface 5,9 / 7,6 · số trên cột --rail-av-ink/--rail-dot 10,5 · --rail-dot/--rail-bg 7,9 / 8,3 · thanh cuộn --rail-soon-icon/--rail-bg 4,8 / 5,1.
   Biểu tượng "sắp có" dùng --muted (KHÔNG --soon: 2,4 / 2,9:1 < 3:1) — mờ bằng viền đứt + chữ "Sắp có", không bằng màu chìm.
   ≥ 1280: neo cạnh cột phân hệ, rộng tối đa 1040 px (4 cột ô); 900–1279: hết chỗ còn lại; < 900: toàn màn; < 600: một cột dạng dòng. */
.erp-wp-bg { position: fixed; inset: 0; z-index: 46; background: var(--scrim); }   /* phủ cả cột phân hệ ⇒ bấm ra ngoài (kể cả cột) là đóng */
.erp-wp-bg[hidden], .erp-wp[hidden] { display: none; }
.erp-wp:focus { outline: none; }   /* tabindex=-1: bấm vùng trống trong hộp thoại ⇒ focus về hộp thoại (phím vẫn tới), không viền cả khung */
.erp-wp { position: fixed; z-index: 47; top: 0; bottom: 0; left: 72px; width: min(1040px, calc(100vw - 72px - 48px)); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-right: 1px solid var(--line); box-shadow: var(--shadow-pop); transition: opacity .16s ease-out, transform .16s ease-out; }
@starting-style { .erp-wp:not([hidden]) { opacity: 0; transform: translateY(4px); } }   /* hiện dần khi mở; trình duyệt cũ: hiện ngay (không chờ JS) */
body.va-on .erp-wp { top: var(--va-h, 40px); }   /* thanh đỏ "Đang xem như…" không bị hộp thoại che */
body.erp-wp-on { overflow: hidden; }   /* lớp của <body> KHÔNG trùng lớp ô (.erp-wp-open = nút mở phân hệ: flex + width 100% làm trang tràn ngang) */
.erp-wp a { text-decoration: none; }
.erp-wp .ic { flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.erp-wp :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.erp-wp-h { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 0 12px; padding: 16px 24px 10px; border-bottom: 1px solid var(--line-2); }
.erp-wp-h h2 { margin: 0; font-size: 20px; line-height: 1.3; color: var(--ink); }
.erp-wp-h h2:focus { outline: none; }
.erp-wp-h h2:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.erp-wp-sub { margin: 2px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); max-width: 70ch; }
.erp-wp-x { color: var(--muted); }
.erp-wp-x .ic { width: 20px; height: 20px; }
@media (hover: hover) { .erp-wp-x:hover { background: var(--hover); color: var(--ink); } }   /* màn chạm: không "dính" nền rê sau khi chạm */
.erp-wp-note { grid-column: 1 / -1; margin: 10px 0 0; font-size: 14px; }
.erp-wp-q { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; max-width: 560px; height: 40px; margin-top: 12px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface-2); color: var(--muted); }
.erp-wp-q:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }   /* vòng focus 2 px (viền + bóng) */
.erp-wp-q .ic { width: 18px; height: 18px; }
.erp-wp-q input { flex: 1; min-width: 0; height: 38px; padding: 0; border: 0; outline: 0; background: none; box-shadow: none; color: var(--ink); font-size: 14px; }
.erp-wp-q input::placeholder { color: var(--muted); opacity: 1; }
.erp-wp-q input:focus-visible { outline: none; }
.erp-wp-err, .erp-wp-state { grid-column: 1 / -1; margin: 6px 0 0; font-size: 14px; line-height: 1.4; }
.erp-wp-err { color: var(--err); font-weight: 600; }
.erp-wp-state { color: var(--muted); }
.erp-wp-err:empty, .erp-wp-state:empty { margin: 0; }
.erp-wp-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 24px; }
.erp-wp-sec { margin-top: 20px; }
.erp-wp-sh { display: flex; align-items: center; gap: 12px; min-height: 32px; margin-bottom: 8px; }
.erp-wp-sh h3 { flex: 1; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.erp-wp-sh .btn[aria-pressed="true"] { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.erp-wp-empty { margin: 4px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.erp-wp-empty + .erp-wp-empty { margin-top: 10px; }
.erp-wp-empty .btn { color: var(--ink); }   /* nút trong dòng mô tả --muted: chữ nút vẫn --ink */
.erp-wp-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.erp-wp-tile { position: relative; min-width: 0; min-height: 80px; padding: 12px 48px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
@media (hover: hover) { .erp-wp-tile:not(.soon):hover { background: var(--hover); } }
.erp-wp-tile.cur { border-color: var(--brand); }
.erp-wp-open, .erp-wp-hd { display: flex; align-items: center; gap: 10px; min-height: 28px; padding: 0; border: 0; background: none; color: var(--ink);
  font: 600 15px/1.3 var(--font); text-align: left; }
.erp-wp-open { width: 100%; cursor: pointer; }
.erp-wp-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }   /* cả ô bấm được; nút ghim nổi trên */
.erp-wp-open:focus-visible { outline: none; }
.erp-wp-open:focus-visible::after { outline: 2px solid var(--brand); outline-offset: 1px; }
.erp-wp-open > .ic, .erp-wp-hd > .ic { width: 24px; height: 24px; color: var(--brand); }
.erp-wp-nl { flex: 1 1 auto; min-width: 0; min-height: 24px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }   /* tên · số · nhãn; nhãn xuống dòng thẳng cột tên + mô tả */
.erp-wp-n { min-width: 0; overflow-wrap: anywhere; }
.erp-wp-open .erp-ext-g { width: 14px; height: 14px; color: var(--muted); }
.erp-wp .erp-tag { margin: 0; font-size: 12px; line-height: 1.5; }
.erp-wp .erp-tag.cur { background: var(--brand-soft); color: var(--brand-dark); }
.erp-wp-d { margin: 4px 0 0 34px; font-size: 14px; line-height: 1.45; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
@media (pointer: fine) and (min-width: 600px) { .erp-wp-tile:not(.soon) .erp-wp-d, .erp-wp-tile:not(.soon) .erp-wp-m { margin-right: -36px; } }   /* mô tả chạy dưới nút ghim (ghim chỉ ở dòng tên) */
.erp-wp-m { margin: 4px 0 0 34px; font-size: 13px; line-height: 1.4; color: var(--ink); }
.erp-wp .erp-cnt { position: static; box-shadow: none; background: var(--err); color: var(--on-err); }
.erp-wp-pin { position: absolute; top: 6px; right: 6px; z-index: 1; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--muted); cursor: pointer; }
.erp-wp-pin .ic { width: 18px; height: 18px; }
@media (hover: hover) { .erp-wp-pin:hover { background: var(--line-2); color: var(--ink); } }
.erp-wp-pin[aria-pressed="true"] { color: var(--brand); }
.erp-wp-tile.soon { padding-right: 12px; border-style: dashed; background: var(--surface); cursor: default; }   /* không có nút ghim */
.erp-wp-tile.soon .erp-wp-hd { color: var(--muted); }
.erp-wp-tile.soon .erp-wp-hd > .ic { color: var(--muted); }
/* "Đổi thứ tự": danh sách dọc */
.erp-wp-sort { list-style: none; margin: 0; padding: 0; max-width: 640px; border: 1px solid var(--line); border-radius: var(--radius); }
.erp-wp-row { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 8px; border-bottom: 1px solid var(--line-2); background: var(--surface); cursor: grab; }
.erp-wp-row:last-child { border-bottom: 0; }
.erp-wp-row > .ic { width: 20px; height: 20px; color: var(--brand); }
.erp-wp-drag { display: grid; color: var(--muted); }
.erp-wp-drag .ic { width: 16px; height: 16px; }
.erp-wp-row-n { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.erp-wp-mv { width: 36px; padding: 0; display: inline-grid; place-items: center; }
.erp-wp-mv .ic { width: 16px; height: 16px; }
.erp-wp-mv:disabled { opacity: .45; cursor: not-allowed; }
.erp-wp-row.dragging { opacity: .5; }
.erp-wp-row.drop-on { outline: 2px dashed var(--brand); outline-offset: -2px; }
.erp-wp-done { margin-top: 10px; }
.erp-wp-f { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 24px; border-top: 1px solid var(--line-2); }
.erp-wp-f:empty { display: none; }
.erp-wp-link { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; color: var(--brand-dark); font-size: 14px; }
.erp-wp-link .ic { width: 16px; height: 16px; }
@media (hover: hover) { .erp-wp-link:hover span { text-decoration: underline; text-underline-offset: 2px; } }
.erp-wp-f .btn { margin-left: auto; }
@media (pointer: coarse) {
  .erp-wp-kbd { display: none; }   /* màn chạm không có phím Esc */
  .erp-wp-empty .btn { min-height: 44px; }
  .erp-wp-pin, .erp-wp-mv, .erp-wp-x { width: 44px; height: 44px; }
  .erp-wp-open { min-height: 44px; }
  .erp-wp-mv, .erp-wp-row .btn, .erp-wp-sh .btn, .erp-wp-f .btn, .erp-wp-link { min-height: 44px; }
  .erp-wp-tile { padding-right: 56px; }
}
@media (max-width: 1279px) { .erp-wp { width: calc(100vw - 72px - 24px); } }
@media (max-width: 899px) {   /* toàn màn (cột phân hệ đang là ngăn kéo); tiêu đề + ô tìm đứng yên, thân cuộn */
  .erp-wp { left: 0; right: 0; width: auto; height: 100vh; height: 100dvh; border-right: 0; box-shadow: none; }
  body.va-on .erp-wp { height: auto; bottom: 0; }
  .erp-wp-bg { background: var(--overlay); }
  .erp-wp-h { padding: 12px 16px 8px; }
  .erp-wp-body { padding: 0 16px 16px; }
  .erp-wp-f { padding: 8px 16px; }
  .erp-wp-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .erp-wp-q { max-width: none; margin-top: 8px; }
  .erp-wp-sec { margin-top: 16px; }
}
@media (max-width: 599px) {   /* một cột dạng dòng: biểu tượng · tên + mô tả (2 dòng) · ghim 44 px bên phải; dòng ≥ 56 px */
  .erp-wp-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .erp-wp-tile { min-height: 56px; padding: 8px 52px 8px 0; border: 0; border-bottom: 1px solid var(--line-2); border-radius: 0; background: none; }
  .erp-wp-tile.soon { padding-right: 0; border-style: none; border-bottom: 1px dashed var(--line); }
  .erp-wp-tile.cur { border-bottom-color: var(--line-2); }
  .erp-wp-tile.cur::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background: var(--brand); }   /* viền trái 2 px trong lề 16 px — dòng không lệch */
  .erp-wp-open::after { border-radius: 0; }
  .erp-wp-pin { top: 6px; right: 0; width: 44px; height: 44px; }
  .erp-wp-q input { font-size: 16px; }   /* iOS không phóng to khi chạm ô */
  .erp-wp-h h2 { font-size: 18px; }
  .erp-wp-sub { display: none; }   /* đầu hộp thoại ≤ 104 px (tiêu đề + ô tìm); cách ghim: nhãn của nút ghim + dòng "Chưa ghim…" */
  .erp-wp-x { margin: -10px -10px -10px 0; }   /* nút đóng 44 px (màn chạm) lấn vào lề — không đẩy cao dòng tiêu đề */
  .erp-wp-f .btn { margin-left: 0; }
}
@media print { .erp-wp, .erp-wp-bg { display: none !important; } }

/* ---- màn "Tuỳ chỉnh menu" (#/tuy-chinh-menu) ---- */
.mc-intro { max-width: 72ch; margin-top: -8px; }
.mc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 14px; }
.mc-mod { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.mc-mod select { min-height: 36px; }
.mc-sp { flex: 1 1 auto; }
.mc-state { font-size: 14px; }
.mc-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; align-items: start; }
.mc-grp { min-width: 0; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mc-gh { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.mc-gname { flex: 1; min-width: 0; }
.mc-gname input { width: 100%; min-height: 36px; font-weight: 600; }
.mc-items { list-style: none; margin: 0; padding: 0; min-height: 44px; border-radius: 6px; }
.mc-it { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; padding: 4px 6px; border-bottom: 1px solid var(--line-2); background: var(--surface); cursor: grab; }
.mc-it:last-child { border-bottom: 0; }
.mc-it .ic { width: 16px; height: 16px; color: var(--muted); }
.mc-drag { display: grid; color: var(--muted); }
.mc-it-t { flex: 1 1 120px; min-width: 0; overflow-wrap: anywhere; }
.mc-ib { width: 32px; padding: 0; display: inline-grid; place-items: center; }
.mc-ib:disabled, .mc-gh .btn:disabled { opacity: .45; cursor: not-allowed; }
.mc-move { max-width: 200px; min-height: 32px; font-size: 14px; }
.mc-it.dragging { opacity: .5; }
.mc-items.drop-on, .mc-it.drop-on { outline: 2px dashed var(--brand); outline-offset: -2px; }
.mc-none { padding: 10px; font-size: 14px; }
@media (pointer: coarse) { .mc-ib { width: 44px; min-height: 44px; } .mc-move { min-height: 44px; } }
@media (max-width: 560px) { .mc-move { flex-basis: 100%; max-width: none; } .mc-mod { flex-basis: 100%; } .mc-mod select { flex: 1; min-width: 0; } }
