/* ==========================================================================
   Data tables: horizontal scroll shell (sticky first column, the scroll
   container owns overflow - tables never break layout), current-mode grid,
   cell values, C/U pills and delta badges.
   ========================================================================== */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-raise) transparent;
}

.table-scroll::-webkit-scrollbar {
  height: 10px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: var(--surface-raise);
  border-radius: var(--radius-pill);
  border: 2px solid var(--surface-panel);
}

.table-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.table-scroll:focus-visible {
  box-shadow:
    inset 0 0 0 2px var(--accent-violet),
    inset 0 0 0 4px var(--surface-canvas);
}

.vb-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 640px;
  font-size: var(--fs-small);
  animation: fade-in var(--dur-standard) var(--ease-standard) both;
}

.vb-table th,
.vb-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: top;
}

.vb-table th:last-child,
.vb-table td:last-child {
  border-right: 0;
}

.vb-table tbody tr:last-child th,
.vb-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Column headers: sticky bar, uppercase micro labels, data right-aligned. */
.vb-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-elevated);
  color: var(--text-tertiary);
  font-size: var(--fs-micro);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  text-align: right;
  white-space: normal;
  min-width: 7.5rem;
  border-bottom: 1px solid var(--border-default);
}

.vb-table thead th:first-child {
  text-align: left;
  left: 0;
  z-index: 3;
}

/* Row labels: sticky first column with a hairline overlap edge. */
.vb-table th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  font-weight: 650;
  color: var(--text-primary);
  background: var(--surface-panel);
  border-right: 1px solid var(--border-default);
  min-width: 7rem;
  white-space: nowrap;
}

.vb-table td {
  text-align: right;
  min-width: 7.5rem;
}

.vb-table tbody tr:nth-child(even) td {
  background: var(--zebra-fill);
}

.vb-table tbody tr:hover th[scope="row"],
.vb-table tbody tr:hover td {
  background: var(--surface-hover);
}

/* ----------------------------------------------------------------- cells */

.cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.cell-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
}

.cell-value--none {
  color: var(--text-quaternary);
}

/* --------------------------------------------------------- value badges */

.pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
}

.pill--current {
  background: var(--pill-current-bg);
  color: var(--pill-current-fg);
  box-shadow: inset 0 0 0 1px rgba(165, 163, 255, 0.3);
}

.pill--unavailable {
  background: var(--pill-unavailable-bg);
  color: var(--pill-unavailable-fg);
  box-shadow: inset 0 0 0 1px rgba(240, 179, 87, 0.3);
}

.delta {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.delta--up {
  background: var(--status-advance-bg);
  color: var(--status-advance);
  box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.3);
}

.delta--down {
  background: var(--status-regress-bg);
  color: var(--status-regress);
  box-shadow: inset 0 0 0 1px rgba(255, 99, 105, 0.32);
}

.delta--flat {
  background: var(--status-flat-bg);
  color: var(--status-flat);
}

.delta--text {
  background: var(--status-flat-bg);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
}

.delta--none {
  background: transparent;
  color: var(--text-quaternary);
  font-weight: 500;
}
