/* ==========================================================================
   TableX — shared theme
   ==========================================================================
   One stylesheet for every adapter (React, Angular, vanilla / ASP.NET), so a
   grid looks and behaves identically on every platform.

   Theming: every color/shape below reads a `--tbx-*` custom property, so a
   host app can re-skin the grid by overriding tokens — no class overrides
   needed. Dark mode: add `.tbx-dark` on the root (or any ancestor), or use
   `.tbx-auto` to follow the OS preference.

   Direction: anything that means "the reading-order start/end" uses logical
   properties (`inset-inline-*`, `padding-inline-*`, `text-align: start`) so a
   host that sets `dir="rtl"` gets a mirrored grid for free. The handful of
   places that stay physical are commented where they appear — they are either
   direction-neutral geometry (a checkmark glyph, a downward shadow) or paired
   with a physical offset computed in the adapter (pinned columns).
   ========================================================================== */

.tbx-root {
  /* ---- Design tokens (light defaults) ---- */
  --tbx-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --tbx-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tbx-bg: #ffffff;
  --tbx-card: #ffffff;
  --tbx-card-2: #f9fafb;
  --tbx-border: #e5e7eb;
  --tbx-border-subtle: #f3f4f6;
  --tbx-fg: #111827;
  --tbx-muted: #f3f4f6;
  --tbx-muted-fg: #6b7280;
  --tbx-primary: #2563eb;
  --tbx-primary-active: #1d4ed8;
  --tbx-primary-fg: #ffffff;
  --tbx-selected-bg: #ebf5ff;
  --tbx-danger: #dc2626;
  --tbx-radius-outer: 16px;
  --tbx-radius: 10px;
  --tbx-radius-sm: 8px;
  --tbx-radius-xs: 6px;
  --tbx-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --tbx-shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.05), 0 4px 12px -2px rgba(0, 0, 0, 0.02);
  --tbx-focus-ring: 0 0 0 2px rgba(37, 99, 235, 0.35);

  /* Backwards-compatibility aliases */
  --nxg-font: var(--tbx-font);
  --nxg-font-mono: var(--tbx-font-mono);
  --nxg-bg: var(--tbx-bg);
  --nxg-card: var(--tbx-card);
  --nxg-card-2: var(--tbx-card-2);
  --nxg-border: var(--tbx-border);
  --nxg-fg: var(--tbx-fg);
  --nxg-muted: var(--tbx-muted);
  --nxg-muted-fg: var(--tbx-muted-fg);
  --nxg-primary: var(--tbx-primary);
  --nxg-primary-fg: var(--tbx-primary-fg);
  --nxg-danger: var(--tbx-danger);
  --nxg-radius: var(--tbx-radius);
  --nxg-radius-sm: var(--tbx-radius-sm);
  --nxg-shadow: var(--tbx-shadow);
  --nxg-focus-ring: var(--tbx-focus-ring);

  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  padding: 24px;
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: var(--tbx-radius-outer);
  box-shadow: var(--tbx-shadow-card);
  font-family: var(--tbx-font);
  color: var(--tbx-fg);
  box-sizing: border-box;
}

.tbx-root *,
.tbx-root *::before,
.tbx-root *::after {
  box-sizing: inherit;
}

/* ==========================================================================
   Ultra-thin & Elegant Scrollbars (Default)
   ========================================================================== */

/* Standard Firefox/CSS */
.tbx-root,
.tbx-root *,
.tbx-table-wrap,
.tbx-filter-popover-options,
.tbx-menu {
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.45) transparent;
}

/* WebKit (Chrome, Edge, Safari, Opera) */
.tbx-root ::-webkit-scrollbar,
.tbx-table-wrap::-webkit-scrollbar,
.tbx-filter-popover-options::-webkit-scrollbar,
.tbx-menu::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.tbx-root ::-webkit-scrollbar-track,
.tbx-table-wrap::-webkit-scrollbar-track,
.tbx-filter-popover-options::-webkit-scrollbar-track,
.tbx-menu::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 9999px;
}

.tbx-root ::-webkit-scrollbar-thumb,
.tbx-table-wrap::-webkit-scrollbar-thumb,
.tbx-filter-popover-options::-webkit-scrollbar-thumb,
.tbx-menu::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.4);
  border-radius: 9999px;
  transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tbx-root ::-webkit-scrollbar-thumb:hover,
.tbx-table-wrap::-webkit-scrollbar-thumb:hover,
.tbx-filter-popover-options::-webkit-scrollbar-thumb:hover,
.tbx-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 114, 128, 0.7);
}

.tbx-root ::-webkit-scrollbar-corner,
.tbx-table-wrap::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---- Dark theme ---- */
.tbx-dark .tbx-root,
.tbx-root.tbx-dark {
  --tbx-bg: #0f172a;
  --tbx-card: #1e293b;
  --tbx-card-2: #16213a;
  --tbx-border: #334155;
  --tbx-border-subtle: #1e293b;
  --tbx-fg: #f8fafc;
  --tbx-muted: #334155;
  --tbx-muted-fg: #94a3b8;
  --tbx-primary: #3b82f6;
  --tbx-primary-active: #2563eb;
  --tbx-primary-fg: #ffffff;
  --tbx-selected-bg: rgba(59, 130, 246, 0.15);
  --tbx-shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
}

/* ---- Dark theme scrollbar ---- */
.tbx-dark,
.tbx-dark .tbx-root,
.tbx-root.tbx-dark,
.tbx-dark .tbx-table-wrap,
.tbx-dark .tbx-filter-popover-options,
.tbx-dark .tbx-menu {
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.tbx-dark ::-webkit-scrollbar-thumb,
.tbx-dark .tbx-root ::-webkit-scrollbar-thumb,
.tbx-root.tbx-dark ::-webkit-scrollbar-thumb,
.tbx-dark .tbx-table-wrap::-webkit-scrollbar-thumb,
.tbx-dark .tbx-filter-popover-options::-webkit-scrollbar-thumb,
.tbx-dark .tbx-menu::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
}

.tbx-dark ::-webkit-scrollbar-thumb:hover,
.tbx-dark .tbx-root ::-webkit-scrollbar-thumb:hover,
.tbx-root.tbx-dark ::-webkit-scrollbar-thumb:hover,
.tbx-dark .tbx-table-wrap::-webkit-scrollbar-thumb:hover,
.tbx-dark .tbx-filter-popover-options::-webkit-scrollbar-thumb:hover,
.tbx-dark .tbx-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(203, 213, 225, 0.6);
}

@media (prefers-color-scheme: dark) {
  .tbx-auto .tbx-root,
  .tbx-root.tbx-auto {
    --tbx-bg: #0f172a;
    --tbx-card: #1e293b;
    --tbx-card-2: #16213a;
    --tbx-border: #334155;
    --tbx-border-subtle: #1e293b;
    --tbx-fg: #f8fafc;
    --tbx-muted: #334155;
    --tbx-muted-fg: #94a3b8;
    --tbx-primary: #3b82f6;
    --tbx-primary-active: #2563eb;
    --tbx-primary-fg: #ffffff;
    --tbx-selected-bg: rgba(59, 130, 246, 0.15);
    --tbx-shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
  }

  .tbx-auto ::-webkit-scrollbar-thumb,
  .tbx-root.tbx-auto ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
  }

  .tbx-auto ::-webkit-scrollbar-thumb:hover,
  .tbx-root.tbx-auto ::-webkit-scrollbar-thumb:hover {
    background: rgba(203, 213, 225, 0.6);
  }
}

/* ==========================================================================
   Toolbar
   ========================================================================== */

.tbx-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

@media (min-width: 640px) {
  .tbx-toolbar {
    flex-direction: row;
    align-items: center;
  }
}

.tbx-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.tbx-toolbar-group--end {
  justify-content: flex-end;
}

@media (max-width: 639px) {
  .tbx-toolbar-group {
    width: 100%;
  }

  .tbx-toolbar-group--end {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
  }

  .tbx-toolbar-extra,
  .toolbar-extra {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  /* Compact square icon-only buttons on narrow mobile screens.
     The rule below hides each button's visible label, which is exactly why the
     toolbar buttons carry an `aria-label` in every adapter: the accessible name
     must not depend on that span being rendered. A host theme that wants an
     icon-only toolbar at every width can hide the same span safely. */
  .tbx-toolbar .tbx-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
  }

  .tbx-toolbar .tbx-btn span:not(.tbx-sr-only):not(.tbx-sort-order) {
    display: none;
  }

  .tbx-toolbar .tbx-btn .tbx-chevron {
    display: none;
  }

  .tbx-toolbar .tbx-select {
    height: 36px;
    font-size: 12px;
    padding-block: 0;
    padding-inline: 8px 24px;
    max-width: 130px;
  }
}

/* ---- Search ---- */

.tbx-search {
  position: relative;
  width: 100%;
}

@media (min-width: 640px) {
  .tbx-search {
    width: 320px;
    min-width: 290px;
    max-width: 420px;
    flex-shrink: 0;
  }
}

@media (min-width: 1024px) {
  .tbx-search {
    width: 340px;
  }
}

.tbx-search-icon {
  position: absolute;
  inset-inline-start: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #94a3b8;
  pointer-events: none;
}

.tbx-search-input {
  height: 36px;
  width: 100%;
  /* Room for the leading magnifier (start) and the trailing clear button (end). */
  padding-block: 0;
  padding-inline: 34px 30px;
  font-size: 13px;
  font-family: inherit;
  color: var(--tbx-fg);
  background: var(--tbx-card);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.tbx-dark .tbx-search-input {
  border-color: var(--tbx-border);
}

.tbx-search-input::placeholder {
  color: #94a3b8;
  font-size: 13px;
}

.tbx-search-input:focus {
  border-color: var(--tbx-primary);
  box-shadow: var(--tbx-focus-ring);
}

.tbx-search-clear {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--tbx-muted-fg);
  cursor: pointer;
}

.tbx-search-clear:hover {
  color: var(--tbx-fg);
}

/* ---- Buttons ---- */

.tbx-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #334155;
  background: var(--tbx-card);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.tbx-dark .tbx-btn {
  color: var(--tbx-fg);
  border-color: var(--tbx-border);
}

.tbx-btn:hover {
  background: var(--tbx-card-2);
  border-color: #94a3b8;
  color: var(--tbx-fg);
}

.tbx-btn:focus-visible {
  outline: none;
  box-shadow: var(--tbx-focus-ring);
}

.tbx-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tbx-btn .tbx-icon {
  color: #475569;
}

.tbx-dark .tbx-btn .tbx-icon {
  color: var(--tbx-muted-fg);
}

.tbx-btn--export {
  font-weight: 500;
  color: #334155;
}

.tbx-dark .tbx-btn--export {
  color: var(--tbx-fg);
}

.tbx-btn--export:hover {
  background: var(--tbx-card-2);
}

.tbx-select {
  display: inline-flex;
  align-items: center;
  height: 36px;
  /* Trailing room for the painted chevron below. */
  padding-block: 0;
  padding-inline: 12px 28px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #334155;
  background-color: var(--tbx-card);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.tbx-dark .tbx-select {
  color: var(--tbx-fg);
  border-color: var(--tbx-border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.tbx-select:hover {
  background-color: var(--tbx-card-2);
  border-color: #94a3b8;
}

/* `background-position` has no logical form, so the chevron needs an explicit
   flip: under RTL the select's trailing edge is on the left. */
[dir="rtl"] .tbx-select,
.tbx-select[dir="rtl"] {
  background-position: left 8px center;
}

.btn-action,
.tbx-btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: var(--tbx-card);
  color: #475569;
  cursor: pointer;
  transition: all 120ms ease;
}

.btn-action:hover,
.tbx-btn-action:hover {
  background: var(--tbx-card-2);
  border-color: #94a3b8;
  color: var(--tbx-fg);
}

.tbx-dark .btn-action,
.tbx-dark .tbx-btn-action {
  border-color: var(--tbx-border);
  color: var(--tbx-muted-fg);
}

.tbx-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tbx-capitalize {
  text-transform: capitalize;
}

/* ---- Dropdown menus ---- */

.tbx-menu-wrap {
  position: relative;
  display: inline-flex;
}

/* Anchored to the trigger's inline START edge. Logical, not `left`: the
   toolbar's end group flips sides under `dir="rtl"`, and a physically-anchored
   panel would then hang off the opposite edge of the viewport. */
.tbx-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  z-index: 50;
  min-width: 208px;
  padding: 6px;
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: var(--tbx-radius-sm);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* Re-anchored to the trigger's inline END edge (the export menu, which sits
   last in the toolbar and would otherwise overflow the container). */
.tbx-menu--end {
  inset-inline-start: auto;
  inset-inline-end: 0;
  min-width: 224px;
}

.tbx-menu-label {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tbx-muted-fg);
}

.tbx-menu-separator {
  height: 1px;
  margin: 4px 0;
  background: var(--tbx-border);
}

.tbx-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  text-align: start;
  color: var(--tbx-fg);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 100ms ease;
}

.tbx-menu-item:hover {
  background: var(--tbx-muted);
}

.tbx-menu-item .tbx-check {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--tbx-primary);
  visibility: hidden;
}

.tbx-menu-item[aria-checked="true"] .tbx-check {
  visibility: visible;
}

.tbx-menu-item-title {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.tbx-menu-item-title strong {
  font-weight: 600;
  color: var(--tbx-fg);
}

.tbx-menu-item-title small {
  font-size: 11px;
  color: var(--tbx-muted-fg);
}

.tbx-icon--excel {
  color: #10b981;
  width: 16px;
  height: 16px;
}

.tbx-icon--csv {
  color: #06b6d4;
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Table & Cards Layout
   ========================================================================== */

.tbx-table-wrap {
  position: relative;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: var(--tbx-radius);
  box-shadow: none;
  scrollbar-width: thin;
}

.tbx-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 767px) {
  .tbx-root:has(.tbx-cards) .tbx-table-wrap {
    display: none;
  }
}

@media (min-width: 768px) {
  .tbx-cards {
    display: none !important;
  }
  .tbx-root:has(.tbx-cards) .tbx-table-wrap {
    display: block;
  }
}

.tbx-table {
  width: 100%;
  text-align: start;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  color: var(--tbx-fg);
}

.tbx-table thead tr {
  background: var(--tbx-card-2);
}

.tbx-th {
  position: relative;
  padding: 10px;
  padding-inline-start: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tbx-fg);
  border-bottom: 1px solid var(--tbx-border);
  user-select: none;
  white-space: nowrap;
  background: var(--tbx-card-2);
}

.tbx-th--serial {
  width: 56px;
  padding: 10px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--tbx-fg);
}

.tbx-th--select {
  width: 44px;
  padding: 10px 8px;
  text-align: center;
}

/* Multi-level column header grouping */
.tbx-th--group {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--tbx-card-2);
  border-bottom: 1px solid var(--tbx-border);
  border-inline-end: 1px solid var(--tbx-border);
  padding: 8px 12px;
}

.tbx-th-group-title {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tbx-muted-fg);
}

.tbx-th--grouped-child {
  border-bottom: 1px solid var(--tbx-border);
}

.tbx-th--sortable {
  cursor: pointer;
}

.tbx-th--sortable:hover {
  background: var(--tbx-muted);
}

.tbx-th--sortable:focus-visible {
  outline: none;
  box-shadow: var(--tbx-focus-ring);
}

.tbx-th-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.tbx-th-inner--center {
  justify-content: center;
}

.tbx-th-inner--right {
  justify-content: flex-end;
}

.tbx-th-inner > span:first-child {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.tbx-sort-icon-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.tbx-sort-icon {
  width: 14px;
  height: 14px;
  color: var(--tbx-primary);
  flex-shrink: 0;
}

.tbx-sort-icon--idle {
  color: var(--tbx-muted-fg);
  opacity: 0.4;
}

.tbx-sort-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--tbx-font-mono);
  color: var(--tbx-primary);
  background: color-mix(in srgb, var(--tbx-primary) 15%, transparent);
  border-radius: 4px;
}

/* ---- Column filter popover ---- */
.tbx-col-filter-wrap {
  position: relative;
  display: inline-flex;
  margin-inline-start: auto;
  flex-shrink: 0;
}

.tbx-col-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  margin-inline-end: -4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--tbx-muted-fg);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.tbx-th:hover .tbx-col-filter-btn,
.tbx-col-filter-btn:focus-visible,
.tbx-col-filter-btn--active {
  opacity: 1;
}

.tbx-col-filter-btn:hover {
  opacity: 1;
  background: var(--tbx-muted);
  color: var(--tbx-fg);
}

.tbx-col-filter-btn--active {
  color: var(--tbx-primary);
  background: color-mix(in srgb, var(--tbx-primary) 15%, transparent);
  border-color: color-mix(in srgb, var(--tbx-primary) 30%, transparent);
}

.tbx-filter-popover {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 50;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 24px));
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: var(--tbx-radius-sm);
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  padding: 8px;
  text-align: start;
}

.tbx-filter-popover-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--tbx-fg);
  background: var(--tbx-card-2);
  border: 1px solid var(--tbx-border);
  border-radius: 6px;
  outline: none;
  box-sizing: border-box;
}

.tbx-filter-popover-input:focus {
  border-color: var(--tbx-primary);
  box-shadow: var(--tbx-focus-ring);
}

.tbx-filter-popover-options {
  max-height: 180px;
  overflow-y: auto;
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tbx-filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--tbx-fg);
  border-radius: 4px;
  cursor: pointer;
}

.tbx-filter-option:hover {
  background: var(--tbx-muted);
}

.tbx-filter-option--selected {
  font-weight: 600;
  color: var(--tbx-primary);
  background: color-mix(in srgb, var(--tbx-primary) 10%, transparent);
}

.tbx-filter-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--tbx-border);
}

.tbx-filter-popover-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--tbx-fg);
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 120ms ease;
}

.tbx-filter-popover-btn .tbx-icon {
  width: 12px;
  height: 12px;
}

.tbx-filter-popover-btn:hover {
  background: var(--tbx-card-2);
  border-color: #94a3b8;
}

.tbx-filter-popover-btn--primary {
  color: #ffffff;
  background: var(--tbx-primary-active);
  border-color: var(--tbx-primary-active);
}

.tbx-filter-popover-btn--primary:hover {
  opacity: 0.9;
}

.tbx-filter-popover.tbx-btn--primary:hover {
  opacity: 0.9;
}

/* ---- Active Filter Pills Bar ---- */
.tbx-filter-pills-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--tbx-card-2, #f8fafc);
  border-bottom: 1px solid var(--tbx-border-subtle, #f1f5f9);
  font-size: 12px;
}

.tbx-dark .tbx-filter-pills-bar {
  background: rgba(30, 41, 59, 0.5);
  border-bottom-color: var(--tbx-border);
}

.tbx-filter-pills-title {
  font-weight: 600;
  color: var(--tbx-muted-fg);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-inline-end: 4px;
}

.tbx-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* Tighter on the trailing edge, where the remove button sits. */
  padding-block: 3px;
  padding-inline: 10px 8px;
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: 9999px;
  color: var(--tbx-fg);
  font-size: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color 120ms ease, background-color 120ms ease;
}

.tbx-filter-pill:hover {
  border-color: var(--tbx-primary);
}

.tbx-filter-pill-label {
  font-weight: 500;
  color: var(--tbx-muted-fg);
}

.tbx-filter-pill-val {
  font-weight: 600;
  color: var(--tbx-fg);
}

.tbx-filter-pill-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-inline-start: 2px;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--tbx-muted-fg);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.tbx-filter-pill-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.tbx-filter-pill-clear-all {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: transparent;
  border: none;
  color: var(--tbx-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 120ms ease;
}

.tbx-filter-pill-clear-all:hover {
  opacity: 0.8;
}

.tbx-menu-item--reset {
  color: var(--tbx-muted-fg);
  font-size: 12px;
  border-top: 1px solid var(--tbx-border);
  margin-top: 4px;
  padding-top: 8px;
}

.tbx-menu-item--reset:hover {
  color: var(--tbx-fg);
}


/* ---- Column resize handles ---- */
.tbx-resize-handle {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  z-index: 10;
}

.tbx-resize-handle::after {
  content: "";
  position: absolute;
  top: 20%;
  bottom: 20%;
  inset-inline-end: 3px;
  width: 2px;
  background: var(--tbx-border);
  opacity: 0;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.tbx-th:hover .tbx-resize-handle::after,
.tbx-resize-handle:hover::after,
.tbx-resize-handle--active::after {
  opacity: 1;
  background: var(--tbx-primary);
}

.tbx-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

.tbx-table tbody {
  background: var(--tbx-card);
}

.tbx-row {
  white-space: nowrap;
  transition: background-color 100ms ease;
  background: var(--tbx-card);
}

.tbx-row:hover:not(.tbx-row--selected) {
  background: var(--tbx-card-2);
}

.tbx-row--selected {
  background-color: var(--tbx-selected-bg) !important;
}

.tbx-row--selected:hover {
  background-color: color-mix(in srgb, var(--tbx-primary) 20%, var(--tbx-selected-bg)) !important;
}

.tbx-row--clickable {
  cursor: pointer;
}

.tbx-td {
  padding: 12px 14px;
  color: var(--tbx-fg);
  font-size: 13px;
  border-bottom: 1px solid var(--tbx-border);
  vertical-align: middle;
}

.tbx-row:last-child .tbx-td {
  border-bottom: none;
}

.tbx-td--serial {
  width: 56px;
  padding: 12px 10px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--tbx-fg);
  user-select: none;
}

.tbx-td--select {
  width: 44px;
  padding: 12px 8px;
  text-align: center;
}

/* Density: padding + font-size on data cells */
.tbx-root[data-density="compact"] .tbx-td {
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 12px;
}

.tbx-root[data-density="default"] .tbx-td {
  padding-top: 12px;
  padding-bottom: 12px;
  font-size: 13px;
}

.tbx-root[data-density="comfortable"] .tbx-td {
  padding-top: 16px;
  padding-bottom: 16px;
  font-size: 14px;
}

/* ---- Checkbox ---- */

.tbx-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  transition: all 120ms ease;
}

.tbx-dark .tbx-checkbox {
  border-color: #64748b;
  background: #1e293b;
}

.tbx-checkbox[type="radio"] {
  border-radius: 50%;
}

.tbx-checkbox:checked {
  background: var(--tbx-primary);
  border-color: var(--tbx-primary);
}

/* Deliberately physical: these two rules centre a tick / a dot inside the
   18px box. The glyphs are direction-neutral — a checkmark is not mirrored in
   RTL — so `inset-inline-start` would only move them off-centre. */
.tbx-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid var(--tbx-primary-fg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.tbx-checkbox[type="radio"]:checked::after {
  left: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tbx-primary-fg);
  border: none;
  transform: none;
}

.tbx-checkbox:focus-visible {
  outline: none;
  box-shadow: var(--tbx-focus-ring);
}

/* ==========================================================================
   Empty / loading / error states
   ========================================================================== */

.tbx-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--tbx-muted-fg);
  font-size: 14px;
}

.tbx-state-card {
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: var(--tbx-radius);
  box-shadow: var(--tbx-shadow);
  padding: 32px;
  text-align: center;
}

.tbx-state-card .tbx-state-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--tbx-muted-fg);
  margin: 0;
}

.tbx-state-card .tbx-btn {
  margin-top: 12px;
}

/* Crisp linear dotted loader */
.tbx-dotted-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.tbx-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--tbx-primary);
  display: inline-block;
  animation: tbx-dot-pulse 1.3s infinite ease-in-out both;
}

.tbx-dot:nth-child(1) {
  animation-delay: -0.36s;
}

.tbx-dot:nth-child(2) {
  animation-delay: -0.18s;
}

.tbx-dot:nth-child(3) {
  animation-delay: 0s;
}

.tbx-dot:nth-child(4) {
  animation-delay: 0.18s;
}

@keyframes tbx-dot-pulse {
  0%, 80%, 100% {
    transform: scale(0.65);
    opacity: 0.3;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.tbx-loading-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--tbx-muted-fg);
  letter-spacing: 0.01em;
}

.tbx-spinner {
  display: none;
}

/* ==========================================================================
   Card list (< 768px)
   ========================================================================== */

.tbx-card {
  background: var(--tbx-card);
  border: 1px solid var(--tbx-border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 12px;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
  overflow: hidden;
}

.tbx-card:hover {
  border-color: color-mix(in srgb, var(--tbx-border) 80%, var(--tbx-primary));
}

.tbx-card--selected {
  border-color: var(--tbx-primary);
  background: var(--tbx-selected-bg);
}

.tbx-card--clickable {
  cursor: pointer;
}

.tbx-card--clickable:active {
  transform: scale(0.995);
  background: var(--tbx-muted);
}

.tbx-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 2px 4px 8px 4px;
  border-bottom: 1px solid var(--tbx-border);
}

.tbx-card-serial {
  font-family: var(--tbx-font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--tbx-primary);
  background: color-mix(in srgb, var(--tbx-primary) 10%, transparent);
  padding: 2px 8px;
  border-radius: 4px;
}

.tbx-card-select {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
}

.tbx-card-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.tbx-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 6px;
  transition: background-color 100ms ease;
}

/* Striped styling for mobile cards */
.tbx-card-row:nth-child(odd) {
  background-color: #f8fafc;
}

.tbx-card-row:nth-child(even) {
  background-color: transparent;
}

.tbx-dark .tbx-card-row:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.035);
}

.tbx-dark .tbx-card-row:nth-child(even) {
  background-color: transparent;
}

.tbx-card-row:hover {
  background-color: #f1f5f9;
}

.tbx-dark .tbx-card-row:hover {
  background-color: rgba(255, 255, 255, 0.07);
}

.tbx-card-row dt {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  padding-top: 0;
}

.tbx-dark .tbx-card-row dt {
  color: #94a3b8;
}

.tbx-card-row dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: break-word;
  text-align: end;
  font-size: 13px;
  font-weight: 500;
  color: var(--tbx-fg);
}

/* ==========================================================================
   Footer / pagination
   ========================================================================== */

.tbx-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 4px 0 0 0;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
}

@media (min-width: 768px) {
  .tbx-footer {
    flex-direction: row;
  }
}

.tbx-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.tbx-dark .tbx-range {
  color: var(--tbx-muted-fg);
}

@media (min-width: 768px) {
  .tbx-range {
    justify-content: flex-start;
    text-align: start;
  }
}

.tbx-range strong {
  font-weight: 600;
  color: var(--tbx-fg);
  padding: 0 1px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.tbx-selected-badge {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tbx-primary);
  background: color-mix(in srgb, var(--tbx-primary) 12%, transparent);
}

.tbx-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 100%;
}

@media (min-width: 768px) {
  .tbx-pagination {
    justify-content: flex-end;
  }
}

.tbx-rows-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
}

.tbx-dark .tbx-rows-per-page {
  color: var(--tbx-muted-fg);
}

.tbx-rows-select {
  height: 32px;
  min-width: 72px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--tbx-fg);
  background: var(--tbx-bg);
  border: 1px solid #d1d5db;
  border-radius: var(--tbx-radius-xs);
  cursor: pointer;
  outline: none;
  transition: border-color 120ms ease;
}

.tbx-dark .tbx-rows-select {
  border-color: var(--tbx-border);
}

.tbx-rows-select:focus {
  border-color: var(--tbx-primary);
  box-shadow: var(--tbx-focus-ring);
}

.tbx-pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.tbx-page-btn,
.tbx-page-nav {
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: center;
  color: #374151;
  background: #ffffff;
  border: 1px solid var(--tbx-border);
  border-radius: var(--tbx-radius-xs);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 120ms ease;
}

.tbx-dark .tbx-page-btn,
.tbx-dark .tbx-page-nav {
  background: #1e293b;
  color: var(--tbx-fg);
}

.tbx-page-nav {
  color: #6b7280;
}

.tbx-page-btn:hover:not(.tbx-page-btn--current),
.tbx-page-nav:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
}

.tbx-dark .tbx-page-btn:hover:not(.tbx-page-btn--current),
.tbx-dark .tbx-page-nav:hover:not(:disabled) {
  background: #334155;
  border-color: #475569;
  color: #ffffff;
}

.tbx-page-btn--current {
  background: var(--tbx-primary-active) !important;
  border-color: var(--tbx-primary-active) !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(29, 78, 216, 0.2);
}

.tbx-page-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent;
}

/* The prev/next chevrons are drawn pointing left/right, which is backwards
   once the page reads right-to-left. Mirror the glyph rather than shipping a
   second icon per adapter. */
[dir="rtl"] .tbx-page-nav > svg {
  transform: scaleX(-1);
}

.tbx-page-ellipsis {
  padding: 0 4px;
  color: #9ca3af;
  font-size: 13px;
  user-select: none;
  flex-shrink: 0;
}

.tbx-jump {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tbx-jump-label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}

.tbx-dark .tbx-jump-label {
  color: var(--tbx-muted-fg);
}

.tbx-jump-input {
  width: 48px;
  height: 32px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--tbx-primary);
  background: var(--tbx-bg);
  border: 1px solid #d1d5db;
  border-radius: var(--tbx-radius-xs);
  outline: none;
  -moz-appearance: textfield;
}

.tbx-dark .tbx-jump-input {
  border-color: var(--tbx-border);
}

.tbx-jump-input::-webkit-outer-spin-button,
.tbx-jump-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tbx-jump-input:focus {
  border-color: var(--tbx-primary);
  box-shadow: var(--tbx-focus-ring);
}

/* ==========================================================================
   Utilities & Cells (Avatars, Badges, Cell-stack, Actions)
   ========================================================================== */

.tbx-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tbx-align-center {
  text-align: center;
}

/* Deliberately physical: `.tbx-align-right` is a public utility, and its twin
   `meta.align: "right"` in the column API, both of which promise a physical
   edge. Silently making them mean "inline end" would flip a consumer's
   right-aligned currency column the day they set `dir="rtl"`. Anything that
   should follow reading order uses `text-align: start | end` instead. */
.tbx-align-right {
  text-align: right;
}

.cell-user,
.tbx-cell-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: start;
}

.avatar,
.tbx-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
  border: 1px solid var(--tbx-border);
  flex-shrink: 0;
}

.cell-stack,
.tbx-cell-stack {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.3;
  text-align: start;
}

.cell-stack strong,
.tbx-cell-stack strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tbx-fg);
}

.cell-stack small,
.tbx-cell-stack small {
  font-size: 12px;
  color: var(--tbx-muted-fg);
}

.badge,
.tbx-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  background: #e5e7eb;
  color: #374151;
}

.badge--active,
.tbx-badge--active {
  background: #bbf7d0;
  color: #166534;
}

.badge--pending,
.tbx-badge--pending {
  background: #fed7aa;
  color: #9a3412;
}

.badge--suspended,
.tbx-badge--suspended {
  background: #fecaca;
  color: #991b1b;
}

.badge--alumni,
.tbx-badge--alumni {
  background: #e9d5ff;
  color: #6b21a8;
}

.badge--scholarship,
.tbx-badge--scholarship {
  background: #e5e7eb;
  color: #374151;
}

.tbx-dark .badge--active,
.tbx-dark .tbx-badge--active {
  background: rgba(22, 101, 52, 0.4);
  color: #4ade80;
}

.tbx-dark .badge--pending,
.tbx-dark .tbx-badge--pending {
  background: rgba(180, 83, 9, 0.4);
  color: #fbbf24;
}

.tbx-dark .badge--suspended,
.tbx-dark .tbx-badge--suspended {
  background: rgba(185, 28, 28, 0.4);
  color: #f87171;
}

.tbx-dark .badge--alumni,
.tbx-dark .tbx-badge--alumni {
  background: rgba(126, 34, 206, 0.4);
  color: #c084fc;
}

.tbx-dark .badge--scholarship,
.tbx-dark .tbx-badge--scholarship {
  background: rgba(100, 116, 139, 0.4);
  color: #cbd5e1;
}

.score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--tbx-fg);
  font-size: 13px;
}

.score--high {
  font-weight: 600;
  color: var(--tbx-fg);
}

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

.row-actions .tbx-btn,
.btn-action {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #6b7280;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tbx-dark .row-actions .tbx-btn,
.tbx-dark .btn-action {
  background: #1e293b;
  border-color: #475569;
  color: #94a3b8;
}

.row-actions .tbx-btn:hover,
.btn-action:hover {
  background: #f3f4f6;
  color: #111827;
  border-color: #9ca3af;
}

.tbx-dark .row-actions .tbx-btn:hover,
.tbx-dark .btn-action:hover {
  background: #334155;
  color: #ffffff;
}

/* ==========================================================================
   Enterprise Features
   ========================================================================== */

/* ---- Pinned / Sticky Columns ----
   Deliberately physical. The adapters compute each pinned column's cumulative
   offset in JS and write it as an inline `left` / `right`; converting only the
   rules below to `inset-inline-*` would leave the two fighting under RTL (the
   sheet pinning to one edge, the inline style to the other). Pinning follows
   the physical `pin: "left" | "right"` column API, so it stays physical until
   that API grows start/end values and the adapters emit logical offsets. */
.tbx-th--pinned-left,
.tbx-td--pinned-left {
  position: sticky !important;
  left: 0;
  z-index: 2;
  background-color: var(--tbx-card);
}

.tbx-th--pinned-right,
.tbx-td--pinned-right {
  position: sticky !important;
  right: 0;
  z-index: 2;
  background-color: var(--tbx-card);
}

.tbx-th.tbx-th--pinned-left,
.tbx-th.tbx-th--pinned-right {
  z-index: 4;
  background-color: var(--tbx-card-2);
}

/* Physical by necessity: `box-shadow` offsets have no logical form, and these
   two shadows sit on the physically pinned edges above. */
.tbx-pinned-border-left {
  box-shadow: inset -1px 0 0 var(--tbx-border), 4px 0 8px -3px rgba(0, 0, 0, 0.08);
}

.tbx-pinned-border-right {
  box-shadow: inset 1px 0 0 var(--tbx-border), -4px 0 8px -3px rgba(0, 0, 0, 0.08);
}

/* ---- Bulk Actions Floating Bar ---- */
.tbx-bulk-bar {
  position: sticky;
  bottom: 16px;
  margin: -48px auto 0 auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 9999px;
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 500;
  animation: tbx-slide-up 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tbx-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tbx-dark .tbx-bulk-bar {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f1f5f9;
}

.tbx-bulk-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--tbx-primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.tbx-bulk-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tbx-bulk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease;
}

.tbx-bulk-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.tbx-bulk-btn--close {
  padding: 0 6px;
  border: none;
  background: transparent;
  opacity: 0.7;
}

.tbx-bulk-btn--close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* ---- Row Expansion / Detail Rows ---- */
.tbx-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tbx-muted-fg);
  cursor: pointer;
  transition: transform 150ms ease, background-color 120ms ease, color 120ms ease;
}

.tbx-expand-btn:hover {
  background: var(--tbx-muted);
  color: var(--tbx-fg);
}

.tbx-expand-btn--open {
  transform: rotate(90deg);
}

/* Collapsed, the disclosure chevron points along the reading direction; open,
   it points down. Under RTL both halves have to mirror. */
[dir="rtl"] .tbx-expand-btn > svg {
  transform: scaleX(-1);
}

[dir="rtl"] .tbx-expand-btn--open {
  transform: rotate(-90deg);
}

.tbx-expanded-row {
  background-color: #f8fafc;
}

.tbx-dark .tbx-expanded-row {
  background-color: rgba(255, 255, 255, 0.02);
}

.tbx-expanded-cell {
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--tbx-border);
}

.tbx-detail-panel {
  animation: tbx-fade-in 140ms ease;
}

/* ---- Summary / Aggregation Footer Row ---- */
.tbx-table tfoot {
  border-top: 2px solid var(--tbx-border);
}

.tbx-summary-row {
  background: var(--tbx-card-2);
}

.tbx-summary-cell {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tbx-fg);
  border-top: 2px solid var(--tbx-border);
  border-bottom: 1px solid var(--tbx-border);
}

.tbx-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tbx-muted-fg);
  margin-inline-end: 4px;
}

/* ---- Range Filters ---- */
.tbx-range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.tbx-range-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  font-size: 12px;
  border: 1px solid var(--tbx-border);
  border-radius: 4px;
  background: var(--tbx-card);
  color: var(--tbx-fg);
}

.tbx-range-input:focus {
  outline: none;
  border-color: var(--tbx-primary);
}

.tbx-range-sep {
  font-size: 12px;
  color: var(--tbx-muted-fg);
  flex-shrink: 0;
}

/* ---- Column Drag-and-Drop Reordering ---- */
.tbx-th--draggable {
  cursor: grab;
}

.tbx-th--dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* Physical by necessity again — `box-shadow` has no logical offset. The two
   classes name the physical edge the drop indicator is painted on, and the
   adapter picks between them from the pointer's own physical position. */
.tbx-th--drag-over-left {
  box-shadow: inset 3px 0 0 var(--tbx-primary) !important;
}

.tbx-th--drag-over-right {
  box-shadow: inset -3px 0 0 var(--tbx-primary) !important;
}

/* ---- Inline Cell Editing ---- */
.tbx-cell--editable {
  cursor: pointer;
  position: relative;
}

.tbx-cell--editable:hover::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px dashed color-mix(in srgb, var(--tbx-primary) 50%, transparent);
  border-radius: 4px;
  pointer-events: none;
}

.tbx-cell-edit-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.tbx-cell-edit-input {
  width: 100%;
  height: 28px;
  padding: 0 6px;
  font-size: 13px;
  border: 1px solid var(--tbx-primary);
  border-radius: 4px;
  background: var(--tbx-card);
  color: var(--tbx-fg);
}

.tbx-cell-edit-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tbx-primary) 20%, transparent);
}

.tbx-cell-edit-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.tbx-cell-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.tbx-cell-edit-btn--save {
  color: #10b981;
}

.tbx-cell-edit-btn--save:hover {
  background: rgba(16, 185, 129, 0.1);
}

.tbx-cell-edit-btn--cancel {
  color: #ef4444;
}

.tbx-cell-edit-btn--cancel:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ---- Print Optimization ---- */
@media print {
  .tbx-toolbar,
  .tbx-bulk-bar,
  .tbx-footer,
  .tbx-col-filter-wrap,
  .tbx-cards,
  .row-actions {
    display: none !important;
  }

  .tbx-table-wrap {
    border: none !important;
    overflow: visible !important;
  }

  .tbx-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .tbx-th,
  .tbx-td,
  .tbx-summary-cell {
    border: 1px solid #94a3b8 !important;
    color: #000000 !important;
    background: transparent !important;
    page-break-inside: avoid;
  }
}


.row-actions .tbx-btn .tbx-icon,
.btn-action .tbx-icon {
  width: 14px;
  height: 14px;
  color: currentColor;
}
