/**
 * Neittor Metal — dense ERP tables (Bootstrap .table in the workspace).
 */
.nm-workspace .table {
  --bs-table-bg: var(--nm-surface);
  --bs-table-color: var(--nm-text);
  --bs-table-border-color: var(--nm-border);
  --bs-table-striped-bg: rgba(127, 135, 145, 0.05);
  --bs-table-hover-bg: rgba(0, 174, 239, 0.06);
  --bs-table-hover-color: var(--nm-text);
  --bs-table-active-bg: rgba(0, 174, 239, 0.1);
  margin-bottom: var(--nm-space-4);
  font-size: var(--nm-text-sm);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.nm-workspace .table > :not(caption) > * > * {
  padding: 0.5rem 0.65rem;
}

.nm-workspace .table-sm > :not(caption) > * > * {
  padding: 0.3rem 0.5rem;
}

.nm-workspace .table > thead > tr > th,
.nm-workspace .table > thead > tr > td {
  background: var(--nm-surface-2);
  color: var(--nm-text-muted);
  font-size: var(--nm-text-xs);
  font-weight: var(--nm-weight-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  /* Headers may wrap between words (never inside a word): a nowrap header in a fixed-layout or tight table
     overflows its column and gets clipped. Auto-layout tables still size to the header when there is room. */
  white-space: normal;
  overflow-wrap: normal;
  vertical-align: bottom;
  border-bottom: 1px solid var(--nm-border-strong);
}

.nm-workspace .table > thead > tr > th a {
  color: inherit;
  text-decoration: none;
}

.nm-workspace .table > thead > tr > th a:hover {
  color: var(--nm-text);
}

.nm-workspace .table > tbody > tr:last-child > * {
  border-bottom-width: 0;
}

/* Rounded, framed table when it sits in a .table-responsive wrapper */
.nm-workspace .table-responsive {
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius);
  background: var(--nm-surface);
  box-shadow: var(--nm-shadow-sm);
  margin-bottom: var(--nm-space-4);
}

.nm-workspace .table-responsive > .table {
  margin-bottom: 0;
}

.nm-workspace .table-responsive > .table > thead > tr:first-child > th:first-child {
  border-top-left-radius: calc(var(--nm-radius) - 1px);
}

.nm-workspace .table-responsive > .table > thead > tr:first-child > th:last-child {
  border-top-right-radius: calc(var(--nm-radius) - 1px);
}

.nm-workspace .table td.text-end,
.nm-workspace .table th.text-end,
.nm-workspace .table .text-end {
  font-variant-numeric: tabular-nums;
}

.nm-workspace .table code,
.nm-workspace .table .font-monospace {
  font-family: var(--nm-font-mono);
  font-size: 0.95em;
}

/* ---------------------------------------------------------------------------------------------------------------
 * Phones (< 768px): readable tables. Several views give their columns fixed widths (table-layout: fixed); squeezed
 * into ~390px the headers and cells overlapped and words broke letter by letter. Tables size to their content and
 * scroll sideways inside .nm-table-scroll (added by app.js) instead of widening the whole page.
 * ------------------------------------------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .nm-workspace table,
  .modal table {
    table-layout: auto !important;
  }

  .nm-workspace table :is(th, td),
  .modal table :is(th, td) {
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: manual;
  }

  .nm-workspace table th,
  .modal table th {
    white-space: nowrap;
  }

  .nm-workspace table td,
  .modal table td {
    min-width: 4.5rem;
  }

  .nm-workspace table td.nm-td-long,
  .modal table td.nm-td-long {
    min-width: 15rem;
  }

  .nm-workspace table :is(th, td):is(:has(> .btn:only-child), :has(> input[type="checkbox"]:only-child)) {
    min-width: 0;
  }

  .nm-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin-bottom: var(--nm-space-4, 1rem);
  }

  .nm-table-scroll > table {
    min-width: 100%;
    margin-bottom: 0 !important;
  }

  /* Any other wide block (code, long forms with fixed widths) stays inside the screen. */
  .nm-workspace :is(pre, .table-responsive) {
    max-width: 100%;
    overflow-x: auto;
  }
}

/* Table scrollers contain their absolutely positioned children (e.g. .visually-hidden labels in action cells):
   without a positioned scroller those escape the clipping and widen the whole page, which iOS lets users pan. */
.nm-workspace :is(.table-responsive, .nm-table-scroll),
.modal :is(.table-responsive, .nm-table-scroll) {
  position: relative;
}
