/* HSVG Portal (D-28; module Offer)
   Bảng màu: nền xám xanh nhạt, mực xanh đen, teal cho thao tác,
   vàng "tem giá" chỉ dùng cho giá deal — điểm nhấn duy nhất của giao diện. */
:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --ink: #1b2430;
  --ink-2: #4a5563;
  --ink-3: #7a8592;
  --line: #d9dfdc;
  --teal: #0e5e6f;
  --teal-2: #0b4a58;
  --teal-bg: #e3f0f2;
  --tag: #f2c230;
  --tag-ink: #3d2f00;
  --red: #b42318;
  --red-bg: #fdecea;
  --amber-bg: #fff4d6;
  --amber-ink: #7a4b00;
  --green: #1f7a4d;
  --green-bg: #e6f4ec;
  --radius: 6px;
  --ctl-h: 38px; /* OPS-15: chiều cao chung ô nhập / select / shared input / select height */
  --font: "Be Vietnam Pro", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
h1 { font-size: 1.6rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: .87rem; }
[hidden] { display: none !important; }

/* ---------- khung ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.rail { background: var(--ink); color: #dfe5ea; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
/* OPS-14: logo HSV ở menu trái / HSV logo in the left menu */
.brand-logo { position: relative; width: 36px; flex: none; transform-origin: 50% 90%; animation: brandBloom 4s ease-in-out infinite; }
.brand-logo img { display: block; width: 100%; height: auto; animation: brandGlow 4s ease-in-out infinite; }
/* OPS-14: logo động như trang đăng nhập — nở / bay nhẹ + vệt sáng lướt theo đúng hình logo (mask = file logo); giảm chuyển động thì đứng yên
   OPS-14: animated like the sign-in page — gentle bloom / float + a shine across the logo shape only (mask = the logo file); still under reduced motion */
.brand-logo::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .8) 50%, transparent 62%) no-repeat; background-size: 250% 100%;
  -webkit-mask: url("hsv-logo.png") center / contain no-repeat; mask: url("hsv-logo.png") center / contain no-repeat;
  animation: brandShine 4s ease-in-out infinite; }
@keyframes brandBloom { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-2px) scale(1.06); } }
@keyframes brandShine { 0%, 45% { background-position: 150% 0; } 85%, 100% { background-position: -50% 0; } }
@keyframes brandGlow { 0%, 100% { filter: drop-shadow(0 0 4px rgba(34, 211, 238, .18)); } 50% { filter: drop-shadow(0 0 10px rgba(34, 211, 238, .45)); } }
.brand-text { min-width: 0; }
.brand strong { display: block; font-size: 1.05rem; color: #fff; }
.brand span { font-size: .8rem; color: #93a1ae; }
.rail a { display: block; padding: 9px 10px; border-radius: var(--radius); color: #c9d2da; text-decoration: none; }
.rail a:hover { background: #26323f; color: #fff; }
.rail a[aria-current="page"] { background: #2c3a48; color: #fff; box-shadow: inset 3px 0 0 var(--tag); }
.rail .spacer { flex: 1; }
.rail .nav { display: flex; flex-direction: column; gap: 4px; }
/* OPS-06: icon menu / menu icons */
.rail .nav a { display: flex; align-items: center; gap: 10px; }
.nav-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .85; }
/* OPS-13: nhóm menu (Offer, Cài đặt chung) có mục con thụt vào; bấm tiêu đề nhóm để thu / mở
   OPS-13: menu groups (Offer, General settings) with indented sub-items; click the group title to fold / unfold */
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius); background: none;
  color: #c9d2da; text-align: left; cursor: pointer; }
.nav-head:hover { background: #26323f; color: #fff; }
.nav-head.has-current { color: #fff; font-weight: 500; }
.nav-head > span { flex: 1; min-width: 0; }
.nav-chev { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .7; transition: transform .15s; }
.nav-head[aria-expanded="false"] .nav-chev { transform: rotate(-90deg); }
.nav-head[aria-expanded="false"] + .nav-sub { display: none; }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin-left: 18px; padding-left: 8px; border-left: 1px solid #2c3a48; }
.rail .nav-sub a { padding: 7px 10px; font-size: .93rem; }
.nav-sub .nav-ico { width: 16px; height: 16px; }
/* OPS-05: nút chuyển ngôn ngữ VI / EN / language switch */
/* Nút gạt 2 lựa chọn, bo tròn; nút đang chọn nổi bật / two-option pill toggle; the active option stands out */
.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); align-self: flex-start; }
.lang-switch button { min-width: 36px; padding: 3px 10px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  font-size: .78rem; font-weight: 600; letter-spacing: .04em; line-height: 1.4; text-decoration: none; cursor: pointer; transition: background .15s, color .15s; }
.lang-switch button:hover { background: var(--teal-bg); color: var(--teal); }
.lang-switch button[aria-pressed="true"] { background: var(--teal); color: #fff; cursor: default; }
/* trên thanh menu tối / on the dark menu bar */
.who .lang-switch { margin-top: 12px; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .18); }
.who .lang-switch button { color: #c9d2da; padding: 3px 10px; font-size: .78rem; text-decoration: none; } /* gỡ kiểu link của .who button / undo the .who button link style */
.who .lang-switch button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.who .lang-switch button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.who { border-top: 1px solid #2c3a48; padding: 14px 10px 0; font-size: .85rem; }
/* nút avatar: chỉ hiện ở màn hẹp (OPS-06) và khi menu trái thu gọn (OPS-09) / avatar button: narrow screens (OPS-06) and collapsed left menu (OPS-09) only */
.who-btn { display: none; align-items: center; gap: 2px; flex: none; min-height: 38px; padding: 3px 6px 3px 3px; border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px; background: rgba(255, 255, 255, .06); color: #dfe5ea; cursor: pointer; }
.who-btn:hover, .who-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .14); }
.who-btn .avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #fff; font-size: .78rem; font-weight: 600; letter-spacing: .02em; }
.who-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- OPS-09: thu gọn menu trái (máy tính) — chỉ còn icon / collapse the left menu (desktop) — icons only ---------- */
.shell { transition: grid-template-columns .2s ease; }
.rail { z-index: 5; }
.rail-toggle { position: absolute; top: 22px; right: -14px; z-index: 6; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--teal); cursor: pointer; box-shadow: 0 2px 8px rgba(16, 24, 32, .15); }
.rail-toggle:hover { background: var(--teal-bg); }
.rail-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
@media (min-width: 861px) {
  /* OPS-16: menu dài hơn màn hình thì chỉ vùng menu cuộn; logo và khối tài khoản (tên, Đăng xuất, VI / EN) luôn nằm trong nền tối
     OPS-16: when the menu is taller than the screen only the menu area scrolls; the logo and the account block (name, Sign out, VI / EN) always stay on the dark rail */
  .rail > :not(.nav) { flex-shrink: 0; }
  .rail .nav { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a4856 transparent; }
  .shell.collapsed { grid-template-columns: 72px 1fr; }
  .shell.collapsed .rail { padding: 20px 10px; align-items: center; }
  .shell.collapsed .rail-toggle svg { transform: rotate(180deg); }
  .shell.collapsed .brand { flex-direction: column; gap: 6px; padding: 4px 0 22px; }
  .shell.collapsed .brand-logo { width: 34px; }
  .shell.collapsed .brand span { display: none; }
  .shell.collapsed .brand strong { font-size: 0; } /* chỉ chữ "HSVG" / just "HSVG" (D-28) */
  .shell.collapsed .brand strong::before { content: "HSVG"; font-size: .85rem; letter-spacing: .03em; }
  .shell.collapsed .env { margin: 0 0 14px; padding: 4px; justify-content: center; }
  .shell.collapsed .env > span { display: none; }
  .shell.collapsed .env select { margin: 0; padding: 2px 3px; font-size: .72rem; }
  .shell.collapsed .rail .nav { width: 100%; }
  .shell.collapsed .rail .nav a { justify-content: center; padding: 10px 0; }
  .shell.collapsed .rail .nav a span { display: none; }
  .shell.collapsed .nav-ico { width: 20px; height: 20px; }
  /* OPS-13: thu gọn: bỏ tiêu đề nhóm, mục con thành icon, nhóm cách nhau bằng vạch / collapsed: no group titles, sub-items as icons, groups split by a line */
  .shell.collapsed .nav-head { display: none; }
  .shell.collapsed .rail .nav-sub { display: flex; margin: 0; padding: 0; border: 0; }
  .shell.collapsed .rail .nav-group { padding-top: 4px; border-top: 1px solid #2c3a48; }
  .shell.collapsed .rail .nav-group + a { margin-top: 4px; padding-top: 10px; border-top: 1px solid #2c3a48; border-radius: 0; }
  /* tài khoản: nút avatar + bảng bật ra bên phải / account: avatar button + a popover on the right */
  .shell.collapsed .rail .spacer { flex: 1; }
  .shell.collapsed .who-btn { display: inline-flex; padding: 3px; }
  .shell.collapsed .who-btn svg { display: none; }
  .shell.collapsed .who { display: none; position: absolute; left: calc(100% + 8px); bottom: 12px; z-index: 40; width: 280px; padding: 14px 16px 16px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 12px 32px rgba(16, 24, 32, .2); }
  .shell.collapsed .who.open { display: block; }
  .shell.collapsed .who b { color: var(--ink); font-weight: 600; }
  .shell.collapsed .who .role { color: var(--ink-2); font-size: .82rem; }
  .shell.collapsed .who button { color: var(--ink); }
  .shell.collapsed .who .lang-switch { background: var(--surface); border-color: var(--line); }
  .shell.collapsed .who .lang-switch button { color: var(--ink-2); }
  .shell.collapsed .who .lang-switch button[aria-pressed="true"] { background: var(--teal); color: #fff; }
}
.who b { display: block; color: #fff; font-weight: 500; }
.who .role { color: #93a1ae; }
.who .links { display: flex; gap: 12px; margin-top: 8px; }
.who button { background: none; border: 0; padding: 0; color: #c9d2da; text-decoration: underline; cursor: pointer; font-size: .85rem; }
.env { margin: 0 10px 14px; padding: 6px 10px; border-radius: var(--radius); font-size: .8rem; background: #3a2f0a; color: #f6dc84; }
.env.live { background: #13392b; color: #9fe3bf; }
/* BC-15: ô chọn company trong nhãn ERP / company select inside the ERP badge */
.env:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.env select { margin-left: auto; padding: 2px 6px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 4px; background: rgba(255, 255, 255, .06);
  color: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.env select:hover { border-color: rgba(255, 255, 255, .5); }
.env select:disabled { opacity: .6; cursor: wait; }
.env select option { color: var(--ink); background: #fff; }

main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1680px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head p.small { margin-top: 2px; font-size: 12.5px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }

/* ---------- nút & form ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: var(--radius); cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); }
/* Nút tải file mẫu: xanh lá kiểu Excel + teal nhạt / template download buttons: Excel green + soft teal */
.btn.excel { background: var(--green); border-color: var(--green); color: #fff; font-weight: 500; }
.btn.excel:hover { background: #17633e; border-color: #17633e; }
.btn.soft { background: var(--teal-bg); border-color: #b9d8de; color: var(--teal-2); font-weight: 500; }
.btn.soft:hover { background: #d3e8ec; border-color: var(--teal); }
/* Nút quay lại Danh sách offer / back-to-Offer-list button */
.back-row { margin: 0 0 14px; }
.btn.back { padding: 6px 14px 6px 10px; color: var(--ink-2); font-weight: 500; font-size: .9rem; box-shadow: 0 1px 2px rgba(27, 36, 48, .06); }
.btn.back:hover { color: var(--teal); border-color: var(--teal); background: var(--teal-bg); }
.btn.back .ico { transition: transform .15s; }
.btn.back:hover .ico { transform: translateX(-2px); }
.btn .ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.link { border: 0; background: none; padding: 4px 6px; color: var(--teal); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: .87rem; color: var(--ink-2); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=datetime-local], input[type=time], input[type=tel], input[type=url], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; background: #fff; min-width: 0;
}
/* OPS-15: ô nhập 1 dòng và select cùng chiều cao (input không ghi type, datetime-local trước đây không có style nên thấp hơn select)
   OPS-15: single-line inputs and selects share one height (untyped and datetime-local inputs used to be unstyled and shorter than selects) */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=datetime-local], input[type=time], input[type=tel], input[type=url], select { height: var(--ctl-h); line-height: 1.3; }
/* AUTH-10: ô mật khẩu có nút con mắt bên trong (public/pw.js) */
.pw { position: relative; display: flex; flex: 1; min-width: 180px; }
.pw input { flex: 1; width: 100%; padding-right: 40px; }
.pw-eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); display: flex; padding: 6px; border: 0; border-radius: 4px; background: none; color: var(--ink-3); cursor: pointer; }
.pw-eye:hover { color: var(--ink); }
.pw-eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pw-eye .eye-off, .pw-eye[aria-pressed="true"] .eye { display: none; }
.pw-eye[aria-pressed="true"] .eye-off { display: block; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-bg); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.grid-form .wide { grid-column: 1 / -1; }

/* ---------- bảng ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th { text-align: left; font-weight: 500; color: var(--ink-2); background: #f6f8f7; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid #edf0ee; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #f6faf9; }
tr.warn-row td { background: #fffaf0; }
td.actions { white-space: nowrap; text-align: right; }

/* ---------- trạng thái ---------- */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.badge.on { background: var(--green-bg); color: var(--green); }
.badge.off { background: #edf0f2; color: var(--ink-2); }
.badge.err { background: var(--red-bg); color: var(--red); }
.badge.ldap { background: var(--teal-bg); color: var(--teal-2); }
.badge.warn { background: var(--amber-bg); color: var(--amber-ink); }
/* IMP-08: No. Series khi import / No. Series at import */
.series-pick { max-width: 280px; font-size: .85rem; padding: 4px 8px; }
.series-pick.need { border-color: var(--amber-ink); background: var(--amber-bg); } /* chưa chọn series / no series picked yet */
.pred { color: var(--teal-2); font-weight: 500; white-space: nowrap; }
.series-all { align-items: flex-end; gap: 8px 20px; }
.series-all label.f { min-width: 280px; }
.series-all p { margin: 0; flex: 1 1 300px; }
@media (max-width: 640px) { .preview-offer > header .series-pick { max-width: 100%; flex: 1 1 100%; } }
/* BC-18: Validation Period — kỳ mới + danh sách offer dùng chung / new period + list of sharing offers */
.vp-new { margin-top: 10px; padding: 10px 14px 14px; border: 1px dashed var(--line); border-radius: var(--radius); }
.vp-new legend { padding: 0 6px; font-size: .85rem; color: var(--ink-2); }
ul.usage { margin: 8px 0 0; padding-left: 18px; max-height: 200px; overflow: auto; }
ul.usage li { margin: 2px 0; }
/* BC-16: nhãn loại offer / offer type badges */
.badge.type-MixMatch { background: var(--teal-bg); color: var(--teal-2); }
.badge.type-LineDiscount { background: #ece8fb; color: #4b3a99; }
.badge.type-TotalDiscount { background: var(--amber-bg); color: var(--amber-ink); }
h1 .badge { vertical-align: middle; font-size: .8rem; margin-left: 6px; }

/* Tem giá: điểm nhấn duy nhất */
.tag { position: relative; display: inline-block; background: var(--tag); color: var(--tag-ink); font-weight: 600; padding: 2px 10px 2px 16px;
  border-radius: 3px 5px 5px 3px; font-variant-numeric: tabular-nums; clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%); }
.tag::before { content: ""; position: absolute; left: 7px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: var(--surface); }
.was { color: var(--ink-3); text-decoration: line-through; font-size: .85rem; margin-right: 6px; }
.off-pct { color: var(--ink-2); font-size: .82rem; margin-left: 6px; }

.notice { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: .93rem; }
.notice.err { background: var(--red-bg); color: var(--red); }
.notice.warn { background: var(--amber-bg); color: var(--amber-ink); }
.notice.info { background: var(--teal-bg); color: var(--teal-2); }
.notice.ok { background: var(--green-bg); color: var(--green); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- offer ---------- */
.offer-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 24px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: .82rem; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- import: 3 bước là trình tự thật ---------- */
.steps { display: flex; gap: 0; padding: 0; margin-bottom: 18px; counter-reset: s; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.steps li { list-style: none; flex: 1; padding: 10px 16px; color: var(--ink-3); counter-increment: s; border-right: 1px solid var(--line); }
.steps li:last-child { border-right: 0; }
.steps li::before { content: counter(s) ". "; }
.steps li.now { color: var(--ink); font-weight: 600; box-shadow: inset 0 -3px 0 var(--teal); }
.steps li.done { color: var(--green); }
.drop { display: block; margin: 0 0 14px; cursor: pointer; border: 2px dashed var(--line); border-radius: var(--radius); padding: 30px; text-align: center; background: #fafbfa; }
.drop:hover { border-color: var(--teal); }
.drop.over { border-color: var(--teal); background: var(--teal-bg); }
/* IMP-09: chọn loại offer import / import offer-type picker */
.kind-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kind-opt { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); cursor: pointer; background: #fff; }
.kind-opt:hover { border-color: var(--teal); }
.kind-opt:has(input:checked) { border-color: var(--teal); background: var(--teal-bg); box-shadow: 0 0 0 1px var(--teal) inset; }
.kind-opt input { grid-row: span 2; margin-top: 3px; accent-color: var(--teal); }
.kind-opt .small { color: var(--ink-2); }
.panel h2 #tpl-kind { font-weight: 500; font-size: .9em; margin-left: 6px; }
.preview-offer { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; }
.preview-offer > header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.preview-offer > header .grow { min-width: 200px; }
.preview-offer .body { padding: 0 16px 14px; }
.preview-offer.bad { border-color: #f1b5ad; }
.issues { margin: 0; padding-left: 18px; font-size: .9rem; }
.issues.e li { color: var(--red); }
.issues.w li { color: var(--amber-ink); }

/* ---------- ma trận quyền ---------- */
.matrix td.c, .matrix th.c { text-align: center; }
/* BC-23: ô tick Exclude giữa cột / Exclude checkbox centred */
td.c, th.c { text-align: center; }
.matrix .mod td { background: #f6f8f7; font-weight: 600; color: var(--ink-2); font-size: .85rem; }
.matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--teal); }
.matrix .sens { color: var(--red); font-size: .78rem; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(640px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(27, 36, 48, .45); }
dialog form { padding: 20px 22px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.err-text { color: var(--red); font-size: .88rem; min-height: 1.2em; margin-top: 8px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 50; max-width: 420px; }
.toast.err { background: var(--red); }

/* ---------- đăng nhập ---------- */

@media (max-width: 860px) {
  /* BUG-14: minmax(0,1fr) + min-width:0 — cột lưới không được giãn theo hàng menu cuộn ngang */
  /* BUG-14: minmax(0,1fr) + min-width:0 — the grid column must not grow to the scrolling menu row */
  /* BUG-21: hàng menu = auto (không bị kéo cao ở trang ít nội dung), nội dung = 1fr / menu row = auto (never stretched on short pages), content = 1fr */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { min-width: 0; }
  /* OPS-06: kiểu app — thanh tiêu đề 1 hàng (tên portal, company, nút tài khoản) + thanh tab cố định ở đáy
     OPS-06: app style — a one-row title bar (portal name, company, account button) + a fixed bottom tab bar */
  .rail { position: sticky; top: 0; z-index: 20; height: auto; min-height: 56px; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 10px;
    padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
  .brand { display: flex; gap: 8px; padding: 0; flex: 1 1 auto; min-width: 0; }
  .brand-logo { width: 30px; }
  .brand strong { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand span, .rail .spacer { display: none; }
  .env { margin: 0; padding: 4px 6px 4px 10px; flex: none; border-radius: 999px; }
  .env select { border-radius: 999px; padding: 3px 8px; }
  /* nút tài khoản: avatar chữ cái đầu / account button: initials avatar */
  .rail-toggle { display: none; }
  .who-btn { display: inline-flex; }
  /* menu tài khoản thả xuống (ẩn đến khi bấm nút) / account dropdown (hidden until the button is pressed) */
  .who { display: none; position: absolute; top: calc(100% + 6px); right: 8px; z-index: 40; width: min(300px, calc(100vw - 16px)); padding: 14px 16px 16px;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: 0 12px 32px rgba(16, 24, 32, .2); font-size: .9rem; }
  .who.open { display: block; }
  .who b { display: block; color: var(--ink); font-weight: 600; }
  .who .role { display: block; color: var(--ink-2); font-size: .82rem; }
  .who .links { flex-direction: column; gap: 0; margin-top: 10px; border-top: 1px solid var(--line); }
  .who .links button { display: block; width: 100%; padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-align: left; text-decoration: none; font-size: .95rem; }
  .who .links button:hover { color: var(--teal); }
  .who .lang-switch { margin-top: 12px; background: var(--surface); border-color: var(--line); }
  .who .lang-switch button { color: var(--ink-2); }
  .who .lang-switch button:hover { background: var(--teal-bg); color: var(--teal); }
  .who .lang-switch button[aria-pressed="true"] { background: var(--teal); color: #fff; }
  /* thanh tab ở đáy: nền trắng, mục đang chọn tô nền nhạt cả ô + vạch teal cạnh trên + chữ teal
     bottom tab bar: white background, the current item gets a light fill over the whole cell + a teal top line + teal text */
  .rail .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0;
    margin: 0; padding: 0; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(16, 24, 32, .06); }
  /* OPS-13: thanh tab đáy giữ phẳng — mỗi mục con là 1 tab, không có tiêu đề nhóm / the bottom tab bar stays flat — each sub-item is a tab, no group titles */
  .rail .nav .nav-group, .rail .nav .nav-sub { display: contents; }
  .nav-head { display: none; }
  .rail .nav a { flex-direction: column; justify-content: center; align-items: center; gap: 5px; min-width: 0; min-height: 60px; padding: 8px 2px 7px; border-radius: 0;
    border-top: 2px solid transparent; background: none; box-shadow: none; color: var(--ink-2); font-size: .72rem; font-weight: 500; line-height: 1.15; white-space: nowrap; }
  .rail .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .rail .nav a:hover { background: #f3f6f7; color: var(--ink); }
  .rail .nav a[aria-current="page"] { background: var(--teal-bg); border-top-color: var(--teal); box-shadow: none; color: var(--teal); font-weight: 600; }
  .nav-ico { width: 24px; height: 24px; opacity: 1; }
  main { padding: 18px 16px 96px; }
  .toast { bottom: 84px; }
  h1 { font-size: 1.35rem; }
}
/* OPS-14: điện thoại hẹp — logo + "HSVG" (như menu thu gọn) để không cắt chữ / narrow phones — logo + "HSVG" (as in the collapsed menu) so the name is not cut */
@media (max-width: 480px) {
  .brand strong { font-size: 0; }
  .brand strong::before { content: "HSVG"; font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.mt { margin-top: 14px; }
.nowrap { white-space: nowrap; }
/* BC-13 / OPS-06: khung tìm offer co giãn theo màn hình — nhóm tìm kiếm + nhóm ngày, tự xuống dòng */
.search-form .sf-toggle { display: none; } /* chỉ hiện trên điện thoại / phones only */
.search-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.sf-main { display: flex; gap: 10px; align-items: center; flex: 1 1 460px; min-width: 0; }
.sf-main input[type=search] { flex: 1 1 auto; min-width: 140px; }
.sf-main select { flex: 0 0 auto; }
/* BUG-20: nhóm ngày giãn hết hàng (không margin-left: auto -> không lệch phải khi xuống hàng); nút dồn phải */
/* BUG-20: the date group fills the row (no margin-left: auto -> no lone right shift when wrapped); buttons pushed right */
.sf-dates { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1 1 auto; }
.sf-dates .sf-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.sf-dates label { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: .87rem; }
.sf-dates input[type=date] { min-width: 0; }
.pager { justify-content: flex-end; gap: 6px; margin: 10px 0; }
.pager .small { padding: 0 6px; color: var(--ink-2); }
@media (max-width: 640px) {
  .kind-pick { grid-template-columns: minmax(0, 1fr); }
  .sf-main { flex-wrap: wrap; flex-basis: 100%; }
  .sf-main input[type=search] { flex-basis: 100%; order: -1; }
  .sf-main select { flex: 1 1 40%; }
  .sf-dates { flex-basis: 100%; }
  .sf-dates .sf-actions { flex: 1 1 100%; margin-left: 0; }
  .sf-dates label { flex: 1 1 40%; }
  .sf-dates input[type=date] { flex: 1; }
  .sf-dates .btn.primary { flex: 1 1 auto; justify-content: center; }
  .pager { justify-content: center; }
  .pager .small { flex-basis: 100%; text-align: center; order: -1; }
  .col-opt { display: none; } /* bảng hẹp: ẩn cột phụ / narrow table: hide secondary columns */

  /* ===== OPS-06: điện thoại / phones ===== */
  /* thanh tiêu đề + thanh tab ở đáy: xem khối 860px / title bar + bottom tab bar: see the 860px block */
  .rail { padding-left: 10px; padding-right: 10px; gap: 8px; }
  main { padding: 16px 12px 96px; }
  .toast { left: 12px; right: 12px; max-width: none; }

  /* Ô nhập 16px để iPhone không tự phóng to; nút dễ bấm / 16px inputs so iPhones do not zoom; easy-to-tap buttons */
  input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date], input[type=datetime-local], input[type=time], input[type=tel], input[type=url], select, textarea { font-size: 16px; }
  .btn { min-height: 40px; }
  :root { --ctl-h: 40px; } /* OPS-15: ô nhập cao bằng nút trên điện thoại / inputs match button height on phones */
  .page-head { gap: 10px; margin-bottom: 14px; }
  .page-head > .row, .page-head .head-actions { width: 100%; }

  /* Bảng thành thẻ: mỗi dòng 1 thẻ "nhãn: giá trị", nhãn lấy từ tiêu đề cột (cardify trong app.js)
     Tables become cards: one card per row, "label: value", labels taken from the column headers (cardify in app.js) */
  .table-wrap:has(> table.cardify) { overflow: visible; border: 0; background: transparent; }
  table.cardify, table.cardify tbody, table.cardify tr, table.cardify td { display: block; width: 100%; }
  table.cardify thead { display: none; }
  table.cardify tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 10px; padding: 10px 12px; }
  /* nhãn đặt tuyệt đối bên trái, nội dung ô giữ nguyên (nhiều phần tử vẫn đúng) / label absolutely placed on the left, cell content untouched */
  table.cardify td { position: relative; padding: 5px 0 5px 38%; min-height: 28px; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  table.cardify td::before { content: attr(data-label); position: absolute; left: 0; top: 6px; width: 35%; color: var(--ink-2); font-size: .8rem; line-height: 1.3; }
  table.cardify td:first-child { padding: 0 0 8px; margin-bottom: 4px; font-size: 1rem; font-weight: 600; border-bottom: 1px solid var(--line); }
  table.cardify td:first-child::before, table.cardify td[data-label=""]::before, table.cardify td[colspan]::before { display: none; }
  table.cardify td[data-label=""], table.cardify td[colspan] { padding-left: 0; }
  table.cardify td.blank, table.cardify td.col-opt { display: none; }
  table.cardify td.num { text-align: left; }

  /* Khung tìm thu gọn: ô tìm + Tìm, bộ lọc khác sau nút "Bộ lọc" / compact search: box + Search, other filters behind "Filters" */
  .search-form .sf-toggle { display: flex; flex: 1 1 100%; justify-content: space-between; gap: 10px; min-width: 0; order: -1; }
  .search-form .sf-toggle .small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .search-form:not(.open) .sf-main select, .search-form:not(.open) .sf-dates label, .search-form:not(.open) #d30 { display: none; }
  .search-form:not(.open) .sf-dates .btn.primary { flex: 1 1 100%; }

  /* Hộp thoại gần full màn hình, nút xếp dọc / near full-screen dialogs, stacked buttons */
  dialog { width: calc(100vw - 16px); max-height: calc(100vh - 32px); overflow: auto; }
  dialog form { padding: 16px; }
  dialog .foot { flex-direction: column-reverse; }
  dialog .foot .btn { width: 100%; justify-content: center; }
}
.notice details summary { cursor: pointer; margin-top: 6px; }
/* IMP-10: chuyển file Local Promotion / Local Promotion conversion */
.lp-opts { align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.lp-opts .f input { width: 130px; }
.lp-file { cursor: pointer; }
/* OPS-15: nút trên cùng hàng với ô chọn cao bằng ô chọn / buttons on the same row as the selects match their height */
.lp-opts .btn { height: var(--ctl-h); }
/* USR-07: ô tìm người dùng đủ rộng cho chữ gợi ý / the user search box is wide enough for its placeholder */
.user-find input[type=search] { min-width: 260px; }
.lp-files { display: grid; gap: 8px; margin: 12px 0; }
.lp-file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
/* tùy chọn ghi đè: dòng riêng, nền vàng cảnh báo; khi tick chuyển viền đậm / overwrite option: own line, amber warning box; bolder border when ticked */
.lp-check { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 10px 14px; border: 1.5px solid #f2c230; border-left-width: 5px;
  border-radius: 8px; background: var(--amber-bg); color: var(--amber-ink); cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
.lp-check:hover { box-shadow: 0 0 0 3px rgba(242, 194, 48, .25); }
.lp-check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: #b7791f; }
.lp-check strong { display: block; font-size: .95rem; color: #5c3a00; }
.lp-check .small { display: block; margin-top: 2px; color: var(--amber-ink); }
.lp-check:has(input:checked) { border-color: #d97706; background: #ffe8b3; box-shadow: 0 0 0 3px rgba(217, 119, 6, .18); }
/* IMP-10: cảnh báo chuyển đổi màu đỏ / conversion warnings in red */
.warn-count { color: var(--red); font-weight: 600; }
.warn-text { color: var(--red); }
.notice-inline { color: var(--teal); margin: 2px 0 0; }
#as-item { margin-left: 8px; }
/* IMP-10: Price Group / No. Series theo thương hiệu — CBX teal, TFS tím / by brand — CBX teal, TFS purple */
.lp-opts select { font-weight: 600; border-width: 1.5px; border-radius: 8px; padding-top: 7px; padding-bottom: 7px; }
.lp-opts select[data-brand="CBX"] { border-color: var(--teal); background-color: var(--teal-bg); color: var(--teal-2); }
.lp-opts select[data-brand="TFS"] { border-color: #6b55c9; background-color: #ece8fb; color: #4b3a99; }
.lp-opts select:focus { outline: 2px solid currentColor; outline-offset: 1px; }
/* BC-20: nút gạt Enabled / Disabled / Enabled / Disabled switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #c9d0cd; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .track { background: #1f8a4c; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--teal); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }
.switch .switch-text { font-size: .85rem; font-weight: 600; color: var(--ink-2); min-width: 62px; }
.switch input:checked ~ .switch-text { color: #1f8a4c; }
.offer-title .switch { margin-left: 4px; }
/* IMP-11: nút tải log lỗi import / import error-log button */
.btn.log-dl { color: var(--red); border-color: var(--red); background: var(--red-bg); font-weight: 600; }
.btn.log-dl:hover { background: #fbd9d5; }

/* ---------- Open VAT (OV-01…OV-13) ---------- */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 18px; flex-wrap: wrap; }
.subtabs a { padding: 8px 14px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs a:hover { color: var(--ink); }
.subtabs a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--teal); }
code { font-size: .85em; background: #f1f3f2; padding: 0 4px; border-radius: 3px; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--teal); }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
.f.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; } /* OV-14: nhãn + ô chọn cùng hàng / label + select on one row */

/* SUI-28: trang có tab (frame) — tiêu đề riêng của tab nhỏ lại vì tiêu đề chính nằm trên thanh tab
   SUI-28: tabbed pages (frames) — a tab's own title is smaller since the main title sits above the tab bar */
.frame-body > .page-head { margin-bottom: 12px; }
.frame-body > .page-head h1 { font-size: 1.15rem; }
