.xpat-wrapper {
  container-name: xpat-table;
  container-type: inline-size;
  width: 100%;
  max-width: 100%;
  margin: 32px 0 8px;
  font-size: 14px;
}

.xpat-intro { margin-bottom: 18px; }
.xpat-title { margin: 0 0 8px; font-size: clamp(1.3rem, 2vw, 1.65rem); }
.xpat-description { margin: 0; color: var(--xl-muted, var(--wp--preset--color--muted, #667085)); }

.xpat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.xpat-filter-input {
  flex: 1 1 300px;
  width: 100%;
  max-width: 650px;
  min-height: 42px;
  box-sizing: border-box;
  padding: 9px 13px;
  border: 1px solid var(--xl-line, rgba(127, 127, 127, 0.3));
  border-radius: 10px;
  background: var(--xl-surface, var(--wp--preset--color--base, #fff));
  color: inherit;
  font: inherit;
}

.xpat-filter-input:focus { outline: 2px solid currentColor; outline-offset: 2px; }
.xpat-count { flex: 0 0 auto; font-size: 0.8rem; color: var(--xl-muted, var(--wp--preset--color--muted, #667085)); }

.xpat-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--xl-line, rgba(127, 127, 127, 0.22));
  border-radius: 12px;
  background: var(--xl-surface, var(--wp--preset--color--base, #fff));
}

.xpat-table {
  width: 100%;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
}

.xpat-row {
  display: grid;
  grid-template-columns: var(--xpat-grid-template, repeat(var(--xpat-cols, 2), minmax(0, 1fr)));
  width: 100%;
  min-width: 0;
  border-top: 1px solid color-mix(in srgb, var(--xl-line, #d9dcd9) 75%, transparent);
}

.xpat-row:first-child,
.xpat-row-head { border-top: 0; }
.xpat-row-head { background: var(--xl-surface-2, rgba(127, 127, 127, 0.08)); }
.xpat-body .xpat-row:hover { background: color-mix(in srgb, var(--xl-surface-2, #f0f1ef) 55%, transparent); }

.xpat-cell {
  min-width: 0;
  padding: 11px 12px;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.xpat-density-compact .xpat-table { font-size: 13.5px; }
.xpat-density-compact .xpat-cell { padding: 9px 10px; }
.xpat-density-normal .xpat-table { font-size: 14.5px; }
.xpat-density-normal .xpat-cell { padding: 12px 14px; }

.xpat-cell + .xpat-cell { border-left: 1px solid color-mix(in srgb, var(--xl-line, #d9dcd9) 75%, transparent); }
.xpat-head-cell { font-size: 0.94em; font-weight: 750; line-height: 1.3; }
.xpat-col-year { text-align: center; white-space: nowrap; }
.xpat-col-site { overflow: hidden; }
.xpat-col-summary { line-height: 1.5; }

.xpat-site-link,
.xpat-external-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  color: inherit;
  font-size: 0.95em;
  font-weight: 650;
  text-decoration: none;
}

.xpat-site-link span:first-child,
.xpat-external-link span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xpat-site-link:hover,
.xpat-external-link:hover { color: var(--xl-accent, #1b5cff); }
.xpat-row[hidden] { display: none !important; }
.xpat-empty { padding: 18px; border: 1px dashed var(--xl-line, rgba(127, 127, 127, 0.3)); border-radius: 10px; color: var(--xl-muted, #667085); }

/*
 * Project-specific wide layout. Theme files are not changed. This integration
 * layer is only active when the project has a table and the setting is enabled.
 */
body.xpat-project-wide-layout .project-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

body.xpat-project-wide-layout .project-content { order: 2; width: 100%; min-width: 0; }
body.xpat-project-wide-layout .project-sidebar { position: static; order: 1; width: 100%; }

@media (min-width: 981px) {
  body.xpat-project-wide-layout .project-sidebar .fact-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.34fr);
  }
  body.xpat-project-wide-layout .project-sidebar .fact-card-header { grid-column: 1 / -1; }
  body.xpat-project-wide-layout .project-sidebar .fact-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  body.xpat-project-wide-layout .project-sidebar .fact-list li {
    display: block;
    min-width: 0;
    border-right: 1px solid var(--xl-line, rgba(127, 127, 127, 0.22));
  }
  body.xpat-project-wide-layout .project-sidebar .fact-list li span,
  body.xpat-project-wide-layout .project-sidebar .fact-list li strong {
    display: block;
    max-width: none;
    text-align: left;
  }
  body.xpat-project-wide-layout .project-sidebar .fact-list li strong { margin-top: 4px; }
  body.xpat-project-wide-layout .project-sidebar .sidebar-progress {
    align-self: stretch;
    border-top: 0;
    border-left: 1px solid var(--xl-line, rgba(127, 127, 127, 0.22));
  }
  body.xpat-project-wide-layout .project-sidebar .sidebar-links {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container xpat-table (max-width: 820px) {
  .xpat-toolbar { align-items: stretch; }
  .xpat-filter-input { max-width: none; }
  .xpat-table-scroll { overflow: visible; border: 0; background: transparent; }
  .xpat-table { min-width: 0; }
  .xpat-head { display: none; }
  .xpat-body { display: grid; gap: 12px; }
  .xpat-row {
    display: block;
    overflow: hidden;
    border: 1px solid var(--xl-line, rgba(127, 127, 127, 0.22));
    border-radius: 11px;
    background: var(--xl-surface, var(--wp--preset--color--base, #fff));
  }
  .xpat-cell,
  .xpat-density-compact .xpat-cell,
  .xpat-density-normal .xpat-cell {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
    gap: 12px;
    padding: 10px 13px;
    text-align: left;
    white-space: normal;
  }
  .xpat-cell + .xpat-cell { border-top: 1px solid color-mix(in srgb, var(--xl-line, #d9dcd9) 70%, transparent); border-left: 0; }
  .xpat-cell::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    color: var(--xl-muted, var(--wp--preset--color--muted, #667085));
  }
}

@media (max-width: 767px) {
  .xpat-toolbar { align-items: stretch; }
  .xpat-filter-input { max-width: none; }
  .xpat-table-scroll { overflow: visible; border: 0; background: transparent; }
  .xpat-table { min-width: 0; }
  .xpat-head { display: none; }
  .xpat-body { display: grid; gap: 12px; }
  .xpat-row { display: block; overflow: hidden; border: 1px solid var(--xl-line, rgba(127, 127, 127, 0.22)); border-radius: 11px; background: var(--xl-surface, #fff); }
  .xpat-cell,
  .xpat-density-compact .xpat-cell,
  .xpat-density-normal .xpat-cell { display: grid; grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr); gap: 12px; padding: 10px 13px; text-align: left; white-space: normal; }
  .xpat-cell + .xpat-cell { border-top: 1px solid rgba(127, 127, 127, 0.14); border-left: 0; }
  .xpat-cell::before { content: attr(data-label); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.025em; text-transform: uppercase; color: var(--xl-muted, #667085); }
}
