/* The Tabulator look of /v1/, light and dark theme */
:root {
  --ft-tbl-bg: #ffffff;
  --ft-tbl-head: #f8fafc;
  --ft-tbl-border: #e2e8f0;
  --ft-tbl-row-line: #f1f5f9;
  --ft-tbl-text: #0f172a;
  --ft-tbl-muted: #64748b;
  --ft-tbl-hover: #f8fafc;
  --ft-tbl-accent: #059669;
  --ft-tbl-edit-bdr: #cbd5e1;
  --ft-row-active-bg: #ecfdf5;
  --ft-tbl-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.14), 0 4px 10px -4px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  --ft-tbl-bg: #0f172a;
  --ft-tbl-head: #1e293b;
  --ft-tbl-border: #334155;
  --ft-tbl-row-line: #1e293b;
  --ft-tbl-text: #f1f5f9;
  --ft-tbl-muted: #94a3b8;
  --ft-tbl-hover: #17233a;
  --ft-tbl-accent: #34d399;
  --ft-tbl-edit-bdr: #475569;
  --ft-row-active-bg: #093026;
  --ft-tbl-shadow: 0 14px 30px -5px rgba(0, 0, 0, 0.55);
}

.table-card:has(.tbl-cols) {
  overflow: visible !important;
}

.ft-tbl-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ft-tbl-card-head .row-center-10 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ft-hidden {
  display: none !important;
}

.tbl-cols {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tbl-cols .btn-chip {
  font-size: 13px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--ft-tbl-border);
  background: var(--ft-tbl-bg);
  color: var(--ft-tbl-text);
  cursor: pointer;
}

.tbl-cols .btn-chip:hover {
  border-color: var(--ft-tbl-accent);
}

.tbl-cols-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  background: var(--ft-tbl-bg);
  border: 1px solid var(--ft-tbl-border);
  border-radius: 12px;
  box-shadow: var(--ft-tbl-shadow);
  padding: 10px 14px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tbl-cols-menu .ft-switch-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ft-tbl-text);
  cursor: pointer;
}

.tbl-cols-note {
  font-size: 11px;
  color: var(--ft-tbl-muted);
  padding-top: 7px;
  margin-top: 4px;
  border-top: 1px solid var(--ft-tbl-border);
  line-height: 1.4;
}

/* Core .ft-tbl-wrap — Overrides tabulator.min.css grey defaults completely */
.ft-tbl-wrap {
  width: 100%;
}

.ft-tbl-wrap {
  background: transparent !important;
  border: none !important;
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif !important;
  font-size: 14px !important;
  color: var(--ft-tbl-text) !important;
  width: 100% !important;
}

.ft-tbl-wrap .tabulator-header,
.ft-tbl-wrap .tabulator-header .tabulator-headers {
  background: var(--ft-tbl-head) !important;
  border-top: none !important;
  border-bottom: 1px solid var(--ft-tbl-border) !important;
  color: var(--ft-tbl-muted) !important;
  font-weight: 500 !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col,
.ft-tbl-wrap .tabulator-header .tabulator-col.tabulator-frozen {
  background: var(--ft-tbl-head) !important;
  border-right: none !important;
  border-left: none !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col .tabulator-col-content {
  padding: 10px 10px !important;
  justify-content: flex-start;
  background: transparent !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col[style*="text-align: right"] .tabulator-col-content {
  justify-content: flex-end;
}

.ft-tbl-wrap .tabulator-header .tabulator-col[style*="text-align: center"] .tabulator-col-content {
  justify-content: center;
}

.ft-tbl-wrap .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--ft-tbl-muted) !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  padding-right: 0 !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter {
  display: none !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col.tabulator-sortable.tabulator-col-sorter-element:hover {
  background: var(--ft-tbl-head) !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col.tabulator-sortable:hover .tabulator-col-title {
  color: var(--ft-tbl-text) !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col[aria-sort="ascending"] .tabulator-col-title,
.ft-tbl-wrap .tabulator-header .tabulator-col[aria-sort="descending"] .tabulator-col-title {
  color: var(--ft-tbl-accent) !important;
  font-weight: 600 !important;
}

.ft-tbl-wrap .tabulator-header .tabulator-col[aria-sort="ascending"] .tabulator-col-title::after {
  content: " ↑";
}

.ft-tbl-wrap .tabulator-header .tabulator-col[aria-sort="descending"] .tabulator-col-title::after {
  content: " ↓";
}

.ft-tbl-wrap .tabulator-tableholder {
  background: transparent !important;
  scrollbar-gutter: auto;
}

.ft-tbl-wrap .tabulator-tableholder::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.ft-tbl-wrap .tabulator-tableholder::-webkit-scrollbar-thumb {
  background: var(--ft-tbl-edit-bdr);
  border-radius: 5px;
}

.ft-tbl-wrap .tabulator-tableholder .tabulator-table {
  background: transparent !important;
  color: var(--ft-tbl-text) !important;
}

.ft-tbl-wrap .tabulator-placeholder {
  background: var(--ft-tbl-bg) !important;
  padding: 28px 16px !important;
}

.ft-tbl-wrap .tabulator-placeholder .tabulator-placeholder-contents {
  color: var(--ft-tbl-muted) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
}

/* Odd and even rows have the same white fill */
.ft-tbl-wrap .tabulator-row,
.ft-tbl-wrap .tabulator-row.tabulator-row-even,
.ft-tbl-wrap .tabulator-row.tabulator-row-odd {
  background: var(--ft-tbl-bg) !important;
  border-bottom: 1px solid var(--ft-tbl-row-line) !important;
  color: var(--ft-tbl-text) !important;
  min-height: 52px;
}

.ft-tbl-wrap .tabulator-row:last-child {
  border-bottom: none !important;
}

.ft-tbl-wrap .tabulator-row .tabulator-cell {
  padding: 10px 10px !important;
  border-right: none !important;
  border-left: none !important;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.ft-tbl-wrap .tabulator-row .tabulator-cell.ft-wrap-cell {
  white-space: normal !important;
}

.ft-tbl-wrap .tabulator-row .tabulator-cell.tabulator-frozen {
  background: var(--ft-tbl-bg) !important;
  border-left: none !important;
  box-shadow: none !important;
}

.ft-tbl-wrap .tabulator-row.is-clickable {
  cursor: pointer;
}

.ft-tbl-wrap .tabulator-row:hover,
.ft-tbl-wrap .tabulator-row.tabulator-selectable:hover,
.ft-tbl-wrap .tabulator-row:hover .tabulator-cell.tabulator-frozen {
  background: var(--ft-tbl-hover) !important;
}

/* Active order row in Confirm $ & Record Sale queue */
.ft-tbl-wrap .tabulator-row.ft-active-order-row,
.ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-active-order-row,
.ft-tbl-wrap .tabulator-row.ft-active-order-row .tabulator-cell.tabulator-frozen {
  background: var(--ft-row-active-bg) !important;
}

.ft-tbl-wrap .tabulator-row.ft-active-order-row {
  box-shadow: inset 3px 0 0 0 var(--ft-tbl-accent);
}

/* All Flips' table view: a bundle's row (slate, indigo left edge) and the rows of the sales in it (white, slate left edge) */
.ft-tbl-wrap .tabulator-row.ft-bundle-parent-row,
.ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-parent-row,
.ft-tbl-wrap .tabulator-row.ft-bundle-parent-row .tabulator-cell.tabulator-frozen {
  background: #f8fafc !important;
}

.ft-tbl-wrap .tabulator-row.ft-bundle-parent-row {
  border-left: 3px solid #6366f1 !important;
}

.ft-tbl-wrap .tabulator-row.ft-bundle-parent-row:hover,
.ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-parent-row:hover,
.ft-tbl-wrap .tabulator-row.ft-bundle-parent-row:hover .tabulator-cell.tabulator-frozen {
  background: #f1f5f9 !important;
}

.ft-tbl-wrap .tabulator-row.ft-bundle-subrow,
.ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-subrow,
.ft-tbl-wrap .tabulator-row.ft-bundle-subrow .tabulator-cell.tabulator-frozen {
  background: #ffffff !important;
}

.ft-tbl-wrap .tabulator-row.ft-bundle-subrow {
  border-left: 3px solid #cbd5e1 !important;
}

.ft-tbl-wrap .tabulator-row.ft-bundle-subrow:hover,
.ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-subrow:hover,
.ft-tbl-wrap .tabulator-row.ft-bundle-subrow:hover .tabulator-cell.tabulator-frozen {
  background: #f8fafc !important;
}

html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-parent-row,
html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-parent-row,
html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-parent-row .tabulator-cell.tabulator-frozen {
  background: #1e293b !important;
}

html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-parent-row {
  border-left: 3px solid #818cf8 !important;
}

html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-parent-row:hover,
html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-parent-row:hover {
  background: #334155 !important;
}

html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-subrow,
html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.tabulator-row-even.ft-bundle-subrow,
html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-subrow .tabulator-cell.tabulator-frozen {
  background: #0f172a !important;
}

html[data-theme="dark"] .ft-tbl-wrap .tabulator-row.ft-bundle-subrow {
  border-left: 3px solid #475569 !important;
}

/* All Flips' grid and row views: a bundle's card (slate, indigo left edge) and the cards of the sales in it (white, slate left edge; the row view sets them in) */
.ft-bundle-card {
  background: rgba(248, 250, 252, 0.8);
  border: 1px solid #e2e8f0;
  border-left: 4px solid #6366f1;
}

.ft-bundle-card:hover {
  border-color: #cbd5e1;
  border-left-color: #6366f1;
}

.ft-bundle-member-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #cbd5e1;
}

.ft-bundle-member-card:hover {
  border-color: #cbd5e1;
}

.ft-virtualrows-tabulator .ft-bundle-member-card {
  margin-left: 1.5rem;
  width: calc(100% - 1.5rem);
}

html[data-theme="dark"] .ft-bundle-card {
  background: #1e293b;
  border-color: #2b3445;
  border-left-color: #818cf8;
}

html[data-theme="dark"] .ft-bundle-member-card {
  background: #0f172a;
  border-color: #2b3445;
  border-left-color: #475569;
}

/* The button before a bundle's SKU that folds or opens its sales */
.ft-bundle-fold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.25rem;
  background: #ffffff;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.ft-bundle-fold:hover {
  border-color: #818cf8;
  color: #4338ca;
}

html[data-theme="dark"] .ft-bundle-fold {
  background: #171c26;
  border-color: #2b3445;
  color: #94a3b8;
}

/* All Flips' toolbar: the search box's clear button, the Filters count and the Clear Filters & Search button */
.ft-inv-search {
  padding-right: 2rem;
}

.ft-inv-search-x {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 700;
  transition: background-color 0.15s, color 0.15s;
}

.ft-inv-search-x:not(.hidden) {
  display: flex;
}

.ft-inv-search-x:hover {
  color: #334155;
  background: rgba(226, 232, 240, 0.7);
}

.ft-inv-filter-badge {
  margin-left: 0.125rem;
  padding: 0 0.375rem;
  border-radius: 9999px;
  background: #059669;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
}

.ft-inv-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid #fcd34d;
  border-radius: 0.5rem;
  background: #fffbeb;
  color: #78350f;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
}

.ft-inv-clear-all:hover {
  background: #fef3c7;
}

.ft-inv-clear-all:disabled {
  border-color: #e2e8f0;
  background: rgba(248, 250, 252, 0.7);
  color: #94a3b8;
  font-weight: 500;
  cursor: default;
}

html[data-theme="dark"] .ft-inv-search-x:hover {
  color: #f1f5f9;
  background: rgba(51, 65, 85, 0.7);
}

html[data-theme="dark"] .ft-inv-clear-all {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

html[data-theme="dark"] .ft-inv-clear-all:disabled {
  border-color: #2b3445;
  background: #171c26;
  color: #64748b;
}

/* =========================================================================
   Tabulator Card & Row-Formatter Views (rowEl.innerHTML = ""; appendChild)
   1. .ft-cardgrid-tabulator — 4-across Photo Card Grid (#inv-view-grid)
   2. .ft-cardstack-tabulator — Stacked Rounded Cards
   ========================================================================= */
.ft-cardgrid-tabulator.tabulator, .ft-cardgrid-tabulator .tabulator,
.ft-cardstack-tabulator.tabulator, .ft-cardstack-tabulator .tabulator {
  background: transparent !important;
  border: none !important;
}

.ft-cardgrid-tabulator .tabulator-tableholder,
.ft-cardstack-tabulator .tabulator-tableholder {
  overflow-x: hidden !important;
}

/* 1. 4-Column Responsive Card Grid (matches lg:grid-cols-4 sm:grid-cols-2 gap-4 p-4) */
.ft-cardgrid-tabulator .tabulator-table {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
  width: 100% !important;
  background: var(--ft-tbl-head) !important;
}

@media (max-width: 1024px) {
  .ft-cardgrid-tabulator .tabulator-table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .ft-cardgrid-tabulator .tabulator-table {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 2. Stacked Rounded Cards with Gap */
.ft-cardstack-tabulator .tabulator-table {
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  width: 100% !important;
  background: transparent !important;
}

/* Strip default Tabulator row chrome on all rowFormatter card modes */
.ft-cardgrid-tabulator .tabulator-row,
.ft-cardgrid-tabulator .tabulator-row.tabulator-row-even,
.ft-cardgrid-tabulator .tabulator-row:hover,
.ft-cardstack-tabulator .tabulator-row,
.ft-cardstack-tabulator .tabulator-row.tabulator-row-even,
.ft-cardstack-tabulator .tabulator-row:hover {
  background: transparent !important;
  border: none !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
}

.ft-cardgrid-tabulator .tabulator-row,
.ft-cardstack-tabulator .tabulator-row {
  white-space: normal !important;
}

.ft-cardstack-tabulator.tabulator,
.ft-cardstack-tabulator .tabulator-tableholder,
.ft-cardstack-tabulator .tabulator-table,
.ft-cardstack-tabulator .tabulator-row {
  overflow: visible !important; /* card shadow */
}

/* Equal-height Grid Cards */
.ft-cardgrid-tabulator .tabulator-row {
  display: flex !important;
  align-items: stretch !important;
}

/* Virtual-Scrolled Row Cards (#inv-view-row): keeps .tabulator-table padding free for Tabulator Virtual DOM spacers! */
.ft-virtualrows-tabulator.tabulator,
.ft-virtualrows-tabulator .tabulator {
  background: transparent !important;
  border: none !important;
}

.ft-virtualrows-tabulator .tabulator-tableholder {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

.ft-virtualrows-tabulator .tabulator-table {
  display: block !important;
  width: 100% !important;
  background: transparent !important;
}

.ft-virtualrows-tabulator .tabulator-row,
.ft-virtualrows-tabulator .tabulator-row.tabulator-row-even,
.ft-virtualrows-tabulator .tabulator-row:hover {
  background: transparent !important;
  border: none !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 5px 12px !important;
  display: block !important;
}

/* Scrollable holder for progressiveLoad: "scroll" Card Grid */
.ft-cardgrid-tabulator .tabulator-tableholder {
  overflow-y: auto !important;
}


/* Guarantee native <select> inside custom K1-K4 dropdown wrapper NEVER unhides even if className is reassigned */
.ss-specific-ms-wrap > select {
  display: none !important;
}

/* Fix header-hidden & odd-row bleed on Card Grid / Stack / Virtual views */
.tabulator .tabulator-header.tabulator-header-hidden,
.ft-tbl-wrap .tabulator-header.tabulator-header-hidden,
.ft-cardgrid-tabulator .tabulator-header,
.ft-cardstack-tabulator .tabulator-header,
.ft-virtualrows-tabulator .tabulator-header {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
  border: none !important;
}

.ft-tbl-wrap.ft-cardgrid-tabulator .tabulator-row,
.ft-tbl-wrap.ft-cardgrid-tabulator .tabulator-row.tabulator-row-odd,
.ft-tbl-wrap.ft-cardgrid-tabulator .tabulator-row.tabulator-row-even,
.ft-tbl-wrap.ft-cardgrid-tabulator .tabulator-row:hover,
.ft-tbl-wrap.ft-cardstack-tabulator .tabulator-row,
.ft-tbl-wrap.ft-cardstack-tabulator .tabulator-row.tabulator-row-odd,
.ft-tbl-wrap.ft-cardstack-tabulator .tabulator-row.tabulator-row-even,
.ft-tbl-wrap.ft-cardstack-tabulator .tabulator-row:hover,
.ft-tbl-wrap.ft-virtualrows-tabulator .tabulator-row,
.ft-tbl-wrap.ft-virtualrows-tabulator .tabulator-row.tabulator-row-odd,
.ft-tbl-wrap.ft-virtualrows-tabulator .tabulator-row.tabulator-row-even,
.ft-tbl-wrap.ft-virtualrows-tabulator .tabulator-row:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
