/* Shared comparison, pricing, worksheet and legal tables. */
.data-table,
.legal-table {
  margin: var(--space-5) 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
:is(.data-table, .legal-table):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: var(--space-1);
}
:is(.data-table, .legal-table) table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
  line-height: 1.6;
}
:is(.data-table, .legal-table) caption {
  caption-side: top;
  text-align: left;
  padding: var(--space-3) var(--space-4) 0;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
:is(.data-table, .legal-table) :is(th, td) {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-light);
  background: var(--table-cell-bg, var(--surface));
  line-height: 1.6;
}
:is(.data-table, .legal-table) thead th {
  --table-cell-bg: color-mix(in srgb, var(--text-primary) 4%, var(--surface));
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
}
:is(.data-table, .legal-table) tbody th[scope="row"] {
  --table-cell-bg: color-mix(in srgb, var(--text-primary) 2%, var(--surface));
  font-weight: 600;
  color: var(--text-primary);
}
:is(.data-table, .legal-table) tbody tr:hover > * {
  --table-cell-bg: color-mix(in srgb, var(--gold) 4%, var(--surface));
}
:is(.data-table, .legal-table) tbody tr:last-child > * { border-bottom: none; }
:is(.data-table, .legal-table) :is(th, td):first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  box-shadow: 1px 0 var(--border-light);
}
:is(.data-table, .legal-table) thead th:first-child { z-index: 2; }
.legal-table { margin: var(--space-4) 0 var(--space-5); }
.legal-table table { font-size: 14px; color: var(--text-secondary); }
.legal-table tbody th[scope="row"] { min-width: 160px; }

/* Overlay fades remain visible above opaque sticky cells. Native background
   scroll shadows sit underneath those cells and disappear, hence the small
   progressive enhancement in table-scroll.js. No JS is needed to scroll. */
.table-frame { position: relative; margin: var(--space-5) 0; }
.table-frame:has(> .legal-table) { margin: var(--space-4) 0 var(--space-5); }
.table-frame > :is(.data-table, .legal-table) { margin: 0; }
.table-frame::before,
.table-frame::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: var(--space-6);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}
.table-frame::before {
  left: var(--table-first-width, 0px);
  width: var(--space-4);
  background: linear-gradient(to right, var(--surface), transparent);
}
.table-frame::after {
  right: 1px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background: linear-gradient(to left, var(--surface), transparent);
}
.table-frame:has(> .is-scrollable-left)::before,
.table-frame:has(> .is-scrollable-right)::after { opacity: 1; }

@media (max-width: 479px) {
  :is(.data-table, .legal-table) table { min-width: 100%; font-size: 14px; }
  :is(.data-table, .legal-table) :is(th, td) {
    min-width: 7.5rem;
    padding: var(--space-2) var(--space-3);
    white-space: normal;
    overflow-wrap: normal;
  }
  .legal-table table { font-size: 13px; }
  .legal-table tbody th[scope="row"] { min-width: 7.5rem; }
  :is(.data-table, .legal-table) :is(th, td):first-child {
    width: 7.5rem;
    min-width: 7.5rem;
    max-width: 9rem;
  }
}
