/* Shared spacing and type. Low specificity preserves each screen's palette,
   including themed headers and translucent match-state backgrounds. */
:root {
  --collection-radius: 8px;
  --collection-inset: 16px;
  --collection-rule: color-mix(in srgb, var(--color-border) 70%, var(--color-surface));
  --collection-hover: var(--color-surface-tint);
}
:where(.collection-card) {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--collection-radius);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: none;
}
.collection-card--padded { padding: var(--collection-inset); }
.collection-card--compact { --collection-inset: 12px; }
.collection-card--interactive { text-decoration: none; }
.collection-card--interactive:focus-visible,
.collection-card:has(.result-card-link:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.collection-heading {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px;
  margin: 0; padding: 12px var(--collection-inset); border-bottom: 1px solid var(--collection-rule);
}
.collection-heading h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; font-weight: 600; line-height: 1.5; }
.collection-heading .icon, .collection-meta-line .icon { width: 16px; height: 16px; flex: none; }
.collection-heading--green {
  border-radius: calc(var(--radius-card) - 1px) calc(var(--radius-card) - 1px) 0 0;
  background: var(--color-primary-surface);
  color: var(--color-on-primary);
}
.collection-heading--green :is(h2, h3) {
  display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0;
  color: inherit; font-size: 16px; font-weight: 600; letter-spacing: 0; line-height: 1.5; overflow-wrap: anywhere;
}
.collection-heading-count {
  margin-inline-start: auto; padding: 3px 9px; border-radius: 5px;
  background: #ffffff20; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.collection-meta-line { display: flex; align-items: center; gap: 8px; }
.collection-meta { color: var(--color-muted); font-size: 12px; font-weight: 400; }
.collection-footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  border-top: 1px solid var(--collection-rule); background: transparent;
}
.collection-pagination { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.collection-pagination .page-link {
  box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; min-height: 32px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px;
  color: var(--color-primary); background: var(--color-surface); text-decoration: none;
}
.collection-pagination .page-link .icon { width: 16px; height: 16px; }
.collection-pagination .page-previous .icon { transform: rotate(180deg); }
.collection-pagination a.page-link:hover { background: var(--color-soft); }
.collection-pagination .is-current { background: var(--color-primary-surface); color: var(--color-on-primary); border-color: var(--color-primary); font-weight: 700; }
.collection-pagination .is-disabled { opacity: .3; background: transparent; }
.collection-pagination .page-mobile-state { display: none; }
@media (max-width: 560px) {
  .collection-pagination .page-link { min-width: 44px; min-height: 44px; }
  .collection-pagination :is(.page-number, .page-ellipsis) { display: none; }
  .collection-pagination .page-mobile-state {
    display: inline-flex; justify-content: center; align-items: center;
    min-width: 56px; color: var(--color-primary); font-variant-numeric: tabular-nums;
  }
}

/* Plain tables retain their columns, sorting, paging and mobile presentations. */
.collection-table, #result_list {
  width: 100%; border-collapse: collapse; border-spacing: 0; text-align: left;
  color: var(--color-text); background: var(--color-surface); font-size: 13px; line-height: 1.6;
}
.collection-table :is(th, td), #result_list :is(th, td) {
  padding: 12px 10px; border: 0; border-bottom: 1px solid var(--collection-rule);
  background: var(--color-surface); vertical-align: middle;
}
.collection-table thead th, #result_list thead th {
  background: var(--color-bg);
  color: var(--color-muted); font-size: 11px; font-weight: 500; letter-spacing: 0; white-space: nowrap;
}
.collection-table tbody tr:last-child > *, #result_list tbody tr:last-child > * { border-bottom: 0; }
.collection-table tbody tr:hover > *, #result_list tbody tr:not(.selected):hover > * { background-color: var(--collection-hover); }
.collection-table small { margin-top: 3px; color: var(--color-muted); font-size: 11px; line-height: 1.5; }
.collection-table strong { font-weight: 600; }
.collection-table :is(time, .rating), #result_list { font-variant-numeric: tabular-nums; }
.collection-table.compact-table :is(th, td) { padding: 9px 8px; font-size: 12px; }
.collection-table.compact-table thead th { font-size: 11px; }
:is(.ui-overlay, .result-reader, .overview-match-browser, .reschedule-form) .collection-table thead th,
:is(.ui-overlay, .result-reader, .overview-match-browser, .reschedule-form) .collection-table small { font-size: var(--font-size-label); }
.collection-table .empty-cell { padding: 28px 12px; color: var(--color-muted); text-align: center; }
.collection-table [data-label="Acciones"] :is(a, button) { display: inline-flex; align-items: center; min-height: 36px; }

/* Matrix intersections and score emphasis remain meaningful, with quiet headers. */
.collection-matrix thead th, .collection-matrix thead .matrix-person { background: var(--color-soft); color: var(--color-primary); }
.collection-score-table thead th { background: var(--color-surface-tint); color: var(--color-muted); }
.collection-matrix :is(th, td) { border-color: var(--collection-rule); }
.collection-matrix .matrix-diagonal { background: var(--color-bg); }

/* Third-party tables share the same surface without hiding selection feedback. */
table.dataTable.collection-table > tbody > tr > * { box-shadow: none; }
#changelist #result_list thead th { padding: 12px 10px; }
#changelist #result_list tbody tr:not(.selected) > * { background-color: var(--color-surface); }
#changelist #result_list tbody tr:not(.selected):hover > * { background-color: var(--collection-hover); }
#changelist #result_list tbody tr.selected > * { background-color: var(--color-soft); }

@media (max-width: 768px) {
  :root { --collection-inset: 12px; }
  .collection-table :is(th, td) { padding: 11px 8px; }
  .collection-table [data-label="Acciones"] :is(a, button) { min-height: 44px; }
  .collection-card--compact { --collection-inset: 12px; }
}
@media (max-width: 600px) {
  .collection-table.responsive-matches :is(th, td) { padding: 8px 0; }
  .collection-table.responsive-matches td[data-label="Encuentro"] { padding: 8px 0; background: transparent; }
}
@media print {
  .collection-card { box-shadow: none; break-inside: avoid; }
  .collection-table { font-size: 10px; }
  .collection-table :is(th, td) { padding: 6px; }
}

.collection-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: clamp(24px, 5vw, 48px) 8px;
}

.collection-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--color-soft);
  color: var(--color-primary);
}

.collection-empty-icon .icon { width: 22px; height: 22px; }
.collection-empty :is(h2, h3) { margin: 0; font-size: clamp(19px, 3vw, 24px); line-height: 1.25; }
.collection-empty p { max-width: 44ch; margin: 8px 0 0; color: var(--color-muted); }
.collection-empty .collection-empty-title { margin: 0; color: var(--color-text); font-size: 14px; font-weight: 600; line-height: 1.45; }
.collection-empty > :is(a, form, .collection-empty-actions) { margin-top: 18px; }
.collection-empty .button { min-height: 44px; }
.collection-empty--wide { grid-column: 1 / -1; }
.collection-empty--compact { padding: 18px 8px; }
.collection-empty--compact .collection-empty-icon { width: 32px; height: 32px; margin-bottom: 8px; border-radius: 8px; }
.collection-empty--compact .collection-empty-icon .icon { width: 17px; height: 17px; }
.collection-empty--compact > :is(a, form, .collection-empty-actions) { margin-top: 12px; }

.collection-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
