/* Tables. On phones .table--stack turns rows into blocks (first cell spans the row) and
 * .table--cards into two-column cards; plain tables scroll inside .table-wrap. */
@layer components {
  .table-wrap { overflow-x: auto; }
  table.table { width: 100%; border-collapse: collapse; }
  .table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
  .table th { font-size: 12px; color: var(--ink-3); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
  .table tbody tr:hover { background: var(--surface-hover); }
  .table tfoot td { font-weight: 700; background: var(--surface-2); }
  .table td.actions { text-align: right; white-space: nowrap; }
  .table td .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
  .table input[type=number], .table input[type=text], .table select { height: 34px; }
  .table--compact th, .table--compact td { padding: 6px 8px; }
  .table .row--bad td, .table .row-over td { background: var(--row-bad); }
  .table .row--warn td { background: var(--row-warn); }

  /* Timesheet grid */
  .timesheet input { width: 56px; text-align: center; padding: 0 4px; }
  .timesheet td.weekend, .timesheet th.weekend { background: var(--weekend); }

  @media (max-width: 860px) {
    .table--stack thead { display: none; }
    .table--stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line-2); }
    .table--stack td { border: 0; padding: 0 !important; width: auto !important; min-width: 0 !important; }
    .table--stack td:first-child { grid-column: 1 / -1; }
    .table--stack td.actions { text-align: right; align-self: center; }
    .table--stack tr.row--bad { background: var(--row-bad); }
    .table--stack tr.row--warn { background: var(--row-warn); }
    .table--stack tr.row--bad td, .table--stack tr.row--warn td { background: none; }
    .table--stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--ink-3); }
    .table--cards thead { display: none; }
    .table--cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 8px 4px; border-bottom: 1px solid var(--line-2); }
    .table--cards td { border: 0; padding: 2px 8px; }
  }
}
