.table-wrapper {
  container-type: inline-size;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.table {
  border-collapse: collapse;
  min-width: 100%;
  width: 100%;
}

.table--fixed {
  table-layout: fixed;
}

.table-column--small {
  width: 8rem;
}

.table-column--medium {
  width: 11rem;
}

.table-column--large {
  width: 15rem;
}

.table thead {
  background: var(--surface-muted);
}

.table th {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-transform: uppercase;
}

.table th.text-left {
  text-align: left;
}

.table th.text-right {
  text-align: right;
}

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

.table tbody tr + tr,
.table tbody tr.table-group-row {
  border-top: 1px solid var(--border);
}

.table td {
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table-cell-primary {
  color: var(--text);
  font-weight: 500;
}

.table-cell-secondary {
  color: var(--text-muted);
}

.table-cell-actions {
  font-weight: 500;
  text-align: right;
  width: 1%;
}

.table-cell-actions > .cluster {
  flex-wrap: nowrap;
}

.table-cell-fill {
  max-width: 0;
  width: 100%;
}

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

.table-cell-breakable {
  overflow-wrap: anywhere;
  white-space: normal;
}

.table-total-row {
  border-top: 1px solid var(--border);
}

.table-total-cell {
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table-empty {
  color: var(--text-muted);
  padding: 2rem 1rem;
  text-align: center;
}

.table-empty a {
  color: var(--text-muted);
}

.table-empty a:hover {
  text-decoration: underline;
}

.table-group-row {
  background: var(--surface-muted);
}

.table-group-cell {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.table-group-row--nested {
  background: var(--surface);
}

.table-group-row--nested .table-group-cell {
  color: var(--text-subtle);
  font-size: 0.6875rem;
  padding-left: 1.5rem;
}

.badge {
  align-items: center;
  border-radius: var(--radius-full);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.25rem 0.625rem;
}

.badge--success {
  background: var(--lime-100);
  color: var(--lime-700);
}

.badge--warning {
  background: var(--amber-100);
  color: var(--amber-800);
}

.badge--info {
  background: var(--blue-100);
  color: var(--blue-800);
}

.badge--neutral {
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.table tbody tr:has(.table-row-link) {
  cursor: pointer;
}

.table tbody tr:has(.table-row-link):hover,
.table tbody tr:has(.table-row-link):focus-within {
  background: var(--surface-subtle);
}

.table-row-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@container (width < 52rem) {
  .table--responsive colgroup {
    display: none;
  }

  .table--responsive,
  .table--responsive tbody,
  .table--responsive tr,
  .table--responsive td {
    display: block;
  }

  .table--responsive thead {
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  .table--responsive tr:not(.table-group-row) {
    display: grid;
    gap: 0.75rem 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 1rem;
  }

  .table--responsive td {
    min-width: 0;
    padding: 0;
    white-space: normal;
  }

  .table--responsive td[data-label]::before {
    color: var(--text-muted);
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
  }

  .table--responsive .table-cell-primary {
    grid-column: 1 / -1;
    overflow-wrap: anywhere;
  }

  .table--responsive .table-cell-actions {
    align-self: end;
    width: auto;
  }

  .table--responsive .table-cell-actions:has(> .cluster) {
    grid-column: 1 / -1;
  }

  .table--responsive .table-cell-number {
    text-align: left;
  }

  .table--responsive .table-cell-actions > .cluster {
    flex-wrap: wrap;
  }

  .table--responsive .table-group-cell {
    display: block;
    padding: 0.75rem 1rem;
  }
}
