.data-table {
  container: data-table / inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.data-table__scroll,
.table-wrap {
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table.htmx-request .data-table__scroll {
  opacity: 0.55;
  transition: opacity var(--motion);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table caption {
  text-align: left;
}

.table th {
  height: var(--head-height);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-page);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  color: var(--color-body);
  white-space: nowrap;
}

.table td {
  height: var(--row-height);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  color: var(--color-body);
  vertical-align: middle;
  white-space: nowrap;
}

.table th:first-child,
.table td:first-child {
  padding-left: var(--space-2);
}

.table th:last-child,
.table td:last-child {
  padding-right: var(--space-2);
}

.table tbody tr:hover td {
  background: var(--color-row-hover);
}

.table tbody tr[aria-selected="true"] td,
.table tbody tr:has(.check:checked) td {
  background: var(--color-accent-soft);
}

.table tr[data-row-href],
.table tr[data-row-preview],
.table tr[data-row-expand] {
  cursor: pointer;
}

.table .sort {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: inherit;
}

.table .sort:hover {
  color: var(--color-ink);
  text-decoration: none;
}

.table .sort svg {
  color: var(--color-muted);
}

.table th[aria-sort="ascending"],
.table th[aria-sort="descending"] {
  color: var(--color-ink);
}

.table th[aria-sort="ascending"] svg,
.table th[aria-sort="descending"] svg {
  color: var(--color-accent);
}

.table .is-numeric,
.table .cell--numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .is-select,
.table .cell--select,
.table .cell--action {
  width: 1%;
}

.table .cell--action {
  text-align: right;
}

.table .cell--primary,
.table .table__cell--primary {
  width: 100%;
  min-width: 168px;
  max-width: 0;
}

.table__cell--primary > a,
.table__cell--primary > span:not(.table__primary):not(.table__lines) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table td.cell--code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.cell__clip {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell--text .cell__clip {
  max-width: 24ch;
}

.table__lines .tag-list {
  flex-wrap: nowrap;
}

.table [data-col].is-hidden-col,
.table [data-col].is-squeezed {
  display: none;
}

@container data-table (max-width: 1100px) {
  .col--low {
    display: none;
  }
}

@container data-table (max-width: 860px) {
  .col--medium {
    display: none;
  }
}

@container data-table (max-width: 600px) {
  .col--high {
    display: none;
  }
}

@media (min-width: 1024px) {
  .data-table__scroll {
    overflow: visible;
  }

  .data-table .table th {
    position: sticky;
    top: var(--topbar-height);
    z-index: 2;
  }
}

.table td .stack {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.table td .cluster {
  flex-wrap: nowrap;
}

.table td .masked {
  flex-wrap: nowrap;
}
