/* ============================================
   BUSCO DEALER PORTAL - MAIN STYLESHEET
   ============================================ 
   
   🎨 COLOR SCHEME CONFIGURATION
   To match tpsv1.com, update the CSS variables below with exact hex codes:
   
   1. Visit tpsv1.com
   2. Use browser DevTools (F12) or a color picker extension
   3. Extract these colors:
      - Primary (main navigation/header background)
      - Primary-light (hover states, highlights)
      - Primary-dark (sidebar, footer)
      - Accent (buttons, CTAs, important actions)
      - Accent-light (button hovers)
   4. Replace the hex values in the :root section below
   
   ============================================ */

:root {
  /* TPSV1.COM Color Scheme - Matched to Premium Transportation Solutions branding */
  --primary: #000000;           /* Pure black - main backgrounds */
  --primary-light: #1a1a1a;     /* Very dark gray - hover states */
  --primary-dark: #000000;      /* Pure black - emphasized areas */
  --accent: #FF6600;            /* Bright orange - CTA buttons & highlights */
  --accent-light: #FF7A1F;      /* Lighter orange - button hovers */
  
  /* System colors - typically standard across portals */
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #FF6600;           /* Using brand orange for warnings */
  --warning-light: #FFE6D5;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0284c7;              /* Blue for informational badges/messages */
  --info-light: #e0f2fe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #3A3A3A;          /* Dark gray from tpsv1.com headers */
  --gray-800: #2a2a2a;
  --gray-900: #1a1a1a;
  --white: #ffffff;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 56px;
  --header-height: 64px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.15);
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0a0a;          /* Very dark background like tpsv1.com */
  color: #e5e5e5;               /* Light gray text on dark */
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- TYPOGRAPHY ---- */
h1 { font-size: 1.75rem; font-weight: 700; color: #ffffff; }
h2 { font-size: 1.375rem; font-weight: 600; color: #ffffff; }
h3 { font-size: 1.125rem; font-weight: 600; color: #ffffff; }
h4 { font-size: 1rem; font-weight: 600; color: #ffffff; }
p { color: #b0b0b0; }

/* ---- LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- iOS PWA SAFE AREA ----
   When running as a standalone PWA on iPhone/iPad with viewport-fit=cover,
   the status bar overlaps the top of the UI. env(safe-area-inset-top)
   gives us the exact pixel height of the notch/status bar so we can
   push the header and sidebar down by exactly that amount.
   On Android and desktop this value is 0, so there is no visual change. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

.sidebar {
  width: var(--sidebar-width);
  background: #000000;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
  border-right: 1px solid #1a1a1a;
  padding-top: var(--safe-top);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;        /* allow flex children to shrink below their natural size */
  /* overflow intentionally NOT set — let the sidebar's own width clip content.
     overflow:hidden here would clip the pin button when img has flex:1. */
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: #FF6600;          /* Bright orange from tpsv1.com */
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-logo h1 {
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo span {
  color: var(--gray-400);
  font-size: 0.7rem;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1 1 0;
  min-height: 0;
  padding: 16px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #FF6600 #1a1a1a;
}
.sidebar-nav::-webkit-scrollbar {
  width: 8px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: #1a1a1a;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: #FF6600;
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: #ff8533;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gray-500);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: #b0b0b0;               /* Medium gray text */
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: #1a1a1a;
  color: #ffffff;
}

.nav-item.active {
  background: rgba(255,102,0,0.15);  /* Orange tint */
  color: #ffffff;
  border-left-color: #FF6600;        /* Bright orange accent */
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ---- SIDEBAR COLLAPSIBLE SECTIONS ---- */

/* Chevron icon on nav items that have sub-tabs */
.nav-item .nav-chevron {
  margin-left: auto;
  font-size: 0.7rem;
  color: #555;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.nav-item.expanded .nav-chevron {
  transform: rotate(90deg);
  color: #FF6600;
}

/* Sub-nav container — hidden by default, slides open */
.nav-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  background: #050505;
  border-left: 2px solid #1a1a1a;
  margin-left: 0;
}
.nav-sub.open {
  max-height: 600px; /* large enough for any tab list */
}

/* Individual sub-nav tab buttons */
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 36px;
  color: #888;
  font-size: 0.8rem;
  font-weight: 400;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: var(--transition);
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-sub-item:hover {
  background: #111;
  color: #ddd;
}
.nav-sub-item.active {
  color: #FF6600;
  background: rgba(255,102,0,0.08);
  border-left-color: #FF6600;
  font-weight: 500;
}
.nav-sub-item .sub-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #1a1a1a;
  flex-shrink: 0;               /* Never compress — always visible at bottom */
  background: #000000;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #FF6600;          /* Bright orange avatar */
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name { color: white; font-weight: 600; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { color: var(--gray-400); font-size: 0.7rem; }

.btn-logout {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
  font-size: 16px;
}
.btn-logout:hover { color: var(--danger); }

/* ---- SIDEBAR PIN BUTTON ---- */
.sidebar-pin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;    /* never squish below this */
  background: none;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;     /* NEVER let flex shrink this button out of view */
  margin-left: auto;
  transition: color 0.2s, border-color 0.2s, background 0.2s, opacity 0.2s;
}
.sidebar-pin-btn:hover {
  color: #FF6600;
  border-color: #FF6600;
  background: rgba(255,102,0,0.08);
}
.sidebar-pin-btn.pinned {
  color: #FF6600;
  border-color: #FF6600;
  background: rgba(255,102,0,0.15);
}
/* v912: Explicit rule — pin button is ALWAYS visible when sidebar is pinned open (not collapsed) */
.sidebar:not(.collapsed) .sidebar-pin-btn {
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COLLAPSIBLE SIDEBAR  (v908 rewrite)
   ───────────────────────────────────────────────────────────────────────────
   COLLAPSED (default): sidebar is --sidebar-collapsed-width (56px) wide.
     • The sidebar itself stays overflow:hidden so nothing leaks out.
     • On hover the sidebar expands to full width and floats above content.
     • Labels / chevrons / user info fade out via opacity (NOT width:0) so
       the layout never breaks and scroll always works.
   PINNED: sidebar stays at full --sidebar-width permanently.
     • Pin button is always clickable so the user can always toggle.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Base sidebar width transition — applies to both collapsed and pinned states */
.sidebar {
  transition: width 0.22s ease, box-shadow 0.22s ease;
}

/* ── COLLAPSED STATE ── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  /* overflow stays hidden — no overflow:visible hackery */
}

/* Hover: sidebar floats over content at full width */
.sidebar.collapsed:hover,
.sidebar.collapsed:focus-within {
  width: var(--sidebar-width);
  z-index: 101;
  box-shadow: 4px 0 24px rgba(0,0,0,0.7);
}

/* Logo area when collapsed: tight padding, clip the image but keep pin button */
.sidebar.collapsed .sidebar-logo {
  padding: 14px 8px;
}
.sidebar.collapsed:hover .sidebar-logo,
.sidebar.collapsed:focus-within .sidebar-logo {
  padding: 20px 20px 16px;
}

/* Pin button: invisible when collapsed+not-hovered, visible when hovered */
.sidebar.collapsed:not(:hover):not(:focus-within) .sidebar-pin-btn {
  opacity: 0;
  pointer-events: none;
}
.sidebar.collapsed:hover .sidebar-pin-btn,
.sidebar.collapsed:focus-within .sidebar-pin-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Labels / chevrons / user text / logout: fade out via opacity only.
   Using opacity instead of width:0 keeps flex layout intact so nav
   items can still be hovered and scroll always works. */
.sidebar.collapsed:not(:hover):not(:focus-within) .nav-section-label,
.sidebar.collapsed:not(:hover):not(:focus-within) .nav-item > span:not(.nav-icon),
.sidebar.collapsed:not(:hover):not(:focus-within) .nav-item .nav-chevron,
.sidebar.collapsed:not(:hover):not(:focus-within) .nav-sub,
.sidebar.collapsed:not(:hover):not(:focus-within) .user-info,
.sidebar.collapsed:not(:hover):not(:focus-within) .btn-logout {
  opacity: 0;
  pointer-events: none;
  /* overflow:hidden clips text that wraps when narrow */
  overflow: hidden;
  /* max-width:0 collapses the text without breaking flex height */
  max-width: 0;
  white-space: nowrap;
}

/* Restore text when hovered/focus-within */
.sidebar.collapsed:hover .nav-section-label,
.sidebar.collapsed:hover .nav-item > span:not(.nav-icon),
.sidebar.collapsed:hover .nav-item .nav-chevron,
.sidebar.collapsed:hover .nav-sub.open,
.sidebar.collapsed:hover .user-info,
.sidebar.collapsed:hover .btn-logout,
.sidebar.collapsed:focus-within .nav-section-label,
.sidebar.collapsed:focus-within .nav-item > span:not(.nav-icon),
.sidebar.collapsed:focus-within .nav-item .nav-chevron,
.sidebar.collapsed:focus-within .nav-sub.open,
.sidebar.collapsed:focus-within .user-info,
.sidebar.collapsed:focus-within .btn-logout {
  opacity: 1;
  pointer-events: auto;
  overflow: visible;
  max-width: none;
}

/* Center the icon when collapsed + not hovered */
.sidebar.collapsed:not(:hover):not(:focus-within) .nav-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
/* Active item has border-left:3px which shifts the icon right by 3px.
   Cancel it out so all icons sit on the same column. */
.sidebar.collapsed:not(:hover):not(:focus-within) .nav-item.active {
  margin-left: -3px;
}
.sidebar.collapsed:not(:hover):not(:focus-within) .user-card {
  justify-content: center;
}

/* Higher-specificity reinforcement — beats any inherited or cascade override */
.sidebar .sidebar-nav {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* Smooth transitions for the labels fading in/out */
.sidebar .nav-item > span:not(.nav-icon),
.sidebar .nav-item .nav-chevron,
.sidebar .nav-section-label,
.sidebar .user-info,
.sidebar .btn-logout,
.sidebar-pin-btn {
  transition: opacity 0.18s ease, max-width 0.18s ease;
}

/* ── MAIN CONTENT MARGIN ── */
/* When sidebar is collapsed, shrink main-content left margin to icon-rail width */
.app-layout.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
  transition: margin-left 0.22s ease;
}
.app-layout:not(.sidebar-collapsed) .main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.22s ease;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-header {
  /* Grow the header by the status bar height so content sits below it */
  height: calc(var(--header-height) + var(--safe-top));
  background: #0a0a0a;          /* Very dark header like tpsv1.com */
  border-bottom: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  /* Top padding = status bar height; left/right = normal 28px; bottom = 0 */
  padding-top: var(--safe-top);
  padding-left: 28px;
  padding-right: 28px;
  padding-bottom: 0;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  box-sizing: border-box;
}

.page-title {
  flex: 1;
}

.page-title h2 { font-size: 1.125rem; color: #ffffff; }
.page-title p { font-size: 0.8rem; color: #b0b0b0; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.content-area {
  padding: 28px;
  padding-bottom: calc(28px + var(--safe-bottom));
  flex: 1;
}

/* ---- CARDS ---- */
.card {
  background: #1a1a1a;          /* Dark card backgrounds */
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid #2a2a2a;
  /* overflow:clip clips visually (preserves border-radius) but does NOT create
     a scroll-container, so position:sticky on thead th still works through it.
     Falls back to overflow:hidden on very old browsers — sticky broken there
     is acceptable since those browsers don't support sticky anyway. */
  overflow: clip;
}
/* Belt-and-suspenders: any card that directly wraps a table-wrapper must
   never be overflow:hidden — sticky header + filter-row break otherwise. */
.card:has(> .table-wrapper),
.card:has(> .card-header + .table-wrapper) {
  overflow: visible;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header h3 { flex: 1; font-size: 0.9rem; color: #ffffff; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; background: #141414; border-top: 1px solid #2a2a2a; }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #1a1a1a;
  border-radius: var(--border-radius-lg);
  padding: 20px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: 0 6px 20px rgba(255,102,0,0.2); transform: translateY(-1px); border-color: #FF6600; }

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-info { flex: 1; }
.stat-info .label { font-size: 0.75rem; color: #888888; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-info .value { font-size: 1.75rem; font-weight: 700; color: #ffffff; line-height: 1.2; }
.stat-info .change { font-size: 0.75rem; margin-top: 2px; }
.change.up { color: var(--success); }
.change.down { color: var(--danger); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: #FF6600; color: white; }
.btn-primary:hover { background: #FF7A1F; box-shadow: 0 4px 12px rgba(255,102,0,0.4); }
.btn-accent { background: #FF6600; color: white; }
.btn-accent:hover { background: #FF7A1F; box-shadow: 0 4px 12px rgba(255,102,0,0.4); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; border-color: #3a3a3a; color: #e5e5e5; }
.btn-outline:hover { background: #2a2a2a; border-color: #FF6600; color: #FF6600; }
.btn-ghost { background: transparent; border-color: transparent; color: #b0b0b0; }
.btn-ghost:hover { background: #2a2a2a; color: #ffffff; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 10px 22px; font-size: 0.95rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- BADGES / TAGS ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: rgba(255,102,0,0.15); color: #FF6600; border: 1px solid rgba(255,102,0,0.3); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ---- TABLES ---- */

/* ── Table panel: sticky toolbar + scrolling table body ────────────────────
   Standard page layout for every table view:

     .table-panel                 ← flex-column, fills available height
       .tf-toolbar                ← sticky at page top (below app header)
         .section-header          ← title + action buttons + search bar
         .tf-export-bar           ← row count + Export to Excel  (JS-injected)
         .tf-filter-bar           ← active-filter pills           (JS-injected)
       .table-wrapper             ← flex:1, min-height:0 → scrolls within panel

   The toolbar sticks at the viewport level (position:sticky, top=header height)
   so title, search, export button, and filter pills are all always visible.
   The .table-wrapper then holds the scrolling table; thead th / filter-row th
   are sticky within that scroll container (top:0 / top:header-row-height).
   ────────────────────────────────────────────────────────────────────────── */
.table-panel {
  display: flex;
  flex-direction: column;
  /* Grow to fill the tab panel / page-section it sits inside */
  flex: 1;
  min-height: 0;
}

/* Sticky toolbar: sticks just below the fixed app header (64px) */
.tf-toolbar {
  position: sticky;
  top: var(--header-height, 64px);
  z-index: 20;                  /* above thead th z-index:5, below modals */
  background: #0a0a0a;          /* matches body/page background */
  /* Bottom border gives a clean visual separation from the table */
  border-bottom: 1px solid #1e2a35;
  /* Small shadow so it looks raised above the scrolling rows */
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  padding: 10px 0 8px;
  /* Flex column so section-header, export-bar, filter-bar stack vertically */
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* When the toolbar is inside a .page-section, account for the section's own
   padding so it snaps cleanly to the section's visual edge. */
.page-section > .table-panel > .tf-toolbar {
  padding-left: 0;
  padding-right: 0;
}

/* The section-header inside a toolbar loses its bottom margin
   (spacing is handled by the toolbar gap). */
.tf-toolbar > .section-header,
.tf-toolbar .section-header {
  margin-bottom: 0;
}

/* Export bar and filter bar lose their own top margins inside toolbar */
.tf-toolbar > .tf-export-bar { margin-bottom: 0; }
.tf-toolbar > .tf-filter-bar { margin-bottom: 0; }

/* Table wrapper fills remaining panel height */
.table-panel > .table-wrapper {
  flex: 1;
  min-height: 0;
  /* Override the fixed max-height — panel flex layout controls the height */
  max-height: none;
}

/* When no .table-panel parent, keep the legacy standalone max-height */
.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 72vh;          /* frozen header: container scrolls, thead stays */
  border-radius: var(--border-radius);
  position: relative;        /* stacking context for sticky cells */
}

/* thead th top:0 is correct inside .table-wrapper (sticks to scroll container top).
   No change needed — existing rules already handle this. */

/* ── BOM main table ─────────────────────────────────────────────────────────
   sticky rowspan cells (BOM#, Description, Chassis, Status, Actions) require
   border-separate — border-collapse:collapse prevents position:sticky on <td>.
   border-spacing:0 keeps visual appearance identical to collapse.              */
#bom-main-table {
  border-collapse: separate;
  border-spacing: 0;
}
/* BOM main-table: header needs slightly higher z-index so rowspan sticky <td>s
   (BOM#, Description, Chassis, Status, Actions columns) don't bleed through */
#bom-main-table thead th {
  z-index: 6;                /* above global z-index:5 */
  background: #141414;
  background-color: #141414;
  border-bottom: 2px solid #2a2a2a;
  will-change: transform;
}
#bom-main-table thead tr.filter-row th {
  top: 37px;
  z-index: 5;
  background: #0a0a0a;
  background-color: #0a0a0a;
  will-change: transform;
}
/* Restore row/cell borders lost when switching away from border-collapse:collapse */
#bom-main-table tbody tr td {
  border-bottom: 1px solid #2a2a2a;
}
#bom-main-table tbody tr:last-child td {
  border-bottom: none;
}

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

thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888888;
  /* ── Fully opaque background (never rgba/transparent on a sticky cell) ── */
  background: #141414;
  background-color: #141414;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
  /* ── Sticky: sticks to the top of the scroll container ── */
  position: sticky;
  top: 0;
  z-index: 5;
  /* ── Force GPU compositing layer so the header background is ALWAYS
     painted on top of scrolling body rows — no bleed-through on any browser.
     will-change:transform promotes the element to its own compositing layer;
     isolation:isolate ensures it forms a stacking context above the tbody. */
  will-change: transform;
  isolation: isolate;
}

/* filter row (second <tr> in thead) sticks just below the column headers */
thead tr.filter-row th {
  position: sticky;
  top: 37px;   /* header row height: padding(10+10) + line-height(~17px) */
  z-index: 4;
  background: #0a0a0a;
  background-color: #0a0a0a;
  padding: 4px 6px;
  will-change: transform;
  isolation: isolate;
}

tbody tr {
  border-bottom: 1px solid #2a2a2a;
  transition: var(--transition);
}
tbody tr:hover { background: #222222; }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 11px 14px;
  color: #e5e5e5;
  vertical-align: middle;
}

td.actions { display: flex; gap: 6px; align-items: center; }

/* ── Actions column auto-sizing ─────────────────────────────────────────────
   Strategy: let the browser render the table once with table-layout:auto so
   the action column gets its natural content width, then _snapshotColumnWidths
   locks that measured px value onto the <th> style.width — after which
   table-layout:fixed uses that explicit width on every repaint.

   white-space:nowrap keeps buttons on one line so the measured width is always
   the full single-line button row. overflow:hidden (NOT visible) prevents any
   content from bleeding into the next column.
   ──────────────────────────────────────────────────────────────────────────── */
th[data-col="actions"],
th[data-col="action"] {
  min-width: 0 !important;     /* cancel the 60px floor from tf-excel-styles    */
  white-space: nowrap !important;
  overflow: hidden !important;
  padding-right: 12px;
}

td[data-col="actions"],
td[data-col="action"] {
  white-space: nowrap !important;
  overflow: hidden !important;
  padding-right: 12px;
}

/* Buttons inside action cells: keep their own labels unwrapped */
td[data-col="actions"] .btn,
td[data-col="action"]  .btn {
  white-space: nowrap !important;
  display: inline-flex;
  align-items: center;
}

/* ── Order / Quote preview tables — override dark global table styles ── */
.preview-page thead th {
  background: #fff !important;
  color: #555 !important;
  border-bottom: 2px solid #e2e8f0 !important;
}
.preview-page tbody tr {
  border-bottom: 1px solid #e2e8f0 !important;
  background: #fff !important;
}
.preview-page tbody tr:hover {
  background: #fff !important;
}
.preview-page tbody td {
  color: #1a1a1a !important;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e5e5e5;
  margin-bottom: 5px;
}
label .required { color: #FF6600; margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #ffffff;
  background: #1a1a1a;
  transition: var(--transition);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #FF6600;
  box-shadow: 0 0 0 3px rgba(255,102,0,0.15);
  background: #1a1a1a;
}

input.error, select.error { border-color: var(--danger); }
.form-hint { font-size: 0.75rem; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 4px; }

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checkbox-group input[type="checkbox"] { width: auto; cursor: pointer; }

/* ---- SEARCH BAR ---- */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-bar .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 14px;
}
.search-bar input {
  padding-left: 32px;
}

/* ---- PERMISSION HELPER — Read-Only mode ---- */
/* Elements hidden by permission-helper.js enforceReadOnly() carry this class.
   The class itself provides the hiding, making it reversible via classList.remove()
   without relying solely on inline style.display='none'. (S8 Finding 19.3) */
.perm-ro-hidden { display: none !important; }

/* ---- TABS ---- */
/* The sidebar sub-nav replaces the horizontal top-level tab bar.
   Hide the .tabs row at the page level; preserve sub-tabs inside tabs
   (e.g. Purchasing sub-tabs) which use a nested .tabs with a border style. */
.tabs {
  display: none;             /* hidden — sidebar drives top-level tab switching */
  border-bottom: 2px solid #2a2a2a;
  margin-bottom: 20px;
  gap: 0;
  flex-wrap: wrap;
}

/* Nested tabs (sub-tabs inside a tab-content, e.g. Purchasing sub-tabs)
   keep their horizontal display because they have an explicit border style. */
.tab-content .tabs,
.tab-content > .tabs {
  display: flex;
}

/* Engineering uses .tab-nav instead of .tabs — keep it hidden too */
.tab-nav {
  display: none;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #888888;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { color: #FF6600; background: rgba(255,102,0,0.05); }
.tab-btn.active {
  color: #FF6600;
  border-bottom-color: #FF6600;
  font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9999; /* v537: bumped from 200 — must exceed sandbox platform overlays (BrowserOverlay, SandboxInspect, content-80.js) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #1a1a1a;
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: none;         /* JS sets exact size — no CSS cap needed */
  max-height: none;
  height: auto;
  /* overflow must be non-visible for CSS resize handle to work */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.7);
  border: 1px solid #2a2a2a;
  transform: scale(0.95);
  transition: transform 0.2s;
  /* Allow free resizing by dragging bottom-right corner */
  resize: both;
  min-width: 320px;
  min-height: 200px;
  box-sizing: border-box;
}
.modal-overlay.open .modal { transform: scale(1); }

/* Modals open full-viewport in absolute/draggable mode.
   JS sets left/top/width/height as inline styles; this class enables
   absolute positioning and removes flex/transform constraints. */
.modal.modal-draggable {
  position: absolute;
  margin: 0;
  max-width: none !important;
  max-height: none !important;
  transform: none !important;
  transition: none;
}

.modal.modal-lg { max-width: 860px; }
.modal.modal-xl { max-width: 1100px; }

/* Full-height variant — header + footer pinned, body scrolls */
.modal.modal-fullheight {
  height: 90vh;
}

/* Drag handle cursor on modal header */
.modal-header.modal-drag-handle {
  cursor: grab;
  user-select: none;
}
.modal-header.modal-drag-handle:active {
  cursor: grabbing;
}

/* Resize corner grip indicator (visual only — actual resize via CSS resize property) */
.modal-resize-grip {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(circle, #888 1px, transparent 1px);
  background-size: 4px 4px;
  background-position: bottom right;
}
.modal:hover .modal-resize-grip { opacity: 0.75; }

/* Drag hint in header */
.modal-drag-hint {
  font-size: 0.7rem;
  color: #555;
  margin-left: auto;
  margin-right: 6px;
  letter-spacing: 0.02em;
  pointer-events: none;
  flex-shrink: 0;
}

.modal-header {
  flex-shrink: 0;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-header h3 { flex: 1; font-size: 1rem; color: #ffffff; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: #888888; font-size: 20px;
  padding: 4px; border-radius: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: #ffffff; background: #2a2a2a; }
.modal-body {
  padding: 24px;
  flex: 1 1 0;
  overflow-y: auto;
  min-height: 0;
}

/* ── Vendor Parts Catalog panel — visible scrollbar on dark background ──────
   The catalog list sits on #0a1628. Browser overlay scrollbars are nearly
   invisible on dark surfaces. This gives the scroll container a styled,
   always-visible thin scrollbar so users know the list is scrollable.       */
#po-vendor-catalog-panel .catalog-scroll {
  scrollbar-width: thin;                        /* Firefox */
  scrollbar-color: #FF6600 #0f1e2e;             /* Firefox: thumb / track */
}
#po-vendor-catalog-panel .catalog-scroll::-webkit-scrollbar {
  width: 7px;
}
#po-vendor-catalog-panel .catalog-scroll::-webkit-scrollbar-track {
  background: #0f1e2e;
  border-radius: 4px;
}
#po-vendor-catalog-panel .catalog-scroll::-webkit-scrollbar-thumb {
  background: #FF6600;
  border-radius: 4px;
}
#po-vendor-catalog-panel .catalog-scroll::-webkit-scrollbar-thumb:hover {
  background: #e65a00;
}

/* ── Modal body that contains a table with a frozen header ──────────────────
   When .modal-body is the scroll container, position:sticky on thead th is
   anchored to .modal-body's top — NOT to the .table-wrapper's top — so the
   header appears to float away from the table as you scroll.

   Fix: .modal-body--table strips the modal-body's own scroll and makes it a
   flex column so the .table-wrapper becomes the sole scroll container.
   Apply this class to any modal-body whose direct or near-direct child is a
   .table-wrapper (report modals, cycle-count history, back-order report, etc.)
   ─────────────────────────────────────────────────────────────────────────── */
.modal-body--table {
  overflow: hidden;            /* modal-body must NOT scroll */
  display: flex;
  flex-direction: column;
  padding: 0;                  /* spacing lives inside the toolbar / table */
}

/* The table-wrapper inside takes all remaining space and scrolls itself */
.modal-body--table .table-wrapper {
  flex: 1;
  min-height: 0;
  max-height: none;            /* flex layout drives height, not max-height */
  border-radius: 0;            /* full-bleed inside the modal */
}

/* Optional toolbar / filter bar that sits above the table-wrapper */
.modal-body--table .modal-table-toolbar {
  flex-shrink: 0;
  padding: 12px 20px;
  border-bottom: 1px solid #1e293b;
  background: #071020;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* Stats bar (summary row) above the table */
.modal-body--table .modal-table-stats {
  flex-shrink: 0;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: #0d1117;
  border-bottom: 1px solid #1e293b;
}

/* Padding wrapper (used when table needs a content-padded container) */
.modal-body--table .modal-table-pad {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 20px;
}
.modal-body--table .modal-table-pad .table-wrapper {
  flex: 1;
  min-height: 0;
  max-height: none;
}
.modal-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid #2a2a2a;
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: rgba(22,163,74,0.15); color: #86efac; border: 1px solid rgba(22,163,74,0.3); }
.alert-danger { background: rgba(220,38,38,0.15); color: #fca5a5; border: 1px solid rgba(220,38,38,0.3); }
.alert-warning { background: rgba(255,102,0,0.15); color: #FFB366; border: 1px solid rgba(255,102,0,0.3); }
.alert-info { background: rgba(255,102,0,0.15); color: #FFB366; border: 1px solid rgba(255,102,0,0.3); }

/* ---- PAGE SECTIONS ---- */
.page-section { margin-bottom: 28px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-header h3 { font-size: 1rem; color: #ffffff; }

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1a1a1a;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  border: 1px solid #2a2a2a;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  pointer-events: all;
}
.toast.success { background: var(--success); border-color: var(--success); }
.toast.error { background: var(--danger); border-color: var(--danger); }
.toast.warning { background: #FF6600; border-color: #FF6600; }

@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateX(120%); }
}

/* ---- PROGRESS BAR ---- */
.progress-bar {
  background: #2a2a2a;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 99px;
  background: #FF6600;
  transition: width 0.5s ease;
  box-shadow: 0 0 8px rgba(255,102,0,0.5);
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #888888;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h4 { color: #b0b0b0; margin-bottom: 8px; }

/* ---- GRID ---- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ---- UTILITIES ---- */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.72rem; }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mb-4 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 12px; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.nowrap { white-space: nowrap; }

/* ---- SPINNER ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid #2a2a2a;
  border-top-color: #FF6600;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- LOADING OVERLAY ---- */
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  border-radius: inherit;
}

/* ---- GLOBAL BUTTON-LOCK SCREEN ---- */
/* Shown while any async button action is processing — blocks all input */
#global-btn-lock {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99998;               /* below toast (9999) but above everything else */
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  cursor: not-allowed;
}
#global-btn-lock.active {
  display: flex;
}
#global-btn-lock .gbl-spinner {
  width: 52px; height: 52px;
  border: 5px solid rgba(255,255,255,0.15);
  border-top-color: #FF6600;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
#global-btn-lock .gbl-label {
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  opacity: 0.85;
  font-family: inherit;
}
/* Prevent accidental clicks on buttons that are "behind" the lock */
body.btn-locked button,
body.btn-locked a,
body.btn-locked input[type="submit"],
body.btn-locked input[type="button"] {
  pointer-events: none;
}

/* Per-button in-flight state — applied synchronously before async starts.
   aria-busy=true is set by the button-lock system; cursor communicates busy state
   even before the global overlay appears. */
button[aria-busy="true"],
input[type="button"][aria-busy="true"],
input[type="submit"][aria-busy="true"] {
  cursor: wait !important;
  pointer-events: none;
  opacity: 0.6;
}

/* data-no-lock buttons are always interactive */
button[data-no-lock="true"] {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  padding: 12px 0 0;
  flex-wrap: wrap;
}
.page-btn {
  width: 32px; height: 32px;
  border: 1px solid #3a3a3a;
  background: #1a1a1a;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: #e5e5e5;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.page-btn:hover { border-color: #FF6600; color: #FF6600; background: #2a2a2a; }
.page-btn.active { background: #FF6600; border-color: #FF6600; color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- HAMBURGER TOGGLE ---- */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 6px;
  transition: background 0.2s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); }
.sidebar-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: #e2e8f0;
  border-radius: 2px;
  transition: var(--transition);
}

/* Sidebar backdrop overlay */
#sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
  display: none;
}
#sidebar-overlay.active { display: block; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .sidebar-toggle { display: flex; }
}

@media (max-width: 768px) {
  .content-area { padding: 16px; padding-bottom: calc(16px + var(--safe-bottom)); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .top-header { padding: var(--safe-top) 16px 0; }

  /* ---- MODALS — full-width on small screens ---- */
  .modal-overlay { padding: 8px; }
  .modal,
  .modal.modal-lg,
  .modal.modal-xl {
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    max-height: 92vh;
    resize: none;               /* disable manual resize on touch */
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px 12px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }

  /* ---- INVENTORY — Receiving tab ---- */
  /* Search bar: let it fill the full width */
  #inv-tab-receiving .form-group { max-width: 100% !important; }

  /* ---- INVENTORY — Cycle Counts: stat cards 2-up then 1-up ---- */
  .inv-stat-row { grid-template-columns: 1fr 1fr !important; }

  /* ---- INVENTORY — Cycle Counts: action button row wraps ---- */
  .inv-cycle-actions { flex-wrap: wrap; gap: 8px; }
  /* Ensure cycle count action buttons are large enough to tap on mobile */
  #inv-tab-cycle .btn-sm { min-height: 36px; padding: 6px 10px; font-size: 0.8rem; }
  #inv-tab-cycle td:first-child { white-space: nowrap; }

  /* ---- INVENTORY — Daily Count card: stack controls ---- */
  .inv-daily-count-controls { flex-direction: column; align-items: flex-start !important; gap: 8px !important; }
  .inv-daily-count-controls select { min-width: 0; width: 100%; }

  /* ---- INVENTORY — On-Hand: header toolbar stacks ---- */
  .inv-onhand-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .inv-onhand-toolbar input[type="text"] {
    width: 100% !important;
  }
  .inv-onhand-loc-filter { flex-direction: column; align-items: flex-start !important; gap: 6px !important; }
  .inv-onhand-loc-filter select { min-width: 0; width: 100%; }
  .inv-onhand-sku-bar { margin-left: 0 !important; width: 100%; justify-content: flex-start !important; }

  /* ---- INVENTORY — Mass Count overlay ---- */
  #overlay-inv-mass-count > div { padding: 16px 12px 80px !important; }
  .inv-mc-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
  .inv-mc-info-row { flex-direction: column !important; gap: 10px !important; }
  .inv-mc-info-row .form-group { min-width: 0 !important; flex: none !important; width: 100% !important; }
  .inv-mc-actions { justify-content: stretch !important; }
  .inv-mc-actions .btn { flex: 1 1 auto; text-align: center; justify-content: center; }
  /* Override hard-coded min-width so the table doesn't force horizontal scroll */
  #inv-mass-count-table { min-width: 0 !important; }
  /* Mass count overlay — compact the Description + System Qty columns on small screens
     so they stay visible without forcing a horizontal scroll. */
  #inv-mass-count-table thead th:nth-child(3),
  #inv-mass-count-table tbody  td:nth-child(3) {
    min-width: 90px !important;
    max-width: 140px !important;
    white-space: normal !important;
    font-size: 0.72rem !important;
    padding: 4px 4px !important;
    word-break: break-word;
  }
  /* Part # input — tighten on small screens */
  #inv-mass-count-table input[id^="inv-mc-pn-"]  { width: 90px !important; }
  /* Location input — tighten on small screens */
  #inv-mass-count-table input[id^="inv-mc-loc-"] { width: 80px !important; }
  /* System Qty input — tighten */
  #inv-mass-count-table input[id^="inv-mc-sys-"] { width: 58px !important; }
  /* Counted Qty input — tighten */
  #inv-mass-count-table input[id^="inv-mc-cnt-"] { width: 64px !important; }
  /* Chassis count overlay table */
  #inv-chassis-count-entry-table { min-width: 0 !important; }

  /* ---- INVENTORY — Label Review: hide less-critical columns ---- */
  #label-review-table th:nth-child(2),
  #label-review-table td:nth-child(2),
  #label-review-table th:nth-child(3),
  #label-review-table td:nth-child(3) { display: none; }

  /* ---- INVENTORY — Receiving modal table: hide Expected Date col ---- */
  #receive-items-body tr td:nth-child(4),
  #receive-items-body tr td:nth-child(3) { display: none; }
}

/* ---- INVENTORY mobile — single column stat cards at very small screens ---- */
@media (max-width: 480px) {
  .inv-stat-row { grid-template-columns: 1fr !important; }

  /* Table font slightly smaller so more fits before horizontal scroll kicks in */
  #inv-tab-receiving table,
  #inv-tab-cycle table,
  #inv-tab-on-hand table { font-size: 0.78rem; }
  #inv-tab-receiving thead th,
  #inv-tab-cycle thead th,
  #inv-tab-on-hand thead th { padding: 8px 8px; font-size: 0.68rem; }
  #inv-tab-receiving tbody td,
  #inv-tab-cycle tbody td,
  #inv-tab-on-hand tbody td { padding: 8px 8px; }

  /* Receiving tab: hide Order Date and Total columns on very small screens */
  #inv-tab-receiving thead th:nth-child(3),
  #inv-tab-receiving tbody td:nth-child(3),
  #inv-tab-receiving thead th:nth-child(5),
  #inv-tab-receiving tbody td:nth-child(5) { display: none; }

  /* Single count table: Actions=col1, hide SysQty(5), Variance(7), CountedBy(9), Date(10) */
  #inv-tab-cycle .card:nth-of-type(1) thead th:nth-child(5),
  #inv-tab-cycle .card:nth-of-type(1) tbody td:nth-child(5),
  #inv-tab-cycle .card:nth-of-type(1) thead th:nth-child(7),
  #inv-tab-cycle .card:nth-of-type(1) tbody td:nth-child(7),
  #inv-tab-cycle .card:nth-of-type(1) thead th:nth-child(9),
  #inv-tab-cycle .card:nth-of-type(1) tbody td:nth-child(9),
  #inv-tab-cycle .card:nth-of-type(1) thead th:nth-child(10),
  #inv-tab-cycle .card:nth-of-type(1) tbody td:nth-child(10) { display: none; }
  /* Mass count table: Actions=col1, hide CountedBy(5), Notes(7) */
  #inv-tab-cycle .card:nth-of-type(2) thead th:nth-child(5),
  #inv-tab-cycle .card:nth-of-type(2) tbody td:nth-child(5),
  #inv-tab-cycle .card:nth-of-type(2) thead th:nth-child(7),
  #inv-tab-cycle .card:nth-of-type(2) tbody td:nth-child(7) { display: none; }
  /* Chassis count table: same hide pattern as mass */
  #inv-tab-cycle .card:nth-of-type(3) thead th:nth-child(5),
  #inv-tab-cycle .card:nth-of-type(3) tbody td:nth-child(5),
  #inv-tab-cycle .card:nth-of-type(3) thead th:nth-child(7),
  #inv-tab-cycle .card:nth-of-type(3) tbody td:nth-child(7) { display: none; }

  /* On-Hand: hide Print Number, UOM, Min/Max, Unit Cost, Vendor columns */
  #inv-tab-on-hand thead th:nth-child(3),
  #inv-tab-on-hand tbody td:nth-child(3),
  #inv-tab-on-hand thead th:nth-child(6),
  #inv-tab-on-hand tbody td:nth-child(6),
  #inv-tab-on-hand thead th:nth-child(10),
  #inv-tab-on-hand tbody td:nth-child(10),
  #inv-tab-on-hand thead th:nth-child(11),
  #inv-tab-on-hand tbody td:nth-child(11),
  #inv-tab-on-hand thead th:nth-child(13),
  #inv-tab-on-hand tbody td:nth-child(13) { display: none; }

  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

/* ============================================================
   INVENTORY — MOBILE-FIRST ENHANCEMENTS
   All rules are inside @media so desktop is never affected.
   ============================================================ */

/* ── Touch-target enlargement ────────────────────────────────
   Buttons inside inventory tabs need at minimum 44×44 px
   tap targets (Apple HIG / WCAG 2.5.5).                      */
@media (max-width: 1024px) {
  /* All buttons inside inventory tabs get a taller minimum */
  #inv-tab-receiving .btn,
  #inv-tab-cycle .btn,
  #inv-tab-on-hand .btn {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  /* Inputs and selects inside inventory tabs */
  #inv-tab-receiving input,
  #inv-tab-receiving select,
  #inv-tab-cycle input,
  #inv-tab-cycle select,
  #inv-tab-on-hand input,
  #inv-tab-on-hand select {
    min-height: 44px;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
  /* Modals: inputs / selects also need 44px + 16px font to stop iOS zoom */
  .modal input,
  .modal select,
  .modal textarea {
    min-height: 44px;
    font-size: 16px;
  }
  /* Mass-count overlay inputs (inline borderless style) */
  #overlay-inv-mass-count input[type="text"],
  #overlay-inv-mass-count input[type="number"] {
    min-height: 40px;
    font-size: 16px;
    padding: 6px 8px;
  }
}

/* ── Top-header: collapse header-actions items on narrow screens ── */
@media (max-width: 768px) {
  /* Hide "Refresh" text, keep icon; hide "Settings" text, keep icon;
     hide the date string to save header space                        */
  #header-date { display: none; }
  #global-refresh-btn span:last-child { display: none; }  /* "Refresh" text */
  .btn-settings .settings-icon ~ * { display: none; }     /* "Settings" text */

  /* Make header buttons icon-only and square */
  #global-refresh-btn,
  .btn-settings {
    min-width: 36px;
    padding: 6px 8px;
    justify-content: center;
  }

  /* Sign-Out button: show only icon on mobile */
  .top-header > .header-actions > button[onclick*="logout"] span:last-child { display: none; }
}

/* ── Receiving tab — card-style rows on phones ─────────────────
   At 480px the table gets tight. Give each PO its own "card row"
   by hiding less critical columns and making the Receive button
   easier to tap.                                                 */
@media (max-width: 480px) {
  /* Receiving table: hide Expected Date column entirely */
  #inv-tab-receiving thead th:nth-child(4),
  #inv-tab-receiving tbody td:nth-child(4) { display: none; }

  /* Larger Receive button */
  #inv-tab-receiving .btn-primary {
    width: 100%;
    justify-content: center;
  }

  /* Receive modal line-items table: show only Part # and Receive Now */
  #receive-items-body tr td:nth-child(2) { display: none; } /* Description already hidden */

  /* Receive qty input: full-width on phone */
  .receive-qty-input { width: 100% !important; }
}

/* ── Cycle Counts tab — mobile improvements ────────────────────
   Make status badges and action buttons easier to read/tap.     */
@media (max-width: 768px) {
  /* Single count table: stack variance + status closer */
  #inv-tab-cycle .badge { font-size: 0.72rem; padding: 4px 8px; }

  /* Mass count notes column: cap width */
  #inv-tab-cycle tbody td[style*="max-width:180px"] {
    max-width: 120px !important;
    font-size: 0.75rem;
  }

  /* Daily Count card: full-width Create button */
  .inv-daily-count-controls .btn { width: 100%; justify-content: center; }
}

/* ── Mass Count overlay — phone-optimised layout ───────────────
   The overlay is a full-page fixed element (#overlay-inv-mass-count).
   On phones we turn the count table into a card-per-row layout.   */
@media (max-width: 640px) {
  /* Overlay container padding: keep content away from the notch */
  #overlay-inv-mass-count > div {
    padding: 12px 10px 100px !important; /* extra bottom for sticky bar */
  }

  /* Header: title smaller, close button stays top-right */
  #overlay-inv-mass-count h2 { font-size: 1.1rem !important; }

  /* Card-style mass count table —
     Hide the standard table layout and render each row as a mini card.
     We do this with display:block on tbody/tr/td.                       */
  #inv-mass-count-table { display: block; min-width: 0 !important; }
  #inv-mass-count-table thead { display: none; } /* labels become pseudo-elements */
  #inv-mass-count-table tbody { display: block; }

  #inv-mass-count-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "num    del"
      "pn     loc"
      "desc   desc"
      "sys    cnt";
    gap: 4px 10px;
    background: #141414;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  /* Grid area assignments */
  #inv-mass-count-table tbody tr td:nth-child(1) { grid-area: num;  align-self: center; }
  #inv-mass-count-table tbody tr td:nth-child(2) { grid-area: pn;   }
  #inv-mass-count-table tbody tr td:nth-child(3) { grid-area: desc; }
  #inv-mass-count-table tbody tr td:nth-child(4) { grid-area: loc;  }
  #inv-mass-count-table tbody tr td:nth-child(5) { grid-area: sys;  }
  #inv-mass-count-table tbody tr td:nth-child(6) { grid-area: cnt;  }
  #inv-mass-count-table tbody tr td:nth-child(7) { grid-area: del;  text-align: right; align-self: center; }

  /* Data labels above each input (uses ::before pseudo with content from data-label) */
  #inv-mass-count-table tbody tr td:nth-child(2)::before { content: "Part #"; display: block; font-size: 0.65rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
  #inv-mass-count-table tbody tr td:nth-child(4)::before { content: "Location"; display: block; font-size: 0.65rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
  #inv-mass-count-table tbody tr td:nth-child(5)::before { content: "System Qty"; display: block; font-size: 0.65rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
  #inv-mass-count-table tbody tr td:nth-child(6)::before { content: "Counted Qty ✱"; display: block; font-size: 0.65rem; color: #0284c7; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }

  /* Inputs inside the card: full-width */
  #inv-mass-count-table tbody tr td input[type="text"],
  #inv-mass-count-table tbody tr td input[type="number"] {
    width: 100% !important;
    border: 1px solid #334155 !important;
    border-radius: 5px !important;
    padding: 6px 8px !important;
    background: #1e2a35 !important;
    font-size: 16px !important; /* prevents iOS zoom */
    min-height: 40px;
  }
  /* Counted qty input: highlight blue border */
  #inv-mass-count-table tbody tr td:nth-child(6) input {
    border-color: #0284c7 !important;
  }

  /* Actions bar: sticky at the bottom so Save/Submit always visible */
  .inv-mc-actions {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: #0d1117 !important;
    border-top: 1px solid #1e2a35 !important;
    padding: 12px 16px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    z-index: 1200 !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: stretch !important;
    margin: 0 !important;
  }
  .inv-mc-actions .btn {
    flex: 1 !important;
    justify-content: center !important;
    font-size: 0.8rem !important;
    padding: 10px 6px !important;
    min-height: 44px !important;
  }

  /* Info banner above the actions */
  #overlay-inv-mass-count > div > div[style*="rgba(234,179,8"] {
    margin-bottom: 80px !important; /* clear the sticky bar */
  }
}

/* ── On-Hand tab — search bar improvement on mobile ─────────────
   The search input and filter row already stack via the
   .inv-onhand-toolbar rule — just make sure the input is
   fully tappable and readable.                                    */
@media (max-width: 768px) {
  /* Low-stock highlight — keep it visible but smaller */
  #inv-tab-on-hand tbody tr[style*="rgba(220,38,38"] td {
    font-size: 0.78rem;
  }
}

/* ── Label review modal — compact on phone ──────────────────── */
@media (max-width: 480px) {
  /* Label review footer buttons: stack vertically */
  #modal-label-review .modal-footer {
    flex-direction: column;
    gap: 8px;
  }
  #modal-label-review .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
  /* Label table: full-width inputs */
  .label-qty-input {
    width: 100% !important;
    font-size: 16px !important;
  }
}

/* ── Single Count modals — better tap targets ───────────────── */
@media (max-width: 640px) {
  #modal-inv-cycle-count .modal-footer,
  #modal-inv-enter-count .modal-footer {
    flex-direction: column;
    gap: 8px;
  }
  #modal-inv-cycle-count .modal-footer .btn,
  #modal-inv-enter-count .modal-footer .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }
  /* Variance preview: larger font */
  #inv-count-variance-preview {
    font-size: 1rem !important;
    text-align: center;
  }
}

/* ── Safe-area insets (iOS notch / home indicator) ──────────────
   Applied globally to any sticky bottom bar and the toast.       */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .toast-container {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
  /* When the mass-count sticky bar is active, content-area needs
     extra bottom padding so the last row isn't hidden under it.  */
  @media (max-width: 640px) {
    .content-area {
      padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE TABLE FIXES  —  iOS / small-screen horizontal-scroll layout
   Problem: after _snapshotColumnWidths locks pixel widths, the total table
   width may exceed the phone viewport. Fix: let .table-wrapper scroll
   horizontally so the table keeps its full measured width.
   table-layout is NOT overridden here — _snapshotColumnWidths handles it.
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Table-wrapper: enable horizontal scroll on touch ── */
  .table-wrapper,
  .table-panel > .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
  }

  /* ── Excel table: min-width ensures it never squishes below its measured size ── */
  .excel-table {
    min-width: max-content !important;
  }

  /* ── Purchasing overlays that contain tables ── */
  #overlay-mass-count .table-wrapper,
  #overlay-mass-count > div {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Extra compactness on very small phones ── */
@media (max-width: 480px) {
  /* Slightly smaller font in excel tables so more columns are visible
     before horizontal scroll kicks in */
  .excel-table {
    font-size: 0.75rem !important;
  }
  .excel-table thead th {
    padding: 7px 8px !important;
    font-size: 0.66rem !important;
  }
  .excel-table tbody td {
    padding: 6px 8px !important;
  }

  /* Compact buttons inside table action cells on phone */
  .excel-table td[data-col="actions"] .btn,
  .excel-table td[data-col="action"]  .btn {
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
    min-height: 32px !important;
  }
}

/* ---- PRINT (global) ---- */
@media print {
  /* ── Always hide navigation chrome ── */
  .sidebar,
  .top-header,
  .no-print,
  .preview-no-print,
  #edit-mode-banner { display: none !important; }

  /* ── Reset dark app shell to white ── */
  html, body {
    background: #fff !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ── When printing a dealer/sales order preview ── */
  body.printing-order-preview .sidebar,
  body.printing-order-preview .top-header,
  body.printing-order-preview .tabs,
  body.printing-order-preview .tab-btn,
  body.printing-order-preview .preview-no-print { display: none !important; }

  body.printing-order-preview .app-layout,
  body.printing-order-preview .main-content,
  body.printing-order-preview .content-area,
  body.printing-order-preview [class*="tab-content"] {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    min-height: unset !important;
    overflow: visible !important;
  }

  body.printing-order-preview #order-preview-root {
    display: block !important;
    background: #fff !important;
    padding: 0 !important;
    min-height: unset !important;
  }

  body.printing-order-preview .preview-page {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    background: #fff !important;
  }

  /* ── Generic fallback when #order-preview-root exists ── */
  #order-preview-root {
    background: #fff !important;
  }
  .preview-page {
    box-shadow: none !important;
    border: none !important;
    background: #fff !important;
  }

  /* ── Normal (non-preview) print ── */
  .main-content { margin-left: 0 !important; }
  .label-preview { border: 2px solid black !important; }

  /* ── Sales Rep Review Order — hide override inputs & buttons ── */
  input[id^="sales-ovr-"],
  button[onclick*="salesAcceptOverride"] { display: none !important; }

  td[id^="sales-sp-"] span { display: block !important; }
  td[id^="sales-sp-"] {
    background: #e6ffe6 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  th.sales-sp-col-header {
    background: #c6f6d5 !important;
    color: #166534 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ============================================
   PALLET LABEL EDITOR
   ============================================ */
.plt-placed-field {
  box-sizing: border-box;
  transition: outline 0.1s;
  cursor: move;
  user-select: none;
}
.plt-placed-field:hover {
  outline: 2px solid #FF6600;
  outline-offset: 1px;
}
.plt-placed-field.plt-selected {
  outline: 2px solid #38bdf8 !important;
  outline-offset: 1px;
  z-index: 10;
}
.plt-field-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: #dc2626;
  color: #fff;
  font-size: 0.6rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 20;
}
.plt-placed-field:hover .plt-field-del,
.plt-placed-field.plt-selected .plt-field-del {
  display: flex;
}
.plt-resize-handle {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  background: #38bdf8;
  border-radius: 2px;
  cursor: se-resize;
  display: none;
  z-index: 20;
}
.plt-placed-field:hover .plt-resize-handle,
.plt-placed-field.plt-selected .plt-resize-handle {
  display: block;
}
.plt-tmpl-row:hover {
  background: #0a1a2a !important;
}
.plt-tmpl-row.active {
  background: #0a2a3a !important;
  border-left: 3px solid #FF6600;
}
.plt-field-chip:hover {
  background: #0a2a3a !important;
  border-color: #FF6600 !important;
  color: #FF6600 !important;
  cursor: grab;
}

/* ============================================
   PAGE CANVAS EDITOR (Production Order & Order Confirmation)
   ============================================ */
.pc-placed-field {
  box-sizing: border-box;
  transition: outline 0.1s;
  cursor: move;
  user-select: none;
}
.pc-placed-field:hover {
  outline: 2px solid #FF6600;
  outline-offset: 1px;
}
.pc-placed-field.pc-selected {
  outline: 2px solid #38bdf8 !important;
  outline-offset: 1px;
  z-index: 10;
}
.pc-field-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: #dc2626;
  color: #fff;
  font-size: 0.6rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 20;
}
.pc-placed-field:hover .pc-field-del,
.pc-placed-field.pc-selected .pc-field-del {
  display: flex;
}
.pc-resize-handle {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  background: #38bdf8;
  border-radius: 2px;
  cursor: se-resize;
  display: none;
  z-index: 20;
}
.pc-placed-field:hover .pc-resize-handle,
.pc-placed-field.pc-selected .pc-resize-handle {
  display: block;
}
.pc-tmpl-row:hover {
  background: #0a1a2a !important;
}
.pc-tmpl-row.active {
  background: #0a2a3a !important;
  border-left: 3px solid #FF6600;
}
.pc-field-chip:hover {
  background: #0a2a3a !important;
  border-color: #FF6600 !important;
  color: #FF6600 !important;
  cursor: grab;
}

/* ── Pallet Label Rotation Buttons ─────────────────── */
.plt-rot-btn {
  background: #1e2a35;
  color: #94a3b8;
  border: 1px solid #334155;
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.plt-rot-btn:hover {
  background: #263445;
  color: #e2e8f0;
  border-color: #FF6600;
}
.plt-rot-btn.active,
.plt-rot-btn[style*="FF6600"] {
  background: #FF6600 !important;
  color: #fff !important;
  border-color: #FF6600 !important;
}

/* ============================================
   PAGE SETTINGS — Sidebar reorder & column reorder
   ============================================ */

/* Settings button in top header */
.btn-settings {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid #3a3a3a;
  color: #b0b0b0;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-settings:hover {
  background: rgba(255,102,0,0.1);
  border-color: #FF6600;
  color: #FF6600;
}
.btn-settings .settings-icon {
  font-size: 1rem;
  transition: transform 0.4s;
}
.btn-settings:hover .settings-icon {
  transform: rotate(60deg);
}

/* Settings modal overlay */
#modal-page-settings {
  z-index: 8500;
}
#modal-page-settings .modal {
  max-width: 680px;
}

/* Modal body layout */
#ps-modal-body {
  padding: 0;
}

/* Section blocks inside the settings modal */
.ps-section {
  padding: 20px 24px;
  border-bottom: 1px solid #2a2a2a;
}
.ps-section:last-child {
  border-bottom: none;
}
.ps-section-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}
.ps-section-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.ps-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 2px;
}
.ps-section-desc {
  font-size: 0.78rem;
  color: #888;
}

/* Page / table selector tabs inside the settings modal */
.ps-page-tabs,
.ps-col-tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.ps-page-tab,
.ps-col-tab {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: #b0b0b0;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.ps-page-tab:hover,
.ps-col-tab:hover {
  background: #3a3a3a;
  color: #ffffff;
}
.ps-page-tab.active,
.ps-col-tab.active {
  background: rgba(255,102,0,0.15);
  border-color: #FF6600;
  color: #FF6600;
  font-weight: 600;
}

/* Page/col panels */
.ps-page-panel,
.ps-col-panel {
  display: none;
}
.ps-page-panel.active,
.ps-col-panel.active {
  display: block;
}

/* List header row (hint text + reset button) */
.ps-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}

/* Drag-to-reorder list */
.ps-subtab-list,
.ps-col-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 40px;
}

/* Individual draggable item */
.ps-drag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 7px;
  cursor: grab;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  position: relative;
}
.ps-drag-item:hover {
  background: #242424;
  border-color: #3a3a3a;
}
.ps-drag-item.ps-dragging {
  opacity: 0.45;
  border-color: #FF6600;
  box-shadow: 0 4px 16px rgba(255,102,0,0.2);
}
.ps-drag-item.ps-drag-over {
  border-color: #FF6600;
  background: rgba(255,102,0,0.08);
  box-shadow: 0 0 0 2px rgba(255,102,0,0.25);
}

/* Drag handle dots */
.ps-drag-handle {
  color: #555;
  font-size: 1.1rem;
  line-height: 1;
  cursor: grab;
  flex-shrink: 0;
  letter-spacing: -1px;
}
.ps-drag-item:hover .ps-drag-handle {
  color: #888;
}

/* Item icon */
.ps-item-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

/* Item label */
.ps-item-label {
  flex: 1;
  font-size: 0.875rem;
  color: #e0e0e0;
  font-weight: 500;
}

/* Up/down arrow buttons */
.ps-item-arrows {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.ps-arrow {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #888;
  width: 26px;
  height: 26px;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  padding: 0;
}
.ps-arrow:hover {
  background: #FF6600;
  border-color: #FF6600;
  color: #fff;
}

/* Drag-over indicator line */
.ps-drag-item.ps-drag-over::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #FF6600;
  border-radius: 2px;
}

/* =============================================
   QUOTE TEMPLATE EDITOR (v1165m)
   Settings modal Section 4 — ps-qt-* classes
   ============================================= */

/* Dragover highlight for quote template rows */
.ps-qt-row.ps-qt-dragover {
  border-color: #FF6600 !important;
  background: rgba(255,102,0,0.06) !important;
  box-shadow: 0 0 0 2px rgba(255,102,0,0.2);
}

/* Drag handle inside qt rows */
.ps-qt-drag-handle {
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  transition: color 0.12s;
}
.ps-qt-row:hover .ps-qt-drag-handle {
  color: #FF6600;
}

/* Input / textarea fields inside qt expand panel */
.ps-qt-field:focus {
  outline: none;
  border-color: #FF6600 !important;
  box-shadow: 0 0 0 2px rgba(255,102,0,0.15);
}

/* ============================================
   COMPANY DASHBOARD  (page-dashboard.js)
   ============================================ */

/* Card wrapper */
.dash-card {
  background: #111111;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Card header row: title on left, action button on right */
.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}
.dash-card-header > span:first-child {
  font-size: 0.9rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.01em;
}

/* Empty state inside a card */
.dash-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  color: #555555;
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
}
