/* New Portal table surfaces only. Geometry, scroll/sticky ownership, actions,
   semantic status/selection colours and document/print palettes stay unchanged.
   Standalone so no unrelated application JavaScript needs to be released. */
@media screen {
  /* Operational registers include semantic tables and the existing responsive
     Project / Worker / Asset grid registers. Keep controls on their own surface. */
  html.testing-portal .client-visual-theme main.command-content :is(
    table,
    .registry-table,
    .work-scope-table-shell,
    .worker-table-scroll,
    .worker-card.worker-section:has(> .worker-table-scroll):not(:has(form)),
    div.bg-white:has(> .project-management-grid),
    :is(div, section, article):is(.bg-white, .command-panel):has(> table),
    :is(div, section, article):is(.bg-white, .command-panel):has(> div > table)
  ):not(:where(
    [role='dialog'], [role='dialog'] *, [role='alertdialog'], [role='alertdialog'] *,
    form, form *, fieldset, fieldset *,
    .print-document, .print-document *, .safety-document-form, .safety-document-form *,
    .field-worker-form, .field-worker-form *, .ps-root, .ps-root *,
    .ps-print-table, .ps-print-table *, .schedule-day, .schedule-day *,
    .sd-drawer-theme, .sd-drawer-theme *, .crew-schedule, .crew-schedule *,
    [aria-label='Shared asset schedule'], [aria-label='Shared asset schedule'] *,
    .analysis-screen, .analysis-screen *, figure, figure *,
    .recharts-wrapper, .recharts-wrapper *,
    [data-document-preview], [data-document-preview] *,
    [data-theme-exempt], [data-theme-exempt] *
  )) {
    background-color: var(--client-canvas) !important;
  }

  html.testing-portal .client-visual-theme main.command-content :is(
    .project-management-grid.management-grid-header,
    .registry-table > .management-grid-header,
    .worker-detail-table thead th
  ):not(:where([role='dialog'] *, [role='alertdialog'] *, [data-theme-exempt] *)) {
    background-color: var(--client-inset) !important;
  }

  html.testing-portal .client-visual-theme main.command-content table tbody :is(th, td).sticky.bg-white:not(:where(
    [role='dialog'] *, [role='alertdialog'] *, form *, .print-document *,
    .safety-document-form *, .field-worker-form *, .ps-root *, .schedule-day *,
    .crew-schedule *, [aria-label='Shared asset schedule'] *, .analysis-screen *,
    figure *, [data-document-preview] *, [data-theme-exempt] *,
    [aria-selected='true'], [aria-selected='true'] *, [data-highlight='true'] *,
    [data-analysis-source-highlight], [data-analysis-source-highlight] *
  )) {
    background-color: var(--client-canvas) !important;
  }

  html.testing-portal .client-visual-theme main.command-content table thead th.sticky.bg-white:not(:where(
    [role='dialog'] *, [role='alertdialog'] *, form *, .print-document *,
    .safety-document-form *, .field-worker-form *, .ps-root *, .schedule-day *,
    .crew-schedule *, [aria-label='Shared asset schedule'] *, .analysis-screen *,
    figure *, [data-document-preview] *, [data-theme-exempt] *
  )) {
    background-color: var(--client-inset) !important;
  }

  /* Analysis deliberately opts out of generic theme adapters. Bridge only its
     named neutral table surfaces; never rebind its chart/valuation tokens. */
  html.testing-portal .client-visual-theme main.command-content .analysis-screen :is(
    .analysis-panel:has(> .analysis-table-scroll),
    .analysis-panel:has(> .analysis-register-desktop),
    .analysis-matrix-panel,
    .approved-sheet-register,
    .approved-sheet-details,
    .approved-register-mobile > .analysis-register-card,
    .analysis-table-scroll,
    table.analysis-register-table,
    table.analysis-rank-table,
    table.analysis-coverage-table,
    table.analysis-matrix,
    table.approved-sheet-table,
    table.app-data-table
  ):not(:where(
    [role='dialog'] *, [role='alertdialog'] *, .analysis-drawer *,
    .analysis-query-tools-body *, .analysis-date-popover *,
    form, form *, figure, figure *, .recharts-wrapper *,
    .print-document, .print-document *, .safety-document-form, .safety-document-form *,
    .field-worker-form, .field-worker-form *,
    .bg-amber-50, .bg-red-50, .bg-emerald-50,
    [data-document-preview], [data-document-preview] *
  )) {
    background-color: var(--client-canvas) !important;
  }

  /* Opaque neutral sticky cells must match the table when it scrolls. Totals,
     selected rows, semantic warning cells and editable controls are not targets. */
  html.testing-portal .client-visual-theme main.command-content .analysis-screen :is(
    .analysis-matrix tbody :is(th, td).sticky.bg-white,
    .analysis-register-table tbody .analysis-source-cell,
    table.app-data-table tbody :is(th, td).sticky.bg-white
  ):not(:where(
    [role='dialog'] *, [role='alertdialog'] *, .analysis-drawer *,
    form *, .print-document *, .safety-document-form *, .field-worker-form *,
    [data-document-preview] *,
    [aria-selected='true'], [aria-selected='true'] *, [data-highlight='true'] *,
    [data-analysis-source-highlight], [data-analysis-source-highlight] *
  )) {
    background-color: var(--client-canvas) !important;
  }
}
