/* Use the existing table scroll regions for both axes. */
.ew-ui main .ew-table-scroll,
.ew-ui.ew-app-anuncios main .tablewrap,
.ew-ui.ew-app-financeiro main :is(.table-wrap, .pulse-table) {
  max-height: min(64vh, 720px);
  max-height: min(64dvh, 720px);
  overflow: auto;
  scroll-padding-block-start: 48px;
  scrollbar-width: thin;
}

.ew-ui main :is(.ew-table-scroll, .tablewrap, .table-wrap, .pulse-table):focus-visible {
  outline: 2px solid var(--ui-focus, #654aba);
  outline-offset: 2px;
}

.ew-ui main .ew-table-scroll > table,
.ew-ui.ew-app-anuncios main .tablewrap > table,
.ew-ui.ew-app-financeiro main :is(.table-wrap, .pulse-table) > table {
  border-collapse: separate;
  border-spacing: 0;
}

.ew-ui main .ew-table-scroll > table > thead > tr > th,
.ew-ui.ew-app-anuncios main .tablewrap > table > thead > tr > th,
.ew-ui.ew-app-financeiro main :is(.table-wrap, .pulse-table) > table > thead > tr > th {
  position: sticky;
  inset-block-start: 0;
  z-index: 4;
  box-shadow: 0 1px 0 var(--ui-line, #d8e0ec);
}

.ew-ui main table .ew-sticky-id {
  box-sizing: border-box;
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  width: var(--ew-id-width, 12rem);
  min-width: var(--ew-id-width, 12rem);
  max-width: var(--ew-id-width, 12rem);
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: start;
  font-weight: 700;
  box-shadow: 1px 0 0 var(--ui-line, #d8e0ec), 3px 0 5px rgb(22 34 55 / 6%);
}

.ew-ui main :is(.ew-table-scroll, .tablewrap, .table-wrap, .pulse-table) > table > thead > tr > th.ew-sticky-id {
  z-index: 6;
  background: #e9eef7;
  box-shadow: 1px 0 0 var(--ui-line, #d8e0ec), 0 1px 0 var(--ui-line, #d8e0ec);
}

.ew-ui main table > tbody > tr > .ew-sticky-id { background: #fff; }
.ew-ui main table > tbody > tr:nth-child(even) > .ew-sticky-id { background: #f7f9fc; }
.ew-ui main table > tbody > tr:hover > .ew-sticky-id { background: #edf2fa; }
.ew-ui main table > tbody > tr.variation-row > .ew-sticky-id { background: #f0f7f3; }

/* Products formerly pinned the third physical column. Heading styles still apply. */
.ew-ui.ew-app-gestao #products-screen .product-table tr > :nth-child(3) {
  inset-inline-start: auto;
  box-shadow: none;
}
.ew-ui.ew-app-gestao #products-screen .product-table tbody tr > :nth-child(3) { position: static; }
.ew-ui.ew-app-gestao #products-screen .product-table tr > .ew-sticky-id { --ew-id-width: 11rem; }
.ew-ui.ew-app-gestao #products-screen .product-table thead th.ew-sticky-id { z-index: 6; }
.ew-ui.ew-app-gestao #products-screen .product-table .variation-row > .ew-sticky-id { padding-left: 12px; }
.ew-ui.ew-app-gestao #products-screen .product-table .ew-sticky-id .product-code {
  display: block;
  max-width: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* The rich listings view keeps its existing cards in the scrolling columns. */
.ew-ui.ew-app-anuncios main .tablewrap { padding: 0; }
.ew-ui #catalog-panel #catalog-table.ew-list-mode { overflow: auto; }
.ew-ui #catalog-panel #catalog-table.ew-list-mode > table { min-width: 1050px; border-collapse: separate; }
.ew-ui #catalog-panel .ew-list-mode thead th:is(.ew-sticky-id, .ew-select-heading, .ew-listing-heading) {
  display: table-cell;
}
.ew-ui #catalog-panel #catalog-table .ew-sticky-id {
  --ew-id-width: 10rem;
  width: var(--ew-id-width);
}
.ew-ui #catalog-panel #catalog-table .ew-select-heading {
  width: 36px;
  min-width: 36px;
  text-align: center;
}
.ew-ui #catalog-panel .ew-list-mode .ew-side-actions details[open] > div {
  position: static;
  min-width: 0;
  max-height: 220px;
  overflow-y: auto;
}
.ew-ui #catalog-panel .ew-list-mode .ew-side-actions details[open] > div button {
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .ew-ui #catalog-panel #catalog-table.ew-list-mode > table { min-width: 740px; }
  .ew-ui #catalog-panel #catalog-table.ew-list-mode .ew-listing {
    grid-template-columns: 58px minmax(185px, 1fr) minmax(180px, .9fr) 96px;
    gap: 8px;
  }
  .ew-ui #catalog-panel #catalog-table.ew-list-mode :is(.ew-financial, .ew-side-actions) {
    grid-column: auto;
    padding-inline-start: 0;
  }
  .ew-ui #catalog-panel #catalog-table.ew-list-mode .ew-side-actions { flex-direction: column; }
  .ew-ui #catalog-panel #catalog-table.ew-list-mode .ew-photo :is(img, .ew-photo-empty) {
    width: 52px;
    height: 58px;
  }
}

@media (max-width: 660px) {
  .ew-ui main .ew-table-scroll > table .ew-sticky-id,
  .ew-ui #catalog-panel #catalog-table .ew-sticky-id,
  .ew-ui.ew-app-gestao #products-screen .product-table tr > .ew-sticky-id {
    --ew-id-width: clamp(76px, 27vw, 110px);
    padding-inline: 8px;
  }
  .ew-ui.ew-app-financeiro main table .ew-sticky-id {
    --ew-id-width: clamp(82px, 29vw, 120px);
    padding-inline: 8px;
    font-variant-numeric: tabular-nums;
  }
  .ew-ui.ew-app-financeiro main table td.ew-sticky-id { font-size: 11px; }
}

@media print {
  .ew-ui main .ew-table-scroll,
  .ew-ui.ew-app-anuncios main .tablewrap,
  .ew-ui.ew-app-financeiro main :is(.table-wrap, .pulse-table) {
    max-height: none !important;
    overflow: visible !important;
  }
  .ew-ui main table :is(.ew-sticky-id, thead th) { position: static !important; box-shadow: none; }
}
