/* ════════════════════════════════════════════════════════════
   POS-V2 — App Styles (Shell + Components)
   ════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: var(--ff-base);
  font-size: var(--fs-14);
  color: var(--c-text);
  background: var(--c-bg-muted);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ─────────────────────────────────────────────────────────────
   SHELL — Desktop default (≥ 1024px)
   ───────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  transition: grid-template-columns 0.2s ease;
  grid-template-areas:
    "rail sidebar top"
    "rail sidebar main";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
.shell .rail    { grid-area: rail; }
.shell .sidebar { grid-area: sidebar; }
.shell .topbar  { grid-area: top; }
.shell .content { grid-area: main; }

/* Direct-link sections (e.g. dashboard) — no sidebar panel */
.shell--no-sidebar {
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-areas:
    "rail top"
    "rail main";
}
.shell--no-sidebar .topbar__btn--menu { display: none; }

/* ── Icon Rail ── */
.rail {
  background: var(--c-rail);
  color: var(--c-rail-fg);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--sp-12) 0;
  gap: var(--sp-4);
  overflow-y: auto;
  scrollbar-width: thin;
}
.rail__brand {
  width: 36px; height: 36px;
  border-radius: var(--r-8);
  background: var(--c-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-13);
  margin-bottom: var(--sp-12);
  letter-spacing: 0.5px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--t-fast), transform var(--t-fast);
}
.rail__brand:hover { background: var(--c-primary-hover, var(--c-primary)); }
.rail__brand:active { transform: scale(0.96); }
.rail__item {
  width: 40px; height: 40px;
  border-radius: var(--r-8);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-rail-fg-muted);
  background: transparent;
  border: 0;
  transition: background var(--t-fast), color var(--t-fast);
  font-size: 18px;
}
.rail__item:hover { background: var(--c-rail-hover); color: var(--c-rail-fg); }
.rail__item.is-active {
  background: var(--c-rail-active);
  color: #fff;
  box-shadow: inset 3px 0 0 #9FE1CB;
}
.rail__spacer { flex: 1; }
/* [Phase 1.x-Polish-UI-20260508] visual separator between rail group blocks */
.rail__divider {
  /* [SetZ-CashMenu-20261109] เส้นคั่น rail ชัดขึ้น (เดิม 1px/opacity .35 จางมาก) */
  width: 32px;
  height: 2px;
  border-radius: 1px;
  margin: var(--sp-8) 0;
  background: var(--c-rail-fg-muted);
  opacity: 0.7;
}

/* ── Inner Sidebar ── */
.sidebar {
  background: var(--c-sidebar);
  border-right: 1px solid var(--c-sidebar-border);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar__header {
  padding: var(--sp-16) var(--sp-16) var(--sp-12);
  border-bottom: 1px solid var(--c-sidebar-border);
}
.sidebar__title {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.sidebar__list {
  padding: var(--sp-8);
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar__item {
  display: flex; align-items: center; gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-12);
  border-radius: var(--r-6);
  font-size: var(--fs-13);
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--t-fast);
}
.sidebar__item:hover { background: var(--c-sidebar-hover); }
.sidebar__item.is-active {
  background: var(--c-sidebar-active);
  color: var(--t-strong,var(--c-primary));
  font-weight: 600;
}
/* [Phase 1.3-Sidebar-Restructure-20260507] Visual-gate items not yet implemented.
   Red italic + non-clickable cursor; click intercepted in app.js → toast. */
.sidebar__item.is-disabled {
  color: #dc2626;
  opacity: 0.78;
  cursor: not-allowed;
  font-style: italic;
}
.sidebar__item.is-disabled:hover {
  background: transparent !important;
  color: var(--c-tint-red-fg,#b91c1c);
}
/* [Fix TabletModuleNav-20261105] module switcher inside the drawer on narrow screens.
   Desktop (>=1024) keeps using the icon rail, so hide this block there. */
.sidebar__modules { display: none; }
@media (max-width: 1023px) {
  .sidebar__modules {
    display: block;
    padding: var(--sp-8) var(--sp-8) var(--sp-4);
    border-bottom: 1px solid var(--c-sidebar-border);
  }
  .sidebar__modules-title {
    font-size: var(--fs-11);
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: var(--sp-4) var(--sp-8);
  }
  .sidebar__mod {
    display: flex; align-items: center; gap: var(--sp-8);
    padding: var(--sp-8) var(--sp-8);
    border-radius: var(--r-6);
    color: var(--c-text);
    font-size: var(--fs-13);
    transition: background var(--t-fast);
  }
  .sidebar__mod:hover { background: var(--c-sidebar-hover); }
  .sidebar__mod.is-active {
    background: var(--c-sidebar-active);
    color: var(--t-strong,var(--c-primary));
    font-weight: 600;
  }
  .sidebar__mod-ic { font-size: 18px; width: 22px; text-align: center; }
}
.sidebar__divider {
  /* [SetZ-CashMenu-20261109] เส้นคั่น sidebar ชัดขึ้น (เดิม 1px/opacity .6 จาง) */
  height: 2px;
  border-radius: 1px;
  background: var(--c-border, var(--c-sidebar-border, rgba(255,255,255,0.1)));
  margin: 8px 8px;
  opacity: 0.95;
}

/* ── Content area ── */
.content {
  background: var(--c-bg-muted);
  overflow-y: auto;
  padding: var(--sp-24);
}
.content__inner { max-width: 1400px; margin: 0 auto; }

/* ─────────────────────────────────────────────────────────────
   TOP BAR (always visible — branch badge, brand, user, logout)
   Hidden menu button on desktop; visible on tablet/mobile.
   ───────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  height: var(--topbar-h);
  background: var(--c-rail);
  color: var(--c-rail-fg);
  align-items: center;
  padding: 0 var(--sp-16);
  gap: var(--sp-12);
  position: relative;
  z-index: 30;
  border-bottom: 1px solid var(--c-rail-hover, rgba(0,0,0,0.2));
  /* [Fix TabletTopbarOverflow-20261112] topbar อยู่คอลัมน์ grid เดียวกับ content (areas "rail top"/"rail main")
     → ของใน topbar (flex nowrap) min-content กว้าง ดันคอลัมน์ทั้งแถบจนเนื้อหาล้นขอบขวาที่จอ ~768 (แท็บเล็ต)
     min-width:0 ให้ topbar หดได้ (brand truncate) → คอลัมน์ไม่พอง · ช่วยทุกหน้าที่จอแคบ */
  min-width: 0;
}
.topbar__btn {
  width: 36px; height: 36px;
  border-radius: var(--r-6);
  background: transparent; border: 0;
  color: var(--c-rail-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.topbar__btn:hover { background: var(--c-rail-hover); }
.topbar__btn--menu { display: flex; }
/* Sidebar mini: collapse sidebar column to 0 */
.shell--sidebar-mini {
  grid-template-columns: var(--rail-w) 0 1fr;
}
.shell--sidebar-mini .sidebar {
  overflow: hidden;
  border-right: none;
}
@media print {
  /* [report-print-20260609] full-bleed: ปลด shell grid → block เต็มหน้า */
  .rail, .sidebar, .sidebar-backdrop, .topbar, .tabbar { display: none !important; }
  .shell {
    display: block !important;
    height: auto !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
  }
  .content {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
    background: #fff !important;
  }
  .content__inner { max-width: none !important; margin: 0 !important; }
  .no-print { display: none !important; }
  .page--branch-transfer-form .card { break-inside: avoid; }
  .page--branch-transfer-form .report-table-wrap { page-break-before: auto; }
}
.topbar__brand {
  font-weight: 700; font-size: var(--fs-15);
  letter-spacing: 0.5px;
  color: var(--c-rail-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  cursor: pointer;            /* [Phase 1.2.2.3 M6] navigates to #/dashboard */
  user-select: none;
}
.topbar__brand:hover { opacity: 0.85; }
.topbar__brand:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.topbar__spacer { flex: 1; }
.topbar__user {
  font-size: var(--fs-12);
  color: var(--c-rail-fg-muted);
  white-space: nowrap;
}
.topbar__user--btn {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  border-radius: var(--r-6);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-12);
  color: var(--c-rail-fg-muted);
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar__user--btn:hover { background: rgba(255,255,255,0.10); color: var(--c-rail-fg); }
.topbar__user--btn:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.topbar__user__caret { font-size: 10px; margin-left: 4px; opacity: 0.7; }

/* ── Branch badge ── */
.branch-badge {
  display: inline-flex; align-items: center; gap: var(--sp-8);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--c-rail-fg);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: default;
  font-family: inherit;
  transition: background var(--t-fast);
}
.branch-badge.is-clickable { cursor: pointer; }
.branch-badge.is-clickable:hover { background: rgba(255,255,255,0.16); }
.branch-badge:disabled { opacity: 0.85; }
.branch-badge__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--branch-color, #888);
  flex: 0 0 10px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}
.branch-badge__code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: var(--fs-12);
  letter-spacing: 0.3px;
}
.branch-badge__name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.branch-badge__caret { font-size: 10px; color: var(--c-rail-fg-muted); }

.branch-badge__dropdown {
  position: absolute;
  top: calc(var(--topbar-h) - 6px);
  right: var(--sp-16);
  margin-top: 6px;
  background: var(--c-surface, #fff);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  box-shadow: var(--sh-md);
  min-width: 240px;
  max-width: 320px;
  padding: 6px 0;
  z-index: 50;
}
.branch-badge__option {
  display: flex; align-items: center; gap: var(--sp-8);
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
  font-size: var(--fs-13);
  color: var(--c-text);
  cursor: pointer;
}
.branch-badge__option:hover { background: var(--c-sidebar-hover); }
.branch-badge__option.is-current { background: var(--c-sidebar-active); font-weight: 700; }
.branch-badge__option-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.branch-badge__option-code { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-11); color: var(--c-text-muted); }
.branch-badge__option-name { font-size: var(--fs-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Profile dropdown (user menu in topbar) ── */
.profile-dropdown {
  position: absolute;
  top: calc(var(--topbar-h) - 6px);
  right: var(--sp-16);
  margin-top: 6px;
  background: var(--c-surface, #fff);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  box-shadow: var(--sh-md);
  min-width: 220px;
  padding: 6px 0;
  z-index: 50;
}
.profile-dropdown__header {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 4px;
}
.profile-dropdown__name { font-weight: 700; color: var(--c-text); font-size: var(--fs-13); }
.profile-dropdown__role { font-size: var(--fs-11); color: var(--c-text-muted); margin-top: 2px; }
.profile-dropdown__item {
  display: flex; align-items: center; gap: var(--sp-8);
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
  font-size: var(--fs-13);
  color: var(--c-text);
  cursor: pointer;
}
.profile-dropdown__item:hover { background: var(--c-sidebar-hover); }
.profile-dropdown__item-icon { width: 20px; text-align: center; }

/* ── Splash (boot loader) ── */
.splash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: var(--sp-16);
  background: var(--c-bg-muted);
  z-index: 1000;
  padding: var(--sp-24);
}
.splash__spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: hced-spin 0.8s linear infinite;
}
.splash__icon { font-size: 42px; color: var(--c-warn-fg, #a85d00); }
.splash__text { color: var(--c-text-muted); font-size: var(--fs-14); text-align: center; }
@keyframes hced-spin { to { transform: rotate(360deg); } }

/* ── Login branch picker (multi-branch on first login) ── */
.modal--branch-picker .modal__panel--form { max-width: 440px; }
.branch-list { display: flex; flex-direction: column; gap: var(--sp-8); }
.branch-pick {
  display: flex; align-items: center; gap: var(--sp-12);
  padding: var(--sp-12);
  background: var(--c-bg-muted);
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.branch-pick:hover { background: var(--c-sidebar-hover); border-color: var(--c-primary); }
.branch-pick__chip {
  width: 40px; height: 40px;
  border-radius: var(--r-8);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: var(--fs-12);
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.4px;
  flex: 0 0 40px;
}
.branch-pick__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.branch-pick__name { font-size: var(--fs-14); font-weight: 600; color: var(--c-text); }
.branch-pick__sub  { font-size: var(--fs-11); color: var(--c-text-muted); }

/* ─────────────────────────────────────────────────────────────
   BOTTOM TABS (mobile only)
   ───────────────────────────────────────────────────────────── */
.tabbar {
  display: none;
  height: var(--tabbar-h);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 30;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.tabbar__list {
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: 100%;
}
.tabbar__item {
  background: transparent; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: var(--fs-11);
  color: var(--c-text-muted);
  padding: var(--sp-4);
}
.tabbar__item .ic { font-size: 20px; }
.tabbar__item.is-active { color: var(--t-strong,var(--c-primary)); font-weight: 600; }

/* ─────────────────────────────────────────────────────────────
   COMPONENTS
   ───────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-12);
  box-shadow: var(--sh-card);
  padding: var(--sp-24);
}
.card--center {
  max-width: 380px;
  margin: 0 auto;
}

.input {
  width: 100%;
  padding: var(--sp-12) var(--sp-12);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-8);
  font-size: var(--fs-14);
  font-family: inherit;
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus {
  outline: 0;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(4, 44, 83, 0.12);
}

.label {
  display: block;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-8);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-8);
  padding: var(--sp-12) var(--sp-20);
  border-radius: var(--r-8);
  border: 0;
  font-size: var(--fs-14);
  font-weight: 600;
  font-family: inherit;
  transition: background var(--t-fast), transform var(--t-fast);
}
.btn--primary {
  background: var(--c-primary);
  color: var(--c-primary-fg);
}
.btn--primary:hover { background: var(--c-primary-hover); }
.btn--primary:active { transform: translateY(1px); }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.alert {
  padding: var(--sp-12) var(--sp-16);
  border-radius: var(--r-8);
  font-size: var(--fs-13);
  margin-bottom: var(--sp-16);
}
.alert--danger { background: var(--c-danger-bg); color: var(--c-danger-fg); }
.alert--success { background: var(--c-success-bg); color: var(--c-success-fg); }
.alert--info { background: var(--c-info-bg); color: var(--c-info-fg); }
.alert--warning { background: var(--c-warn-bg, #fff8e1); color: var(--c-warn-fg, #b07700); }

/* [Phase Sales-CrossLink-20260508] Inline customer picker (DP edit form) */
.cust-picker { position: relative; }
.cust-picker__results {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--c-bg, #fff);
  border: 1px solid var(--c-border, #ddd);
  border-radius: var(--r-6, 6px);
  max-height: 280px; overflow-y: auto; z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.cust-picker__item {
  padding: var(--sp-8) var(--sp-12);
  cursor: pointer;
  border-bottom: 1px solid var(--c-border, #f0f0f0);
}
.cust-picker__item:last-child { border-bottom: 0; }
.cust-picker__item:hover { background: var(--c-bg-muted, #f5f5f5); }
.cust-picker__empty {
  padding: var(--sp-12); color: var(--c-text-muted, #999);
  text-align: center; font-size: var(--fs-12);
}

/* ─────────────────────────────────────────────────────────────
   LOGIN PAGE
   ───────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #042C53 0%, #063C72 60%, #0a4a8a 100%);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-16);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--c-surface);
  border-radius: var(--r-12);
  box-shadow: var(--sh-lg);
  padding: var(--sp-32) var(--sp-24);
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto var(--sp-16);
  border-radius: var(--r-12);
  background: var(--c-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: var(--fs-18);
  letter-spacing: 1px;
}
.login-title {
  text-align: center;
  font-size: var(--fs-22);
  font-weight: 700;
  color: var(--c-text);
  margin: 0 0 var(--sp-4);
}
.login-subtitle {
  text-align: center;
  font-size: var(--fs-13);
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-24);
}

/* ─────────────────────────────────────────────────────────────
   DASHBOARD (placeholder)
   ───────────────────────────────────────────────────────────── */
.page-title {
  font-size: var(--fs-22);
  font-weight: 700;
  color: var(--c-text);
  margin: 0 0 var(--sp-8);
}
.page-subtitle {
  font-size: var(--fs-13);
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-24);
}

.user-chip {
  display: inline-flex; align-items: center; gap: var(--sp-8);
  padding: var(--sp-4) var(--sp-12);
  background: var(--c-success-bg);
  color: var(--c-success-fg);
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR OVERLAY (tablet)
   ───────────────────────────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 25;
}
.sidebar-backdrop.is-open { display: block; }

/* ─────────────────────────────────────────────────────────────
   DASHBOARD
   ───────────────────────────────────────────────────────────── */
.dash__header {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: var(--sp-12);
  margin-bottom: var(--sp-20);
}
.dash__actions { display: flex; gap: var(--sp-8); align-items: center; }

/* ── Phase 1.1 dashboard ── */
.dash { display: flex; flex-direction: column; gap: var(--sp-16); }
.dash__head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: var(--sp-12);
}
.dash__head-actions {
  display: flex; align-items: center; gap: var(--sp-8); flex-wrap: wrap;
}

/* range pills */
.range-pills {
  display: inline-flex; align-items: center; gap: 0;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 3px;
}
.range-pill {
  appearance: none; border: 0; background: transparent;
  padding: 4px 14px; border-radius: 999px;
  font-size: var(--fs-12); font-weight: 600;
  color: var(--c-text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--t-fast), color var(--t-fast);
}
.range-pill:hover { color: var(--c-text); }
.range-pill.is-active {
  background: var(--c-rail);
  color: #fff;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-16);
}
.kpi-card {
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: var(--r-12);
  padding: var(--sp-20);
  box-shadow: var(--sh-card);
  display: flex; flex-direction: column; gap: var(--sp-8);
  min-height: 120px;
}
.kpi-card__label {
  font-size: var(--fs-12);
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.kpi-card__value {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}
.kpi-card__hint {
  margin-top: auto;
  font-size: var(--fs-12);
  color: var(--c-text-muted);
  display: flex; flex-wrap: wrap; gap: var(--sp-8); align-items: center;
}
.kpi-card--accent {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--c-primary-fg);
}
.kpi-card--accent .kpi-card__label,
.kpi-card--accent .kpi-card__hint { color: rgba(255,255,255,0.8); }
.kpi-card--accent .kpi-card__value { color: var(--c-primary-fg); }
.kpi-card--warn { border-color: var(--c-warn-fg, #b97a00); }
.kpi-card--error { background: var(--c-danger-bg); border-color: var(--c-danger-fg); }
.kpi-card--skeleton {
  background:
    linear-gradient(90deg, var(--c-surface,#fff) 0%, var(--c-bg-muted) 50%, var(--c-surface,#fff) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}

/* Two-column row */
.dash-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--sp-16);
}
.dash-col { padding: 0; }
.dash-col--wide {} /* marker only */

/* SVG sales chart */
.ch-svg { width: 100%; height: auto; max-height: 260px; display: block; }
.ch-grid {
  stroke: var(--c-border);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.ch-axis {
  font-size: 10px;
  fill: var(--c-text-muted);
  font-family: ui-monospace, Consolas, monospace;
}
.ch-axis--y { font-size: 10px; }
.ch-line {
  fill: none;
  stroke: var(--c-primary);
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.ch-area {
  fill: var(--c-primary);
  opacity: 0.10;
}
.ch-dot {
  fill: var(--c-primary);
  stroke: var(--c-surface, #fff);
  stroke-width: 2;
}

/* Payment mix donut */
.mix-wrap {
  padding: var(--sp-16) var(--sp-20);
  display: flex; flex-direction: column; gap: var(--sp-16); align-items: center;
}
.mix-donut {
  width: 160px; height: 160px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex: 0 0 auto;
}
.mix-donut__hole {
  width: 110px; height: 110px;
  background: var(--c-surface, #fff);
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
}
.mix-donut__total {
  font-size: var(--fs-15); font-weight: 800;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}
.mix-donut__cap {
  font-size: var(--fs-11); color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.mix-legend {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  width: 100%;
  font-size: var(--fs-13);
}
.mix-legend__row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  align-items: center;
  gap: var(--sp-8);
}
.mix-legend__dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.mix-legend__label { color: var(--c-text); }
.mix-legend__pct {
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-12);
}
.mix-legend__amt {
  font-weight: 700;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

/* Alerts panel */
.alert-group { padding: var(--sp-12) var(--sp-20); border-bottom: 1px solid var(--c-border); }
.alert-group:last-child { border-bottom: 0; }
.alert-group__head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-8);
}
.alert-group__title {
  font-size: var(--fs-12); font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.alert-group__count {
  background: var(--c-rail);
  color: #fff;
  font-size: var(--fs-11); font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
  min-width: 22px; text-align: center;
}
.alert-group__more {
  display: inline-block; margin-top: 6px;
  font-size: var(--fs-12);
}
.alert-list { list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px; }
.alert-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-12);
  padding: 8px 10px;
  border-radius: var(--r-6);
  border-left: 3px solid var(--c-border);
  background: var(--c-bg-muted);
  cursor: pointer;
  transition: background var(--t-fast);
}
.alert-item:hover { background: var(--c-sidebar-hover); }
.alert-item--warn   { border-left-color: var(--c-warn-fg,   #b97a00); }
.alert-item--danger { border-left-color: var(--c-danger-fg, #c0392b); }
.alert-item--info   { border-left-color: var(--c-info-fg,   #1b6ca8); }
.alert-item__main { min-width: 0; flex: 1; }
.alert-item__title {
  font-size: var(--fs-13); font-weight: 600;
  color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alert-item__sub {
  font-size: var(--fs-11); color: var(--c-text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alert-item__amt {
  text-align: right;
  display: flex; flex-direction: column; gap: 2px;
  font-size: var(--fs-11); color: var(--c-text-muted);
  white-space: nowrap;
}
.alert-item__amt strong {
  font-size: var(--fs-13); font-weight: 700;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

/* Tablet — collapse to single column */
@media (max-width: 1023px) {
  .kpi-grid  { grid-template-columns: repeat(2, 1fr); }
  .dash-row  { grid-template-columns: 1fr; }
  .mix-wrap  { flex-direction: row; }
  .mix-legend { width: auto; flex: 1; }
}
@media (max-width: 540px) {
  .kpi-grid  { grid-template-columns: 1fr; }
  .mix-wrap  { flex-direction: column; }
  .mix-legend { width: 100%; }
  .dash__head-actions { width: 100%; justify-content: space-between; }
  .range-pills { flex: 1; justify-content: center; }
  .range-pill { padding: 4px 10px; font-size: var(--fs-11); }
}

/* ─────────────────────────────────────────────────────────────
   PHASE 1.2.1 — SELL PAGE
   ───────────────────────────────────────────────────────────── */
.sell { display: flex; flex-direction: column; gap: var(--sp-16); }
.sell__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: var(--sp-12);
}
.sell__head-l { display: flex; align-items: baseline; gap: var(--sp-12); flex-wrap: wrap; }
.sell__doc-no {
  font-size: var(--fs-12); color: var(--c-text-muted);
  font-family: ui-monospace, Consolas, monospace;
  background: var(--c-bg-muted); padding: 3px 10px; border-radius: 999px;
}
/* [M2-20260429] Doc date pill */
.sell__date-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  background: var(--c-bg-muted);
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: inherit; font-size: var(--fs-12);
  color: var(--c-text); cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.sell__date-pill:hover { border-color: var(--c-primary); }
.sell__date-pill.is-not-today {
  background: var(--c-tint-amber,#fef3c7); color: var(--c-tint-amber-fg,#92400e); border-color: #f59e0b;
}
.sell__date-icon { font-size: 13px; }
.sell__date-label { font-family: ui-monospace, Consolas, monospace; }
.sell__date-input {
  position: absolute; opacity: 0; pointer-events: none;
  width: 0; height: 0; padding: 0; border: 0;
}
.sell__customer { display: flex; align-items: center; gap: var(--sp-8); flex-wrap: wrap; }

/* Customer trigger (the big "who's buying" button) */
.cust-trigger {
  display: inline-flex; align-items: center; gap: var(--sp-12);
  padding: 6px 14px;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-8);
  cursor: pointer; font-family: inherit; min-width: 280px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.cust-trigger:hover { border-color: var(--c-primary); }
.cust-trigger__icon { font-size: 22px; flex: 0 0 22px; }
.cust-trigger__body { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; }
.cust-trigger__name { font-size: var(--fs-14); font-weight: 700; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.cust-trigger__sub  { font-size: var(--fs-11); color: var(--c-text-muted); }
.cust-trigger__caret { color: var(--c-text-muted); font-size: 12px; }
.cust-special-badge {
  background: var(--c-tint-amber,#fff7e0); color: var(--c-tint-amber-fg,#a85d00);
  padding: 4px 10px; border-radius: 999px;
  font-size: var(--fs-12); font-weight: 700;
  border: 1px solid var(--c-tint-amber-bd,#f7d4a0);
}

/* Layout: scan + cart on left, summary on right */
.sell__grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--sp-16);
  align-items: start;
}
.sell__main { display: flex; flex-direction: column; gap: var(--sp-12); min-width: 0; }
.sell__side { display: flex; flex-direction: column; gap: var(--sp-12); position: sticky; top: var(--sp-12); }

.sell__scan .card__body { padding: var(--sp-12) var(--sp-16); }
.sell__bc-input {
  font-size: var(--fs-15); font-weight: 600;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.5px;
}
.sell__scan-hint {
  margin-top: 6px; font-size: var(--fs-11); color: var(--c-text-muted);
}
.sell__cart-card { padding: 0; }
.sell__cart-count {
  display: inline-block; min-width: 22px; padding: 2px 8px;
  background: var(--c-rail); color: #fff;
  border-radius: 999px; font-size: var(--fs-11); font-weight: 700;
  margin-left: 6px; text-align: center;
}
.sell__cart-wrap { padding: 0; }
.sell__cart-empty {
  padding: var(--sp-32) var(--sp-20);
  border-top: 1px dashed var(--c-border);
  color: var(--c-text-muted); font-size: var(--fs-13);
}

/* Cart v2 (Phase 1.2 sell page) */
.cart2 { display: block; font-size: var(--fs-13); }
.cart2__head, .cart2__row {
  display: grid;
  /* [M4-20260429] removed col--disc; M5 reserves slot inside col--price for 💰 button */
  grid-template-columns: 1fr 90px 140px 130px 36px;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-16);
  border-top: 1px solid var(--c-border);
}
.cart2__head {
  background: var(--c-bg-muted);
  font-size: var(--fs-11); font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.cart2__row { background: var(--c-surface); transition: background 350ms ease; }
.cart2__row.is-flash { background: var(--c-success-bg); }
.cart2__row--short { background: var(--c-tint-red,#fff5f5); }
/* [Feature TaxDisplayNo P3-FE-20260919] กริดใบภาษีมีคอลัมน์ "เลขข้อ" เพิ่มหน้าสุด (6 คอลัมน์)
   ★★★ scoped ด้วย `.cart2--taxno` เท่านั้น — **ห้ามแก้ `grid-template-columns` ของ `.cart2__head/.cart2__row`
   ด้านบน** เพราะใช้ร่วมกับ `sell.js` · `quotation.js` · `goods-receipt-edit.js` ⇒ แก้ค่ากลาง = 3 หน้านั้น
   คอลัมน์เลื่อนทันทีโดยไม่มีใครเห็นตอนเทสต์หน้าภาษี
   ★ specificity (0,2,0) > (0,1,0) ของ base ⇒ ทับได้โดยไม่ต้องใช้ `!important` */
/* [Feature TaxUnit-20261024] +คอลัมน์ "หน่วย" ถัดจากจำนวน (7 คอลัมน์) · scope เดิม `.cart2--taxno` เท่านั้น */
/* [TaxNoLineDisc-20261028] คอลัมน์ "ส่วนลด" รายบรรทัด (TaxLineDisc 10-25) เอาออก → กลับเป็น 7 คอลัมน์ */
.cart2--taxno .cart2__head,
.cart2--taxno .cart2__row { grid-template-columns: 76px 1fr 84px 84px 120px 120px 36px; }
.cart2--taxno .col--dno .input { width: 100%; text-align: center; }
.cart2--taxno .col--unit { text-align: center; }
.cart2--taxno .col--unit .input { width: 100%; text-align: center; }
/* [Phase Feature-1-20260513] header/separator row */
.cart2__row--label {
  background: linear-gradient(to right, transparent 0%, var(--c-bg-muted) 15%, var(--c-bg-muted) 85%, transparent 100%);
  border-top: 1px dashed var(--c-border);
  border-bottom: 1px dashed var(--c-border);
}
.cart2__label-input {
  width: 100%;
  background: transparent;
  border: 0;
  font-weight: 700;
  font-size: var(--fs-14);
  /* [Phase Bugfix-Header+RECancel-20260514] left-align per user spec —
     center-align made multi-section bills look misaligned with item rows. */
  text-align: left;
  color: var(--c-text);
  padding: 6px 8px;
  font-family: inherit;
}
.cart2__label-input:focus {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
  background: rgba(255,255,255,0.6);
  border-radius: 4px;
}
.cart2__name { font-weight: 600; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* [UIPolish2-S2b-20260709] tax-doc-edit: manual(input) vs prod(text) row เท่ากัน — ล็อกสูง name element 30px + sub min-height คงที่ */
.cart2__name--line { min-height: 30px; line-height: 30px; }
.cart2__name-input { height: 30px; }
.cart2__sub  { font-size: var(--fs-11); color: var(--c-text-muted); margin-top: 2px; min-height: 15px; display: flex; align-items: center; gap: var(--sp-8); }
/* [UIPolish2-S2b2-20260709] tax-edit line item: จัด name/qty/price/total/× ระดับเดียว (center band บน 30px)
   col--name = name(30)+sub(15)=45 สูงกว่าเซลล์อื่น → top-align แล้วล็อกทุกเซลล์แถวหลักสูง 30 → center ตรงกัน · scoped .tax-edit เท่านั้น */
.tax-edit .cart2__row { align-items: flex-start; }
.tax-edit .cart2__row .cart2__inp { height: 30px; }
.tax-edit .cart2__row .col--total { min-height: 30px; line-height: 30px; }
.tax-edit .cart2__row .col--del { min-height: 30px; display: flex; align-items: center; justify-content: center; }
/* [Line-Desc-STEP-C-20260709] toggle "＋ รายละเอียด" + input ใต้ชื่อ · ไหลใน col--name เท่านั้น (block flow
   ต่อจาก .cart2__sub) → col--name ยืดลงล่าง · qty/price/total คง top-align (S2b2 flex-start) ไม่ขยับ */
.cart2__desc { margin-top: 3px; }
.cart2__desc-toggle {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: var(--fs-11); color: var(--c-text-muted); font-family: inherit;
}
.cart2__desc-toggle:hover { color: var(--t-link,var(--c-accent)); text-decoration: underline; }
.cart2__desc-toggle:disabled { cursor: default; opacity: 0.5; text-decoration: none; }
/* [Line-Desc-multi-20260709] textarea multi-line · auto-grow (JS) · cap 120px แล้ว scroll ·
   ยืดสูง → col--name ยืดลง · qty/price top-align (S2b2 flex-start) ไม่ขยับ */
.cart2__desc-input { width: 100%; min-height: 26px; max-height: 120px; font-size: var(--fs-12); line-height: 1.3; padding: 4px 8px; resize: none; overflow-y: auto; font-family: inherit; display: block; }
.cart2__desc-input[hidden], .cart2__desc-toggle[hidden] { display: none; }
.cart2__sn   { font-size: var(--fs-11); color: var(--c-info-fg, #1b6ca8); margin-top: 2px; }
.cart2__inp  { padding: 4px 8px; font-size: var(--fs-13); text-align: right; font-family: ui-monospace, Consolas, monospace; }
.cart2__locked-qty { display: inline-block; padding: 4px 8px; font-family: ui-monospace, Consolas, monospace; color: var(--c-text-muted); text-align: right; cursor: not-allowed; background: var(--c-bg-muted); border-radius: 4px; }
.col--qty, .col--price { text-align: right; }
.col--total { text-align: right; font-weight: 700; }
.col--del   { text-align: center; }

/* [M5-20260429] Price column wrap with info button */
.cart2__price-wrap {
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.cart2__price-info {
  background: transparent; border: 1px solid transparent;
  border-radius: 4px; padding: 2px 6px;
  font-size: 14px; line-height: 1; cursor: pointer;
  opacity: 0.6; transition: opacity .15s, background .15s;
}
.cart2__price-info:hover { opacity: 1; background: var(--c-bg-muted); }

/* [M5-20260429] Price inspector popover */
.price-pop {
  position: absolute; z-index: 1000;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  min-width: 220px;
  font-family: inherit; font-size: var(--fs-13);
  animation: price-pop-in 120ms ease-out;
}
@keyframes price-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.price-pop__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--c-border);
  font-weight: 600; gap: 8px;
}
.price-pop__title {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px; color: var(--c-text);
}
.price-pop__close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; line-height: 1;
  color: var(--c-text-muted); padding: 0 4px;
}
.price-pop__close:hover { color: var(--c-text); }
.price-pop__body { padding: 8px 12px; }
.price-pop__row {
  display: grid; grid-template-columns: 14px 1fr auto;
  align-items: center; gap: 8px; padding: 4px 0;
}
.price-pop__row .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c, #999);
}
.price-pop__row .lbl { color: var(--c-text); }
.price-pop__row .amt {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 600; color: var(--c-text);
}
.price-pop__row--cost {
  border-top: 1px dashed var(--c-border);
  padding-top: 8px; margin-top: 4px;
}
.price-pop__row--cost .lbl,
.price-pop__row--cost .amt { color: var(--c-text-muted); }

/* [M6-20260429] Cart row override badge */
.cart2__override {
  display: inline-block; margin-top: 4px;
  font-size: var(--fs-11); font-weight: 700;
  color: var(--c-tint-amber-fg,#b45309); background: var(--c-tint-amber,#fef3c7);
  padding: 2px 8px; border-radius: 999px;
  letter-spacing: 0.3px;
}

/* [M6-20260429] Manager override modal */
.modal--override .modal__panel--form { max-width: 460px; }
.override { padding: var(--sp-8) 0 0; }
.override__row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-13);
}
.override__row:last-of-type { border-bottom: none; }
.override__row--attempt .override__val { color: #dc2626; font-weight: 700; }
.override__lbl { color: var(--c-text-muted); }
.override__val { color: var(--c-text); font-weight: 600; }
.override__val.mono { font-family: ui-monospace, Consolas, monospace; }
.override__hint {
  margin: var(--sp-12) 0 var(--sp-8);
  text-align: center;
  font-size: var(--fs-12); color: var(--c-text-muted);
}
.override__form {
  display: flex; flex-direction: column; gap: var(--sp-8);
  padding: var(--sp-8) 0;
}
.override__field {
  display: flex; flex-direction: column; gap: 4px;
}
.override__field-lbl {
  font-size: var(--fs-12); font-weight: 600;
  color: var(--c-text-muted);
}
.override__error {
  min-height: 18px;
  color: #dc2626; font-size: var(--fs-12);
  padding-top: 4px; text-align: center;
}

/* [M3-20260429] Hybrid scan input dropdown */
.bc-drop {
  position: absolute; z-index: 1100;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  max-height: 360px; overflow-y: auto;
  font-family: inherit; font-size: var(--fs-13);
  animation: bc-drop-in 120ms ease-out;
}
@keyframes bc-drop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bc-drop[hidden] { display: none; }
.bc-drop__item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "name  price"
    "sku   stock";
  column-gap: var(--sp-12); row-gap: 2px;
  width: 100%; padding: 8px 12px;
  background: transparent; border: none; border-bottom: 1px solid var(--c-border);
  font-family: inherit; font-size: var(--fs-13);
  text-align: left; cursor: pointer;
  transition: background var(--t-fast);
}
.bc-drop__item:last-child { border-bottom: none; }
.bc-drop__item:hover { background: var(--c-bg-muted); }
.bc-drop__item.is-sel { background: var(--c-primary-bg, #eff6ff); }
.bc-drop__name  { grid-area: name; font-weight: 600; color: var(--c-text);
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-drop__sku   { grid-area: sku; font-size: var(--fs-11); color: var(--c-text-muted);
                  font-family: ui-monospace, Consolas, monospace;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-drop__price { grid-area: price; font-family: ui-monospace, Consolas, monospace;
                  font-weight: 600; color: var(--c-text); text-align: right; white-space: nowrap; }
.bc-drop__stock { grid-area: stock; font-size: var(--fs-11);
                  color: var(--c-text-muted); text-align: right; }
.bc-drop__low   { color: #dc2626; font-weight: 700; }
.bc-drop__empty { padding: 16px; text-align: center; color: var(--c-text-muted); font-size: var(--fs-13); }

/* [M3-20260429] Big search modal */
.modal--bc-search .modal__panel--form { max-width: 720px; }
.bc-modal { display: flex; flex-direction: column; gap: var(--sp-8); }
.bc-modal__input {
  width: 100%; padding: 10px 14px;
  font-size: var(--fs-15);
}
.bc-modal__list {
  max-height: 420px; overflow-y: auto;
  border: 1px solid var(--c-border); border-radius: 8px;
  background: var(--c-surface, #fff);
}
.bc-modal__row {
  display: grid;
  grid-template-columns: 1fr 110px 80px;
  grid-template-rows: auto auto;
  grid-template-areas:
    "name  price stock"
    "meta  meta  meta";
  width: 100%; padding: 10px 14px; column-gap: var(--sp-12); row-gap: 2px;
  background: transparent; border: none; border-bottom: 1px solid var(--c-border);
  font-family: inherit; font-size: var(--fs-13);
  text-align: left; cursor: pointer;
  transition: background var(--t-fast);
}
.bc-modal__row:last-child { border-bottom: none; }
.bc-modal__row:hover { background: var(--c-primary-bg, #eff6ff); }
.bc-modal__name  { grid-area: name; font-weight: 600; color: var(--c-text);
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-modal__meta  { grid-area: meta; font-size: var(--fs-11); color: var(--c-text-muted);
                   font-family: ui-monospace, Consolas, monospace;
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-modal__price { grid-area: price; font-family: ui-monospace, Consolas, monospace;
                   font-weight: 700; color: var(--c-text); text-align: right; white-space: nowrap; }
.bc-modal__stock { grid-area: stock; font-size: var(--fs-12); color: var(--c-text-muted);
                   text-align: right; align-self: center; }
.bc-modal__empty { padding: 24px; text-align: center; color: var(--c-text-muted); font-size: var(--fs-13); }
.cart2__stock-warn {
  display: inline-block; margin-left: 6px;
  background: var(--c-danger-bg); color: var(--c-danger-fg);
  padding: 1px 6px; border-radius: 4px; font-size: var(--fs-11); font-weight: 600;
}

/* Summary */
.sell-summary { display: flex; flex-direction: column; gap: var(--sp-12); }
.sell-summary__rows { display: flex; flex-direction: column; gap: 6px; }
.sell-summary__row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  font-size: var(--fs-14);
}
.sell-summary__lab { color: var(--c-text-muted); font-size: var(--fs-12); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.sell-summary__val { font-variant-numeric: tabular-nums; font-weight: 600; }
.sell-summary__row--input { gap: var(--sp-8); }
.sell-summary__disc { width: 130px; text-align: right; font-family: ui-monospace, Consolas, monospace; }
.sell-summary__row--grand {
  border-top: 2px solid var(--c-border);
  margin-top: 6px; padding-top: 12px;
}
.sell-summary__row--grand .sell-summary__lab { font-size: var(--fs-13); color: var(--c-text); }
.sell-summary__row--grand .sell-summary__val { font-size: 22px; font-weight: 800; color: var(--c-text); letter-spacing: -0.3px; }
.sell-summary__hint { font-size: var(--fs-11); color: var(--c-text-muted); text-align: center; margin: 0; }

/* Customer drawer */
.cust-drawer { display: flex; flex-direction: column; gap: var(--sp-12); }
.cust-drawer__pinned { padding-bottom: var(--sp-8); border-bottom: 1px solid var(--c-border); }
.cust-drawer__list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; }
.cust-row {
  display: flex; align-items: center; gap: var(--sp-12);
  padding: var(--sp-8) var(--sp-12);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-8);
  font-family: inherit;
  cursor: pointer;
  text-align: left; width: 100%;
}
.cust-row:hover { background: var(--c-sidebar-hover); border-color: var(--c-border); }
.cust-row--walkin { background: var(--c-bg-muted); border-color: var(--c-border); }
.cust-row__icon { font-size: 22px; flex: 0 0 22px; }
.cust-row__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cust-row__name { font-weight: 600; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-row__sub  { font-size: var(--fs-11); color: var(--c-text-muted); margin-top: 2px; }

/* Payment dialog */
.modal--pay-dlg .modal__panel--form { max-width: 540px; }
.pay-dlg { display: flex; flex-direction: column; gap: var(--sp-12); }
.pay-dlg__total {
  background: var(--c-primary); color: var(--c-primary-fg);
  border-radius: var(--r-8);
  padding: var(--sp-12) var(--sp-16);
  display: flex; justify-content: space-between; align-items: center;
}
.pay-dlg__total-cap { font-size: var(--fs-12); text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.85; }
.pay-dlg__total-val { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pay-dlg__methods { display: flex; flex-direction: column; gap: var(--sp-8); }
.pay-row {
  display: grid;
  grid-template-columns: 90px 140px 1fr;
  gap: var(--sp-8);
  align-items: center;
  padding: var(--sp-8);
  background: var(--c-bg-muted);
  border: 1px solid var(--c-border);
  border-radius: var(--r-6);
}
.pay-row[hidden] { display: none; }
.pay-row__lab { font-size: var(--fs-13); font-weight: 700; }
.pay-row__amt { text-align: right; font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.pay-row__extra { font-size: var(--fs-12); }
.pay-row--multi { grid-template-columns: 90px 140px 1fr; }
.pay-row__cheque {
  display: grid; grid-template-columns: 1fr 1fr 130px;
  gap: 6px; min-width: 0;
}
.pay-row__cheque .input { font-size: var(--fs-12); padding: 6px 8px; }
.pay-row__credit { display: flex; align-items: center; gap: 6px; }
.pay-row__cap   { font-size: var(--fs-12); color: var(--c-text-muted); }
.pay-row__days  { width: 70px; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.pay-dlg__note  { font-size: var(--fs-12); color: var(--c-text-muted); margin: 0; padding: 4px 8px; }
.pay-dlg__balance {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--sp-8) var(--sp-12);
  border-top: 1px dashed var(--c-border);
}
.pay-dlg__balance-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-13);
}
.pay-dlg__balance-row strong { font-variant-numeric: tabular-nums; }
.pay-dlg__balance-row.is-balanced { color: var(--c-success-fg); }
.pay-dlg__balance-row.is-balanced strong { color: var(--c-success-fg); }
.pay-dlg__balance-row.is-over { color: var(--c-danger-fg); }
.pay-dlg__balance-row.is-over strong { color: var(--c-danger-fg); }
.pay-dlg__balance-row--autocredit { color: var(--c-info-fg, #1b6ca8); font-style: italic; }
.pay-dlg__balance-row--autocredit strong { color: var(--c-info-fg, #1b6ca8); }
.pay-dlg__remark { display: flex; flex-direction: column; gap: 4px; }

/* [Phase 1.2.2-20260429] Quotation page — extends sell.* classes */
.qt-page .qt-card-actions { display: flex; gap: var(--sp-8); align-items: center; }
.qt-page .qt-meta { display: flex; flex-direction: column; gap: 4px; margin-top: var(--sp-12); }
/* [UIPolish2-S3-fix-20260709] #1 BUG: .qt-page .qt-meta{display:flex} (0,2,0) override UA [hidden]
   (0,1,0) → applyTypeConfig set hidden=true แต่ row ยังโผล่. fix scoped tax-edit · specificity (0,2,1)
   ชนะ → [hidden] มีผลจริง (row ที่ควรซ่อนต่อ doc-type หายจริง). ไม่แตะ quotation (.qt-page ตัวอื่น). */
.tax-edit .qt-meta[hidden] { display: none; }
/* [UIPolish2-S3-#2-20260709] ย้ายลูกค้าขึ้น header ขวาบน (mirror .sell__customer หน้าขาย) —
   stack compact · width จำกัด · ★ ไม่มี walk-in default (TQ บังคับเลือกลูกค้าจดทะเบียน) */
.tax-edit .sell__customer { flex-direction: column; align-items: stretch; gap: 6px; min-width: 300px; max-width: 360px; }
.tax-edit .sell__customer #tx-taxid-warn { margin-top: 0; }
/* [UIPolish2-S3d-20260709] pill เดียว (button) → กดเปิด drawer (mirror sell) · เต็มกว้าง header slot ·
   ตัด S3c searchpill/sibling-hide (inline picker เลิกใช้ · drawer แทน) · disabled = readonly/refLocked */
.tax-edit .sell__customer .cust-trigger { min-width: 0; width: 100%; cursor: pointer; }
.tax-edit .sell__customer .cust-trigger:disabled { cursor: not-allowed; opacity: 0.75; }
.qt-page .qt-row__manual {
  display: inline-block; padding: 1px 6px; font-size: var(--fs-11);
  background: var(--c-warn-bg, #fff8e1); color: var(--c-warn-fg, #b07700);
  border-radius: 999px; font-weight: 600; letter-spacing: 0.3px;
}
.qt-page .cart2__stock-info {
  font-size: var(--fs-11); color: var(--c-text-muted);
  padding: 1px 6px; background: var(--c-bg-muted); border-radius: 4px;
}
.qt-mode-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: var(--fs-11); font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase;
}
.qt-mode-pill--edit      { background: var(--c-info-bg, #e3f2ff); color: var(--c-info-fg, #1b6ca8); }
.qt-mode-pill--converted { background: var(--c-success-bg, #e7f7ed); color: var(--c-success-fg, #237b46); }
.qt-mode-pill--cancelled { background: var(--c-bg-muted);          color: var(--c-text-muted); }

/* [Phase 1.2.2-20260429] Quotation list page */
.qt-list { display: flex; flex-direction: column; gap: var(--sp-12); }
.qt-list__head { display: flex; align-items: center; justify-content: space-between; }
.qt-list__filters .card__body { padding: var(--sp-12); }
.qt-filt { display: flex; gap: var(--sp-8); align-items: center; flex-wrap: wrap; }
.qt-filt__q       { flex: 1 1 240px; min-width: 200px; }
.qt-filt__date    { width: 150px; }
.qt-filt__status  { width: 220px; }
.qt-filt__dash    { color: var(--c-text-muted); }
.qt-list__table-wrap { overflow-x: auto; }
/* [Hotfix4] table-layout: fixed — column widths stable on sort/filter (use <colgroup>) */
.qt-tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-13); table-layout: fixed; }
.qt-tbl thead th {
  padding: 8px 12px; text-align: left; font-weight: 700;
  font-size: var(--fs-11); color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--c-bg-muted); border-bottom: 1px solid var(--c-border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qt-tbl tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--c-border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qt-tbl tbody tr:hover { background: var(--c-bg-muted); }
.qt-tbl__num     { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.qt-tbl__actions { white-space: nowrap; text-align: right; overflow: visible; }
.qt-tbl__actions .btn--icon { margin-left: 4px; }
.qt-tbl__actions .btn--icon:disabled { opacity: 0.35; cursor: not-allowed; }
/* [Hotfix4] Customer/seller name column — allow wrap (long names won't truncate awkwardly) */
.qt-tbl .qt-tbl__col-cust,
.qt-tbl .qt-tbl__col-flex { white-space: normal; overflow: visible; word-break: break-word; }

/* [Phase 1.x-Polish-UI5-20260508] Reusable wrap + line-clamp utility for .qt-tbl cells.
   PROBLEM: .qt-tbl tbody td { white-space:nowrap } inherits to children, defeating
   -webkit-line-clamp (which requires text to wrap before clamping).
   USAGE:
     <td class="is-wrap"><div class="clamp-2">long text…</div></td>
     <td class="is-wrap"><div class="clamp-3">longer text…</div></td>
   See Mistake #32 in CLAUDE.md for full history. */
.qt-tbl tbody td.is-wrap {
  white-space: normal !important;
  vertical-align: top;
  text-overflow: clip;
  overflow: visible;
}
.qt-tbl tbody td.is-wrap .clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  white-space: normal !important;
  line-height: 1.35;
  max-height: 2.7em;
}
.qt-tbl tbody td.is-wrap .clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  white-space: normal !important;
  line-height: 1.35;
  max-height: 4.05em;
}
.qt-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: var(--fs-11); font-weight: 700; letter-spacing: 0.3px;
  background: var(--c-bg-muted); color: var(--c-text-muted);
}
.qt-pill--draft     { background: var(--c-info-bg, #e3f2ff);    color: var(--c-info-fg, #1b6ca8); }
.qt-pill--converted { background: var(--c-success-bg, #e7f7ed); color: var(--c-success-fg, #237b46); }
.qt-pill--cancelled { background: var(--c-bg-muted);            color: var(--c-text-muted); }
.qt-list__pager {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-12); border-top: 1px solid var(--c-border);
}
.qt-pager__info { color: var(--c-text-muted); font-size: var(--fs-12); }
.qt-pager__btns { display: flex; gap: var(--sp-8); }

/* [Phase 1.2.2.1-20260429] M6: Sale list — pay-type pills + QT ref link */
.iv-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: var(--fs-11); font-weight: 700; letter-spacing: 0.3px;
  background: var(--c-bg-muted); color: var(--c-text-muted);
}
.iv-pill--cash     { background: var(--c-tint-green,#e7f7ed); color: var(--c-tint-green-fg,#237b46); }
.iv-pill--transfer { background: var(--c-tint-blue,#e3f2ff); color: var(--c-tint-blue-fg,#1b6ca8); }
.iv-pill--cheque   { background: var(--c-tint-violet,#f3e8ff); color: var(--c-tint-violet-fg,#6d28d9); }
.iv-pill--card     { background: var(--c-tint-violet,#ede9fe); color: #7c3aed; }
.iv-pill--credit   { background: var(--c-tint-amber,#fff8e1); color: #b07700; }
.iv-pill--mixed    { background: var(--c-tint-amber,#fef3c7); color: var(--c-tint-amber-fg,#92400e); }
.iv-ref-link {
  color: var(--c-info-fg, #1b6ca8); text-decoration: underline dotted;
}
.iv-ref-link:hover { text-decoration: underline; }

/* [Phase 1.2.2.1-20260429] M7: SN-convert flow — highlight + scan progress */
.cart2__row--needs-sn {
  background: var(--c-tint-amber,#fef9c3);
  border-left: 3px solid #eab308;
}
.cart2__sn-needed {
  display: inline-block; padding: 2px 8px; margin-top: 4px;
  background: var(--c-tint-amber,#fef3c7); color: var(--c-tint-amber-fg,#92400e); border-radius: 999px;
  font-size: var(--fs-11); font-weight: 700;
}
.cart2__qty-progress {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--c-tint-amber-fg,#92400e); font-weight: 700;
}

/* SN capture modal — bigger input */
.modal--sn-capture .modal__panel--form { max-width: 460px; }
.modal--sn-capture .input--lg {
  font-size: var(--fs-15); font-weight: 600;
  letter-spacing: 0.4px;
  font-family: ui-monospace, Consolas, monospace;
}

/* Post-save dialog */
.modal--post-save .modal__panel--form { max-width: 420px; }
.modal--print-opts .modal__panel--form { max-width: 480px; }
.post-save { text-align: center; padding: var(--sp-8) 0; }
.post-save__doc {
  font-family: ui-monospace, Consolas, monospace;
  font-size: var(--fs-18); font-weight: 800;
  color: var(--t-strong,var(--c-primary));
  margin-bottom: 4px; letter-spacing: 0.5px;
}
.post-save__total { font-size: 22px; font-weight: 800; color: var(--c-text); }
.post-save__sub   { font-size: var(--fs-12); color: var(--c-text-muted); margin: 6px 0 12px; }
.post-save__actions { display: flex; gap: var(--sp-8); justify-content: center; flex-wrap: wrap; }

/* Print options panel (post-save) */
.print-opts { padding-top: var(--sp-8); }
.print-opts__divider {
  font-size: var(--fs-12); color: var(--c-text-muted);
  text-align: center; padding: 4px 0 var(--sp-8);
  border-top: 1px dashed var(--c-border);
}
/* [Phase 1.2.2.1-20260429] M2: locked field for QT-only docType */
.print-opts__locked {
  display: inline-block; padding: 6px 12px;
  background: var(--c-bg-muted); color: var(--c-text-muted);
  border-radius: 6px; font-weight: 600; font-size: var(--fs-13);
}
.print-opts__group { margin-bottom: var(--sp-12); }
.print-opts__group--row { display: flex; gap: var(--sp-16); flex-wrap: wrap; }
/* [Feature TaxCopyType-20261103] กลุ่ม required ที่ยังไม่เลือก — กดพิมพ์แล้วเน้นให้เห็นด้วยตา
   (toast อย่างเดียวหายเร็วเกิน คนหาไม่เจอว่าต้องกดตรงไหน) */
.print-opts__group--missing {
  outline: 2px solid var(--c-danger-fg, #dc2626);
  outline-offset: 3px;
  border-radius: 4px;
}
.print-opts__group--missing .print-opts__label { color: var(--c-danger-fg, #dc2626); font-weight: 700; }
.print-opts__label {
  font-size: var(--fs-12); font-weight: 700;
  color: var(--c-text-muted); margin-bottom: 4px;
}
.print-opts__radio, .print-opts__check {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 2px; cursor: pointer;
  font-size: var(--fs-14); color: var(--c-text);
}
.print-opts__radio input:disabled + span { color: var(--c-text-muted); opacity: 0.6; }
.print-opts__hint {
  font-size: var(--fs-12); color: #d97706;
  margin-top: 2px; padding-left: 22px;
}
.print-opts__seg {
  display: inline-flex; border: 1px solid var(--c-border);
  border-radius: 8px; overflow: hidden; background: var(--c-surface);
}
.print-opts__seg-btn {
  background: transparent; border: none; padding: 6px 14px;
  font-family: inherit; font-size: var(--fs-13); cursor: pointer;
  color: var(--c-text); border-right: 1px solid var(--c-border);
}
.print-opts__seg-btn:last-child { border-right: none; }
.print-opts__seg-btn.is-active {
  background: var(--c-primary); color: #fff; font-weight: 700;
}

/* Tablet — stack columns */
@media (max-width: 1023px) {
  .sell__grid { grid-template-columns: 1fr; }
  .sell__side { position: static; }
  .cart2__head, .cart2__row {
    grid-template-columns: 1fr 70px 130px 110px 32px;
  }
}
@media (max-width: 640px) {
  .cart2__head { display: none; }
  .cart2__row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name del"
      "sub  sub"
      "sn   sn"
      "qty  total"
      "price total";
    gap: 4px;
  }
  .cart2__row .col--name  { grid-area: name; }
  .cart2__row .col--qty   { grid-area: qty; }
  .cart2__row .col--price { grid-area: price; }
  .cart2__row .col--total { grid-area: total; align-self: center; font-size: var(--fs-15); }
  .cart2__row .col--del   { grid-area: del; }
  .pay-row { grid-template-columns: 80px 1fr; }
  .pay-row__extra { grid-column: 1 / -1; }
  .pay-row__cheque { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .pay-row__cheque .input[type="date"] { grid-column: 1 / -1; }
  .cust-trigger { min-width: 0; flex: 1 1 100%; }   /* [Fix MobileCustCard-20261112] จอ ≤640: ตัวเลือกลูกค้าเต็มแถว → ปุ่มเพิ่ม/ล้าง wrap ลงล่าง (เดิม flex:1 → ถูกบีบ 66px ข้อความตัดบรรทัดอ่านยาก) */
}

.btn--ghost {
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border-strong);
  padding: var(--sp-8) var(--sp-16);
}
.btn--ghost:hover { background: var(--c-bg-muted); }

/* [Phase 1.3-R3.E-E5a-Hotfix1-20260507] Back buttons in page headers — match
   sibling action buttons (Save/Print) instead of being smaller. Targets every
   header back button by `id="*-back"` (matches gr-back/po-back/aji-back/ajo-back/
   adj-back/sc-back/ce-back/se-back/df-back/bf-back/md-back/pe-back/uf-back).
   Pagination "← ก่อนหน้า" buttons (id="*-pg-prev") keep btn--sm sizing. */
.btn[id$="-back"] {
  padding: var(--sp-8) var(--sp-16);
  font-size: var(--fs-13);
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-16);
  margin-bottom: var(--sp-20);
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-12);
  padding: var(--sp-20);
  box-shadow: var(--sh-card);
  display: flex; flex-direction: column; gap: var(--sp-8);
  min-height: 120px;
}
.stat-card--dark {
  background: var(--c-rail);
  border-color: var(--c-rail);
  color: #fff;
}
.stat-card--dark .stat-card__label,
.stat-card--dark .stat-card__hint { color: rgba(255,255,255,0.7); }
.stat-card__label {
  font-size: var(--fs-12);
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat-card__value {
  font-size: var(--fs-22);
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.1;
}
.stat-card__meta {
  display: flex; align-items: center; gap: var(--sp-8);
  margin-top: auto;
  flex-wrap: wrap;
}
.stat-card__hint { font-size: var(--fs-12); color: var(--c-text-muted); }

.stat-card--skeleton {
  background:
    linear-gradient(90deg, #fff 0%, var(--c-bg-muted) 50%, #fff 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.trend {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-12); font-weight: 600;
}
.trend--up   { background: var(--c-success-bg); color: var(--c-success-fg); }
.trend--down { background: var(--c-danger-bg);  color: var(--c-danger-fg); }
.trend--neutral { background: var(--c-bg-muted); color: var(--c-text-muted); }

/* ── 2-column dashboard layout ── */
.dash-cols {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-16);
}
.dash-col { padding: 0; overflow: hidden; }
.card__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--sp-16) var(--sp-20);
  border-bottom: 1px solid var(--c-border);
}
.card__title {
  margin: 0;
  font-size: var(--fs-15);
  font-weight: 700;
  color: var(--c-text);
}
.card__sub { font-size: var(--fs-12); color: var(--c-text-muted); }
.link {
  color: var(--t-strong,var(--c-primary));
  font-size: var(--fs-12); font-weight: 600;
}
.link:hover { color: var(--c-primary-hover); }

/* ── Data table (compact) ── */
.data-table { font-size: var(--fs-13); }
.data-table__row {
  display: grid;
  grid-template-columns: 1.3fr 1.5fr 0.8fr 1fr 0.9fr;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-12) var(--sp-20);
  border-bottom: 1px solid var(--c-border);
}
.data-table__row:last-child { border-bottom: 0; }
.data-table__row--head {
  background: var(--c-bg-muted);
  font-size: var(--fs-11);
  font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: var(--sp-8) var(--sp-20);
}
.col { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col--amt  { text-align: right; }
.col--time { color: var(--c-text-muted); font-size: var(--fs-12); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: var(--fs-12); }

/* ── Status badges ── */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-11);
  font-weight: 600;
  white-space: nowrap;
}
.status-badge--success { background: var(--c-success-bg); color: var(--c-success-fg); }
.status-badge--warn    { background: var(--c-warn-bg);    color: var(--c-warn-fg); }
.status-badge--danger  { background: var(--c-danger-bg);  color: var(--c-danger-fg); }
.status-badge--info    { background: var(--c-info-bg);    color: var(--c-info-fg); }
.status-badge--neutral { background: var(--c-bg-muted);   color: var(--c-text-muted); }

/* ── Top products list ── */
.rank-list {
  list-style: none;
  margin: 0;
  padding: var(--sp-8) 0;
}
.rank-list__item {
  display: flex; align-items: center; gap: var(--sp-12);
  padding: var(--sp-12) var(--sp-20);
  border-bottom: 1px solid var(--c-border);
}
.rank-list__item:last-child { border-bottom: 0; }
.rank-badge {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--c-rail);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--fs-12);
}
.rank-list__body { flex: 1; min-width: 0; }
.rank-list__name {
  font-size: var(--fs-13); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-list__sub {
  font-size: var(--fs-11); color: var(--c-text-muted);
  margin-top: 2px;
}
.rank-list__qty {
  text-align: right;
  font-size: var(--fs-12); color: var(--c-text-muted);
}
.rank-list__qty strong {
  display: block;
  font-size: var(--fs-15); color: var(--c-text);
  font-weight: 700;
}

/* ── Empty + skeleton rows ── */
.empty {
  padding: var(--sp-32) var(--sp-20);
  text-align: center;
  color: var(--c-text-muted);
  font-size: var(--fs-13);
}
.skeleton-row {
  height: 44px;
  margin: var(--sp-8) var(--sp-20);
  border-radius: var(--r-6);
  background:
    linear-gradient(90deg, var(--c-bg-muted) 0%, #fff 50%, var(--c-bg-muted) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────
   SALES (NEW)
   ───────────────────────────────────────────────────────────── */
.sale__header {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: var(--sp-12); margin-bottom: var(--sp-16);
}
.sale__actions { display: flex; gap: var(--sp-8); align-items: center; }
.sale__grid {
  display: grid; grid-template-columns: 1fr 340px;
  gap: var(--sp-16);
}
.sale__main { display: flex; flex-direction: column; gap: var(--sp-12); }
.sale__pay  { display: flex; flex-direction: column; gap: var(--sp-12); }

.card__body { padding: var(--sp-16) var(--sp-20); }

.kbd {
  display: inline-block;
  padding: 1px 6px; margin-left: 6px;
  border: 1px solid var(--c-border-strong);
  border-radius: 4px;
  background: var(--c-bg-muted);
  font-size: var(--fs-11); font-family: ui-monospace, Consolas, monospace;
  color: var(--c-text-muted);
}
kbd { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-11);
      padding: 1px 4px; background: var(--c-bg-muted); border-radius: 3px;
      border: 1px solid var(--c-border); color: var(--c-text-muted); }

.btn--sm  { padding: 4px 10px; font-size: var(--fs-12); }
.btn--lg  { padding: var(--sp-16); font-size: var(--fs-15); }
/* [Phase BtnAction-20260721] ปุ่ม action หลัก (แถบ .doc-action-bar / header edit page + ปุ่มคู่ back/cancel/print/close)
   สูงเท่ากันทั้งระบบ = ปุ่มบันทึกเดิม (~50px). ★ ปรับ height ทีหลัง = แก้ min-height บรรทัดเดียว.
   ★ วางหลัง .btn--sm/.btn--lg → font-size ชนะ cascade (ปุ่ม back ที่เป็น --sm ได้ font 15 + สูง 50).
   ปุ่มเล็กในแถว/ตาราง (+เพิ่ม/×ลบ/icon/utility) ไม่ใส่ class นี้ = คงเดิม. */
.btn--action { min-height: 50px; font-size: var(--fs-15); padding-inline: var(--sp-16); }
.btn--icon {
  background: transparent; border: 0;
  width: 28px; height: 28px;
  border-radius: var(--r-6);
  color: var(--c-text-muted); font-size: 14px;
}
.btn--icon:hover { background: var(--c-danger-bg); color: var(--c-danger-fg); }

/* search + dropdown */
.search { position: relative; }
.search__dropdown {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--c-surface); border: 1px solid var(--c-border-strong);
  border-radius: 0 0 var(--r-8) var(--r-8);
  box-shadow: var(--sh-md);
  max-height: 320px; overflow-y: auto;
  z-index: 20;
}
.dd__item { padding: var(--sp-8) var(--sp-12); cursor: pointer; border-bottom: 1px solid var(--c-border); }
.dd__item:hover { background: var(--c-sidebar-hover); }
.dd__item:last-child { border-bottom: 0; }
.dd__name { font-size: var(--fs-13); font-weight: 600; color: var(--c-text); }
.dd__sub  { font-size: var(--fs-11); color: var(--c-text-muted); margin-top: 2px;
            display: flex; justify-content: space-between; gap: var(--sp-8); }
.dd__stock { color: var(--c-text-muted); }
.dd__empty { padding: var(--sp-12); text-align: center; color: var(--c-text-muted); font-size: var(--fs-13); }

/* customer selected */
.cust-selected {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-12) var(--sp-16);
  background: var(--c-info-bg);
  border-radius: var(--r-8);
}
.cust-selected__name { font-size: var(--fs-15); font-weight: 700; color: var(--c-text); }
.cust-selected__sub  { font-size: var(--fs-12); color: var(--c-text-muted); margin-top: 2px; }

/* cart */
.cart { font-size: var(--fs-13); }
.cart__row {
  display: grid;
  grid-template-columns: 2.4fr 1fr 0.8fr 1fr 0.7fr 1fr 36px;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-20);
  border-top: 1px solid var(--c-border);
}
.cart__row--head {
  background: var(--c-bg-muted);
  font-size: var(--fs-11); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--c-text-muted);
  padding: var(--sp-8) var(--sp-20);
}
.cart__empty {
  padding: var(--sp-32); text-align: center;
  color: var(--c-text-muted); font-size: var(--fs-13);
  border-top: 1px solid var(--c-border);
}
.input--sm { padding: 6px 8px; font-size: var(--fs-13); }
.col--name  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col--sku   { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-12); color: var(--c-text-muted); }
.col--del   { text-align: center; }

/* summary */
.summary { display: flex; flex-direction: column; gap: var(--sp-8); padding: var(--sp-16) var(--sp-20); }
.summary__row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: var(--fs-13); color: var(--c-text);
  padding: var(--sp-4) 0;
}
.summary__row--check { cursor: pointer; }
.summary__row--check input { margin-right: var(--sp-8); }
.summary__row--grand {
  border-top: 1px solid var(--c-border);
  margin-top: var(--sp-8); padding-top: var(--sp-12);
  font-size: var(--fs-18); font-weight: 700;
}

/* payment panel */
.pay-card {
  background: var(--c-rail);
  color: #fff;
  border-radius: var(--r-12);
  padding: var(--sp-20);
  display: flex; flex-direction: column; gap: var(--sp-8);
}
.pay-card__label { font-size: var(--fs-12); color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 0.5px; }
.pay-card__value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.pay-card__remain {
  display: flex; justify-content: space-between;
  font-size: var(--fs-13); color: rgba(255,255,255,0.8);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: var(--sp-8); margin-top: var(--sp-4);
}
.pay-card__status {
  font-size: var(--fs-12); font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  align-self: flex-start;
}
.pay-card__status--ok     { background: var(--c-success-bg); color: var(--c-success-fg); }
.pay-card__status--warn   { background: var(--c-warn-bg);    color: var(--c-warn-fg); }
.pay-card__status--danger { background: var(--c-danger-bg);  color: var(--c-danger-fg); }

.pay-list { display: flex; flex-direction: column; gap: var(--sp-8); }
.pay-row {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  padding: var(--sp-12);
}
.pay-row__label { font-size: var(--fs-12); font-weight: 700; color: var(--c-text-muted); margin-bottom: var(--sp-8); text-transform: uppercase; letter-spacing: 0.4px; }
.pay-row__inputs { display: flex; flex-direction: column; gap: var(--sp-8); }
.pay-row__inline { display: flex; align-items: center; gap: var(--sp-8); font-size: var(--fs-12); color: var(--c-text-muted); }
.pay-row__inline .input { flex: 1; }

/* ── Hold Bill (Phase H) ─────────────────────────────────────── */
.holds-bar {
  display: flex; align-items: center; gap: var(--sp-12);
  margin: var(--sp-12) 0 var(--sp-16);
  padding: var(--sp-8) var(--sp-12);
  background: var(--c-warn-bg, #fff7e6);
  border: 1px solid var(--c-warn-border, #f7d4a0);
  border-radius: var(--r-8);
  flex-wrap: wrap;
}
.holds-bar__label { font-size: var(--fs-12); font-weight: 700; color: var(--c-warn-fg, #a85d00); text-transform: uppercase; letter-spacing: 0.4px; }
.holds-bar__chips { display: flex; flex-wrap: wrap; gap: var(--sp-8); flex: 1; }
.hold-chip {
  display: inline-flex; align-items: stretch;
  background: var(--c-rail, #2C2C2A);
  color: #fff;
  border-radius: var(--r-8);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.hold-chip__body {
  appearance: none; border: 0; background: transparent; color: inherit;
  padding: 6px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--sp-8);
  font-size: var(--fs-13);
}
.hold-chip__body:hover { background: rgba(255,255,255,0.08); }
.hold-chip__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hold-chip__amt  { color: rgba(255,255,255,0.85); font-weight: 700; }
.hold-chip__del {
  appearance: none; border: 0; background: transparent; color: rgba(255,255,255,0.6);
  padding: 0 10px; cursor: pointer; font-size: 14px;
  border-left: 1px solid rgba(255,255,255,0.1);
}
.hold-chip__del:hover { color: #ff6b6b; background: rgba(255,255,255,0.05); }

/* ── Reports (Phase K) ───────────────────────────────────── */
.reports { display: flex; flex-direction: column; gap: var(--sp-16); }
.rp-tabs {
  display: flex; flex-wrap: wrap; gap: var(--sp-8);
  padding: 0; margin: 0;
  background: transparent;
}
.rp-tab {
  appearance: none; border: 1px solid var(--c-border);
  background: var(--c-surface); color: var(--c-text);
  padding: 6px 14px; border-radius: 999px;
  font-size: var(--fs-13); font-weight: 600; cursor: pointer;
  transition: background-color .12s ease;
}
.rp-tab:hover { background: var(--c-surface-2, #f5f5f2); }
.rp-tab.is-active { background: var(--c-rail, #2C2C2A); color: #fff; border-color: var(--c-rail, #2C2C2A); }
.rp-section { display: flex; flex-direction: column; gap: var(--sp-16); }
.chart-box { position: relative; width: 100%; height: 280px; }
@media (max-width: 640px) {
  .chart-box { height: 220px; }
}
.pay-input { font-weight: 700; font-size: var(--fs-15); text-align: right; font-family: ui-monospace, Consolas, monospace; }

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-16);
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
}
.modal__panel {
  position: relative;
  background: var(--c-surface);
  border-radius: var(--r-12);
  padding: var(--sp-32) var(--sp-24);
  max-width: 420px; width: 100%;
  box-shadow: var(--sh-lg);
  text-align: center;
}
.modal__icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--c-success-bg); color: var(--c-success-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  margin: 0 auto var(--sp-16);
}
.modal__title { margin: 0 0 var(--sp-8); font-size: var(--fs-18); font-weight: 700; }
.modal__msg   { margin: 0 0 var(--sp-4); color: var(--c-text-muted); font-size: var(--fs-13); }
.modal__actions {
  display: flex; gap: var(--sp-8); justify-content: center;
  margin-top: var(--sp-20); flex-wrap: wrap;
}

/* ─────────────────────────────────────────────────────────────
   MASTER DATA PAGES (products, customers)
   ───────────────────────────────────────────────────────────── */
.master__header {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: var(--sp-12); margin-bottom: var(--sp-16);
}
.master__actions { display: flex; gap: var(--sp-8); }

.filter-bar {
  display: flex; gap: var(--sp-12);
  padding: var(--sp-16) var(--sp-20);
  border-bottom: 1px solid var(--c-border);
}
.filter-bar .search { flex: 1; }

.btn--danger {
  background: var(--c-danger-bg); color: var(--c-danger-fg);
}
.btn--danger:hover { background: #ffbcbc; }

/* ── data table .dt ── */
.table-wrap { overflow-x: auto; }
.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.dt thead th {
  padding: var(--sp-8) var(--sp-12);
  background: var(--c-bg-muted);
  font-size: var(--fs-11); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--c-text-muted);
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.dt tbody td {
  padding: var(--sp-12);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.dt tbody tr { cursor: pointer; transition: background var(--t-fast); }
.dt tbody tr:hover { background: var(--c-sidebar-hover); }
.dt-name  { font-weight: 600; color: var(--c-text); }
.dt-sub   { font-size: var(--fs-11); color: var(--c-text-muted); margin-top: 2px; }
.dt-addr {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 360px; line-height: 1.3;
}
.dt-actions { text-align: right; white-space: nowrap; }
.dt-actions .btn { margin-left: 4px; }
.dt-col-sku, .dt-col-cat, .dt-col-tel { width: 130px; }
.dt-col-price, .dt-col-stock { width: 110px; text-align: right; }
.num { text-align: right; }
.dt-col-actions { width: 90px; }
.dt__loading {
  text-align: center;
  padding: var(--sp-32) !important;
  color: var(--c-text-muted);
}

/* ── pager ── */
.pager {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-12) var(--sp-20);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-12); color: var(--c-text-muted);
}
.pager__nav { display: flex; align-items: center; gap: var(--sp-8); }
.pager__nav .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── modal (form variant) ── */
.modal { opacity: 0; transition: opacity 180ms ease; pointer-events: none; }
.modal.is-visible { opacity: 1; pointer-events: auto; }
.modal__panel--form {
  text-align: left;
  padding: 0;
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(8px);
  transition: transform 180ms ease;
}
.modal.is-visible .modal__panel--form { transform: translateY(0); }
.modal__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-16) var(--sp-20);
  border-bottom: 1px solid var(--c-border);
}
.modal__title { margin: 0; font-size: var(--fs-15); font-weight: 700; color: var(--c-text); }
.modal__close {
  background: transparent; border: 0; font-size: 18px;
  width: 32px; height: 32px; border-radius: var(--r-6);
  color: var(--c-text-muted);
}
.modal__close:hover { background: var(--c-bg-muted); }
.modal__body { padding: var(--sp-20); overflow-y: auto; flex: 1; }
.modal__footer {
  display: flex; justify-content: flex-end; gap: var(--sp-8);
  padding: var(--sp-12) var(--sp-20);
  border-top: 1px solid var(--c-border);
  background: var(--c-bg-muted);
}
.modal--confirm .modal__panel--form { max-width: 420px; }

/* ── form layout ── */
.form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-12) var(--sp-16);
}
.ig { display: flex; flex-direction: column; gap: 4px; }
.ig--full { grid-column: 1 / -1; }
.ig--check {
  grid-column: 1 / -1;
  flex-direction: row; align-items: center; gap: var(--sp-8);
  font-size: var(--fs-13);
}
.ig__label {
  font-size: var(--fs-12); font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}

/* ── drawer ── */
.drawer {
  position: fixed; inset: 0;
  z-index: 90;
  pointer-events: none;
}
.drawer__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 220ms ease;
}
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  background: var(--c-surface);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms ease;
}
.drawer.is-open { pointer-events: auto; }
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer.is-open .drawer__panel { transform: translateX(0); }
.drawer__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-16) var(--sp-20);
  border-bottom: 1px solid var(--c-border);
}
.drawer__title { margin: 0; font-size: var(--fs-15); font-weight: 700; }
.drawer__close {
  background: transparent; border: 0; font-size: 18px;
  width: 32px; height: 32px; border-radius: var(--r-6);
  color: var(--c-text-muted);
}
.drawer__close:hover { background: var(--c-bg-muted); }
.drawer__body { padding: var(--sp-20); overflow-y: auto; flex: 1; }
.drawer__actions {
  display: flex; gap: var(--sp-8); justify-content: flex-end;
  margin-top: var(--sp-20); padding-top: var(--sp-16);
  border-top: 1px solid var(--c-border);
}

.kv { display: flex; flex-direction: column; gap: var(--sp-8); font-size: var(--fs-13); }
.kv__row {
  display: flex; justify-content: space-between; gap: var(--sp-12);
  padding: var(--sp-8) 0; border-bottom: 1px dashed var(--c-border);
}
.kv__row:last-child { border-bottom: 0; }
.kv__row span:first-child { color: var(--c-text-muted); flex: 0 0 130px; }
.kv__row > span:last-child, .kv__row > strong:last-child { text-align: right; flex: 1; word-break: break-word; }
.kv__row--full { flex-direction: column; }
.kv__row--full span:first-child { flex: none; }
.kv__row--full > span:last-child { text-align: left; }

/* ── toast ── */
.toast-root {
  position: fixed; top: var(--sp-16); right: var(--sp-16);
  z-index: 200;
  display: flex; flex-direction: column; gap: var(--sp-8);
  pointer-events: none;
}
.toast {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-text-muted);
  border-radius: var(--r-8);
  box-shadow: var(--sh-md);
  padding: var(--sp-12) var(--sp-16);
  display: flex; align-items: center; gap: var(--sp-8);
  min-width: 280px; max-width: 400px;
  font-size: var(--fs-13);
  pointer-events: auto;
  opacity: 0; transform: translateY(-4px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast--success { border-left-color: var(--c-success-fg); }
.toast--error   { border-left-color: var(--c-danger-fg); }
.toast--warn    { border-left-color: var(--c-warn-fg); }
.toast--info    { border-left-color: var(--c-info-fg); }
.toast__icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex: 0 0 22px;
}
.toast--success .toast__icon { background: var(--c-success-bg); color: var(--c-success-fg); }
.toast--error   .toast__icon { background: var(--c-danger-bg);  color: var(--c-danger-fg); }
.toast--warn    .toast__icon { background: var(--c-warn-bg);    color: var(--c-warn-fg); }
.toast--info    .toast__icon { background: var(--c-info-bg);    color: var(--c-info-fg); }
.toast__msg { flex: 1; line-height: 1.4; word-break: break-word; white-space: pre-line; }

/* [Phase Feature-3-20260513] Customer historical price hint (cart row) */
.cart2__last-price-hint {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--c-text-muted);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  line-height: 1.3;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.cart2__last-price-hint:hover {
  color: var(--t-link,var(--c-accent));
  background: var(--c-bg-muted);
  border-color: var(--c-accent);
}

/* [Phase Feature-2-20260513] Toast actions (inline buttons under message) */
.toast__body { display:flex; flex-direction:column; gap:6px; flex:1; }
.toast__actions { display:flex; gap:6px; flex-wrap:wrap; }
.toast--with-actions { padding-bottom: 12px; }

/* [Phase Feature-2-20260513] Notification dropdown panel (bell click) */
.notif-dropdown {
  position: absolute;
  top: calc(var(--topbar-h) - 6px);
  right: var(--sp-16);
  margin-top: 6px;
  background: var(--c-surface, #fff);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  box-shadow: var(--sh-md);
  min-width: 340px;
  max-width: 420px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.notif-dropdown__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-13);
}
.notif-dropdown__more {
  font-size: var(--fs-11);
  color: var(--t-link,var(--c-accent));
  text-decoration: none;
}
.notif-dropdown__more:hover { text-decoration: underline; }
.notif-dropdown__list { overflow-y: auto; max-height: 60vh; }
.notif-dropdown__empty {
  padding: 24px;
  text-align: center;
  color: var(--c-text-muted);
  font-size: var(--fs-13);
}
.notif-dd-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  display: flex; flex-direction: column; gap: 4px;
}
.notif-dd-item__from { font-weight: 600; font-size: var(--fs-13); display:flex; align-items:center; justify-content:space-between; }
.notif-dd-item__time { color: var(--c-text-muted); font-size: var(--fs-11); font-weight: 400; }
.notif-dd-item__msg { font-size: var(--fs-12); color: var(--c-text); line-height: 1.4; word-break: break-word; }
.notif-dd-item__actions { display:flex; gap:6px; margin-top:4px; }

/* ─────────────────────────────────────────────────────────────
   SALES LIST (filter bar, quick ranges, drawer detail)
   ───────────────────────────────────────────────────────────── */
.filter-bar--sticky {
  position: sticky; top: 0; z-index: 5;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap; align-items: center;
}
.date-range {
  display: flex; align-items: center; gap: var(--sp-4);
}
.date-range__sep { color: var(--c-text-muted); font-size: var(--fs-12); }
.date-range .input { width: 150px; padding: 6px 8px; font-size: var(--fs-13); }

.quick-ranges {
  display: flex; gap: var(--sp-4);
  padding: var(--sp-8) var(--sp-20);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--c-border);
}
.qr-btn {
  background: var(--c-bg-muted);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: var(--fs-12); font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.qr-btn:hover { background: var(--c-sidebar-hover); }
.qr-btn.is-active {
  background: var(--c-primary);
  color: var(--c-primary-fg);
  border-color: var(--c-primary);
}

/* sale-list table column widths */
.dt-col-doc    { width: 160px; }
.dt-col-date   { width: 110px; }
.dt-col-cust   { min-width: 200px; }
.dt-col-pay    { width: 90px; }
.dt-col-amt    { width: 130px; text-align: right; }
.dt-col-status { width: 110px; }

/* ── drawer detail content ── */
.section-h {
  margin: var(--sp-20) 0 var(--sp-8);
  font-size: var(--fs-12); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--c-text-muted);
}
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-12);
}
.mini-table th, .mini-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
}
.mini-table thead th {
  background: var(--c-bg-muted);
  font-size: var(--fs-11); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--c-text-muted);
}
.mini-table .muted { color: var(--c-text-muted); font-size: var(--fs-11); }

.totals {
  margin-top: var(--sp-12);
  padding: var(--sp-12);
  background: var(--c-bg-muted);
  border-radius: var(--r-8);
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--fs-13);
}
.totals > div {
  display: flex; justify-content: space-between;
  padding: 2px 0;
}
.totals__grand {
  border-top: 2px solid var(--c-text);
  margin-top: 6px; padding-top: 6px;
  font-size: var(--fs-15); font-weight: 700;
}

.kv--sub { font-size: var(--fs-11); color: var(--c-text-muted); margin-top: var(--sp-12); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* Tablet: 768–1023px → rail + content, sidebar slides, topbar still visible */
@media (max-width: 1023px) {
  .shell {
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-areas:
      "rail top"
      "rail main";
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h); left: var(--rail-w); bottom: 0;
    width: var(--sidebar-w);
    z-index: 26;
    /* [Fix SidebarSliver-20261029] เดิมเลื่อนแค่ 110% ของความกว้าง จาก left:rail-w → ขอบขวาค้างที่ x≈34px
       ทับแถบ rail (แท็บเล็ต 768–1023) = แถบขาวเศษเมนูด้านซ้าย · ตอนนี้เลื่อนพ้น rail ทั้งแผง + ซ่อน (visibility)
       ตอนปิด (เงา/โฟกัสคีย์บอร์ดไม่หลุดออกมา) · เปิดด้วย ☰ (.is-open) เหมือนเดิม */
    transform: translateX(calc(-100% - var(--rail-w) - 24px));
    visibility: hidden;
    transition: transform var(--t-base), visibility 0s linear var(--t-base);
    box-shadow: var(--sh-lg);
  }
  .sidebar.is-open { transform: translateX(0); visibility: visible; transition: transform var(--t-base), visibility 0s; }
  .topbar__btn--menu { display: flex; }

  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .dash-cols   { grid-template-columns: 1fr; }
  .sale__grid  { grid-template-columns: 1fr; }
  .form__grid  { grid-template-columns: 1fr; }
}

/* [Phase Products-NameColumn-Tablet-20260528] Opt-in utility — hide low-priority
   .qt-tbl columns on tablet so the flex column (e.g. name) keeps readable width.
   Add class="is-hide-tablet" to BOTH the <th> and matching <td>. */
@media (max-width: 1023px) {
  .qt-tbl th.is-hide-tablet,
  .qt-tbl td.is-hide-tablet { display: none; }
}

/* Mobile: <768px → topbar + content + tabbar */
@media (max-width: 767px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr var(--tabbar-h);
    grid-template-areas:
      "top"
      "main"
      "tab";
  }
  .rail { display: none; }
  .sidebar {
    top: var(--topbar-h);
    left: 0;
    width: 80vw;
    max-width: 300px;
  }
  .topbar { padding: 0 var(--sp-12); }
  .topbar__user,
  .topbar__user--btn { display: none; }
  .topbar__brand { max-width: 140px; font-size: var(--fs-14); }
  .branch-badge__name { display: none; }
  .branch-badge__dropdown { right: var(--sp-12); }
  .tabbar { display: block; grid-area: tab; position: static; }
  .content {
    grid-area: main;
    padding: var(--sp-16);
    padding-bottom: calc(var(--sp-16) + var(--tabbar-h));
  }

  .stats-grid { grid-template-columns: 1fr; }
  .data-table__row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "doc    status"
      "cust   amt"
      "time   amt";
    row-gap: 4px;
  }
  .data-table__row .col--doc    { grid-area: doc; }
  .data-table__row .col--cust   { grid-area: cust; white-space: normal; }
  .data-table__row .col--status { grid-area: status; justify-self: end; }
  .data-table__row .col--amt    { grid-area: amt; align-self: center; font-weight: 700; }
  .data-table__row .col--time   { grid-area: time; }
  .data-table__row--head { display: none; }

  .cart__row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name del"
      "sku  amt"
      "qp   amt"
      "disc amt";
    row-gap: 4px;
  }
  .cart__row--head { display: none; }
  .cart__row .col--name  { grid-area: name; font-weight: 600; white-space: normal; }
  .cart__row .col--sku   { grid-area: sku; }
  .cart__row .col--qty   { grid-area: qp; display: inline-flex; gap: 4px; align-items: center; }
  .cart__row .col--qty::before  { content: 'จำนวน:'; font-size: var(--fs-11); color: var(--c-text-muted); margin-right: 4px; }
  .cart__row .col--price { grid-area: qp; }
  .cart__row .col--price::before { content: '×'; color: var(--c-text-muted); margin: 0 4px; }
  .cart__row .col--disc  { grid-area: disc; }
  .cart__row .col--disc::before  { content: 'ส่วนลด %:'; font-size: var(--fs-11); color: var(--c-text-muted); margin-right: 4px; }
  .cart__row .col--amt   { grid-area: amt; align-self: center; font-weight: 700; font-size: var(--fs-15); }
  .cart__row .col--del   { grid-area: del; justify-self: end; }

  /* compact data table on mobile */
  .dt thead { display: none; }
  .dt tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name actions"
      "sku  meta";
    gap: 4px;
    padding: var(--sp-12);
  }
  .dt tbody td { padding: 0; border: 0; }
  .dt tbody tr td:nth-child(1) { grid-area: sku; font-size: var(--fs-11); color: var(--c-text-muted); }
  .dt tbody tr td:nth-child(2) { grid-area: name; }
  .dt tbody tr td:nth-child(3),
  .dt tbody tr td:nth-child(4) { grid-area: meta; font-size: var(--fs-11); color: var(--c-text-muted); }
  .dt tbody tr td:last-child   { grid-area: actions; }
  .dt tbody tr { border-bottom: 1px solid var(--c-border); }

  .toast-root { left: var(--sp-12); right: var(--sp-12); }
  .toast { min-width: 0; max-width: 100%; }
}

/* ─────────────────────────────────────────────────────────────
   Phase F — S/N capture + stock pages
   ───────────────────────────────────────────────────────────── */
.modal--sn-capture .modal__panel { width: min(640px, 92vw); }
.sn-capture { display: flex; flex-direction: column; gap: var(--sp-12); }
.sn-capture__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-12);
}
.sn-capture__prod { font-weight: 600; font-size: var(--fs-15); }
.sn-capture__meta { font-size: var(--fs-12); margin-top: 2px; }
.sn-capture__counter {
  padding: 6px 12px;
  border-radius: var(--r-8);
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
}
.sn-capture__scanbox {
  display: flex; gap: var(--sp-8); align-items: center;
}
.sn-capture__scanbox .input--lg {
  flex: 1 1 auto;
  font-size: var(--fs-15);
  padding: 10px 14px;
}
.sn-capture__msg {
  min-height: 22px;
  padding: 4px 10px;
  border-radius: var(--r-6);
  font-size: var(--fs-13);
  transition: background .15s;
}
.sn-capture__msg--ok   { background: var(--c-tint-green,#e7f7ec); color: var(--c-tint-green-fg,#1f7a3a); }
.sn-capture__msg--warn { background: var(--c-tint-amber,#fff7e0); color: var(--c-tint-amber-fg,#8a5a00); }
.sn-capture__msg--err  { background: var(--c-tint-red,#fdecec); color: var(--c-tint-red-fg,#a42121); }

.sn-capture__chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 40px;
  padding: 8px;
  border: 1px dashed var(--c-border);
  border-radius: var(--r-8);
}
.sn-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 4px 4px 10px;
  background: var(--c-bg-muted);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: var(--fs-12);
}
.sn-chip__del {
  border: none; background: transparent;
  cursor: pointer; padding: 2px 6px;
  border-radius: 50%;
  color: var(--c-text-muted);
  line-height: 1;
}
.sn-chip__del:hover { background: var(--c-tint-red,#fdecec); color: var(--c-tint-red-fg,#a42121); }

.sn-capture__picklist {
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  max-height: 260px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.sn-picklist__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  background: var(--c-bg-muted);
  gap: var(--sp-8);
  border-bottom: 1px solid var(--c-border);
}
.sn-picklist__body { overflow-y: auto; max-height: 210px; }
.sn-pick-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--sp-8);
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-13);
}
.sn-pick-row:last-child { border-bottom: none; }
.sn-pick-row:hover { background: var(--c-bg-muted); }

/* cart S/N slot */
.cart__sn-row {
  grid-column: 1 / -1;
  display: flex; gap: 8px; align-items: center;
  padding: 4px 12px 10px 12px;
  font-size: var(--fs-12);
  color: var(--c-text-muted);
  flex-wrap: wrap;
}
.cart__sn-row .sn-chip { background: var(--c-bg-elevated,#fff); }
.cart__sn-row .btn { white-space: nowrap; }
.cart__sn-row--need { color: #a65a00; }
.cart__sn-row--ok   { color: var(--c-tint-green-fg,#1f7a3a); }

/* stock-in / adjust / transfer shared layout */
.stk-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: var(--sp-12); gap: var(--sp-12); flex-wrap: wrap; }
.stk-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-16); }
@media (max-width: 920px) { .stk-grid { grid-template-columns: 1fr; } }
.stk-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-12); margin-bottom: var(--sp-12); }
.stk-cart { width: 100%; border-collapse: collapse; }
.stk-cart th, .stk-cart td { padding: 8px; border-bottom: 1px solid var(--c-border); font-size: var(--fs-13); text-align: left; }
.stk-cart th { background: var(--c-bg-muted); font-weight: 600; }
.stk-cart td.num, .stk-cart th.num { text-align: right; }
.stk-cart input.input--sm { width: 100%; }
.stk-summary { padding: var(--sp-12); background: var(--c-bg-muted); border-radius: var(--r-8); }
.stk-summary__row { display: flex; justify-content: space-between; padding: 4px 0; font-size: var(--fs-13); }

/* ── Phase 1.2.2.2 — Action menu (⋮) used by sale-list / quotation-list ── */
.action-menu__trigger {
  width: 32px; height: 32px;
  font-size: 18px; line-height: 1;
}
.action-menu__trigger:hover { background: var(--c-bg-muted); color: var(--c-text); }
/* [Phase Tax-WF-Dropdown-20260802] badge สถานะที่ทำหน้าที่เป็นตัวเปิด action menu.
   ★ แยก class จาก .action-menu__trigger เพราะตัวนั้นบังคับ 32×32px — จะบีบ pill เสียรูป.
   ปุ่มโปร่งใสหมด ให้ .iv-pill ข้างในเป็นตัวกำหนดหน้าตาทั้งหมด. */
.qt-status-trigger {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; line-height: inherit;
  cursor: pointer;
}
.qt-status-trigger:hover { opacity: .85; }
.qt-status-trigger:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: var(--r-6); }
.action-menu {
  position: absolute;
  z-index: 100;
  min-width: 180px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-8);
  box-shadow: var(--sh-md);
  padding: 4px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.action-menu.is-open { opacity: 1; transform: translateY(0); }
.action-menu__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent; border: 0;
  border-radius: var(--r-6);
  font-size: var(--fs-13);
  color: var(--c-text);
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.action-menu__item:hover:not(.is-disabled) { background: var(--c-sidebar-hover); }
.action-menu__item.is-disabled {
  color: var(--c-text-muted);
  opacity: 0.5;
  cursor: not-allowed;
}
.action-menu__item--danger:not(.is-disabled) { color: var(--c-danger-fg); }
.action-menu__item--danger:not(.is-disabled):hover { background: var(--c-danger-bg); }
.action-menu__icon { font-size: 16px; min-width: 20px; text-align: center; }

/* selectable rows on list pages — single-click highlight, dblclick navigates */
.qt-tbl tbody tr { cursor: pointer; }
.qt-tbl tbody tr.is-selected { background: var(--c-info-bg); }

/* sell.js / quotation.js edit & view mode pill */
.iv-mode-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 600;
  margin-left: var(--sp-8);
}
.iv-mode-pill--edit { background: var(--c-tint-amber,#fef3c7); color: var(--c-tint-amber-fg,#92400e); }
.iv-mode-pill--view { background: var(--c-bg-muted); color: var(--c-text-muted); }

/* sell.js view-only mode: dim + disable non-essential UI */
.sell--view-only .sell__bc-input,
.sell--view-only .input,
.sell--view-only .cart2__inp {
  background: var(--c-bg-muted) !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}
.sell--view-only .cart2__price-info,
.sell--view-only [data-action="remove"],
.sell--view-only #cart-clear,
.sell--view-only #btn-add-manual,
.sell--view-only #cust-quickadd,
.sell--view-only #cust-walkin,
.sell--view-only #cust-trigger { display: none !important; }
.sell--view-only .cart2__row { opacity: 0.92; }
/* [Fix IvProjectViewMode-20261024] ช่อง Project ต้องเปลี่ยนได้แม้บิลเปิดโหมดดู (ชำระแล้ว · Nui 10-24)
   ★ `.sell--view-only .input` ด้านบนตั้ง pointer-events:none !important ทับ inline ของ #iv-project-wrap ไม่ได้
     (กฎนั้นจับที่ตัว <select class="input"> เอง) ⇒ ยกเว้นด้วย id (specificity สูงกว่า · !important เท่ากัน) */
.sell--view-only #iv-project {
  pointer-events: auto !important;
  cursor: pointer !important;
  background: var(--c-surface) !important;
}

/* [Phase 1.2.2.3-20260430] M2 — view-mode action buttons (replace save) */
.view-actions {
  display: flex; gap: 12px;
  padding: 12px 16px;
  margin-top: var(--sp-8);
}
.view-actions .btn { flex: 1; min-height: 44px; font-size: var(--fs-14); }
/* [Phase BtnAction-20260721] defensive override — ถ้าปุ่ม btn--action หลุดเข้า .view-actions/.doc-action-bar__right
   (specificity 0,2,0 = .view-actions .btn) → บังคับ 50px (came-later ในไฟล์ = ชนะ · ไม่ใช้ !important · ปุ่ม view-mode ปกติที่ไม่มี btn--action คง 44px). ปัจจุบัน match 0 element = กันอนาคต. */
.view-actions .btn--action,
.doc-action-bar__right .btn--action { min-height: 50px; }

/* [Phase 1.2.2.3-20260430] M3 — payment history (view/edit mode only) */
.payment-history {
  margin-top: var(--sp-16);
  padding: var(--sp-16);
  background: var(--c-bg-muted);
  border-radius: var(--r-8);
  border-left: 4px solid var(--c-info-fg, #1b6ca8);
}
.payment-history__title {
  font-size: var(--fs-14);
  margin: 0 0 var(--sp-12) 0;
  font-weight: 700;
  color: var(--c-text);
}
.payment-history__rows { display: flex; flex-direction: column; }
.payment-history__row {
  display: grid;
  grid-template-columns: 80px 80px 1fr auto;
  gap: var(--sp-12);
  padding: 6px 0;
  border-bottom: 1px dashed var(--c-border);
  align-items: center;
  font-size: var(--fs-13);
}
.payment-history__row:last-child { border-bottom: 0; }
.payment-history__seq { color: var(--c-text-muted); }
.payment-history__amount { text-align: right; font-weight: 600; }
.payment-history__re { text-align: right; }
.re-link {
  color: var(--c-info-fg, #1b6ca8);
  text-decoration: underline dotted;
  cursor: pointer;
}
.re-link:hover { text-decoration: underline; }
.payment-history__summary {
  margin-top: var(--sp-12);
  padding-top: var(--sp-12);
  border-top: 2px solid var(--c-border-strong);
  display: flex;
  gap: var(--sp-24);
  flex-wrap: wrap;
  font-size: var(--fs-13);
}
.payment-history__summary strong { margin-left: 4px; }

/* [Phase 1.2.2.4-20260430] M4 — pending-credit sub-line in IV list total cell */
.iv-tbl__pending {
  font-size: var(--fs-11);
  color: var(--c-warn-fg, #b07700);
  font-weight: 600;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* [Phase 1.2.2.3-20260430] M4 — cancelled-row treatment */
.qt-tbl__row--cancelled {
  opacity: 0.65;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 10px,
    rgba(220, 38, 38, 0.04) 10px, rgba(220, 38, 38, 0.04) 12px);
}
.qt-tbl__row--cancelled .mono { text-decoration: line-through; }
.iv-pill--cancelled { background: var(--c-bg-subtle,#f3f4f6); color: var(--c-mute,#6b7280); }
.iv-pill--active    { background: var(--c-tint-green,#e7f7ed); color: var(--c-tint-green-fg,#237b46); }
/* [Phase AR-2-Polish-20260508] payment-aware status pills */
.iv-pill--paid      { background: var(--c-tint-green,#d1fae5); color: var(--c-tint-green-fg,#065f46); }
.iv-pill--partial   { background: var(--c-tint-amber,#fef3c7); color: var(--c-tint-amber-fg,#92400e); }
/* [Phase IV-Edit-RE-Gate-20260623] บิลยอด 0 ไม่มี RE = ยังไม่มีเงินเข้า (รอแก้ไข) — สีกลาง/เทา */
.iv-pill--draft     { background: var(--c-bg-subtle,#f3f4f6); color: var(--c-mute,#6b7280); }

/* [Phase 1.2.2.3-20260430] M7 — sortable column headers */
.qt-tbl th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}
.qt-tbl th.sortable:hover { background: var(--c-sidebar-hover); }
.qt-tbl th.sortable .sort-arrow {
  display: inline-block;
  width: 12px;
  margin-left: 4px;
  color: var(--c-text-muted);
  font-size: 10px;
}
.qt-tbl th.sortable.is-active .sort-arrow {
  color: var(--c-text);
  font-weight: 700;
}

/* [Phase Polish-Fixes-20260509] Standardized sortable column headers (3-state visual)
   Used by: sale-list, sale-deposit-list, sale-return-list, sale-credit-ledger,
            po-order-list, goods-receipt-list (and any future list page).
   Pattern: <th class="qt-sortable [is-sorted]" data-sort-col="X">label <span class="qt-sort-icon">↕</span></th>
*/
.qt-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}
.qt-sortable:hover {
  background: rgba(37, 99, 235, 0.05);
}
.qt-sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.4;
  transition: opacity 0.15s;
}
.qt-sortable:hover .qt-sort-icon {
  opacity: 0.7;
}
.qt-sortable.is-sorted .qt-sort-icon {
  opacity: 1;
  color: var(--t-link,var(--c-accent, #2563eb));
  font-weight: bold;
}

/* [Phase Doc-Linkage-20260509] Related-doc pills row on view pages.
   Used by: sale-receive-view, sale-deposit-view, sale-return-view, sell.js (IV view mode).
   Pattern: <div class="related-docs">📎 เอกสารที่เกี่ยวข้อง: <a class="related-doc-pill related-doc-pill--{type}">…</a></div>
   Brand colors mirror modern print bodies (RE=green, DP=blue, RT=orange, BN=amber, QT/IV=mono, PO=blue, GR=green).
*/
.related-docs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-8) var(--sp-12);
  background: var(--c-bg-subtle,#f9fafb);
  border: 1px solid var(--c-border);
  border-radius: var(--r-6);
  margin-bottom: var(--sp-12);
  font-size: var(--fs-12);
}
.related-docs__label {
  color: var(--c-text-muted);
  font-weight: 500;
  margin-right: var(--sp-4);
}
.related-doc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--sp-8);
  border-radius: 999px;
  font-size: var(--fs-11);
  font-family: monospace;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: opacity 0.15s, transform 0.05s;
}
.related-doc-pill:hover { opacity: 0.85; }
.related-doc-pill:active { transform: translateY(1px); }
.related-doc-pill--iv  { background: var(--c-bg-subtle,#f3f4f6); color: var(--c-text-strong,#1a1a1a); border-color: var(--c-border-light,#d1d5db); }
.related-doc-pill--qt  { background: var(--c-bg-subtle,#f3f4f6); color: var(--c-text-strong,#1a1a1a); border-color: var(--c-border-light,#d1d5db); }
.related-doc-pill--re  { background: var(--c-tint-green,#dcfce7); color: var(--c-tint-green-fg,#14532d); border-color: var(--c-tint-green-bd,#86efac); }
.related-doc-pill--dp  { background: var(--c-tint-blue,#dbeafe); color: var(--c-tint-blue-fg,#1e3a8a); border-color: var(--c-tint-blue-bd,#93c5fd); }
.related-doc-pill--bn  { background: var(--c-tint-amber,#fef3c7); color: var(--c-tint-amber-fg,#78350f); border-color: var(--c-tint-amber-bd,#fcd34d); }
.related-doc-pill--rt  { background: var(--c-tint-orange,#ffedd5); color: var(--c-tint-orange-fg,#7c2d12); border-color: #fdba74; }
.related-doc-pill--po  { background: var(--c-tint-blue,#dbeafe); color: var(--c-tint-blue-fg,#1e3a8a); border-color: var(--c-tint-blue-bd,#93c5fd); }
.related-doc-pill--gr  { background: var(--c-tint-green,#d1fae5); color: var(--c-tint-green-fg,#064e3b); border-color: #6ee7b7; }
.related-doc-pill--ledger {
  background: var(--c-tint-violet,#f3e8ff);
  color: var(--c-tint-violet-fg,#581c87);
  border-color: #d8b4fe;
  font-family: inherit;
  font-weight: 500;
}
.related-doc-pill--cancelled {
  opacity: 0.55;
  text-decoration: line-through;
}

/* combined post-save dialog: section divider above print options */
.post-save__divider {
  margin: var(--sp-12) 0 var(--sp-8);
  padding-top: var(--sp-12);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-12);
  color: var(--c-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stk-summary__grand { font-size: var(--fs-16); font-weight: 700; border-top: 1px solid var(--c-border); padding-top: 10px; margin-top: 6px; }

/* ── [Phase 1.2.3-20260430] Billing Note (BN) page ─────────── */
.bn-page { display: flex; flex-direction: column; gap: var(--sp-12); }
.bn-page__head { gap: var(--sp-12); }
.bn-page__banner {
  display: flex; align-items: center; gap: var(--sp-8);
  padding: 10px 14px; border-radius: 8px;
  background: var(--c-danger-bg, #fff0f0); color: var(--c-danger-fg, #b13838);
  border: 1px solid var(--c-danger-fg, #d97a7a);
  font-weight: 700; font-size: var(--fs-13);
}
.bn-page__banner-icon { font-size: 18px; }
.bn-page__select-all {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-13); color: var(--c-text-muted); cursor: pointer;
}
/* [Fix BnActionBar-20261028] ปุ่มพิมพ์/ปิด อยู่ในแถบปุ่มเอกสาร (แถวเดียว) · [hidden] ต้องชนะ display:flex ([[mistake-73]]) */
.bn-page__view-actions {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
}
.bn-page__view-actions[hidden] { display: none; }
.bn-page__ivs-wrap { padding: 0; }
.bn-iv-list { display: flex; flex-direction: column; }
.bn-iv-list__head,
.bn-iv-row {
  display: grid;
  grid-template-columns: 32px 1.6fr 1fr 1fr 2fr;
  align-items: center;
  gap: var(--sp-8);
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
}
.bn-iv-list__head {
  font-size: var(--fs-12); color: var(--c-text-muted);
  font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  background: var(--c-bg-muted);
  position: sticky; top: 0; z-index: 1;
}
.bn-iv-row { cursor: pointer; transition: background .12s; }
.bn-iv-row:hover { background: var(--c-bg-muted); }
.bn-iv-row__chk { width: 18px; height: 18px; cursor: pointer; }
.bn-iv-row__chk-col { display: flex; justify-content: center; }
.bn-iv-row__doc { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.bn-iv-row__amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bn-iv-row__pending {
  display: block; font-size: var(--fs-11); color: var(--c-warning-fg, #b07700);
  font-weight: 500; margin-top: 1px;
}
.bn-iv-row__mem { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--fs-12); }
.bn-iv-row--view { cursor: default; }
.bn-iv-row--ivcancelled { opacity: .65; }
.bn-iv-row--ivcancelled .bn-iv-row__doc { text-decoration: line-through; }
.bn-mem-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: var(--fs-11); font-weight: 700;
  text-decoration: none; white-space: nowrap;
}
.bn-mem-badge--active    { background: var(--c-tint-blue,#e3f2ff); color: var(--c-tint-blue-fg,#1b6ca8); }
.bn-mem-badge--cancelled { background: var(--c-bg-muted); color: var(--c-text-muted); }
.bn-mem-badge:hover { text-decoration: underline; }
.bn-tbl__ivcount {
  display: block; font-size: var(--fs-11); color: var(--c-text-muted);
  font-weight: 500; margin-top: 2px;
}
@media (max-width: 720px) {
  .bn-iv-list__head, .bn-iv-row { grid-template-columns: 28px 1fr 1fr; }
  .bn-iv-row__date, .bn-iv-row__mem { display: none; }
}
 
/* [Phase 1.2.3 fix] hidden attribute trumps display:flex */
.bn-page__banner[hidden] { display: none !important; }

/* [Phase UI-Polish-Reports-20260511] Report table styles */
.report-table { width:100%; border-collapse:collapse; font-size:.875rem; }
.report-table th {
  background:var(--c-surface-2,#f5f5f5); padding:10px 14px; text-align:left;
  font-weight:600; border-bottom:2px solid var(--c-border); white-space:nowrap;
  position:sticky; top:0; z-index:1;
}
.report-table td { padding:9px 14px; border-bottom:1px solid var(--c-border-light,#eee); vertical-align:middle; line-height:1.5; }
.report-table tr:hover td { background:var(--c-surface-hover,#fafafa); }
.report-table tr:last-child td { border-bottom:none; }
.report-table td.num, .report-table th.num { text-align:right; font-variant-numeric:tabular-nums; }
.report-table tfoot tr td { font-weight:700; background:var(--c-surface-2,#f5f5f5); border-top:2px solid var(--c-border); padding:8px 10px; }
.report-table-wrap { overflow-x:auto; border-radius:8px; border:1px solid var(--c-border); }
.report-table tbody tr:nth-child(even) td { background:var(--c-surface-1,#fafafa); }
.report-table tbody tr:nth-child(even):hover td { background:var(--c-surface-hover,#f0f0f0); }

/* [Phase UI-Polish-Reports-20260511] Collapsible sidebar groups */
.sidebar__group-toggle {
  display:flex; align-items:center; justify-content:space-between; cursor:pointer;
  padding:8px 12px; font-size:var(--fs-14,0.875rem); font-weight:600; color:var(--c-text); user-select:none; text-transform:none; letter-spacing:0;
}
.sidebar__group-toggle:hover { color:var(--c-text); }
.sidebar__group-toggle .toggle-arrow { font-size:.7rem; transition:transform .2s ease; }
.sidebar__group--collapsed .toggle-arrow { transform:rotate(-90deg); }
.sidebar__group-items { overflow:hidden; max-height:2000px; transition:max-height .25s ease; }
.sidebar__group--collapsed .sidebar__group-items { max-height:0; }

/* ══════════════════════════════════════════════════════
   [Phase Reports-UI-Polish-20260512] World-class Report UI
   ══════════════════════════════════════════════════════ */

/* ── Report Filter Bar ── */
.report-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 16px;
  background: var(--c-surface-1, #fafafa);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  margin-bottom: 14px;
  margin-top: 14px;
}
.report-filter__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.report-filter .input,
.report-filter select,
.report-filter input[type="date"] {
  height: 36px;
  font-size: 13.5px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  min-width: 0;
  box-sizing: border-box;
}
.report-filter select { padding-right: 28px; }
.report-filter .btn {
  height: 36px;
  padding: 0 18px;
  font-size: 13.5px;
  border-radius: 7px;
  white-space: nowrap;
}
.report-filter__sep {
  color: var(--c-text-muted);
  font-size: 13px;
  padding: 0 2px;
  line-height: 36px;
}

/* ── KPI Cards Grid ── */
.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.report-kpi-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}
.report-kpi-card__value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--c-text);
  margin-bottom: 4px;
}
.report-kpi-card__value--primary { color: var(--t-strong,var(--c-primary)); }
.report-kpi-card__value--danger  { color: #dc2626; }
.report-kpi-card__value--success { color: #059669; }
.report-kpi-card__value--warn    { color: #d97706; }
.report-kpi-card__label {
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
}

/* ── Report Table (enhanced) ── */
.report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: var(--c-surface);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.report-table thead th {
  background: var(--c-surface-2, #f5f5f5);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-muted);
  border-bottom: 2px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.report-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--c-border-light, #efefef);
  vertical-align: middle;
  line-height: 1.55;
  color: var(--c-text);
}
.report-table tbody tr:hover td { background: var(--c-surface-hover, #f5f5f5); }
.report-table tbody tr:nth-child(even) td { background: var(--c-surface-1, #fafafa); }
.report-table tbody tr:nth-child(even):hover td { background: var(--c-surface-2, #f0f0f0); }
.report-table tfoot td {
  padding: 10px 14px;
  font-weight: 700;
  background: var(--c-surface-2, #f5f5f5);
  border-top: 2px solid var(--c-border);
}
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table .center { text-align: center; }

/* ── Report Action Bar ── */
.report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Period badge ── */
.report-period-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--c-primary-soft, #eff6ff);
  color: var(--t-strong,var(--c-primary));
  font-size: 12px;
  font-weight: 600;
}

/* ── Report page header buttons (Print / Excel) ── */
.qt-list__head-r .btn--ghost,
.qt-list__head-r .btn--primary,
.report-actions .btn {
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ── [Phase B6-ActionBar] canonical sticky save/action footer for document edit pages ──
   Single source of truth for the "บันทึก" button placement. Layout:
   [← กลับ]  ·····spacer·····  [ปุ่มรอง…] [💾 บันทึก]
   Sticky to viewport bottom so the primary CTA is always reachable on long forms. */
.doc-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin-top: var(--sp-16);
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex-wrap: wrap;
  padding: var(--sp-12) var(--sp-16);
  background: var(--c-surface, #fff);
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: var(--r-6);
  border-bottom-right-radius: var(--r-6);
}
.doc-action-bar__spacer { flex: 1 1 auto; }
.doc-action-bar__right {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex-wrap: wrap;
}
/* narrow screens: keep CTA on its own full-width row so nothing overflows */
@media (max-width: 600px) {
  .doc-action-bar { gap: var(--sp-6); padding: var(--sp-8) var(--sp-12); }
  .doc-action-bar__right { width: 100%; }
  .doc-action-bar__right .btn { flex: 1 1 auto; justify-content: center; }
}

/* ── Report filter bar controls — 36px consistent height ── */
.report-filter select,
.report-filter input[type="date"],
.report-filter input[type="text"],
.report-filter input[type="number"],
.report-filter .input {
  height: 36px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  box-sizing: border-box;
  line-height: normal;
  vertical-align: middle;
}

.report-filter .btn {
  height: 36px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
}
/* [Phase BtnAction-R2-20260721] scoped override — ปุ่ม btn--action ในคอนเทนเนอร์ fix-height (report-filter 36px!important · qt-list__head-r/report-actions 38px) → 50px. วางหลัง rule เดิม (cascade). quick-range pills (.range-pill ≠ .btn) ไม่กระทบ. */
.qt-list__head-r .btn--action,
.report-actions .btn--action { min-height: 50px; height: auto; }
.report-filter .btn--action { min-height: 50px !important; height: auto !important; padding-top: 0; padding-bottom: 0; }

/* ── Print ── */
@media print {
  .report-filter, .report-actions { display: none !important; }
  .report-table thead th { background: #f5f5f5 !important; -webkit-print-color-adjust: exact; }
  .report-table-wrap { border: none; border-radius: 0; overflow: visible; }
  @page { size: A4 landscape; margin: 10mm; }
}


/* ===== [report-print-20260609-v2] Corporate navy report header ===== */
.report-print-header { display: none; }
@media print {
  .report-print-header {
    display: block !important;
    margin: 0 0 14px 0;
    padding: 0;
    font-family: "Sarabun", "TH Sarabun New", sans-serif;
    color: #1a1a1a;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .report-print-header .rph-row {
    display: flex;
    align-items: stretch;
    gap: 16px;
    padding-bottom: 10px;
  }
  .report-print-header .rph-logo {
    height: 62px; width: auto; max-width: 150px;
    object-fit: contain; flex: 0 0 auto;
    align-self: center;
  }
  /* บล็อกข้อมูลบริษัท (ซ้าย) */
  .report-print-header .rph-co {
    flex: 1 1 auto;
    display: flex; flex-direction: column; justify-content: center;
    padding-left: 4px;
    border-left: 3px solid #1E3A5F;
    padding-left: 14px;
  }
  .report-print-header .rph-co-name {
    font-size: 18px; font-weight: 700; color: #1E3A5F;
    line-height: 1.2; letter-spacing: .2px;
  }
  .report-print-header .rph-co-meta {
    font-size: 10.5px; color: #555; line-height: 1.55; margin-top: 3px;
  }
  /* กล่องชื่อรายงาน (ขวา) */
  .report-print-header .rph-right {
    flex: 0 0 auto; text-align: right;
    display: flex; flex-direction: column; justify-content: center;
    min-width: 200px;
    padding-left: 16px;
    border-left: 1px solid #d8dee8;
  }
  .report-print-header .rph-title {
    font-size: 16px; font-weight: 700; color: #1E3A5F; line-height: 1.25;
  }
  .report-print-header .rph-period {
    font-size: 11px; color: #333; margin-top: 5px;
    background: #f1f4f9; border-radius: 4px; padding: 2px 8px; display: inline-block;
    align-self: flex-end;
  }
  .report-print-header .rph-printed {
    font-size: 9.5px; color: #888; margin-top: 4px;
  }
  /* เส้นคาด 2 ชั้น (navy หนา + ทองบาง) */
  .report-print-header::after {
    content: ""; display: block;
    border-top: 2.5px solid #1E3A5F;
    border-bottom: 1.5px solid #C9A227;
    height: 2px; margin-top: 2px;
  }
  /* ตารางคมตอนพิมพ์ */
  .report-table { width: 100% !important; border-collapse: collapse !important; }
  .report-table th, .report-table td { border: 1px solid #ccc !important; }
  .report-table thead th {
    background: #1E3A5F !important; color: #fff !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* ── [Feature DocStickyTop-20261024] แถบปุ่มเอกสารติดบนจอ (js/shell/doc-topbar.js ย้ายแถบมาใต้ส่วนหัว/ลูกค้า) ──
   ★ เฉพาะจอ ≥ 900px (JS ใส่ class เอง) · จอเล็กคง .doc-action-bar เดิม (ติดล่าง)
   ★ top ติดลบเท่า padding ของ .content (sp-24) ⇒ แถบชิดขอบบนพื้นที่เนื้อหาพอดี (วัดจริง Chromium: sticky เคารพ padding
     ของ scroll container · top:0 = เหลือช่อง 24px ให้รายการโผล่เหนือแถบ) */
.doc-action-bar.doc-action-bar--top {
  top: calc(-1 * var(--sp-24, 24px));
  bottom: auto;
  margin: var(--sp-8, 8px) 0 var(--sp-12, 12px);
  border: 1px solid var(--c-border);
  border-radius: var(--r-6, 6px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.doc-topbar__info { display: none; }
.doc-action-bar--top .doc-topbar__info {
  display: flex; align-items: baseline; gap: var(--sp-12, 12px); min-width: 0; flex: 0 1 auto; overflow: hidden;
}
.doc-topbar__info [hidden] { display: none !important; }
.doc-topbar__no { font-family: var(--font-mono, ui-monospace, monospace); font-size: var(--fs-12, 12px); color: var(--t-link,var(--c-accent, #2563eb)); white-space: nowrap; }
.doc-topbar__party { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.doc-topbar__total { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* แผงสรุปด้านขวา (sticky เดิม top: sp-12) ต้องหลบลงใต้แถบที่ติดบน ไม่งั้นโดนแถบทับ */
.doc-action-bar--top ~ .sell__grid .sell__side { top: 76px; }

/* ── [Feature DocStickyTop-Dark-20261024] แถบปุ่มติดบน = พื้นเทาเข้ม (Nui 10-24) · ทุกปุ่มต้องไม่กลืนกับพื้น ──
   ★ เฉพาะ .doc-action-bar--top (จอ ≥ 900px) · มือถือ (แถบล่าง) คงสีเดิม
   ปุ่มหลัก (btn--primary) = เขียว · ปุ่มรอง (btn--ghost: พิมพ์/อื่น ๆ) = เทาอ่อนตัวเข้ม · ปุ่มเล็ก (กลับ) = เทากลางตัวขาว · ปุ่มอันตราย = แดง */
.doc-action-bar.doc-action-bar--top {
  background: #1f2937;
  color: #f9fafb;
  border-color: #111827;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
/* [DocStickyTop-Gap-20261024] Nui: เว้นช่องใต้แถบหัวระบบ — ดันแถบลง 10px + แถบสีพื้นหน้า (::before) ปิดช่องเหนือแถบ ไม่ให้รายการโผล่ตรงช่องว่าง */
.doc-action-bar.doc-action-bar--top { top: calc(-1 * var(--sp-24, 24px) + 10px); }
.doc-action-bar--top::before {
  content: ''; position: absolute; left: -24px; right: -24px; top: -11px; height: 10px;  /* -11..-1 = ช่อง 10px เหนือขอบแถบ (ขอบ 1px อยู่ใต้) */
  background: var(--c-bg-muted); pointer-events: none;
}
.doc-action-bar--top .doc-topbar__no { color: #93c5fd; }
.doc-action-bar--top .doc-topbar__party { color: #f9fafb; }
.doc-action-bar--top .doc-topbar__total { color: #6ee7b7; }
.doc-action-bar--top .btn--primary { background: #047857 !important; border-color: #047857 !important; color: #fff !important; }   /* [Fix DarkTokens-20261026] เดิม #10b981 = ขาวบนเขียวอ่อน contrast 2.5 → เขียวเข้ม 5.5 (ยังเขียวเดิม) */
.doc-action-bar--top .btn--primary:hover:not(:disabled) { background: #065f46 !important; border-color: #065f46 !important; }
.doc-action-bar--top .btn--ghost { background: #e5e7eb !important; border-color: #e5e7eb !important; color: #111827 !important; }
.doc-action-bar--top .btn--ghost:hover:not(:disabled) { background: #fff !important; border-color: #fff !important; }
.doc-action-bar--top .btn--ghost.btn--sm { background: #4b5563 !important; border-color: #6b7280 !important; color: #fff !important; }
.doc-action-bar--top .btn--ghost.btn--sm:hover:not(:disabled) { background: #6b7280 !important; }
.doc-action-bar--top .btn--danger { background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important; }   /* [Fix DarkTokens-20261026] เดิม #ef4444 contrast 3.8 → 4.8 */
.doc-action-bar--top .btn--danger:hover:not(:disabled) { background: #b91c1c !important; border-color: #b91c1c !important; }
.doc-action-bar--top .btn:disabled { opacity: 0.45; }
.doc-action-bar--top a:not(.btn), .doc-action-bar--top small, .doc-action-bar--top span:not([class]) { color: #e5e7eb; }

/* ═════════════════════════════════════════════════════════════════════════════
   [Feature TableWrap-20261025] ตาราง .qt-tbl ทุกหน้า: ข้อความยาว = ขึ้นบรรทัดใหม่ แทนการตัดเป็น "…" (Nui 10-25 · รอบ 1 · CSS ล้วน)
   ★ กติกา: ข้อความทั่วไป (ลูกค้า/สินค้า/Project/ผู้สร้าง/หัวคอลัมน์) ขึ้นบรรทัดได้ ·
            เลขที่เอกสารตัดได้เฉพาะหลังขีด "-" (TQ-AYA- / 2610-0001) ไม่แตกกลางเลข ·
            ตัวเลขเงิน/จำนวน + ปุ่ม + ป้ายสถานะ = ห้ามแตก ·
            ในกล่องที่เลื่อนได้ (.qt-list__table-wrap / .table-wrap / .report-table-wrap) →
            table-layout:auto = คอลัมน์ขยายตามของที่ห้ามแตก · ล้นจอ = เลื่อนซ้ายขวาแทนการตัด
   ★ ไม่แตะตารางนอกกล่องเลื่อน (หน้าแก้/ดูเอกสาร มี dropdown ในเซลล์ — overflow:auto จะตัด popup)
   ★ ในกล่องเลื่อน = table-layout:auto ทุกจอ (คอลัมน์กว้างตามเนื้อหา) · ตารางนอกกล่องเลื่อน = fixed เดิม
   ═════════════════════════════════════════════════════════════════════════════ */
.qt-tbl thead th,
.qt-tbl tbody td { white-space: normal; text-overflow: clip; overflow-wrap: break-word; }
.qt-tbl thead th { line-height: 1.3; vertical-align: bottom; }
.qt-tbl tbody td { line-height: 1.4; }
/* ห้ามแตก: ตัวเลข / ปุ่ม / ป้าย */
.qt-tbl tbody td.qt-tbl__num,
.qt-tbl tbody td.qt-tbl__col-total,
.qt-tbl tbody td.qt-tbl__actions,
.qt-tbl tbody td.qt-tbl__col-act { white-space: nowrap; overflow-wrap: normal; }
.qt-tbl thead th.qt-tbl__num { white-space: normal; }
.qt-tbl .qt-tbl__pill, .qt-tbl .qt-pill, .qt-tbl .iv-pill { white-space: nowrap; }
/* เลขที่เอกสาร (.mono / คอลัมน์ Doc #): แตกได้แค่หลัง "-" — overflow-wrap:normal = ไม่หักกลางคำ */
.qt-tbl tbody td.mono,
.qt-tbl tbody td.qt-tbl__col-doc,
.qt-tbl tbody td .mono { overflow-wrap: normal; word-break: normal; }
/* วันที่ / คอลัมน์ที่หัวเป็น date/doc — ติดป้ายโดย public/js/shell/table-wrap.js */
.qt-tbl tbody td.qt-tbl__nowrap { white-space: nowrap; overflow-wrap: normal; }
/* จอกว้าง (table-layout:fixed) ถ้าคอลัมน์ที่ห้ามแตกยังแคบเกิน → "…" เป็นทางสุดท้าย (ไม่ใช่ตัดเงียบ) */
.qt-tbl tbody td.qt-tbl__nowrap,
.qt-tbl tbody td.qt-tbl__num,
.qt-tbl tbody td.qt-tbl__col-total { text-overflow: ellipsis; }
/* ★ ตารางในกล่องเลื่อน = table-layout:auto ทุกขนาดจอ — fixed เดิมแบ่งคอลัมน์เท่ากัน (ไม่มี colgroup) ⇒
     ชื่อยาวโดนบีบ 4–5 บรรทัดทั้งที่คอลัมน์อื่นเหลือที่ · แลกกับคอลัมน์ขยับเล็กน้อยตอนเรียง (Hotfix4) */
.qt-list__table-wrap > .qt-tbl,
.table-wrap > .qt-tbl,
.report-table-wrap > .qt-tbl { table-layout: auto; }
@media (max-width: 1280px) {
  /* ชื่อยาว ๆ ไม่ถูกบีบเหลือคอลัมน์แคบจนอ่านไม่ได้ (ไม่ตั้งสูง — ชื่อสั้นจะกินที่คอลัมน์วันที่) */
  .qt-list__table-wrap > .qt-tbl td.qt-tbl__col-cust,
  .qt-list__table-wrap > .qt-tbl td.is-wrap { min-width: 96px; }
  /* เลขที่เอกสารอยู่บรรทัดเดียว (auto layout บีบคอลัมน์จนแตก 3 ท่อน) · ล้น = เลื่อนซ้ายขวา */
  .qt-list__table-wrap > .qt-tbl tbody td.mono,
  .qt-list__table-wrap > .qt-tbl tbody td.qt-tbl__col-doc,
  .table-wrap > .qt-tbl tbody td.mono,
  .report-table-wrap > .qt-tbl tbody td.mono { white-space: nowrap; }
  .qt-list__table-wrap > .qt-tbl tbody td.qt-tbl__col-date { white-space: nowrap; }
  .qt-list__table-wrap > .qt-tbl thead th { padding: 8px 10px; }
  .qt-list__table-wrap > .qt-tbl tbody td { padding: 8px 10px; }
}

/* ═════════════════════════════════════════════════════════════════════════════
   [Feature TableCards-20261025] รอบ 2 — มือถือ (≤700px) หน้ารายการแสดงแถวเป็นการ์ด (ทุกหน้า · ไม่แก้ JS รายหน้า)
   ★ ใช้กับตารางใน .qt-list__table-wrap (หน้ารายการ) + ตารางที่ใส่ class `qt-tbl--card` เอง · ปิดรายตาราง = `qt-tbl--nocard`
   ★ ข้อมูลจาก public/js/shell/table-wrap.js: td[data-label] (ชื่อหัวคอลัมน์) · td[data-card] title/total/act/ent/full · td[data-empty]
   ★ หัวการ์ด = [กล่องสีบริษัท] เลขที่ ··· [ปุ่ม⋮] · บรรทัดถัดไป "หัวคอลัมน์ ··· ค่า" · ยอดเงินช่องสุดท้าย = ตัวใหญ่ล่างสุด
   ★ ไม่มีหัวตาราง ⇒ เรียงตามคอลัมน์ไม่ได้บนมือถือ (ใช้ตัวกรอง/ค้นหาแทน)
   ═════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .qt-list__table-wrap, .report-table-wrap:has(> table.qt-tbl--card) { overflow-x: visible; border: 0; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card),
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody { display: block; width: 100%; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > thead,
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > colgroup { display: none; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 10px; row-gap: 2px;
    align-items: center; padding: 10px 12px; margin: 0 0 10px;
    border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-bg-elevated, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
  }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr:hover { background: var(--c-bg-elevated, #fff); }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td {
    grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 3px 0 !important; border: 0; min-width: 0; width: auto; text-align: right !important; background: transparent !important;
    white-space: normal; overflow: visible; font-size: var(--fs-13);
  }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left;
    color: var(--c-text-muted); font-size: var(--fs-12); font-weight: 500;
  }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td:not([data-label])::before { content: none; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-empty] { display: none; }
  /* หัวการ์ด: [ent] title [act] */
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="title"] {
    grid-row: 1; grid-column: 1 / 3; justify-content: flex-start; text-align: left !important;
    font-size: 15px; font-weight: 700; padding-bottom: 6px !important; overflow-wrap: anywhere;
  }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr[data-card-ent] > td[data-card="title"] { grid-column: 2; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="ent"] { grid-row: 1; grid-column: 1; padding-bottom: 6px !important; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="ent"] .tx-ent-box { min-width: 36px; height: 30px; font-size: 13px; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="act"] {
    grid-row: 1; grid-column: 3; justify-content: flex-end; padding-bottom: 6px !important;
  }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="title"]::before,
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="ent"]::before,
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="act"]::before,
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="full"]::before { content: none; }
  /* ยอดหลัก = ล่างสุด ตัวใหญ่ */
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="total"] {
    order: 99; margin-top: 4px; padding-top: 8px !important; border-top: 1px dashed var(--c-border);
    font-size: 17px; font-weight: 800;
  }
  /* แถวเต็ม (กำลังโหลด / ไม่พบ / แถวขยายรายละเอียด) */
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="full"] { display: block; text-align: left !important; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr:has(> td[data-card="full"]:only-child) { display: block; }
  /* ป้ายสถานะ/ข้อความยาวในค่า ห่อได้ · ค่าชิดขวา */
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td > * { max-width: 100%; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td.is-wrap .clamp-2,
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td.is-wrap .clamp-3 { text-align: right; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr.qt-tbl__row--cancelled { opacity: .6; }
}

/* [Feature CompactCards-20261029] การ์ดกระชับ ทุกหน้ารายการ (หนุ่ย 10-29 · เลือกทาง ก หลังลองหน้าสินค้าบนแท็บเล็ต)
   เดิม (TableCards รอบ 2): 1 ช่อง = 1 บรรทัด "ป้ายซ้าย · ค่าขวา" → แท็บเล็ตแนวตั้ง (≤700px) การ์ดยาว 8–9 บรรทัด
   ใหม่: ช่องข้อมูล = กล่องเล็ก ป้ายบน/ค่าล่าง เรียงหลายช่องต่อแถว (auto-fill ≥112px) · แถวบน = [ช่องติ๊ก] [ent] เลขที่/หัว [⋮]
         ข้อความยาว (.is-wrap) เต็มแถว · ยอดหลัก (total) เต็มแถวล่างสุด ป้ายซ้าย/ยอดขวา (เดิม) · แถวเต็ม (โหลด/ไม่พบ) เดิม
   ★ วางท้ายบล็อก TableCards = ทับกฎด้านบน · ไม่แตะ JS (table-wrap.js ติด data-card/data-label เหมือนเดิม) · จอ ≥701px ไม่กระทบ
   ★ เฉพาะแท็บเล็ต (561–700px) — มือถือ (≤560px) คงแบบเดิม "ป้ายซ้าย · ค่าขวา" (วัด 38 หน้า: จอ 390 ใส่ได้แค่ 2 ช่อง/แถว → ป้ายบนทำให้บางหน้าสูงขึ้น)
   ★ หน้าที่จัดเองต่อ (scoped): settings-products-list.html [ProdCompactCard] (ใช้ทั้งแท็บเล็ต+มือถือ) */
@media (min-width: 561px) and (max-width: 700px) {
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); column-gap: 14px; row-gap: 8px; padding: 12px 14px; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td { grid-column: auto; display: block; text-align: left !important; padding: 0 !important; font-size: 14px; line-height: 1.45; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td::before { display: block; max-width: none; margin-bottom: 1px; font-size: 11px; line-height: 1.3; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td.is-wrap:not([data-card]) { grid-column: span 2; }   /* ข้อความยาว = 2 ช่อง (ไม่เต็มแถว — การ์ดที่มีช่องน้อยจะไม่เหลือช่องเดี่ยว ๆ) */
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td.is-wrap .clamp-2, :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td.is-wrap .clamp-3 { text-align: left; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="title"] { grid-row: 1; grid-column: 1 / -2; display: flex; flex-direction: row; align-items: center; padding: 0 !important; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr[data-card-ent] > td[data-card="title"] { grid-column: 2 / -2; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="ent"] { grid-row: 1; grid-column: 1; padding: 0 !important; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="act"] { grid-row: 1; grid-column: -2 / -1; display: flex; flex-direction: row; align-items: center; justify-content: flex-end; padding: 0 !important; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td:has(> input[type="checkbox"]:only-child) { grid-row: 1; grid-column: 1 / 2; display: flex; flex-direction: row; align-items: center; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td:has(> input[type="checkbox"]:only-child) ~ td[data-card="title"] { grid-column: 2 / -2; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="total"] { grid-column: 1 / -1; display: flex; flex-direction: row; justify-content: space-between; align-items: baseline; padding: 8px 0 0 !important; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="total"]::before { display: inline; margin: 0; font-size: var(--fs-12); }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="ent"] { display: flex; }
  :is(.qt-list__table-wrap > .qt-tbl:not(.qt-tbl--nocard), table.qt-tbl.qt-tbl--card) > tbody > tr > td[data-card="full"] { grid-column: 1 / -1; }
}

/* ════════════════════════════════════════════════════════════
   [Feature ProjectEntColor-20261025] กล่องสีบริษัทที่ออกใบกำกับ (ใช้ร่วม: หน้ารายการเอกสารภาษี · หน้ารายการ/หน้าดู Project)
   สี = inline style จาก BE (`entity_color` · SOT utils/taxEntity.js colorOf) · แสดงเฉพาะเมื่อมี > 1 บริษัท
   ════════════════════════════════════════════════════════════ */
.qt-tbl th.tx-ent-th { width: 64px; text-align: center; }
.qt-tbl td.tx-ent-cell { width: 64px; padding: 4px 6px; text-align: center; }
.tx-ent-box { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 36px; padding: 0 8px;
  border-radius: 8px; color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .5px; font-family: ui-monospace, Consolas, monospace;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); white-space: nowrap; }
.tx-ent-box--sm { min-width: 30px; height: 22px; font-size: 12px; border-radius: 5px; padding: 0 6px; }
.tx-ent-stack { display: inline-flex; flex-direction: column; gap: 3px; align-items: center; }
.qt-tbl__row--cancelled .tx-ent-box, tr.tx-ent-row--cx .tx-ent-box { opacity: .45; }

/* ════════════════════════════════════════════════════════════════════════
   [Feature ThemeDeep-20261026] ธีมลงลึก (แบบ B · Nui 10-26 เลือกจากตัวอย่าง 3 แบบ)
   ★ ที่มา: หน้าตั้งค่าธีมตั้งแค่ --c-primary + --c-accent (app.js loadTheme) แต่แถบซ้าย/เมนู/หัวตาราง ฯลฯ
     ใช้สีตายตัว ⇒ เปลี่ยนธีมแล้วต่างแค่บางปุ่ม — บล็อกนี้ "คำนวณ" สีพื้นผิวทั้งหมดจาก 2 สีนั้น (color-mix)
   ★ กฎ:
     ① ทุกสีในบล็อกนี้มาจาก --c-primary / --c-accent เท่านั้น (บริษัทตั้งสีเองได้ทุกค่า) — ห้ามใส่ hex ของธีมใดธีมหนึ่ง
     ② สีสถานะ (--c-success/warn/danger/info · แดง "edited" · ป้ายชำระแล้ว ฯลฯ) ไม่อยู่ในบล็อกนี้ = คงที่ทุกธีม (ห้ามผูกธีม)
     ③ ตั้งค่าบน <body> โดยตั้งใจ: theme.js (ThemeManager) เขียน --c-rail/--c-sidebar* แบบ inline บน <html>
        ซึ่งสไตล์ชีตทับไม่ได้ — ประกาศที่ body แทน (ลูกทุกตัวรับค่าจาก body)
     ④ โหมดมืด = body.theme-dark / body.theme-auto + OS มืด (ชุดค่าด้านล่าง) · ใบพิมพ์ไม่ใช้ไฟล์นี้ (ไม่กระทบ)
     ⑤ ป้ายระบบบนหัวหน้ารายการ = <html data-module> (app.js renderShell) · เพิ่มระบบใหม่ = เพิ่มบรรทัดใน [data-module=…]
   ════════════════════════════════════════════════════════════════════════ */
body:not(.theme-dark):not(.theme-auto) {
  --t-strong:  var(--c-primary);
  --t-link:    var(--c-accent);
  --t-tint:    color-mix(in srgb, var(--c-primary) 10%, #FFFFFF);
  --t-tint-2:  color-mix(in srgb, var(--c-primary) 4%, #FFFFFF);
  --t-tint-3:  color-mix(in srgb, var(--c-primary) 18%, #FFFFFF);
  --t-line:    color-mix(in srgb, var(--c-primary) 16%, #E5E4DF);
  --c-rail:           color-mix(in srgb, var(--c-primary) 55%, #141414);
  --c-rail-hover:     color-mix(in srgb, var(--c-primary) 70%, #2A2A2A);
  --c-rail-active:    var(--c-accent);
  --c-sidebar:        var(--t-tint-2);
  --c-sidebar-border: var(--t-line);
  --c-sidebar-hover:  color-mix(in srgb, var(--c-primary) 8%, #FFFFFF);
  --c-sidebar-active: color-mix(in srgb, var(--c-primary) 15%, #FFFFFF);
  --c-primary-soft:   var(--t-tint);
}
@media (prefers-color-scheme: light) {
  body.theme-auto {
    --t-strong:  var(--c-primary);
    --t-link:    var(--c-accent);
    --t-tint:    color-mix(in srgb, var(--c-primary) 10%, #FFFFFF);
    --t-tint-2:  color-mix(in srgb, var(--c-primary) 4%, #FFFFFF);
    --t-tint-3:  color-mix(in srgb, var(--c-primary) 18%, #FFFFFF);
    --t-line:    color-mix(in srgb, var(--c-primary) 16%, #E5E4DF);
    --c-rail:           color-mix(in srgb, var(--c-primary) 55%, #141414);
    --c-rail-hover:     color-mix(in srgb, var(--c-primary) 70%, #2A2A2A);
    --c-rail-active:    var(--c-accent);
    --c-sidebar:        var(--t-tint-2);
    --c-sidebar-border: var(--t-line);
    --c-sidebar-hover:  color-mix(in srgb, var(--c-primary) 8%, #FFFFFF);
    --c-sidebar-active: color-mix(in srgb, var(--c-primary) 15%, #FFFFFF);
    --c-primary-soft:   var(--t-tint);
  }
}
body.theme-dark {
  --t-strong:  color-mix(in srgb, var(--c-accent) 75%, #FFFFFF);
  --t-link:    color-mix(in srgb, var(--c-accent) 70%, #FFFFFF);
  --t-tint:    color-mix(in srgb, var(--c-accent) 16%, #1E293B);
  --t-tint-2:  color-mix(in srgb, var(--c-accent) 7%, #1E293B);
  --t-tint-3:  color-mix(in srgb, var(--c-accent) 26%, #1E293B);
  --t-line:    color-mix(in srgb, var(--c-accent) 22%, #334155);
  --c-rail:           color-mix(in srgb, var(--c-primary) 25%, #020617);
  --c-rail-active:    var(--c-accent);
  --c-sidebar-active: color-mix(in srgb, var(--c-accent) 24%, #0F172A);
  --c-primary-soft:   var(--t-tint);
}
@media (prefers-color-scheme: dark) {
  body.theme-auto {
    --t-strong:  color-mix(in srgb, var(--c-accent) 75%, #FFFFFF);
    --t-link:    color-mix(in srgb, var(--c-accent) 70%, #FFFFFF);
    --t-tint:    color-mix(in srgb, var(--c-accent) 16%, #1E293B);
    --t-tint-2:  color-mix(in srgb, var(--c-accent) 7%, #1E293B);
    --t-tint-3:  color-mix(in srgb, var(--c-accent) 26%, #1E293B);
    --t-line:    color-mix(in srgb, var(--c-accent) 22%, #334155);
    --c-rail:           color-mix(in srgb, var(--c-primary) 25%, #020617);
    --c-rail-active:    var(--c-accent);
    --c-sidebar-active: color-mix(in srgb, var(--c-accent) 24%, #0F172A);
    --c-primary-soft:   var(--t-tint);
  }
}

/* เมนูที่เลือก: ตัวหนังสือสีธีม + เส้นซ้าย */
.sidebar__item.is-active { color: var(--t-strong, var(--c-primary)); box-shadow: inset 3px 0 0 var(--t-strong, var(--c-primary)); }

/* หัวหน้ารายการ = แถบสีอ่อนของธีม + เส้นล่างสีธีม (ทุกหน้ารายการที่ใช้ .qt-list__head) */
.qt-list__head {
  background: var(--t-tint, var(--c-bg-muted));
  border-bottom: 3px solid var(--t-strong, var(--c-primary));
  border-radius: var(--r-12, 12px) var(--r-12, 12px) 0 0;
  padding: 14px 18px; gap: 10px; flex-wrap: wrap;
}
.qt-list__head .page-title { margin-bottom: 0; }
/* [Feature PageTabs-20261029] แถบแท็บบนหน้าที่รวมเมนู (shell/app.js _injectPageTabs) — ต่อกับแถบหัวสีธีมด้านล่าง */
.pg-tabs { display: flex; gap: 2px; margin: 0 0 -1px; padding: 0 6px; overflow-x: auto; scrollbar-width: none; position: relative; z-index: 1; }
.pg-tabs::-webkit-scrollbar { display: none; }
.pg-tabs__t { flex: none; padding: 8px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; color: var(--c-text-muted); font-size: var(--fs-14); font-weight: 600; text-decoration: none; white-space: nowrap; }
.pg-tabs__t:hover { color: var(--c-text); background: var(--c-bg-muted, #f1f5f9); }
.pg-tabs__t.is-on { color: var(--t-strong, var(--c-primary)); background: var(--t-tint, var(--c-bg-muted, #eef2f7)); border-color: var(--c-border); }

/* [Feature ReportPair-20261029] ปุ่มสลับ "รายละเอียด / สรุป" ข้างชื่อรายงาน (shell/app.js _injectReportPair) */
.qt-list__head-l:has(> .rpt-pair) { display: flex; align-items: center; gap: var(--sp-8) var(--sp-12); flex-wrap: wrap; min-width: 0; }
.qt-list__head-l:has(> .rpt-pair) > p { flex-basis: 100%; margin: 0; }
.rpt-pair { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-bg-muted, #f1f5f9); }
.rpt-pair__b { border: 0; background: transparent; color: var(--c-text-muted); font: inherit; font-size: var(--fs-13); font-weight: 600; padding: 5px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.rpt-pair__b:hover { color: var(--c-text); background: var(--c-surface); }
.rpt-pair__b.is-on { background: var(--c-surface); color: var(--t-strong, var(--c-primary)); box-shadow: 0 1px 3px rgba(15, 23, 42, .14), 0 0 0 1px var(--t-strong, var(--c-primary)) inset; cursor: default; }
.rpt-pair__pt { display: none; }
@media print { .rpt-pair__pt { display: inline; } }

/* [UiPolish-DocHead-20261028] หัวฟอร์มเอกสารแบบหน้าขาย (.sell__head: ขาย · ใบเสนอราคา · ใบวางบิล · ใบรับสินค้า · เอกสารภาษี)
   = แถบสีธีม + ป้ายระบบ เหมือน .qt-list__head ทุกหน้า (หนุ่ย 10-28 "ให้หัวเป็นแถบสีธีมเหมือนหน้าอื่นทั้งหมด") · โครง/ปุ่ม/ตัวเลือกลูกค้าเดิม */
.sell__head {
  background: var(--t-tint, var(--c-bg-muted));
  border-bottom: 3px solid var(--t-strong, var(--c-primary));
  border-radius: var(--r-12, 12px) var(--r-12, 12px) 0 0;
  padding: 14px 18px; align-items: center;
}
.sell__head .sell__head-l { align-items: flex-end; row-gap: 6px; }
.sell__head .page-title { margin: 0; }
.sell__head .sell__doc-no,
.sell__head .sell__date-pill { background: var(--c-surface, #fff); border: 1px solid var(--t-line, var(--c-border)); }
html[data-module] .sell__head .page-title::before {
  content: var(--t-mod-label, none);
  display: table; margin-bottom: 4px;
  font-size: 12px; font-weight: 700; line-height: 1.6; letter-spacing: .2px;
  color: #FFFFFF; background: var(--t-mod, #475569);
  padding: 0 10px; border-radius: 999px;
}

/* ป้ายระบบเหนือชื่อหน้า (สีประจำระบบ · คงที่ทุกธีม = บอกว่าอยู่ระบบไหน) */
html[data-module="sale"]     { --t-mod: #2563EB; --t-mod-label: "ระบบขาย"; }
html[data-module="purchase"] { --t-mod: #0F766E; --t-mod-label: "ระบบซื้อ"; }
html[data-module="stock"]    { --t-mod: #9A3412; --t-mod-label: "คลังสินค้า"; }
html[data-module="tax"]      { --t-mod: #6D28D9; --t-mod-label: "ระบบภาษี"; }
html[data-module="repair"]   { --t-mod: #BE185D; --t-mod-label: "งานซ่อม"; }
html[data-module="reports"]  { --t-mod: #475569; --t-mod-label: "รายงาน"; }
html[data-module="branch"]   { --t-mod: #0369A1; --t-mod-label: "สาขา"; }
html[data-module="settings"] { --t-mod: #57534E; --t-mod-label: "ตั้งค่า"; }
html[data-module] .qt-list__head .page-title::before {
  content: var(--t-mod-label, none);
  display: table; margin-bottom: 4px;
  font-size: 12px; font-weight: 700; line-height: 1.6; letter-spacing: .2px;
  color: #FFFFFF; background: var(--t-mod, #475569);
  padding: 0 10px; border-radius: 999px;
}

/* กล่องค้นหา/ตัวกรอง */
.qt-list__filters { background: var(--t-tint-2, var(--c-surface)); border-color: var(--t-line, var(--c-border)); }
.report-filter    { background: var(--t-tint-2, var(--c-bg-muted)); border-color: var(--t-line, var(--c-border)); }

/* หัวตาราง = สีอ่อนของธีม · ตัวหนังสือสีธีม */
.qt-tbl thead th {
  background: var(--t-tint, var(--c-bg-muted));
  color: var(--t-strong, var(--c-text-muted));
  border-bottom-color: var(--t-line, var(--c-border));
}
.qt-tbl th.sortable:hover { background: var(--t-tint-3, var(--c-sidebar-hover)); }

/* เลขที่เอกสาร (td.mono ที่ไม่ใช่ตัวเลขเงิน) = สีเน้นของธีม · ใบยกเลิกคงสีจาง */
.qt-tbl tbody td.mono:not(.qt-tbl__num) { color: var(--t-link, inherit); font-weight: 600; }
.qt-tbl__row--cancelled td.mono:not(.qt-tbl__num) { color: inherit; font-weight: inherit; }

/* การ์ดตัวเลขสรุปบนหน้ารายงาน */
.report-kpi-grid > .card { background: var(--t-tint-2, var(--c-surface)); border-color: var(--t-line, var(--c-border)); }

/* ════════════════════════════════════════════════════════════════════════
   [Feature DarkTokens-20261026] โหมดมืดลงลึก — สีที่เดิมเขียนตายตัวในหน้าต่าง ๆ
   ★ กฎ:
     ① หน้า/CSS ห่อสีตายตัวเป็น var(--token, <สีเดิม>) — token ด้านล่างประกาศ "เฉพาะโหมดมืด"
        ⇒ โหมดสว่าง = สีเดิมเป๊ะ (token ไม่มีค่า → ใช้สีเดิม) · โหมดมืด = ค่าในบล็อกนี้
     ② ห้ามประกาศ token กลุ่มนี้ใน :root / โหมดสว่าง (= เปลี่ยนสีโหมดสว่างทั้งระบบ)
     ③ สีสถานะแบบพื้นอ่อน+ตัวเข้ม (--c-tint-*) คงสีเดิม (แดง/เขียว/เหลือง…) แค่ปรับให้อ่านได้บนพื้นมืด · สีสถานะกลาง (#dc2626 ฯลฯ) ไม่ห่อ
     ④ ตัวหนังสือสีธีม: color:var(--c-accent) → var(--t-link, …) · var(--c-primary) → var(--t-strong, …) (ThemeDeep ให้ค่าโหมดมืดแล้ว)
     ⑤ @media screen เท่านั้น — สั่งพิมพ์จากโหมดมืดยังได้สีเดิม
     ⑥ หน้าที่ไม่ห่อโดยตั้งใจ: login · stock-qr-generator · repair-tag-generator · settings-module-config (ไม่ถูกโหลด) · settings-doc-format-edit / settings-tax-doc-format-edit (ตัวอย่างกระดาษ) · settings-theme (ตัวอย่างสี) · แถบปุ่มเอกสาร (DocStickyTop)
     ⑦ หน้าใหม่: ใช้ token มาตรฐาน (--c-surface/--c-text/--c-border/--c-*-bg/fg) — ห่อแบบนี้ใช้กับของเดิมเท่านั้น
   ════════════════════════════════════════════════════════════════════════ */
@media screen {
  body.theme-dark {
    --c-bg-elevated: #1E293B; --c-bg-subtle: #243247; --c-bg-soft: #243247;
    --c-surface-1: #223045; --c-surface-2: #2A3952; --c-surface-hover: #2F3F5A;
    --c-text-strong: #F1F5F9; --c-mute: #94A3B8; --c-border-light: #334155;
    --c-primary-bg: #1E3A5F; --c-warning-fg: #FCD34D; --c-warning-bg: #78350F; --c-warn-border: #92400E;
    --c-tint-red: rgba(239,68,68,.16);    --c-tint-red-fg: #FCA5A5;    --c-tint-red-bd: rgba(248,113,113,.45);
    --c-tint-green: rgba(34,197,94,.15);  --c-tint-green-fg: #86EFAC;  --c-tint-green-bd: rgba(74,222,128,.45);
    --c-tint-amber: rgba(245,158,11,.16); --c-tint-amber-fg: #FCD34D;  --c-tint-amber-bd: rgba(251,191,36,.45);
    --c-tint-orange: rgba(249,115,22,.16);--c-tint-orange-fg: #FDBA74; --c-tint-orange-bd: rgba(251,146,60,.45);
    --c-tint-blue: rgba(59,130,246,.18);  --c-tint-blue-fg: #93C5FD;   --c-tint-blue-bd: rgba(96,165,250,.45);
    --c-tint-violet: rgba(139,92,246,.18);--c-tint-violet-fg: #C4B5FD; --c-tint-violet-bd: rgba(167,139,250,.45);
    --c-tint-gray-fg: #CBD5E1;
  }
}
@media screen and (prefers-color-scheme: dark) {
  body.theme-auto {
    --c-bg-elevated: #1E293B; --c-bg-subtle: #243247; --c-bg-soft: #243247;
    --c-surface-1: #223045; --c-surface-2: #2A3952; --c-surface-hover: #2F3F5A;
    --c-text-strong: #F1F5F9; --c-mute: #94A3B8; --c-border-light: #334155;
    --c-primary-bg: #1E3A5F; --c-warning-fg: #FCD34D; --c-warning-bg: #78350F; --c-warn-border: #92400E;
    --c-tint-red: rgba(239,68,68,.16);    --c-tint-red-fg: #FCA5A5;    --c-tint-red-bd: rgba(248,113,113,.45);
    --c-tint-green: rgba(34,197,94,.15);  --c-tint-green-fg: #86EFAC;  --c-tint-green-bd: rgba(74,222,128,.45);
    --c-tint-amber: rgba(245,158,11,.16); --c-tint-amber-fg: #FCD34D;  --c-tint-amber-bd: rgba(251,191,36,.45);
    --c-tint-orange: rgba(249,115,22,.16);--c-tint-orange-fg: #FDBA74; --c-tint-orange-bd: rgba(251,146,60,.45);
    --c-tint-blue: rgba(59,130,246,.18);  --c-tint-blue-fg: #93C5FD;   --c-tint-blue-bd: rgba(96,165,250,.45);
    --c-tint-violet: rgba(139,92,246,.18);--c-tint-violet-fg: #C4B5FD; --c-tint-violet-bd: rgba(167,139,250,.45);
    --c-tint-gray-fg: #CBD5E1;
  }
}
