/* Table primitives only: domain calculations, column widths and row states stay owned by their pages. */
body [data-portal-bid-comparison="up"] { color: var(--accent); }
body [data-portal-bid-comparison="down"] { color: var(--page-danger); }
body [data-portal-bid-comparison="equal"] { color: var(--page-warning); }
:root { --table-line: #dce2e8; --table-head: #f5f7f9; --table-text: #223247; --table-muted: #56667a; --table-surface: #fff; --table-accent: #236458; --table-cell-y: 10px; }
html[data-theme="dark"] { --table-line: #46515d; --table-head: #272f38; --table-text: #e7edf3; --table-muted: #b1bfcd; --table-surface: #20262d; --table-accent: #88ccbc; }
html[data-table-density="compact"] { --table-cell-y: 5px; }
body [data-portal-table-region] { position: relative; min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
body [data-portal-table-region] :is(th, td), body #sticky-stock-table th { padding-top: var(--table-cell-y); padding-bottom: var(--table-cell-y); font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; border-color: var(--table-line); }
body [data-portal-table-region] th, body #sticky-stock-table th { background: var(--table-head); color: var(--table-muted); font-weight: 650; text-transform: none; letter-spacing: normal; white-space: normal; overflow-wrap: anywhere; }
body [data-portal-table-region] :is(.number, .align-right) { text-align: right; }
body [data-portal-table-region] .column-header-label, body #sticky-stock-table .column-header-label { display: block; -webkit-line-clamp: unset; overflow: visible; }
body [data-portal-table-region] :is(.column-menu-trigger, .column-sort), body #sticky-stock-table :is(.column-menu-trigger, .column-sort) { height: auto; min-height: 42px; }
html[data-table-density="compact"] #stock-table:not(.is-advertising-queue) tbody tr:not(.group-row):not(.table-total-row):not(.virtual-spacer),
html[data-table-density="compact"] #stock-table:not(.is-advertising-queue) tbody tr:not(.group-row):not(.table-total-row):not(.virtual-spacer) td { height: 72px; max-height: 72px; }
body [data-portal-table-region] tr.virtual-spacer td { padding: 0; line-height: 0; border: 0; }
body [data-portal-table-region]:focus-visible { outline: 2px solid var(--table-accent); outline-offset: -2px; }
body .portal-table-sort { display: block; width: 100%; min-height: 32px; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; text-align: inherit; cursor: pointer; }
body .portal-table-sort:focus-visible { outline: 2px solid var(--table-accent); outline-offset: 2px; }
.portal-table-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.ad-report-content > .portal-table-tools { padding: 12px 16px 0; }
body .portal-density { display: grid; gap: 4px; min-width: 150px; max-width: 100%; margin: 0; color: var(--table-muted); font: 12px/1.4 system-ui, sans-serif; }
body .portal-density select { width: 100%; min-height: 40px; border: 1px solid var(--table-line); border-radius: 6px; padding: 8px 10px; background: var(--table-surface); color: var(--table-text); font: inherit; }
body .portal-table-actions { min-width: 0; align-self: end; }
body .portal-table-actions > summary { min-height: 40px; padding: 10px 12px; border: 1px solid var(--table-line); border-radius: 6px; background: var(--table-surface); color: var(--table-text); font-size: 12px; cursor: pointer; }
body .portal-table-actions-panel { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 0; }
#app-shell .table-heading-actions { align-items: end; }
#app-shell .table-heading-actions .table-search-field { flex: 1 1 320px; max-width: 520px; }
#app-shell .table-heading-actions .table-row-count { flex-basis: 100%; }
#app-shell .portal-table-actions { flex: 0 1 auto; order: 2; }
#app-shell .portal-table-actions[open] { flex-basis: 100%; }
#app-shell .portal-density { order: 1; }
#app-shell .portal-table-actions-panel .column-settings-button { align-self: center; }
#app-shell[data-portal-page="support_queue"] :is(.portal-density, .portal-table-actions), #app-shell[data-portal-page="allocation"] :is(.portal-density, .portal-table-actions) { display: none; }
body .list-filters { grid-template-columns: minmax(160px, 2fr) repeat(3, minmax(100px, 1fr)) auto; gap: 10px; align-items: end; }
body :is(.list-filters input, .list-filters select, .list-filters button, .pagination button, .ad-report-pagination button) { min-height: 40px; border-radius: 6px; }
body :is(.pagination, .ad-report-pagination) { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
body .evidence-grid > div { min-width: 0; }
@media (max-width: 1000px) {
  body .list-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body .list-filters > label:first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  #app-shell .table-heading-actions .table-search-field { flex-basis: 100%; max-width: none; }
  body .portal-density { flex: 1 1 150px; }
  body .list-filters { grid-template-columns: minmax(0, 1fr); }
  body .list-filters > label:first-child { grid-column: auto; }
}

/* Reusable detail/breakdown tables inside the shared scroll region. */
body [data-portal-table-region] .portal-detail-table { width: 100%; border-collapse: collapse; }
body [data-portal-table-region] .portal-detail-table :is(th, td) { padding-inline: 12px; border-bottom: 1px solid var(--table-line); vertical-align: top; }
body [data-portal-table-region] .portal-detail-table :is(th, td):not(.number) { text-align: left; }
/* Opt-in complete table surface for new shared pages. */
body table.portal-table { border-collapse: collapse; background: var(--table-surface); color: var(--table-text); }
body table.portal-table :is(th, td) { padding-left: 11px; padding-right: 11px; border-bottom: 1px solid var(--table-line); text-align: left; vertical-align: middle; }
/* Opt-in frozen columns. Consumers provide offsets and reduce pins on narrow screens. */
body table.portal-table [data-portal-pinned] { position:sticky; left:var(--portal-sticky-left,0px); z-index:1; background:var(--table-surface); box-shadow:1px 0 0 var(--table-line); }
body table.portal-table th[data-portal-pinned] { background:var(--table-head); z-index:2; }

/* Portal table design, adopted from Summary V11. Heights are minimums:
   long text and editable domain controls may grow without clipping. */
html body table.portal-table {
 --table-number-size:12px;
 border-collapse:separate; border-spacing:0; font:12px/1.2 system-ui,sans-serif;
}
html body table.portal-table :is(th,td) {
 box-sizing:border-box; padding:4px 8px; border-bottom:1px solid var(--table-line);
 font-size:12px; line-height:1.2; font-variant-numeric:tabular-nums; vertical-align:middle;
}
html body table.portal-table thead th {
 height:45px; font-size:11px; font-weight:650; color:var(--table-muted);
 background:var(--table-head); text-transform:none; letter-spacing:normal;
 white-space:normal; overflow-wrap:anywhere;
}
html body table.portal-table tbody td { height:52px; }
html body table.portal-table :is(tfoot,.group-row,.table-total-row) :is(th,td) {
 height:40px; font-weight:650; background:var(--table-head);
}
html body table.portal-table :is(tfoot,.table-total-row) :is(th,td) {font-weight:700;}
html body table.portal-table tr.virtual-spacer td {height:auto;padding:0;border:0;line-height:0;}
html body table.portal-table :is(.stock-value,.ff-cost) {font:inherit;color:inherit;}
html body table.portal-table :is(.number,.align-right) {text-align:right;}
html body table.portal-table :is(.column-menu-trigger,.column-sort,.portal-table-sort) {min-height:34px;}
@media(max-width:600px) {
 html body table.portal-table :is(.column-menu-trigger,.column-sort,.portal-table-sort) {min-height:44px;}
}
