@layer base, components, pages;

/* One table style (A34). Modifiers: .funnel (numbers right), .table-compact (ledger postings),
   .privacy-table (first column bold). On phones each row stacks and every cell shows its
   column name from data-label (A23), filled in by app JS from the table head. */
@layer components {
  .table-wrap { overflow-x: auto; max-width: 100%; }
  .table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
  .table th { text-align: left; color: var(--muted); font-weight: 600; padding: var(--space-2); border-bottom: 2px solid color-mix(in srgb, var(--fg) 15%, transparent); white-space: nowrap; }
  .table td { text-align: left; padding: var(--space-2); border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent); vertical-align: top; }
  .table td form { display: inline; margin-left: var(--space-2); }
  .table code { font-family: var(--font-mono); font-size: var(--text-xs); }
  .table .num, .table.funnel :is(th, td):not(:first-child) { text-align: right; }
  .table.funnel tfoot td { font-weight: 700; }
  .table.funnel .bar { display: block; height: 6px; border-radius: 3px; background: var(--accent); margin-top: 4px; min-width: 2px; }
  .table-compact { margin-top: var(--space-2); }
  .table-compact th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; border-bottom-width: 1px; padding: 0 0 var(--space-1); }
  .table-compact td { padding: var(--space-1) 0; border: 0; }
  .table-compact td:first-child { color: var(--muted); }
  .privacy-table td:first-child { font-weight: 600; white-space: nowrap; }

  @media (max-width: 40rem) {
    .table:not(.funnel, .table-compact) thead { display: none; }
    .table:not(.funnel, .table-compact) tr { display: grid; padding: var(--space-2) 0; border-bottom: 1px solid color-mix(in srgb, var(--fg) 12%, transparent); }
    .table:not(.funnel, .table-compact) td { border: 0; padding: 2px 0; text-align: left; }
    .table:not(.funnel, .table-compact) td[data-label]:not(:empty)::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 600; }
    .privacy-table td:first-child { white-space: normal; }
  }
}
