/*
 * Tables — the data primitive that runs through everything in
 * accounting. Generous padding, light dividers, no heavy outer border
 * by default. A `.table-section` wrapper adds a title row above.
 */

@layer components {
  .table-section {
    margin-bottom: 2.5rem;
  }

  .table-section__title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-heading);
    margin: 0 0 0.75rem;
  }

  .table-section__empty {
    padding: 1rem 1.125rem;
    margin: 0;
    border: 1px dashed var(--color-border);
    border-radius: 0.5rem;
    background: var(--color-white);
  }

  .table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--color-white);
    font-size: 0.875rem;
  }

  .table thead th {
    padding: 0.625rem 0.875rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-body);
    background: oklch(from var(--color-border) 0.98 c h);
    border-bottom: 1px solid var(--color-border);
  }

  .table tbody td {
    padding: 0.75rem 0.875rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-heading);
    vertical-align: middle;
  }

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

  .table tbody tr:hover td {
    background: oklch(from var(--color-border) 0.985 c h);
  }

  .table__cell--actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
  }

  .table__action-form {
    display: inline;
    margin: 0;
  }

  /* Ledger table — lines grouped by journal entry */
  .ledger-table__group-start td {
    border-top: 2px solid var(--color-border);
  }

  .ledger-table tbody tr:first-child td {
    border-top: none;
  }

  /* Locked row — used by surfaces (e.g. the chart-of-accounts import
     review table) where a row is read-only because the underlying
     record has live dependencies that prevent overwrite. Visually
     dimmed to telegraph "you can't act on this." */
  .table tbody tr.is-locked,
  tr.is-locked {
    opacity: 0.5;
  }

  /* Import preview — read-only view of the user's uploaded CSV
     surfaced above the mapping form so they can verify which file
     column got recognized as which canonical field. The recognized-row
     carries the platform's canonical-field labels; the file-header-row
     shows the literal headers as they appear in the file. */
  .import-preview {
    margin: 0 0 1.5rem;
  }

  .import-preview__caption {
    font-size: 0.875rem;
    color: var(--color-text-body);
    margin: 0 0 0.5rem;
  }

  .import-preview__table {
    table-layout: auto;
  }

  .import-preview__table .recognized-row th {
    background: oklch(from var(--color-border) 0.96 c h);
    text-transform: none;
    letter-spacing: 0;
  }

  .import-preview__table .file-header-row th {
    background: var(--color-white);
  }

  .import-preview__table td {
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
