@layer components {
  /* Table Component
     ========================================================================== */

  .table {
    width: 100%;
    border-collapse: collapse;
    border: none;
    margin-block: 0;
    font-size: var(--font-small-medium-responsive);
  }

  /* Remove all default borders */
  .table,
  .table thead,
  .table tbody,
  .table tr,
  .table th,
  .table td {
    border-left: none;
    border-right: none;
  }

  /* Header */
  .table th {
    padding: var(--block-space-half) var(--inline-space);
    text-align: left;
    font-weight: 600;
    font-size: var(--font-small-responsive);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-top: none;
    border-bottom: 1.5px solid var(--color-gray-dark);
  }

  .table th:first-child {
    padding-inline-start: 0;
  }

  .table th:last-child {
    padding-inline-end: 0;
  }

  /* Cells */
  .table td {
    padding: var(--block-space-half) var(--inline-space);
    vertical-align: middle;
    border-top: none;
    border-bottom: var(--border);
  }

  .table td:first-child {
    padding-inline-start: 0;
  }

  .table td:last-child {
    padding-inline-end: 0;
  }

  /* Compact variant — tighter rows for dense lists (e.g. the admin tags table) */
  .table--compact th,
  .table--compact td {
    padding-block: var(--block-space-third);
  }

  /* Alignment helpers */
  .table .text-center,
  .table th.text-center,
  .table td.text-center {
    text-align: center;
  }

  /* Action column: a last cell holding controls never wraps; a last cell of prose does */
  .table td:last-child:has(a, button, form, input, select) {
    white-space: nowrap;
  }

  /* Text variant — every column carries prose (e.g. the correction diff): rows align at the top */
  .table--text td {
    vertical-align: top;
  }

  /* Numeric columns - right align */
  .table td[data-type="number"],
  .table th[data-type="number"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  /* Remove bottom border on last row */
  .table tbody tr:last-child td {
    border-bottom: none;
  }

  /* The award cut line stands in for the row border above it */
  .table tr:has(+ .award-cut-line) td,
  .table .award-cut-line td {
    border-bottom: none;
  }

  /* Shrink columns to fit content */
  .table .col-shrink {
    width: 1%;
    white-space: nowrap;
  }

  /* Limit column width (for name columns that shouldn't expand too much) */
  .table .col-20 {
    width: 20%;
  }

  /* Diagonal header text for compact columns */
  .table .th-diagonal {
    height: 7em;
    vertical-align: bottom;
    position: relative;
  }

  .table .th-diagonal > span {
    position: absolute;
    bottom: 0.5em;
    left: 50%;
    transform: rotate(-45deg);
    transform-origin: bottom left;
    white-space: nowrap;
  }

  /* Responsive column hiding: the queries measure the table's scroll wrapper (`overflow-x contain`) */
  @container (max-width: 900px) {
    .table .hide-md {
      display: none;
    }
  }

  @container (max-width: 500px) {
    .table .hide-sm {
      display: none;
    }
  }
}
