/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input { font: inherit; }

/* ===== VARIABLES ===== */
:root {
  /* --- light mode defaults (no JS needed for initial paint) --- */
  --bg-0: #efefef;
  --bg-1: #f7f7f7;
  --bg-2: #ffffff;
  --bg-3: #f0f0f0;
  --bg-4: #e8e8e8;
  --border: #e0e0e0;
  --border-2: #d0d0d0;
  --border-3: #c0c0c0;
  --text-1: #1a1a1a;
  --text-2: #555;
  --text-3: #696969;
  --text-4: #808080;
  --accent: #000;
  --accent-dim: rgba(0,0,0,.08);
  --accent-glow: rgba(0,0,0,.04);

  /* --- legacy tokens — now driven by the new theme system --- */
  --color-bg: var(--bg-1);
  --color-text: var(--text-1);
  --color-text-secondary: var(--text-3);
  --color-border: var(--border);
  --color-error: #e53935;
  --color-primary: var(--accent);
  --color-primary-text: var(--bg-0);
  --radius: 8px;
  --radius-sm: 7px;
}

/* ===== TYPOGRAPHY ===== */
body { color: var(--color-text); background: var(--color-bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1 { font-size: 24px; font-weight: 500; letter-spacing: -0.3px; }
h2 { font-size: 20px; font-weight: 500; }
p { color: var(--color-text-secondary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--bg-0); }
.btn-primary:hover:not(:disabled) { opacity: .85; }
.btn-secondary { background: var(--bg-2); color: var(--text-2); border: 1px solid var(--border-2); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-3); color: var(--text-1); }
.btn-ghost { background: none; color: var(--text-3); border: 1px solid var(--border-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text-1); border-color: var(--border-3); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-warning { background: #fff7ed; color: #c2410c; border: 1.5px solid #fed7aa; }
.btn-warning:hover { background: #ffedd5; }
.btn-warning-active { background: #f97316; color: #fff; border: 1.5px solid #f97316; }
.btn-warning-active:hover { background: #ea580c; }
.btn-full { width: 100%; }
.log-tab-btn { background: var(--bg-3); color: var(--text-3); border: none; padding: 6px 14px; font-size: 13px; font-weight: 500; cursor: pointer; }
.log-tab-btn:hover { background: var(--bg-4); color: var(--text-2); }
.log-tab-active { background: var(--bg-2); color: var(--text-1); font-weight: 500; box-shadow: inset 0 -2px 0 var(--color-primary); }
.pager-row { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:6px; padding: 10px 0; border-top: 1px solid var(--border); margin-top: 4px; }
.pager-info { font-size: 13px; color: var(--text-3); }
.log-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.inv-row--hidden { display: none; }
.inv-alerts-strip { display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:8px 32px 4px; }
.inv-alert-chip { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:20px; font-size:12px; font-weight:600; cursor:pointer; border:1.5px solid transparent; background:var(--bg-2); color:var(--text-2); border-color:var(--border); transition:background .15s, opacity .15s; user-select:none; }
.inv-alert-chip:hover { background:var(--bg-3); }
.inv-alert-chip--active { background:#fff7ed; color:#c2410c; border-color:#fed7aa; }
.inv-alert-chip--active:hover { background:#ffedd5; }
.inv-alert-chip--loading { opacity:0.6; pointer-events:none; }
@keyframes inv-dot-pulse { 0%,100%{opacity:1} 50%{opacity:0.25} }
.inv-alert-chip--loading .inv-alert-chip__dot { animation:inv-dot-pulse 0.7s ease infinite; }
.inv-alert-chip__dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.inv-alert-chip--miss .inv-alert-chip__dot  { background:#f59e0b; }
.inv-alert-chip--oos  .inv-alert-chip__dot  { background:#ef4444; }
.inv-alert-chip--crit .inv-alert-chip__dot  { background:#f97316; }
.log-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.log-th { padding: 8px 12px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; text-align: left; }
.log-td { padding: 10px 12px; font-size: 14px; border-bottom: 1px solid var(--border); }
.log-search { width: 260px; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--color-text); }
.form-group input {
  padding: 10px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus { border-color: var(--color-primary); }

/* ===== ERROR MESSAGE ===== */
.error-message {
  font-size: 13px;
  color: var(--color-error);
  padding: 8px 0;
}

/* ===== AUTH PAGE LAYOUT ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--color-bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.auth-header { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-logo { height: 52px; width: auto; object-fit: contain; }
.auth-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: #9ca3af;
}
.auth-switch__link {
  color: var(--text-3);
  text-decoration: none;
  font-weight: 500;
}
.auth-switch__link:hover { text-decoration: underline; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-subtitle { font-size: 14px; color: var(--text-secondary); margin: 0; }
.btn-link { background: none; border: none; padding: 0; font-size: 14px; color: var(--primary); cursor: pointer; text-align: center; }
.btn-link:hover { text-decoration: underline; }
.success-message { font-size: 14px; color: #16a34a; margin: 0; }

/* ===== LANDING PAGE LAYOUT ===== */
.landing-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.landing-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}
.landing-title { font-size: 28px; }
.landing-subtitle { font-size: 15px; color: var(--color-text-secondary); }
.landing-buttons { display: flex; gap: 12px; }

/* ===== STUB DASHBOARD ===== */
.stub-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}
.stub-label { font-size: 12px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--color-text-secondary); }

/* ===== PORTAL LAYOUT ===== */
.portal-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.22s ease;
}
.portal-layout.nav-collapsed {
  grid-template-columns: 64px 1fr;
}

/* ===== NAV SIDEBAR ===== */
.nav-sidebar {
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
html[data-portal="piandre"] .nav-sidebar { background: #2d1515; }
html[data-portal="sbi"]     .nav-sidebar { background: #1e2330; }

html[data-portal="piandre"] {
  --accent: #2d1515;
  --accent-dim: rgba(45,21,21,.10);
  --accent-glow: rgba(45,21,21,.05);
  --color-primary: #2d1515;
  --color-primary-text: #fff;
}
html[data-portal="sbi"] {
  --accent: #1e2330;
  --accent-dim: rgba(30,35,48,.10);
  --accent-glow: rgba(30,35,48,.05);
  --color-primary: #1e2330;
  --color-primary-text: #fff;
}

/* Piandré red sidebar — legibility overrides */
html[data-portal="piandre"] .nav-skeleton { background: #2d1515; }
html[data-portal="sbi"]     .nav-skeleton { background: #1e2330; }
html[data-portal="piandre"] .nav-item { color: rgba(255,255,255,0.92); }
html[data-portal="piandre"] .nav-item:hover { color: #fff; background: rgba(255,255,255,0.12); }
html[data-portal="piandre"] .nav-item--active { background: #fff !important; color: #2d1515 !important; border-left-color: transparent !important; }
html[data-portal="piandre"] .nav-group-label { color: rgba(255,255,255,0.55); }
html[data-portal="piandre"] .nav-more-trigger { color: rgba(255,255,255,0.75); }
html[data-portal="piandre"] .nav-more-trigger:hover { background: rgba(0,0,0,0.18); }
html[data-portal="piandre"] .nav-sidebar-divider { border-top-color: rgba(255,255,255,0.22); }
html[data-portal="piandre"] .nav-user-info { border-top-color: rgba(255,255,255,0.22); }
html[data-portal="piandre"] .nav-user-name { color: #fff; }
html[data-portal="piandre"] .nav-user-meta { color: rgba(255,255,255,0.68); }

/* ── Sidebar header (brand + collapse toggle) ── */
.nav-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  min-width: 0;
}
.nav-brand-wrap {
  min-width: 0;
  overflow: hidden;
}
.nav-logo {
  display: block;
  height: 28px;
  width: auto;
  padding: 0 12px;
  margin-bottom: 4px;
  object-fit: contain;
}
.nav-brand {
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 0 12px;
  margin-bottom: 4px;
  white-space: nowrap;
}
.nav-version {
  color: rgba(255,255,255,0.25);
  font-size: 10px;
  padding: 0 12px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* ── Collapse toggle button ── */
.nav-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.3);
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.nav-collapse-btn:hover { color: rgba(255,255,255,0.75); }
.nav-collapse-btn svg { transition: transform 0.22s ease; }

/* ── Collapsed sidebar state ── */
.nav-collapsed .nav-sidebar { align-items: center; }
.nav-collapsed .nav-header { justify-content: center; }
.nav-collapsed .nav-brand-wrap { display: none; }
.nav-collapsed .nav-collapse-btn svg { transform: rotate(180deg); }
.nav-collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
  width: 40px;
}
.nav-collapsed .nav-item__label { display: none; }
.nav-collapsed .nav-user-info { display: none; }

/* ── Collapsed tooltips ── */
.nav-collapsed .nav-item {
  position: relative;
}
.nav-collapsed .nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: fixed;
  left: 72px;
  background: #1e2330;
  color: #fff;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 300;
}
.nav-collapsed .nav-item[data-tooltip]:hover::after { opacity: 1; }
html[data-portal="piandre"] .nav-collapsed .nav-item[data-tooltip]::after { background: #2d1515; }

/* ── BRANCH SWITCHER (sidebar desktop) ────────────────────────────────────── */
.nav-branch-wrapper {
  padding: 0 8px;
  margin-bottom: 16px;
}
.nav-branch-select {
  width: 100%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  appearance: auto;
}
.nav-branch-select:focus {
  outline: none;
  border-color: rgba(255,255,255,0.5);
}
.nav-branch-select option {
  background: #1e2330;
  color: rgba(255,255,255,0.9);
}
html[data-portal="piandre"] .nav-branch-select option { background: #2d1515; }

/* ── MODE SWITCHER (Stock | Retail — retail managers) ───────────────────────── */
.nav-mode-switcher {
  display: flex;
  gap: 4px;
  padding: 6px 8px 10px;
}
.nav-mode-btn {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 8px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.nav-mode-btn:hover {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.8);
}
.nav-mode-btn--active {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}
.nav-collapsed .nav-mode-switcher { display: none; }

/* ── BRANCH BAR (mobile only — above bottom nav) ───────────────────────────── */
.nav-branch-bar {
  display: none;
  position: fixed;
  bottom: 64px;
  left: 0;
  right: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--color-border);
  padding: 6px 16px;
  z-index: 98;
  align-items: center;
  gap: 8px;
}
.nav-branch-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}
.nav-branch-select--mobile {
  background: var(--bg-2) !important;
  border: 1px solid var(--color-border) !important;
  color: var(--color-text) !important;
  flex: 1;
}
.nav-branch-select--mobile option {
  background: var(--bg-2) !important;
  color: var(--color-text) !important;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  letter-spacing: 0.01em;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.12); }
.nav-item--active { color: #fff !important; background: rgba(255,255,255,.12) !important; border-left-color: #fff !important; }
.nav-item__icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: 0.7; }
.nav-item--active .nav-item__icon,
.nav-item:hover .nav-item__icon { opacity: 1; }

.nav-spacer { flex: 1; }

.nav-sidebar-divider {
  border: none;
  border-top: 1px solid #333;
  margin: 6px 10px;
}

/* ── Theme cycle button ── */
.theme-cycle-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
  margin: 0 10px 8px;
}
.theme-cycle-btn:hover { color: var(--text-1); border-color: var(--border-3); background: var(--bg-2); }
.nav-collapsed .theme-cycle-btn { margin: 0 auto 8px; }
/* keep button dark when sidebar is pinned dark */
html[data-theme="light"] .nav-sidebar .theme-cycle-btn { color: rgba(255,255,255,.38) !important; border-color: #404040 !important; }
html[data-theme="light"] .nav-sidebar .theme-cycle-btn:hover { color: rgba(255,255,255,.8) !important; border-color: #505050 !important; background: #252525 !important; }
@media (prefers-color-scheme: light) {
  .nav-sidebar .theme-cycle-btn { color: rgba(255,255,255,.38) !important; border-color: #404040 !important; }
  .nav-sidebar .theme-cycle-btn:hover { color: rgba(255,255,255,.8) !important; border-color: #505050 !important; background: #252525 !important; }
}

/* NAV USER INFO */
.nav-user-info {
  padding: 10px 12px;
  border-top: 1px solid #333;
  margin-bottom: 4px;
}
.nav-user-name {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-user-meta {
  color: rgba(255,255,255,0.38);
  font-size: 10px;
  margin-top: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav-more-item {
  display: block;
  padding: 9px 12px;
  font-size: 14px;
  color: #2d2d2d;
  border-radius: 4px;
  text-decoration: none;
}
.nav-more-item:hover { background: var(--bg-3); }

/* ── Nav group labels + More flyout (desktop hover) ── */
.nav-group-label {
  color: rgba(255,255,255,0.3);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 12px 4px;
}
.nav-collapsed .nav-group-label { display: none; }
/* The mode label (Stock Flow / Retail Flow) is slightly brighter to telegraph
   why the items below it appear or hide when the toggle is switched. */
.nav-group-label--mode { color: rgba(255,255,255,0.55); padding-top: 14px; }
.nav-more-trigger { color: rgba(255,255,255,0.45); font-size: 13px; }
.nav-more-trigger:hover { color: #fff; background: rgba(255,255,255,0.12); }
.nav-more-flyout {
  position: fixed;
  left: 232px;
  background: #1e2330;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 1000;
  min-width: 160px;
}
.nav-collapsed .nav-more-flyout { left: 76px; }
html[data-portal="piandre"] .nav-more-flyout { background: #2d1515; }
.nav-more-flyout__item {
  display: block;
  padding: 9px 16px;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav-more-flyout__item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-more-flyout__item--active { color: #fff; background: rgba(255,255,255,0.12); }

/* ===== NAV BOTTOM BAR (mobile) ===== */
.nav-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e2330;
  height: 60px;
  align-items: stretch;
  z-index: 50;
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-tab--active { color: #fff; }
.nav-tab__icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.nav-tab__label { font-size: 9px; font-weight: 500; }

/* NAV SHEET BACKDROP + SHEET (mobile More) */
html[data-portal="piandre"] .nav-bottom-bar { background: #2d1515; }

.nav-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
}
.nav-sheet {
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  background: var(--bg-2);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  z-index: 70;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.nav-sheet__items { display: flex; flex-direction: column; }

/* ===== MOBILE BREAKPOINT ===== */
@media (max-width: 768px) {
  .portal-layout,
  .portal-layout.nav-collapsed {
    grid-template-columns: 1fr;
    padding-bottom: 60px;
    transition: none;
  }
  .nav-sidebar { display: none; }
  .nav-bottom-bar { display: flex; }
  /* iOS auto-zooms on any field < 16px and often doesn't restore zoom.
     !important required to beat later class selectors (.table-input 13px,
     .branch-select 14px) that come after this block in source order. */
  input, textarea, select,
  .table-input, .branch-select, .ns-text-input { font-size: 16px !important; }
}

/* ===== NAV SKELETON ===== */
.nav-skeleton {
  background: #2d2d2d;
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
  height: 100%;
  gap: 8px;
}
.nav-skeleton__brand {
  height: 20px;
  width: 56px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  margin-bottom: 20px;
}
.nav-skeleton__item {
  height: 36px;
  border-radius: 6px;
  background: rgba(255,255,255,0.07);
  animation: nav-skeleton-pulse 1.4s ease-in-out infinite;
}
.nav-skeleton__item:nth-child(2) { animation-delay: 0s; }
.nav-skeleton__item:nth-child(3) { animation-delay: 0.15s; }
.nav-skeleton__item:nth-child(4) { animation-delay: 0.3s; }
.nav-skeleton__item:nth-child(5) { animation-delay: 0.45s; }
@keyframes nav-skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1;   }
}

/* ===== PORTAL CONTENT ===== */
.portal-content { padding: 32px; height: 100vh; overflow-y: auto; box-sizing: border-box; opacity: 0; transition: opacity 0.18s ease; background: var(--bg-1); }
.portal-content.nav-ready { opacity: 1; }
@media (max-width: 768px) { .portal-content { padding: 16px; padding-bottom: 112px; } }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { color: var(--color-text); }

/* ── Page-level branch switcher ─────────────────────────────────────────────── */
.page-branch-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.page-branch-switcher__label {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ===== COMING SOON ===== */
.coming-soon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 32px;
  gap: 12px;
}
.coming-soon-card__icon { font-size: 48px; }
.coming-soon-card__title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-1);
}
.coming-soon-card__message {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.6;
}

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.kpi-tile {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}
.kpi-tile--red    { border-left-color: #e53935; }
.kpi-tile--amber  { border-left-color: #f9a825; }
.kpi-tile--blue   { border-left-color: #1565c0; }
.kpi-tile--grey   { border-left-color: #999999; }
.kpi-tile__value  { font-size: 32px; font-weight: 500; color: var(--text-1); line-height: 1; margin-bottom: 6px; }
.kpi-tile__label  { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* ===== QUICK LINKS ===== */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.quick-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  text-decoration: none;
  transition: border-color 0.15s;
}
.quick-link-card:hover { border-color: var(--border-3); }
.quick-link-card__icon { font-size: 20px; line-height: 0; display: flex; align-items: center; }

/* ===== BRANCH SELECT ===== */
.branch-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border-2);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  background: var(--bg-2);
  cursor: pointer;
  outline: none;
}
.branch-select:focus { border-color: var(--border-3); }

/* ===== SECTION LABEL ===== */
.section-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-4);
  margin: 0 0 10px;
}

/* ===== BRANCH HEALTH TABLE ===== */
.branch-health-wrap { overflow-x: auto; margin-bottom: 24px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.branch-health-wrap .data-table thead { background: var(--bg-3); }

/* ===== QUICK REFERENCE GUIDE ===== */
.guide-wrap { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 40px; }
.guide-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: none; border: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-1); text-align: left; }
.guide-toggle:hover { background: var(--bg-4); }
.guide-chevron { display: flex; color: var(--text-3); }
.guide-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.guide-step { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 6px; background: var(--bg-2); }
.guide-step--primary { background: #fffbeb; border-left: 3px solid #f59e0b; }
.guide-step__num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.guide-step__num--amber  { background: #fef3c7; color: #92400e; }
.guide-step__num--gray   { background: var(--bg-4); color: var(--text-2); }
.guide-step__num--purple { background: #ede9fe; color: #5b21b6; }
.guide-step__meta { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.guide-step__title { font-weight: 600; font-size: 13px; color: var(--text-1); }
.guide-step__tag { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.guide-step__tag--required { color: #92400e; background: #fef3c7; }
.guide-step__tag--auto     { color: var(--text-2); background: var(--bg-4); }
.guide-step__tag--sbi      { color: #5b21b6; background: #ede9fe; }
.guide-step__tag--clerk    { color: var(--text-2); background: var(--bg-4); }
.guide-step__body { font-size: 13px; color: var(--text-2); margin: 0; line-height: 1.6; }
.guide-step__body a { color: #2563eb; }

/* ===== ALERT CARDS ===== */
.alert-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }

.alert-card { background: var(--bg-2); border: 1.5px solid; border-radius: 8px; overflow: hidden; }
.alert-card--red    { border-color: #fca5a5; }
.alert-card--amber  { border-color: #fcd34d; }
.alert-card--blue   { border-color: #93c5fd; }
.alert-card--purple { border-color: #c4b5fd; }
.alert-card--orange { border-color: #fdba74; }

.alert-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.alert-card__header:hover { opacity: 0.85; }
.alert-card--red    .alert-card__header { background: #fef2f2; }
.alert-card--amber  .alert-card__header { background: #fffbeb; }
.alert-card--blue   .alert-card__header { background: #eff6ff; }
.alert-card--purple .alert-card__header { background: #faf5ff; }
.alert-card--orange .alert-card__header { background: #fff7ed; }

.alert-card__icon { flex-shrink: 0; line-height: 0; }
.alert-card__label { flex: 1; font-weight: 500; font-size: 14px; }
.alert-card--red    .alert-card__label { color: #dc2626; }
.alert-card--amber  .alert-card__label { color: #d97706; }
.alert-card--blue   .alert-card__label { color: #2563eb; }
.alert-card--purple .alert-card__label { color: #7c3aed; }
.alert-card--orange .alert-card__label { color: #ea580c; }
.alert-card__chevron { font-size: 11px; color: #9ca3af; white-space: nowrap; }

.alert-card__body {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 13px;
}
.alert-card__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
  gap: 8px;
}
.alert-card__item:last-of-type { border-bottom: none; }
a.alert-card__item--link { text-decoration: none; color: inherit; cursor: pointer; border-radius: 4px; }
a.alert-card__item--link:hover { background: var(--bg-3); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
a.alert-card__item--link::after { content: '→'; font-size: 12px; color: #9ca3af; margin-left: 4px; flex-shrink: 0; }
a.alert-card__item--link > span:first-child { flex: 1; min-width: 0; }

@keyframes focus-flash {
  0%   { background-color: #fef08a; }
  100% { background-color: transparent; }
}
.focus-highlight td { animation: focus-flash 2.5s ease-out forwards; }
.alert-card__view-all {
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
  margin-top: 8px;
  display: inline-block;
}
.alert-card__view-all:hover { color: var(--text-2); text-decoration: underline; }

/* ===== TASK COMPLETION TRACKER (stock_clerk) ===== */
.task-checks { display:flex; flex-direction:column; gap:8px; margin-bottom:24px; }
.task-check { display:flex; align-items:center; gap:12px; padding:10px 14px; background:var(--bg-2); border:1.5px solid #86efac; border-radius:8px; }
.task-check__mark { font-size:15px; font-weight:700; color:#16a34a; flex-shrink:0; line-height:1; }
.task-check__label { font-weight:600; font-size:13px; color:var(--text-1); flex:1; }
.task-check__detail { font-size:12px; color:#6b7280; }

/* ===== DOCUMENT HUB (SBI viewer) ===== */
.doc-hub-section { margin-bottom: 32px; }
.doc-hub-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.doc-hub-section__title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  margin: 0 0 10px;
}
.doc-hub-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-hub-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.doc-hub-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-3); vertical-align: middle; }
.doc-hub-table tr:last-child td { border-bottom: none; }
.doc-hub-table .badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-4);
  color: var(--text-2);
}

/* ===== TABLE ===== */
.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}
.data-table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead { position: sticky; top: 0; background: var(--bg-1); z-index: 1; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-2);
  white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-1); }
.data-table tbody tr:nth-child(even) { background: var(--bg-3); }
.data-table tbody tr:hover { background: var(--bg-4); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* Status badges — translucent in dark mode, solid tints in light mode */
.badge--out-of-stock  { background: rgba(248,113,113,.16); color: #f87171; }
.badge--critical      { background: rgba(251,146,60,.16);  color: #fb923c; }
.badge--below-optimal { background: rgba(251,191,36,.16);  color: #fbbf24; }
.badge--optimal       { background: rgba(74,222,128,.16);  color: #4ade80; }
.badge--overstock     { background: rgba(96,165,250,.16);  color: #93c5fd; }
.badge--close-watch   { background: var(--bg-4);           color: var(--text-2); }
.badge--category      { background: rgba(167,139,250,.16); color: #a78bfa; }
.badge--remarks       { background: rgba(251,191,36,.16);  color: #fbbf24; }
.badge--remark        { }
.badge--remark-discontinue { background: rgba(248,113,113,.16); color: #f87171; }
.badge--remark-phased      { background: rgba(251,146,60,.16);  color: #fb923c; }
.badge--remark-slow        { background: rgba(251,191,36,.16);  color: #fbbf24; }
.badge--remark-new         { background: rgba(74,222,128,.16);  color: #4ade80; }
.badge--info               { background: rgba(96,165,250,.16);  color: #93c5fd; }
.badge--warning            { background: rgba(251,191,36,.16);  color: #fbbf24; }
.badge--neutral            { background: var(--bg-3); color: var(--text-2); }
/* Light mode: solid tints with dark text */
html[data-theme="light"] .badge--out-of-stock  { background: #fee2e2; color: #b91c1c; }
html[data-theme="light"] .badge--critical      { background: #ffedd5; color: #c2410c; }
html[data-theme="light"] .badge--below-optimal { background: #fef3c7; color: #92400e; }
html[data-theme="light"] .badge--optimal       { background: #dcfce7; color: #15803d; }
html[data-theme="light"] .badge--overstock     { background: #dbeafe; color: #1d4ed8; }
html[data-theme="light"] .badge--category      { background: #ede9fe; color: #5b21b6; }
html[data-theme="light"] .badge--remarks       { background: #fef3c7; color: #92400e; }
html[data-theme="light"] .badge--remark-discontinue { background: #fee2e2; color: #b91c1c; }
html[data-theme="light"] .badge--remark-phased { background: #fff7ed; color: #c2410c; }
html[data-theme="light"] .badge--remark-slow   { background: #fef3c7; color: #92400e; }
html[data-theme="light"] .badge--remark-new    { background: #dcfce7; color: #15803d; }
html[data-theme="light"] .badge--info          { background: #dbeafe; color: #1d4ed8; }
html[data-theme="light"] .badge--warning       { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: light) { html:not([data-theme="dark"]) .badge--out-of-stock  { background: #fee2e2; color: #b91c1c; }
  html:not([data-theme="dark"]) .badge--critical      { background: #ffedd5; color: #c2410c; }
  html:not([data-theme="dark"]) .badge--below-optimal { background: #fef3c7; color: #92400e; }
  html:not([data-theme="dark"]) .badge--optimal       { background: #dcfce7; color: #15803d; }
  html:not([data-theme="dark"]) .badge--overstock     { background: #dbeafe; color: #1d4ed8; }
  html:not([data-theme="dark"]) .badge--category      { background: #ede9fe; color: #5b21b6; }
  html:not([data-theme="dark"]) .badge--remarks       { background: #fef3c7; color: #92400e; }
  html:not([data-theme="dark"]) .badge--remark-discontinue { background: #fee2e2; color: #b91c1c; }
  html:not([data-theme="dark"]) .badge--remark-phased { background: #fff7ed; color: #c2410c; }
  html:not([data-theme="dark"]) .badge--remark-slow   { background: #fef3c7; color: #92400e; }
  html:not([data-theme="dark"]) .badge--remark-new    { background: #dcfce7; color: #15803d; }
  html:not([data-theme="dark"]) .badge--info          { background: #dbeafe; color: #1d4ed8; }
  html:not([data-theme="dark"]) .badge--warning       { background: #fef3c7; color: #92400e; } }
/* New token-aware badge classes — coexist with old .badge--* */
.badge-green  { background: rgba(74,222,128,.16);  color: #4ade80; }
.badge-yellow { background: rgba(251,191,36,.16);  color: #fbbf24; }
.badge-red    { background: rgba(248,113,113,.16); color: #f87171; }
.badge-blue   { background: rgba(96,165,250,.16);  color: #93c5fd; }
html[data-theme="light"] .badge-green  { background: #dcfce7; color: #15803d; }
html[data-theme="light"] .badge-yellow { background: #fef3c7; color: #92400e; }
html[data-theme="light"] .badge-red    { background: #fee2e2; color: #b91c1c; }
html[data-theme="light"] .badge-blue   { background: #dbeafe; color: #1d4ed8; }
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .badge-green  { background: #dcfce7; color: #15803d; }
  html:not([data-theme="dark"]) .badge-yellow { background: #fef3c7; color: #92400e; }
  html:not([data-theme="dark"]) .badge-red    { background: #fee2e2; color: #b91c1c; }
  html:not([data-theme="dark"]) .badge-blue   { background: #dbeafe; color: #1d4ed8; }
}

/* ===== UL-CARD (used on documents, transfers, deliveries) ===== */
.ul-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.ul-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ul-card__header > div:first-child {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.ul-card__title {
  font-weight: 500;
  font-size: 14px;
}
.ul-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.ul-card__note {
  font-style: italic;
  color: var(--text-3);
  font-size: 12px;
}

/* ===== DOC THREAD (documents page PO → DR/GRN nesting) ===== */
.doc-thread {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.doc-thread__children { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.doc-thread__dr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-3);
  border-radius: 6px;
  border-left: 3px solid var(--border-2);
}
.doc-thread__dr--empty { border-left-color: var(--border); }
.doc-thread__dr-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-thread__dr-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.doc-thread__dr-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.doc-thread__dr-number { font-size: 13px; font-weight: 500; }
.doc-thread--clickable { cursor: pointer; }
.doc-thread--clickable:hover { background: var(--bg-3); }
.doc-thread__chevron { font-size: 11px; color: var(--text-4); user-select: none; }

/* ===== DOCUMENT PAGE TABS ===== */
.doc-tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.doc-tab-btn.active {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
  font-weight: 500;
}

/* ===== ALERT LINK CARDS (dashboard incomplete-handler alerts) ===== */
.alert-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.alert-link-card--red {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}
.alert-link-card__label { flex: 1; }
.alert-link-card__arrow { color: #ef4444; font-size: 16px; margin-left: 12px; }

/* ===== HANDLER TABS (settings page — separate from .doc-tab-btn) ===== */
.handler-tab-btn {
  position: relative; /* required for red dot absolute positioning */
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.handler-tab-btn.active {
  color: #f97316;
  border-bottom-color: #f97316;
  font-weight: 500;
}
.handler-tab-dot {
  position: absolute;
  top: 7px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
}

/* ===== SETTINGS BRANCH GRID ===== */
.settings-branch-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
  margin-top: 4px;
}
@media (max-width: 900px) {
  .settings-branch-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== DATE RANGE GROUP ===== */
.date-range-group { display: flex; align-items: center; gap: 6px; }
.date-range-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.date-range-sep   { font-size: 13px; color: #9ca3af; }
.date-range-group input[type="date"] { width: 130px; }

/* ===== FILTER BAR DIVIDER + TODAY CHIP ===== */
.filter-bar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.today-chip { font-size: 11px; color: var(--text-3); background: none; border: 1px solid var(--border-2); border-radius: 4px; padding: 2px 8px; cursor: pointer; white-space: nowrap; line-height: 1.4; }
.today-chip:hover { background: var(--bg-3); color: var(--text-2); }

/* ===== INVENTORY FILTER BAR ===== */
.inv-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.inv-search {
  flex: 1;
  min-width: 200px;
  padding: 7px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
}
.inv-search:focus { outline: none; border-color: #aaa; }
.inv-filter-select { font-size: 14px; padding: 7px 10px; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text); }
.inv-count-note { font-size: 13px; color: var(--color-text-secondary); margin-bottom: 8px; }
.inv-toggle-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--color-text-secondary); white-space: nowrap; cursor: pointer; }
.inv-cat-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.inv-cat-pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  color: var(--color-text-secondary);
  background: var(--color-bg);
  cursor: pointer;
  transition: all 0.15s;
}
.inv-cat-pill:hover { border-color: #aaa; color: var(--color-text); }
.inv-cat-pill.active { background: var(--color-primary); color: var(--color-primary-text); border-color: var(--color-primary); }
.inv-brand-pill { border-style: dashed; }
.inv-brand-pill.active { background: #1565c0; border-color: #1565c0; border-style: solid; }
.inv-pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.inv-page-info { font-size: 13px; color: var(--color-text-secondary); }

/* ===== TABLE INPUT (edit mode) ===== */
.table-input {
  width: 80px;
  padding: 4px 8px;
  border: 1.5px solid var(--border-2);
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-1);
  background: var(--bg-2);
  outline: none;
}
.table-input:focus { border-color: var(--border-3); }

.inv-slow-moving-label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-secondary);
  cursor: pointer;
  user-select: none;
}
.inv-slow-moving-label input { margin-right: 4px; cursor: pointer; }

/* ===== LOADING STATES ===== */
@keyframes sbi-spin    { to { transform: rotate(360deg); } }
@keyframes sbi-shimmer { 0% { background-position: -500px 0; } 100% { background-position: 500px 0; } }
@keyframes sbi-pulse   { 0%, 100% { opacity: 1; } 50% { opacity: 0.38; } }

.loading-spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border-2);
  border-top-color: var(--text-1);
  border-radius: 50%;
  animation: sbi-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.loading-spinner--sm { width: 14px; height: 14px; border-width: 2px; }

.page-loader {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 48px 32px 28px;
}
.page-loader .loading-spinner { width: 32px; height: 32px; border-width: 3px; }
.page-loader__label { text-align: center; }
.page-loader__label p { margin: 0; }
.page-loader__label p:first-child { font-size: 14px; font-weight: 500; color: var(--text-2); }
.page-loader__label p + p      { font-size: 12px; color: var(--text-4); margin-top: 4px; }

.skeleton-bar {
  display: block;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 500px 100%;
  animation: sbi-shimmer 1.5s ease-in-out infinite;
}
.skeleton-row td { padding: 11px 12px !important; vertical-align: middle; }
.skeleton-row:nth-child(even) td > .skeleton-bar { opacity: 0.85; }

/* ===== MISC ===== */
.loading-text { color: var(--text-3); font-size: 14px; animation: sbi-pulse 1.8s ease-in-out infinite; }
.empty-text   { color: var(--text-3); font-size: 14px; text-align: center; padding: 40px 0; }
.empty-state  { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 48px 24px; text-align: center; }
.empty-state__title  { font-size: 14px; font-weight: 500; color: var(--text-2); }
.empty-state__body   { font-size: 13px; color: var(--text-3); line-height: 1.6; max-width: 320px; }
.uc-banner    { background: #fef9c3; border: 1px solid #fde047; border-radius: 6px; padding: 10px 14px; margin-bottom: 20px; font-size: 13px; color: #713f12; display: flex; align-items: center; gap: 8px; }
.uc-banner::before { content: '🚧'; flex-shrink: 0; }
.inv-branch-col--demo { background: #fefce8 !important; }
.save-error    { font-size: 13px; color: #e53935; }
.save-warning  { font-size: 13px; color: #d97706; }
.ns-optional   { font-weight: normal; color: var(--text-3); }
.session-meta  { font-size: 12px; color: var(--text-3); font-weight: normal; }

/* ===== USAGE LOG ===== */
.ul-section {
  margin-top: 24px;
  margin-bottom: 24px;
  background: var(--bg-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px 24px;
}
.ul-section h2 { margin-bottom: 16px; }
.ul-section-header h2 { margin-bottom: 0; }

.ul-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.ul-section-header--sticky {
  position: sticky;
  top: -32px;
  z-index: 10;
  background: var(--bg-2);
  padding: 12px 0;
  margin: -12px 0 4px;
  border-radius: 10px 10px 0 0;
}
@media (max-width: 768px) {
  .ul-section-header--sticky { top: -16px; }
}

/* Pagination */
.pagination-bar { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.pagination-info { font-size: 13px; color: var(--text-2); }

/* Button variants */
.btn-small { padding: 6px 14px; font-size: 13px; }
.po-dl-btn { padding: 4px 8px; font-size: 11px; font-weight: 500; }
.po-awaiting-label { display: inline-block; font-size: 10px; font-weight: 500; color: #92400e; background: #fef3c7; border-radius: 10px; padding: 2px 8px; white-space: nowrap; }

/* Docs dropdown */
.po-docs-dropdown { position: relative; display: inline-block; }
.po-docs-menu { position: fixed; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); min-width: 160px; z-index: 9999; padding: 4px 0; }
.po-docs-item { display: block; width: 100%; text-align: left; padding: 7px 14px; font-size: 12px; border: none; background: none; cursor: pointer; color: var(--text-1); }
.po-docs-item:hover { background: var(--bg-4); }
.btn-danger { background: #e53935; color: #fff; border: none; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-success { background: #2e7d32; color: #fff; border: none; }
.btn-success:hover:not(:disabled) { opacity: 0.85; }

/* Session accordion cards */
.session-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.session-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-3);
}
.session-card__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  flex: 1;
}
.session-card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.session-card__body {
  padding: 16px;
  border-top: 1px solid var(--color-border);
}

/* Add product mini-form inside a card */
.add-product-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
}
.add-product-form label { font-weight: 500; color: var(--color-text-secondary); }
.add-product-select { padding: 4px 8px; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; min-width: 260px; }
.add-product-form .ts-wrapper { min-width: 260px; flex: 1; max-width: 360px; }
.add-qty-input { width: 80px; }
.autofill-label { font-size: 12px; color: var(--color-text-secondary); }
.autofill-label span { color: var(--color-text); font-weight: 500; }
.reopen-locked { font-size: 12px; color: var(--color-text-secondary); font-style: italic; cursor: default; }

/* ── AI Briefing Bar ─────────────────────────────────────────────────────── */
.ai-briefing-bar      { display:flex; align-items:center; gap:10px; padding:10px 16px; background:var(--bg-3); border:1px solid var(--border); border-radius:8px; cursor:pointer; margin-bottom:16px; }
.ai-briefing-icon     { color:var(--text-2); flex-shrink:0; }
.ai-briefing-teaser   { flex:1; color:var(--text-1); font-size:13px; font-weight:500; }
.ai-briefing-toggle   { font-size:11px; color:var(--text-2); white-space:nowrap; }
.ai-briefing-expanded { padding:12px 16px; border:1px solid var(--border); border-top:none; border-radius:0 0 8px 8px; background:#fff; margin-top:-16px; margin-bottom:16px; }
.ai-briefing-bullets  { margin:0; padding-left:18px; line-height:1.8; color:var(--text-1); font-size:13px; }
.ai-briefing-footer   { margin:8px 0 0; font-size:11px; color:var(--text-2); }
.link-btn             { background:none; border:none; padding:0; color:var(--text-2); font-size:inherit; cursor:pointer; text-decoration:underline; }
.product-remarks { display: block; font-size: 10px; color: var(--text-3); margin-top: 1px; }
.session-logged-by { font-size: 11px; color: var(--text-2); font-weight: normal; margin-left: 8px; }
.history-indent { padding-left: 24px; }
.text-right { text-align: right; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-border); }
.pagination-info { font-size: 13px; color: var(--color-text-secondary); }

/* Search input */
.search-input { padding: 6px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; width: 220px; background: var(--color-bg); color: var(--color-text); }
.search-input:focus { outline: none; border-color: var(--color-primary); }

/* Sub-header inside toggleable sections (e.g. history search bar) */
.ul-section-subheader { padding: 10px 0 8px; }

/* Usage log — two-column layout on wide screens */
.ul-top-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-top: 32px;
  margin-bottom: 32px;
}
.ul-top-row .ul-section { margin-top: 0; margin-bottom: 0; }
.ul-section--new-session  { flex: 0 0 420px; }
.ul-section--open-sessions { flex: 1; min-width: 0; }
@media (max-width: 1280px) {
  .ul-top-row { flex-direction: column; gap: 0; }
  .ul-section--new-session,
  .ul-section--open-sessions { flex: none; width: 100%; margin-bottom: 32px; }
}

/* New session form */
.new-session-form { display: flex; flex-direction: column; gap: 18px; max-width: 600px; }
.ns-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.ns-row--bottom { align-items: flex-end; }
.ns-field { display: flex; flex-direction: column; gap: 4px; }
.ns-field label { font-size: 12px; font-weight: 500; color: var(--color-text-secondary); white-space: nowrap; }
/* Staff field: fixed width; Client/Product fields: stretch to fill */
.ns-field--grow { flex: 1; min-width: 160px; }
.ns-field--grow .ns-text-input { width: 100%; box-sizing: border-box; }
.ns-field--small { width: 90px; flex-shrink: 0; }
.ns-field--small .table-input { width: 100%; box-sizing: border-box; }
.ns-field--submit { flex-direction: row; align-items: center; gap: 10px; flex-shrink: 0; align-self: flex-end; }
.ns-text-input { padding: 6px 10px; border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); }
/* Category pills sit between product label and product dropdown */
.ns-cat-pills { min-height: 26px; }
/* TomSelect — fixed width for staff; 100% for product (order matters: product rule must come last) */
.ns-field .ts-wrapper { width: 160px; }
.ns-field--product { flex: 0 0 100%; }
.ns-field--product .ts-wrapper { width: 100%; }
/* Match TomSelect control height to plain inputs */
.ns-field .ts-control { padding: 6px 10px !important; min-height: unset !important; border: 1.5px solid var(--color-border) !important; border-radius: var(--radius-sm) !important; background: var(--bg-2) !important; color: var(--text-1) !important; box-sizing: border-box !important; }
.ns-general-toggle { display: block; font-size: 12px; }
/* Staff: full-width row */
.ns-field--staff .ts-wrapper { width: 100% !important; max-width: 100%; }
/* Category filter toggle button */
.ns-cat-toggle-btn { background: none; border: none; padding: 0; margin-left: 8px; font-size: 11px; color: var(--color-primary); cursor: pointer; font-weight: 500; vertical-align: middle; }
.ns-cat-toggle-btn:hover { text-decoration: underline; }

/* ===== DELIVERY RECEIPTS ===== */
.dr-modal-overlay[hidden] { display: none; }
.dr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 64px;
  overflow-y: auto;
}
.dr-modal {
  background: var(--bg-2);
  border-radius: 10px;
  width: 100%;
  max-width: 780px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.dr-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.dr-modal__header h3 { margin: 0; font-size: 17px; }
.dr-modal__close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-3);
  line-height: 1;
  padding: 4px 8px;
}
.dr-modal__close:hover { color: var(--text-1); }
.dr-modal__body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.dr-modal__date-row { display: flex; align-items: center; gap: 12px; }
.dr-modal__date-row label { font-size: 13px; font-weight: 500; min-width: 100px; }
.dr-modal__date-row input { flex: 1; }
.branch-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.branch-pill { padding: 6px 16px; border-radius: 999px; border: 1.5px solid var(--border-2); background: var(--bg-2); font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.branch-pill:hover { border-color: var(--border-3); }
.branch-pill--active { background: var(--accent); border-color: var(--accent); color: var(--bg-0); }
.dr-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* DR line items table */
.dr-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dr-items-table th {
  padding: 8px 10px;
  text-align: left;
  color: var(--text-3);
  font-weight: 500;
  border-bottom: 2px solid var(--border);
  background: var(--bg-3);
}
.dr-items-table th.right, .dr-items-table td.right { text-align: right; }
.dr-items-table th.center, .dr-items-table td.center { text-align: center; }
.dr-items-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-3); }
.dr-items-table tr.dr-row--unchecked td { opacity: 0.45; }
.dr-qty-input {
  width: 60px;
  text-align: center;
  border: 1.5px solid #d1fae5;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 13px;
  font-weight: 500;
  color: #15803d;
}
.dr-qty-input.short { border-color: #fbbf24; color: #92400e; }
.dr-qty-input:disabled { background: var(--bg-4); color: var(--text-4); border-color: var(--border); }
.dr-short-warn { font-size: 11px; color: #d97706; margin-top: 3px; }
.dr-empty-queue { color: var(--text-3); font-size: 13px; padding: 20px 0; text-align: center; }

/* DR totals */
.dr-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 13px;
  padding-top: 8px;
  border-top: 2px solid var(--border);
}
.dr-totals__row { display: flex; gap: 24px; justify-content: flex-end; }
.dr-totals__label { color: var(--text-3); min-width: 80px; text-align: right; }
.dr-totals__value { min-width: 90px; text-align: right; font-weight: 500; color: var(--text-2); }
.dr-totals__row--total .dr-totals__label { font-weight: 500; color: var(--text-2); }
.dr-totals__row--total .dr-totals__value { font-weight: 500; color: #15803d; font-size: 15px; }

/* DR history table */
.dr-history-empty { color: #999; font-size: 14px; text-align: center; padding: 32px 0; }

/* Stock movement history search + pagination */
.history-search-row { margin-bottom: 12px; }
.history-search-row input { width: 320px; }
.history-pagination { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.history-pagination span { font-size: 13px; color: var(--text-3); }

/* SBI Product Prices */
.prices-search-row { margin-bottom: 12px; }
.prices-search-row input { width: 320px; }
.price-input { width: 100px; text-align: right; }

/* Auto-assigned number display (read-only, replaces manual number inputs) */
.auto-number-display {
  font-family: monospace;
  font-size: 14px;
  color: var(--text-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  display: inline-block;
}

/* Settings page */
.settings-field-group { padding: 4px 0; }
.settings-current     { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.settings-input-row   { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.settings-input-row label { width: 150px; flex-shrink: 0; }
.settings-warning     { font-size: 12px; color: #d97706; margin-top: 6px; }
.settings-success     { font-size: 12px; color: #16a34a; margin-top: 6px; }
.settings-remark-row  { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
.settings-remark-value { font-size: 13px; color: var(--text-2); }
.handlers-checklist { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.handlers-checklist label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 3px 0; cursor: pointer; }
.handlers-checklist input[type="checkbox"] { cursor: pointer; }
.handler-badge { display: inline-block; font-size: 11px; background: var(--bg-3); color: var(--text-2); border-radius: 4px; padding: 1px 6px; margin: 1px 2px; }
.dr-modal--wide { max-width: 900px; width: 95vw; }
.po-item-warning { font-size: 11px; color: #d97706; margin-top: 2px; }

/* ── SBI Inventory page ──────────────────────────────── */

/* Column wrapper for pages where the table needs horizontal overflow.
   The page-header lives here (outside the scroll container) so it never
   scrolls horizontally. The portal-content below is the actual scroll zone. */
.portal-main-col {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-1);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.portal-main-col.nav-ready { opacity: 1; }
.portal-main-col > .page-header { flex-shrink: 0; padding: 32px 32px 0; }
.portal-main-col > .portal-content { flex: 1; min-height: 0; height: auto; opacity: 1; transition: none; padding-top: 0; }

/* portal-content variant that handles horizontal overflow so the single
   inv-table can use native position:sticky on both thead and left cols.
   No horizontal padding — padding area in an overflow container creates a
   dead zone where scrolled content bleeds through. Padding is restored on
   specific child elements instead. */
.portal-content--wide-table { overflow-x: auto; padding-left: 0; padding-right: 0; }

.inv-sticky-filter-bar {
  position: sticky;
  top: 0;
  will-change: transform;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 6px;
  gap: 8px;
  padding: 8px 32px 8px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
/* Keep every button/chip in the filter bar single-line so labels don't wrap
   inside the chip (the row itself can wrap to two lines when crowded). */
.inv-sticky-filter-bar .btn,
.inv-sticky-filter-bar .pc-filter-btn,
.inv-sticky-filter-bar .inv-count-note {
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .portal-content--wide-table { padding-left: 0; padding-right: 0; }
  .portal-main-col > .page-header { padding: 16px 16px 0; }
  .inv-alerts-strip { padding-left: 16px; padding-right: 16px; }
  .inv-sticky-filter-bar {
    top: 0;
    flex-wrap: wrap;
    padding-left: 16px;
    padding-right: 16px;
  }
}
.inv-search-inline {
  flex: 1;
  min-width: 140px;
  max-width: 240px;
}
.inv-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #6366f1;
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 3px;
  vertical-align: middle;
}

#table-wrapper {}

.inv-table-scroll { -webkit-overflow-scrolling: touch; }

/* border-separate required for sticky columns to work correctly */
.inv-table {
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  table-layout: fixed;
}

/* thead cells — sticky top set by JS; horizontal sticky for left cols via .inv-sticky-col */
.inv-table thead th {
  position: sticky;
  top: 0; /* fallback; overridden by JS */
  z-index: 3;
  background: var(--bg-1);
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
/* Align first column with title and filter bar (both use 32px left padding) */
.inv-table thead th:first-child,
.inv-table tbody td:first-child { padding-left: 32px; }
/* Same alignment for data-table used inside wide-table layout (e.g. retail inventory) */
.portal-content--wide-table .data-table thead th:first-child,
.portal-content--wide-table .data-table tbody td:first-child { padding-left: 32px; }
/* Make th cells individually sticky (same pattern as inv-table) so JS top override works */
.portal-content--wide-table .data-table thead th {
  position: sticky;
  top: 0; /* fallback; overridden by JS */
  z-index: 3;
  background: var(--bg-1);
}
@media (max-width: 768px) {
  .inv-table thead th:first-child,
  .inv-table tbody td:first-child { padding-left: 16px; }
  .portal-content--wide-table .data-table thead th:first-child,
  .portal-content--wide-table .data-table tbody td:first-child { padding-left: 16px; }
}

/* ── Retail inventory beginning balance mode ─────────── */
.inv-sticky-filter-bar--edit {
  background: #fffbeb;
  border-bottom-color: #fde68a;
}
.ri-balance-banner {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  padding: 10px 32px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.5;
}

/* PO line flash when trying to add a product already in the form */
@keyframes po-line-flash {
  0%   { background: transparent; }
  30%  { background: #fef9c3; }
  100% { background: transparent; }
}
.po-line--flash { animation: po-line-flash 1.2s ease; }

/* Second header row (sub-labels for expanded branches) */
.inv-table thead tr:nth-child(2) th {
  top: 38px; /* fallback; overridden by JS */
  font-size: 10px;
  padding: 4px 8px;
}

/* Sticky left columns */
.inv-sticky-col {
  position: sticky;
  z-index: 2;
  background: var(--bg-1);
}
/* In thead, sticky left cols need z-index above branch headers */
.inv-table thead .inv-sticky-col {
  z-index: 5;
}

.inv-col-name         { left: 0;     width: 295px; min-width: 295px; max-width: 295px; } /* absorbed old sku col (175+120) */
.inv-col-branch-total { left: 295px; width: 90px;  min-width: 90px; }
.inv-col-price        { left: 385px; width: 110px; min-width: 110px; } /* 295+90 */

/* Shadow on the last sticky col to show separation from scrolling cols */
.inv-col-price,
.inv-table thead .inv-col-price {
  box-shadow: 3px 0 6px -2px rgba(0,0,0,0.12);
}

/* Body cells need explicit background so sticky cols cover scrolled content */
.inv-table tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border-3); vertical-align: top; }
.inv-table tbody tr:nth-child(even) td { background: var(--bg-3); }
.inv-table tbody tr:hover td { background: var(--bg-4); }
/* Sticky body cells must re-declare background to override row background on scroll */
.inv-table tbody td.inv-sticky-col { background: var(--bg-1); }
.inv-table tbody tr:nth-child(even) td.inv-sticky-col { background: var(--bg-3); }
.inv-table tbody tr:hover td.inv-sticky-col { background: var(--bg-4); }

/* Branch column headers */
.inv-branch-col {
  text-align: center;
  border-left: 2px solid var(--border);
  user-select: none;
}
.inv-branch-col--col {
  min-width: 56px;
  width: 56px;
  max-width: 56px;
  max-width: 56px;
  font-size: 11px;
  letter-spacing: 0.03em;
  overflow: hidden;
}
.inv-branch-col--exp {
  min-width: 180px;
  width: 195px;
  font-size: 12px;
}
.inv-bt-icon { font-size: 9px; opacity: 0.6; }

.inv-branch-cell {
  font-size: 12px;
  padding: 6px 8px;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  border-left: 1px solid var(--border-3);
  overflow: hidden;
}
.inv-branch-cell--col {
  border-left: 2px solid var(--border);
  min-width: 56px;
  width: 56px;
  max-width: 56px;
  font-weight: 500;
  overflow: hidden;
}

.inv-cell-label { min-width: 58px; width: 65px; }
.inv-branch-col--warehouse {
  background: #374151;
  color: #f9fafb;
}
.inv-branch-col--warehouse.inv-branch-col--exp {
  min-width: 90px;
  width: 90px;
}
.inv-cell-label--warehouse {
  background: #4b5563;
  color: #f9fafb;
}
.inv-branch-cell--warehouse {
  background: var(--bg-3);
}
.inv-cell-label--mdse {
  background: #78350f;
  color: #fef3c7;
}
.inv-branch-cell--mdse {
  background: #fffbeb;
}

/* Assigned-branch indicator — supervisor's own branches get a tinted header */
.inv-branch-col--mine {
  background: #1a2e1a;
  color: #4ade80;
}
html[data-theme="light"] .inv-branch-col--mine {
  background: #dcfce7;
  color: #15803d;
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .inv-branch-col--mine {
    background: #dcfce7;
    color: #15803d;
  }
}

/* Branch cell stock-level classes — prep for dark-mode cellBg migration */
.inv-branch-cell.lv-ok   { background: rgba(74,222,128,.10);  color: #4ade80; }
.inv-branch-cell.lv-low  { background: rgba(251,191,36,.13);  color: #fbbf24; }
.inv-branch-cell.lv-out  { background: rgba(248,113,113,.14); color: #f87171; }
.inv-branch-cell.lv-over { background: rgba(96,165,250,.11);  color: #93c5fd; }
html[data-theme="light"] .inv-branch-cell.lv-ok   { background: #dcfce7; color: #15803d; }
html[data-theme="light"] .inv-branch-cell.lv-low  { background: #fef3c7; color: #92400e; }
html[data-theme="light"] .inv-branch-cell.lv-out  { background: #fee2e2; color: #b91c1c; }
html[data-theme="light"] .inv-branch-cell.lv-over { background: #dbeafe; color: #1d4ed8; }
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .inv-branch-cell.lv-ok   { background: #dcfce7; color: #15803d; }
  html:not([data-theme="dark"]) .inv-branch-cell.lv-low  { background: #fef3c7; color: #92400e; }
  html:not([data-theme="dark"]) .inv-branch-cell.lv-out  { background: #fee2e2; color: #b91c1c; }
  html:not([data-theme="dark"]) .inv-branch-cell.lv-over { background: #dbeafe; color: #1d4ed8; }
}

/* Status filter pills */
.status-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-2);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
}
.status-pill:hover { color: var(--text-1); border-color: var(--border-3); }
.status-pill.active { background: var(--accent-dim); color: var(--text-1); border-color: var(--accent); }
.status-pill.pill-alert.active { background: rgba(248,113,113,.13); color: #fca5a5; border-color: rgba(248,113,113,.4); }
.status-pill.pill-low.active   { background: rgba(251,191,36,.14);  color: #fbbf24; border-color: rgba(251,191,36,.45); }
.status-pill.pill-out.active   { background: rgba(248,113,113,.14); color: #f87171; border-color: rgba(248,113,113,.4); }
.status-pill.pill-over.active  { background: rgba(96,165,250,.14);  color: #93c5fd; border-color: rgba(96,165,250,.4); }
html[data-theme="light"] .status-pill.pill-alert.active { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
html[data-theme="light"] .status-pill.pill-low.active   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
html[data-theme="light"] .status-pill.pill-out.active   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
html[data-theme="light"] .status-pill.pill-over.active  { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .status-pill.pill-alert.active { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
  html:not([data-theme="dark"]) .status-pill.pill-low.active   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
  html:not([data-theme="dark"]) .status-pill.pill-out.active   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
  html:not([data-theme="dark"]) .status-pill.pill-over.active  { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
}

.inv-warehouse-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fefce8;
  border: 1px solid #facc15;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #713f12;
}
.inv-warehouse-banner a {
  color: #92400e;
  font-weight: 500;
  text-decoration: underline;
}
.inv-warehouse-banner__dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #92400e;
  padding: 0 4px;
}

.inv-row--non-inv td { color: #9ca3af; }
.inv-row--inactive td { opacity: 0.5; }

/* Save/Cancel footer bar */
.inv-save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 100;
}

.inv-save-bar__msg {
  margin-right: auto;
  font-size: 13px;
  color: var(--color-text-muted, #666);
}

.inv-remarks-select {
  display: block;
  color: var(--text-3);
  cursor: pointer;
  box-sizing: border-box;
}

.inv-table td { vertical-align: top; }

/* Physical count cell (Piandré inventory) */
.phys-count-cell { position: relative; }
.phys-count-meta {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 2px;
  white-space: nowrap;
}
.phys-count-indicator {
  font-size: 11px;
  font-weight: 500;
  margin-left: 4px;
}

/* Delivery banner (Piandré delivery-receipts page) */
.delivery-banner {
  border-radius: 8px;
  font-size: 13px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.delivery-banner--warning {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Pull-out submission notice */
.pullout-notice { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; background: #f0fdf4; border: 1px solid #86efac; border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; }
.pullout-notice__body { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #166534; }
.pullout-notice__actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pullout-notice__docs-link { font-size: 12px; color: #166534; text-decoration: underline; }
.pullout-notice__dismiss { background: none; border: none; cursor: pointer; color: #16a34a; font-size: 15px; padding: 0; line-height: 1; flex-shrink: 0; }

/* ===== COMBOBOX ======================================================= */
.cb-wrap { position: relative; }
.cb-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
}
.cb-dropdown[hidden] { display: none; }
.cb-option {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  line-height: 1.4;
}
.cb-option:hover { background: var(--bg-4); }

/* ===== USERS PAGE ===================================================== */
.branch-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-3);
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.branch-tab:hover { background: var(--bg-4); color: var(--text-2); }
.branch-tab--active { background: var(--accent); color: var(--bg-0); border-color: var(--accent); }

.users-table-wrapper {
  overflow-x: auto;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.users-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--color-border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: var(--color-bg-hover); }

/* Role and status badges */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.role-badge--staff            { background: #e8f4fd; color: #1a73e8; }
.role-badge--stock_supervisor { background: #fef9e7; color: #d4a017; }
.role-badge--receptionist     { background: #fce7f3; color: #9d174d; }
.role-badge--branch_manager   { background: #e8f8f5; color: #1a7a5e; }
.role-badge--super_admin      { background: #f3e8ff; color: #7c3aed; }
.role-badge--sbi_manager      { background: #fff3e0; color: #c05600; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.status-badge--active   { background: #e6f9ee; color: #15803d; }
.status-badge--inactive { background: var(--bg-3); color: var(--text-3); }

/* Users action row */
.users-actions { display: flex; gap: 6px; align-items: center; }

/* Modal shared styles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal {
  background: var(--bg-2);
  border-radius: 14px;
  padding: 0;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--color-text); }
.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--color-border);
}
.edit-user-name {
  font-weight: 500;
  font-size: 15px;
  color: var(--color-text);
  margin: 0;
}

/* Branch checkbox/radio list */
.branch-checkbox-list {
  border: 1.5px solid #eeeeee;
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}
.branch-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
  border-radius: 0;
  transition: background 0.1s;
}
.branch-option:hover { background: var(--color-bg-hover); }
.branch-option input { cursor: pointer; accent-color: #2d2d2d; width: 15px; height: 15px; }

/* Modal inputs override the narrow .table-input default width */
.modal-body .table-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 14px;
  padding: 8px 10px;
}

/* Multi-select branch listbox */
.modal-body select[multiple] {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  padding: 4px;
  background: var(--bg-2);
  color: var(--color-text);
  outline: none;
  min-height: 80px;
}
.modal-body select[multiple]:focus {
  border-color: #2d2d2d;
}

/* ── ABC Analysis ─────────────────────────────────────────────────────────── */

.abc-explanation {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.abc-explanation__toggle {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
}

.abc-explanation__toggle:hover { background: #f5f5f5; }

.abc-explanation__body {
  padding: 0 1rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.abc-explanation__body p { margin: 0 0 0.75rem; }

.abc-explanation__table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
}

.abc-explanation__table th,
.abc-explanation__table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.abc-explanation__table th {
  font-weight: 500;
  color: var(--color-text);
  background: #f9f9f9;
}

.abc-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.abc-controls .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.abc-controls .table-input {
  width: auto;
  min-width: 160px;
  box-sizing: border-box;
  font-size: 14px;
  padding: 8px 10px;
}

.abc-controls__export {
  margin-left: auto;
  display: flex;
  align-items: flex-end;
}

.abc-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.abc-class-pills {
  display: flex;
  gap: 0.25rem;
}

.abc-controls .form-field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.abc-summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
  .abc-summary-cards { grid-template-columns: 1fr; }
}

.abc-card {
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1.25rem;
}

.abc-card--A { border-left: 4px solid #ef4444; background: #fff8f8; }
.abc-card--B { border-left: 4px solid #f59e0b; background: #fffdf5; }
.abc-card--C { border-left: 4px solid #22c55e; background: #f6fef9; }

.abc-card__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.abc-card__def {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.abc-card__count {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1;
}

.abc-card__value {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
}

.abc-card__pct {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 0.125rem;
}

/* ABC class badges */
.abc-class-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  flex-shrink: 0;
}

.abc-class-badge--A { background: #fee2e2; color: #b91c1c; }
.abc-class-badge--B { background: #fef3c7; color: #b45309; }
.abc-class-badge--C { background: #dcfce7; color: #15803d; }

/* ABC table */
.abc-table-wrapper { overflow-x: auto; }

.abc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.abc-table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.abc-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.abc-table tr:last-child td { border-bottom: none; }

.abc-table__product-name  { font-weight: 500; color: var(--color-text); }
.abc-table__product-code  { font-size: 0.75rem; color: var(--color-text-secondary); }
.abc-table__number        { text-align: right; }
.abc-table__cumulative    { text-align: right; color: var(--color-text-secondary); }

/* ===== SORTABLE TABLE HEADERS ===== */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sortable-th:hover { color: var(--color-primary); }
.sortable-th--active { color: var(--color-primary); }

/* ===== SPECIAL REQUESTS FORM ===== */
.request-form { max-width: 640px; }
.request-form #req-notes { width: 100%; box-sizing: border-box; }

.request-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.request-line__product { flex: 1; min-width: 0; }
.request-line__product .ts-wrapper { width: 100%; }
.request-line__product .ts-control { padding: 6px 10px !important; min-height: unset !important; border: 1.5px solid var(--color-border) !important; border-radius: var(--radius-sm) !important; background: var(--bg-2) !important; color: var(--text-1) !important; box-sizing: border-box !important; }
.ts-dropdown { z-index: 400 !important; }
.request-line__qty { width: 88px; flex-shrink: 0; }
.request-line__qty .table-input { width: 100%; box-sizing: border-box; }
.request-line__remove { flex-shrink: 0; }

.request-line--header { margin-bottom: 2px; }
.request-line--header div { font-size: 12px; font-weight: 500; color: var(--color-text-secondary); }

/* ── Scorecard ───────────────────────────────────────────────────────────── */
.scorecard-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
}
.scorecard-toolbar #branch-switcher-root .page-branch-switcher {
  margin: 0;
}
.scorecard-toolbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}
.scorecard-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.scorecard-preset {
  padding: 5px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text-1);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.scorecard-preset:hover {
  background: var(--bg-3);
  border-color: var(--border-2);
}
.scorecard-preset.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-0);
}
.scorecard-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.scorecard-range .table-input {
  width: 140px;
}
.scorecard-range__sep {
  color: #9ca3af;
  font-size: 14px;
}
@media (max-width: 600px) {
  .scorecard-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .scorecard-toolbar #branch-switcher-root .page-branch-switcher {
    width: 100%;
  }
  .scorecard-toolbar #branch-switcher-root .page-branch-switcher__select {
    flex: 1;
    min-width: 0;
    width: 100%;
  }
  .scorecard-toolbar__right {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .scorecard-presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .scorecard-preset {
    text-align: center;
  }
  .scorecard-range {
    margin-left: 0;
    justify-content: stretch;
  }
  .scorecard-range .table-input {
    flex: 1;
    min-width: 0;
    width: auto;
  }
  .scorecard-range__sep {
    flex-shrink: 0;
  }
  .scorecard-range .btn {
    white-space: nowrap;
  }
}
.scorecard-section {
  margin-bottom: 40px;
}
.scorecard-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.scorecard-kpi-row .kpi-tile {
  flex: 1 1 160px;
  min-width: 140px;
}
.scorecard-chart-wrapper {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  max-width: 800px;
}
#sbi-table-wrapper,
#health-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.scorecard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 480px;
}
.scorecard-table th,
.scorecard-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.scorecard-table th {
  background: var(--bg-3);
  font-weight: 500;
  color: var(--text-2);
}
.scorecard-ontime-yes { color: #16a34a; font-weight: 500; }
.scorecard-ontime-no  { color: #dc2626; font-weight: 500; }
.scorecard-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}
/* ===== BRAND OVERVIEW ===== */
.brand-search-row {
  margin-bottom: 16px;
}
.brand-search-row .table-input {
  width: 260px;
}
.brand-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.brand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 600px;
}
.brand-table th {
  background: var(--bg-3);
  font-weight: 500;
  color: var(--text-2);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.brand-table th.sortable { cursor: pointer; }
.brand-table th.sortable:hover { background: var(--bg-3); }
.brand-table th .sort-arrow { margin-left: 4px; color: #9ca3af; font-size: 11px; }
.brand-table th.sort-asc .sort-arrow::after  { content: '▲'; color: var(--text-1); }
.brand-table th.sort-desc .sort-arrow::after { content: '▼'; color: var(--text-1); }
.brand-table th:not(.sort-asc):not(.sort-desc) .sort-arrow::after { content: '↕'; }
.brand-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.brand-table tr.brand-row { cursor: pointer; }
.brand-table tr.brand-row:hover td { background: var(--bg-3); }
.brand-table tr.brand-row.is-open td { background: #f0f9ff; border-bottom-color: transparent; }
/* Sub-table row */
.brand-table tr.brand-subtable-row td {
  padding: 0;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}
.brand-subtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.brand-subtable th {
  background: #e0f2fe;
  font-weight: 500;
  color: #0369a1;
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid #bae6fd;
}
.brand-subtable td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.brand-subtable tr:last-child td { border-bottom: none; }
.brand-expand-icon { margin-right: 8px; font-size: 11px; color: var(--text-3); display: inline-block; width: 12px; }
.brand-health-good  { color: #16a34a; font-weight: 500; }
.brand-health-mid   { color: #d97706; font-weight: 500; }
.brand-health-bad   { color: #dc2626; font-weight: 500; }
@media (max-width: 600px) {
  .brand-search-row input { max-width: 100% !important; width: 100%; }
}

/* ─── Physical Count page ──────────────────────────────────────── */
.pc-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.pc-sticky-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pc-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pc-filter-search {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}
.pc-filter-dropdown { position: relative; }
.pc-filter-btn.active {
  border-color: #6366f1;
  color: #6366f1;
}
.pc-filter-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  padding: 8px;
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
}
.pc-filter-bulk-actions {
  display: flex;
  gap: 6px;
  padding: 0 2px 6px;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 4px;
}
.pc-filter-bulk-btn {
  flex: 1;
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.pc-filter-bulk-btn:hover { background: var(--bg-3); }

.pc-filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  cursor: pointer;
  font-size: 13px;
  border-radius: 4px;
}
.pc-filter-option:hover { background: var(--bg-3); }
.pc-row--moved { background: #fffbeb; }
.pc-count-input--variance { border-color: #f59e0b !important; background: #fffbeb; }
.pc-variance-chip {
  font-size: 12px;
  font-weight: 500;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 2px 10px;
  white-space: nowrap;
}
.pc-product-name {
  display: block;
  font-weight: 500;
}
.pc-item-code {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 1px;
}
.pc-category-inline {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 1px;
}
.pc-move-chip {
  display: block;
  font-size: 11px;
  color: #b45309;
  background: #fef3c7;
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 3px;
  font-weight: normal;
  width: fit-content;
}
.pc-row--zero td {
  color: #9ca3af;
}
.pc-row--zero .pc-product-name {
  color: #9ca3af;
}
.pc-submit-meta {
  font-size: 13px;
  color: var(--text-3);
  flex-shrink: 0;
}
.pc-sticky-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pc-return-panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.pc-return-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.pc-return-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pc-return-row .table-input { flex: 1; }
.pc-autosave-status {
  font-size: 13px;
  color: #9ca3af;
  min-height: 1em;
}
.pc-autosave-status--saved { color: #16a34a; }
.pc-autosave-status--error { color: #dc2626; }
.pc-status-banner {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}
.pc-status-banner--pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pc-status-banner--approved {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.pc-status-banner--rejected {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.pc-status-message {
  color: var(--text-3);
  font-size: 14px;
  padding: 24px 0;
}
.pc-empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 0;
}
.pc-workflow-note {
  font-size: 13px;
  color: var(--text-3);
  max-width: 520px;
  line-height: 1.55;
  margin: 0;
}
.pc-table-wrapper { }
.pc-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; }
.pc-table thead { position: sticky; top: 0; background: var(--bg-1); z-index: 1; box-shadow: 0 2px 0 var(--border); }
.pc-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  white-space: nowrap;
}
.pc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
  color: var(--text-1);
}
.pc-table tbody tr:hover { background: var(--bg-3); }
.pc-table tbody tr.pc-row--moved:hover { background: #fef9e7; }
.pc-table tbody tr:last-child td { border-bottom: none; }
/* Desktop column widths: Product | Item Code | Category | Stock | Count | Remarks */
.pc-table th:nth-child(1), .pc-table td:nth-child(1) { width: auto; }
.pc-table th:nth-child(2), .pc-table td:nth-child(2) { width: 90px; }
.pc-table th:nth-child(3), .pc-table td:nth-child(3) { width: 120px; }
.pc-table th:nth-child(4), .pc-table td:nth-child(4) { width: 110px; }
.pc-table th:nth-child(5), .pc-table td:nth-child(5) { width: 110px; }
.pc-table th:nth-child(6), .pc-table td:nth-child(6) { width: 200px; }
.pc-table .pc-count-input   { width: 80px; }
.pc-table .pc-remarks-input { width: 100%; }
/* Desktop-only inline spans not needed — data is in separate columns */
.pc-stock-mobile    { display: none; }
.pc-category-inline { display: none; }
.pc-item-code       { display: none; }

@media (max-width: 640px) {
  .pc-table thead { display: none; }

  .pc-table tbody tr {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
  }
  .pc-table tbody tr.pc-row--moved { background: #fffbeb; border-left: 3px solid #fcd34d; }
  .pc-table tbody tr.pc-row--zero  { background: var(--bg-3); }
  .pc-table tbody tr:last-child     { border-bottom: none; }

  .pc-table td             { display: block; padding: 0; border: none; }
  .pc-table .pc-col-desktop { display: none; }
  .pc-table td.pc-col-stock { display: none; }

  /* Left column: product + remarks stacked */
  .pc-table td:nth-child(1) { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
  .pc-table .pc-product-name { font-size: 12px; font-weight: 500; display: block; white-space: normal; word-break: break-word; }
  .pc-table td.pc-col-remarks { flex: 1; min-width: 0; display: flex; align-items: center; }
  .pc-table .pc-remarks-input { width: 100%; font-size: 13px; }

  /* Movement chip */
  .pc-move-chip { display: inline; font-size: 11px; background: none; padding: 0; color: #b45309; margin-top: 0; width: auto; }
  .pc-move-chip::before { content: ' · '; color: var(--border-2); }

  /* Right column: sys stock label above count input — always last */
  .pc-table td.pc-count-cell { order: 99; flex-shrink: 0; width: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
  .pc-stock-mobile           { display: block; font-size: 10px; color: #9ca3af; text-align: center; }
  .pc-table .pc-count-input  { width: 72px; font-size: 16px; padding: 6px 4px; text-align: center; }
}
.pc-audit-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 0;
}
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 0 8px;
}

.inv-movement-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  margin-left: 4px;
}
.inv-movement-chip--dispatched {
  background: #eff6ff;
  color: #2563eb;
}

/* ── Product History Redesign ─────────────────────────────────── */
.ph-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ph-tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.ph-tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ph-tab:hover { color: var(--text-2); }
.ph-tab--active { color: var(--text-1); border-bottom-color: var(--text-1); }

.ph-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.ph-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ph-filter-group--pills {
  flex: 1;
}
.ph-filter-break { flex-basis: 100%; height: 0; margin: 0; padding: 0; }
.ph-custom-link {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.ph-custom-link:hover { color: #1d4ed8; }
.ph-date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.ph-date-input { width: 130px; font-size: 13px; }
.ph-range-sep { color: var(--text-3); font-size: 14px; }
.ph-month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ph-month-btn {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
}
.ph-month-btn:hover { background: var(--bg-3); }
.ph-month-display {
  font-size: 14px;
  font-weight: 500;
  min-width: 110px;
  text-align: center;
  color: var(--text-1);
}
.ph-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ph-pill {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}
.ph-pill--active {
  background: var(--accent);
  color: var(--color-primary-text);
  border-color: var(--accent);
}
/* ── Branch multi-select dropdown ───────────────────────────── */
.ph-branch-dropdown { position: relative; }
.ph-branch-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-1);
  cursor: pointer;
  min-width: 160px;
  white-space: nowrap;
}
.ph-branch-btn:hover { border-color: #9ca3af; }
.ph-branch-btn-arrow { margin-left: auto; font-size: 10px; color: #9ca3af; }
.ph-branch-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 100;
  padding: 6px 0;
}
.ph-branch-panel[hidden] { display: none; }
.ph-branch-panel-actions {
  display: flex;
  gap: 12px;
  padding: 6px 12px 8px;
  border-bottom: 1px solid #f3f4f6;
}
.ph-branch-action {
  font-size: 12px;
  color: #6366f1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.ph-branch-action:hover { text-decoration: underline; }
.ph-branch-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}
.ph-branch-option:hover { background: var(--bg-3); }
.ph-branch-option input[type="checkbox"] { cursor: pointer; }

.ph-export-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ph-export-label {
  font-size: 12px;
  color: var(--text-3);
  flex: 1;
}
.ph-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ph-summary-table thead th {
  padding: 8px 10px;
  background: var(--bg-3);
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  white-space: nowrap;
}
.ph-summary-table thead th.right { text-align: right; }
.ph-summary-table thead th.left  { text-align: left; }
.ph-summary-row td {
  padding: 9px 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.ph-summary-row:hover td { background: var(--bg-3); cursor: pointer; }
.ph-summary-row--expanded td { background: #f0f9ff; }
.ph-product-name { font-weight: 500; color: var(--text-1); }
.ph-expand-icon { color: #9ca3af; font-size: 11px; transition: transform 0.15s; }
.ph-expand-icon--open { transform: rotate(90deg); }
/* Detail rows use real <td> cells — same columns as summary, so numbers align exactly */
.ph-detail-td {
  padding: 6px 10px;
  border-bottom: 1px solid #f0f2f4;
  background: #f8fafc;
  font-size: 12px;
  color: var(--text-2);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.ph-detail-td--indent { width: 32px; }
.ph-detail-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ph-detail-date { color: var(--text-3); white-space: nowrap; min-width: 84px; }
.ph-detail-ref  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ph-detail-balance { font-weight: 500; color: var(--text-1); }
.ph-detail-row:last-child .ph-detail-td { border-bottom: 2px solid var(--border); }
.ph-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.ph-badge--delivery,
.ph-badge--usage,
.ph-badge--transfer_in,
.ph-badge--transfer_out,
.ph-badge--pullout      { background: var(--accent-dim); color: var(--accent); }
.ph-badge--po           { background: var(--bg-3); color: var(--text-2); }
.ph-totals-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-2);
}
.ph-totals-item { white-space: nowrap; }
.ph-totals-sep  { color: var(--border-2); }
.ph-totals-row td {
  padding: 9px 10px;
  font-weight: 500;
  font-size: 13px;
  border-top: 2px solid var(--border);
  background: var(--bg-3);
}
.ph-net--positive { color: #16a34a; }
.ph-net--negative { color: #dc2626; }
.ph-cost--positive { color: #16a34a; }
.ph-cost--negative { color: #dc2626; }
.right { text-align: right; }

/* ── Inventory toast ── */
.inv-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d4ed8;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: fadeInUp 0.2s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Replenishment queue cards ── */
.queue-branch-card {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.queue-branch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--bg-3);
  user-select: none;
  transition: background .12s;
}
.queue-branch-header:hover { background: var(--bg-4); }
.queue-branch-name { font-weight: 700; font-size: 14px; color: var(--text-1); }
.queue-expand-icon { color: var(--text-3); flex-shrink: 0; display: flex; }
.queue-branch-body { padding: 12px 16px 16px; }

/* ── Queue branch summary span ── */
.queue-branch-summary {
  font-size: 12px;
  color: var(--text-3);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Mobile responsiveness ── */
@media (max-width: 768px) {
  .col-mobile-hide { display: none; }

  .ul-section { padding: 14px 12px; }

  .ul-section-header { flex-wrap: wrap; gap: 6px; }

  .queue-branch-header { flex-wrap: wrap; }
  .queue-branch-summary {
    flex-basis: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    order: 10;
  }

  #po-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  #po-filter-bar input,
  #po-filter-bar button { width: 100%; }

  .page-header { flex-wrap: wrap; gap: 8px; }
  .page-header > div { flex-wrap: wrap; }

  /* ── Card-table pattern ── */
  .data-table--mobile-cards,
  .data-table--mobile-cards tbody { display: block; }

  .data-table--mobile-cards thead { display: none; }

  .data-table--mobile-cards tbody tr:not(.request-detail-row) {
    display: block;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--bg-2);
  }
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border: none;
    font-size: 13px;
    text-align: left;
  }
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td + td {
    border-top: 1px solid #f3f4f6;
  }
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    padding-top: 2px;
    min-width: 72px;
  }
  /* Action cell — no label, full-width button row */
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td[data-label=""] {
    justify-content: flex-end;
    padding-top: 10px;
    gap: 6px;
  }
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td[data-label=""]::before {
    display: none;
  }
  /* First cell = card title (no label, full width, bold) */
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td:first-child {
    justify-content: flex-start;
    font-size: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border) !important;
    border-top: none !important;
  }
  .data-table--mobile-cards tbody tr:not(.request-detail-row) td:first-child::before {
    display: none;
  }

  /* Detail expand rows stay as scrollable block */
  .data-table--mobile-cards .request-detail-row { display: block; margin-bottom: 8px; }
  .data-table--mobile-cards .request-detail-row > td { display: block; padding: 0 0 8px; }

  .log-search { width: 100%; box-sizing: border-box; }
}

/* ─── Replenishment Queue table ──────────────────────────────────────────── */
.rq-table-wrap { padding: 16px 0 40px; }

.rq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rq-th {
  position: sticky;
  top: var(--rq-thead-top, 50px);
  z-index: 5;
  background: var(--bg-1);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.rq-th--left   { text-align: left; }
.rq-th--center { text-align: center; }

.rq-group-row td {
  padding: 24px 12px 6px;
  background: var(--bg-1);
  border-top: 2px solid var(--border);
}
.rq-group-row--first td { border-top: none; padding-top: 0; }

.rq-group-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.rq-group-meta {
  float: right;
  font-size: 11px;
  color: var(--text-4);
}

.rq-data-row td {
  padding: 10px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.rq-data-row:last-of-type td { border-bottom: none; }

.rq-cell-product { font-size: 13px; color: var(--text-1); }
.rq-cell-sku     { font-size: 11px; color: var(--text-4); white-space: nowrap; }
.rq-cell-num     { text-align: center; }
.rq-cell-need    { font-weight: 600; color: #dc2626; }
.rq-cell-mdse    { color: var(--text-3); }
.rq-cell-pending { color: #d97706; font-weight: 500; }
.rq-cell-nil     { color: var(--text-4); }

/* ─── Compact inventory table (branch-columns toggle OFF) ─────────────────────
   Uses real horizontal columns instead of vertical stacks. Inputs render
   borderless by default so the table reads as data, not a form. */
.inv-table--compact {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}
.inv-table--compact thead th {
  padding: 11px 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.inv-table--compact thead th.right { text-align: right; }
.inv-table--compact tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-3);
  font-size: 13px;
}
.inv-table--compact tbody tr:hover td { background: var(--bg-3); }
.inv-table--compact tbody tr:hover td.inv-c-name { background: var(--bg-3); }
.inv-table--compact .right { text-align: right; }

/* Column widths — Product cell carries name + supplier·handler + remark stacked. */
.inv-table--compact .inv-c-code     { width: 180px; min-width: 170px; }
.inv-table--compact .inv-c-name     { width: auto; }
.inv-table--compact .inv-c-price    { width: 10%; min-width: 100px; text-align: right; }
.inv-table--compact .inv-c-status   { width: 80px; text-align: center; }
.inv-table--compact thead th.inv-c-status { text-align: center; }
.inv-table--compact .inv-c-actions  { width: 44px; text-align: center; }
.inv-table--compact thead th.inv-c-actions { text-align: center; }
.inv-table--compact tbody td:first-child { padding-left: 32px; }
.inv-table--compact thead th:first-child { padding-left: 32px; }
.inv-table--compact tbody td { vertical-align: top; }

/* Item-code column — mono, primary identifier */
.inv-table--compact .inv-c-code__input,
.inv-table--compact .inv-c-code__ro {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-2);
}

/* Product cell stacks: name (primary) + supplier·handler meta + remark badge */
.inv-table--compact .inv-c-name__meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.2;
  flex-wrap: wrap;
}
.inv-table--compact .inv-c-name__slot { display: inline-flex; align-items: center; max-width: 100%; min-width: 0; }
.inv-table--compact .inv-c-name__slot select,
.inv-table--compact .inv-c-name__slot input {
  font-size: 11.5px;
  padding: 1px 4px;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  color: var(--text-3);
  max-width: 100%;
  width: auto;
}
.inv-table--compact .inv-c-name__slot .inv-ro-text {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}
.inv-table--compact .inv-c-name__sep { color: var(--text-4); }
.inv-table--compact .inv-c-name__remark { margin-top: 4px; line-height: 1; }
.inv-table--compact .inv-c-name__remark select.table-input { font-size: 11.5px; padding: 2px 6px; max-width: 240px; }

/* Add-remark inline link — hidden until row hover so empty rows feel quiet. */
.inv-c-name__remark--empty { opacity: 0; transition: opacity .12s; }
.inv-table--compact tbody tr:hover .inv-c-name__remark--empty { opacity: 1; }
.inv-add-remark-btn {
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1.4;
}
.inv-add-remark-btn:hover { color: var(--text-1); border-color: var(--border-3); background: var(--bg-2); }

/* Name / code stack inside the Product cell */
.inv-table--compact .inv-c-name__name,
.inv-table--compact .inv-c-name__name-ro {
  display: block;
  width: 100%;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-1);
  line-height: 1.3;
}
.inv-table--compact .inv-c-name__code,
.inv-table--compact .inv-c-name__code-ro {
  display: block;
  width: 100%;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.2;
}

/* Read-only by default: borderless inputs/selects that wake up on hover/focus */
.inv-table--compact input.table-input,
.inv-table--compact select.table-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-1);
  transition: border-color .12s, background .12s;
}
.inv-table--compact .inv-c-price input { text-align: right; font-variant-numeric: tabular-nums; }
.inv-table--compact tbody tr:hover input.table-input:not(:focus),
.inv-table--compact tbody tr:hover select.table-input:not(:focus) {
  border-color: var(--border-2);
}
.inv-table--compact input.table-input:focus,
.inv-table--compact select.table-input:focus {
  border-color: var(--text-2);
  background: var(--bg-1);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

/* ─── Delivery Receipts list table (stock + retail share these classes) ─── */
.dr-table thead th,
.dr-table tbody td { vertical-align: middle; font-size: 13px; }
.dr-table thead th.right { text-align: right; }
.dr-table .dr-col-no       { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 110px; }
.dr-table .dr-col-refs     { white-space: nowrap; min-width: 130px; }
.dr-table .dr-col-refs .dr-ref-po { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.dr-table .dr-col-refs .dr-ref-so { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--text-3); margin-top: 1px; }
.dr-table .dr-col-branch   { min-width: 140px; max-width: 200px; }
.dr-table .dr-col-date     { white-space: nowrap; min-width: 110px; color: var(--text-2); }
.dr-table .dr-col-date .dr-confirmer { font-size: 11px; color: var(--text-3); margin-top: 2px; white-space: normal; line-height: 1.2; }
.dr-table .dr-col-total    { white-space: nowrap; min-width: 100px; font-variant-numeric: tabular-nums; }
.dr-table .dr-col-status   { white-space: nowrap; min-width: 90px; }
.dr-table .dr-col-actions  { white-space: nowrap; text-align: right; }
.dr-table .dr-col-actions .btn + .btn { margin-left: 4px; }

/* Filter bar inside the DR list section — keep controls on one row when they
   fit, wrap gracefully otherwise. */
.dr-table-wrap .ul-section-header { gap: 8px; }
.dr-table-wrap .ul-section-header > div { flex-shrink: 1; }

/* Inline loading state for the branch-columns toggle: button shows a spinner,
   the table dims so the user gets visible feedback during the re-render. */
.btn-loading {
  position: relative;
  padding-left: 26px !important;
  pointer-events: none;
  opacity: 0.85;
}
.btn-loading::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: btn-loading-spin .7s linear infinite;
}
@keyframes btn-loading-spin { to { transform: rotate(360deg); } }

.inv-table--loading { opacity: 0.55; pointer-events: none; transition: opacity .15s; }

/* Status pill */
.inv-status-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.inv-status-pill--active   { background: var(--bg-3); color: var(--text-2); }
.inv-status-pill--inactive { background: #fee2e2; color: #991b1b; }
.inv-status-pill--noninv   { background: #fef3c7; color: #92400e; margin-left: 4px; }

/* Retail Products — VAT-inclusive captions and modal hint */
.rp-vat-incl {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 1px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.rp-vat-incl__label { font-size: 9.5px; opacity: 0.8; }
.rp-th-sub {
  display: block;
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--text-4);
  margin-top: 2px;
}
.rp-vat-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.rp-vat-hint strong { color: var(--text-1); font-weight: 600; }
.rp-vat-exempt-cap {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
  background: #fef3c7;
  display: inline-block;
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 999px;
}
.rp-desc-name { font-weight: 500; color: var(--text-1); line-height: 1.3; }
.rp-desc-meta { margin-top: 2px; font-size: 11.5px; color: var(--text-3); line-height: 1.2; }
.rp-desc-meta-sep { color: var(--text-4); margin: 0 2px; }
.rp-desc-remark { margin-top: 4px; line-height: 1; }

/* Row-action button (Deactivate/Reactivate) — always visible, subdued by default,
   wakes up on row hover. */
.inv-row-action {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity .12s, background .12s, border-color .12s, color .12s;
  font-size: 18px;
  color: var(--text-3);
  line-height: 1;
}
.inv-table--compact tbody tr:hover .inv-row-action { opacity: 1; color: var(--text-2); }
.inv-row-action:hover {
  opacity: 1;
  background: var(--bg-2);
  border-color: var(--border-2);
  color: #b91c1c; /* hint of danger */
}
.inv-row-action:focus { opacity: 1; outline: none; box-shadow: 0 0 0 3px rgba(185,28,28,0.15); }
