.atom-data-page__nav,
.atom-data-page__return,
.atom-data-nav {
  margin-top: 1rem;
}

.atom-data-page__intro {
  margin-bottom: 1.25rem;
}

.table-responsive {
  overflow-x: auto;
  max-width: 100%;
  margin: 1rem 0 1.5rem;
}

/*
  Support both:
  1) existing hand-built pages that use .atom-data-table
  2) generated pages where plain <table> elements are wrapped in .atom-table-wrap
*/
.atom-data-table,
.atom-table-wrap > table {
  width: auto;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid var(--border);
  margin: 0;
}

.atom-data-table caption,
.atom-table-wrap > table caption {
  text-align: left;
  font-weight: 700;
  color: var(--uf-blue);
  padding: 0 0 0.75rem;
  caption-side: top;
}

.atom-data-table th,
.atom-data-table td,
.atom-table-wrap > table th,
.atom-table-wrap > table td {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.atom-data-table thead th,
.atom-data-table tbody th,
.atom-table-wrap > table thead th,
.atom-table-wrap > table tbody th {
  background: var(--surface-muted);
}

.atom-data-table tbody tr:nth-child(even),
.atom-table-wrap > table tbody tr:nth-child(even) {
  background: #f8fafc;
}

/* Base wrapper behavior */
.atom-table-wrap {
  width: 100%;
}

/*
  Width classes for generated pages.
  Tables size to their content, but these wrappers keep them from becoming too wide.
*/
.atom-table-wrap--small > table {
  min-width: 20rem;
}

.atom-table-wrap--medium > table {
  min-width: 28rem;
}

.atom-table-wrap--kinetic > table {
  min-width: 42rem;
}

/* Existing hand-built page class compatibility */
.atom-table-wrap--summary {
  max-width: 100%;
}

.atom-table-wrap--summary > table,
.atom-data-table--summary {
  min-width: 20rem;
}

.atom-table-wrap--kinetic {
  max-width: 100%;
}

.atom-data-table--kinetic {
  min-width: 42rem;
}

/* Summary-style tables: compact first column */
.atom-data-table--summary tbody th,
.atom-table-wrap--small > table tbody th,
.atom-table-wrap--summary > table tbody th {
  width: 32%;
  white-space: nowrap;
}

/* Numeric columns: keep values on one line */
.atom-data-table--kinetic td:nth-child(2),
.atom-data-table--kinetic td:nth-child(3),
.atom-data-table--kinetic th:nth-child(2),
.atom-data-table--kinetic th:nth-child(3),
.atom-table-wrap--kinetic > table td:nth-child(2),
.atom-table-wrap--kinetic > table td:nth-child(3),
.atom-table-wrap--kinetic > table th:nth-child(2),
.atom-table-wrap--kinetic > table th:nth-child(3) {
  white-space: nowrap;
  text-align: right;
}

.atom-data-table--kinetic td:first-child,
.atom-data-table--kinetic th:first-child,
.atom-table-wrap--kinetic > table td:first-child,
.atom-table-wrap--kinetic > table th:first-child {
  white-space: nowrap;
}

.atom-config {
  padding: 0.9rem 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  width: fit-content;
  max-width: 100%;
}

@media (max-width: 640px) {
  .atom-data-table th,
  .atom-data-table td,
  .atom-table-wrap > table th,
  .atom-table-wrap > table td {
    padding: 0.6rem 0.65rem;
  }

  .atom-data-table--summary tbody th,
  .atom-table-wrap--small > table tbody th,
  .atom-table-wrap--summary > table tbody th {
    width: auto;
    white-space: normal;
  }
  
.atom-table-wrap--small > table tbody td:first-child,
.atom-data-table--small tbody td:first-child {
  white-space: nowrap;
}

  .atom-table-wrap--small > table,
  .atom-table-wrap--medium > table,
  .atom-table-wrap--kinetic > table,
  .atom-data-table--summary,
  .atom-data-table--kinetic {
    min-width: 0;
  }
}
