.cost-paid-register-grid {
  container: cost-paid-grid / inline-size;
  max-width: 100%;
  max-height: min(65vh, 42rem);
  overflow: auto;
  border: 1px solid #ccd8e7;
  border-radius: 8px;
  background: #fff;
}

.cost-paid-register-grid > table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* Keep the payer's share of the available width as Linked Record grows. */
.cost-paid-register-grid col:nth-child(2) { width: max(0px, calc(36cqi - 301px)); }
.cost-paid-register-grid col:nth-child(6) { width: clamp(126px, calc(10cqi + 22px), 168px) !important; }

.cost-paid-register-grid > table :is(th, td) {
  height: 31px;
  box-sizing: border-box;
  padding: 2px 7px !important;
  border-right: 1px solid #d9e3ef;
  border-bottom: 1px solid #d9e3ef;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 0.75rem;
}

.cost-paid-register-grid > table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e9eff7;
  color: #27415f;
  font-size: 0.6875rem;
  line-height: 1.2;
  white-space: normal;
}

.cost-paid-register-grid :is(th, td):first-child { text-align: center; }
.cost-paid-register-grid :is(th, td):nth-child(7) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cost-paid-register-grid tbody tr:nth-child(even) td { background: #f6f8fc; }
.cost-paid-register-grid tbody tr:hover td { background: #eaf2ff; }
.cost-paid-register-grid tbody td.row-actions {
  display: table-cell;
  min-width: 0;
}

.cost-paid-register-grid .row-actions > button + button { margin-left: 4px; }
.cost-paid-register-grid .file-link-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 5px;
}

.cost-paid-register-grid > table button {
  min-height: 22px;
  padding: 2px 5px;
  white-space: nowrap;
  font-size: 0.6875rem;
}

.cost-paid-register-grid tbody td.empty {
  text-align: left;
  color: #52647d;
}

@container cost-paid-grid (max-width: 1040px) {
  .cost-paid-register-grid > table,
  .cost-paid-register-grid tbody { display: block; }

  .cost-paid-register-grid > table > colgroup { display: none; }
  .cost-paid-register-grid > table > thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .cost-paid-register-grid tbody tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid #bccde1;
  }

  .cost-paid-register-grid tbody td,
  .cost-paid-register-grid tbody td.row-actions {
    display: block;
    height: auto;
    min-height: 36px;
    min-width: 0;
    text-align: left;
  }

  .cost-paid-register-grid tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: #52647d;
    font-size: 0.6875rem;
    font-weight: 700;
  }

  .cost-paid-register-grid tbody td.empty { grid-column: 1 / -1; }
}

@container cost-paid-grid (max-width: 520px) {
  .cost-paid-register-grid tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
