.ms-products-page {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 14px;
}

.ms-products-category-nav { display: grid; gap: 2px; }

.ms-products-header {
  min-height: 132px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 38%);
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  overflow: hidden;
  border: 1px solid var(--ms-border-color, #dfe4ee);
  border-radius: 14px;
  background: var(--ms-surface, #fff);
  box-shadow: var(--ms-shadow-sm, 0 8px 24px rgba(25, 37, 63, .06));
}

.ms-products-header-copy { min-width: 0; }
.ms-products-header small {
  color: var(--ms-text-muted, #8a94a8);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}
.ms-products-header h1 {
  margin: 4px 0 6px;
  color: var(--ms-text-primary, #182236);
  font-size: clamp(26px, 2.4vw, 34px);
}
.ms-products-header p {
  margin: 3px 0 0;
  color: var(--ms-text-secondary, #59657b);
  font-size: 13px;
}
.ms-products-header-media {
  width: 100%;
  height: 96px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.ms-products-header-media img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 86px;
  margin: auto 0 auto auto;
  object-fit: contain;
  object-position: right center;
}

.ms-products-toolbar {
  width: 100%;
  min-width: 0;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--ms-border-color, #dfe4ee);
  border-radius: 12px;
  background: var(--ms-surface, #fff);
}
.ms-products-toolbar .ms-canonical-toolbar { min-width: 0; }
.ms-products-toolbar .ms-canonical-toolbar-actions { gap: 3px; }
.ms-products-toolbar .ms-canonical-toolbar-button {
  padding-inline: 6px;
  gap: 3px;
  font-size: 10.5px;
}
.ms-products-toolbar .ms-canonical-toolbar-search {
  flex-basis: 170px;
  min-width: 150px;
}
.ms-products-toolbar [data-action="export-pdf"] .ms-canonical-toolbar-icon { font-size: 8px; font-weight: 900; }

.ms-products-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--ms-border-color, #dfe4ee);
  border-radius: 14px;
  background: var(--ms-surface, #fff);
}
.ms-products-table-wrap table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  table-layout: auto;
}
.ms-products-table-wrap th,
.ms-products-table-wrap td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ms-border-color, #dfe4ee);
  color: var(--ms-text-primary, #182236);
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  vertical-align: top;
}
.ms-products-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--ms-surface-secondary, #f7f8fc);
  color: var(--ms-text-secondary, #59657b);
  font-size: 10.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ms-products-table-wrap tbody tr:last-child td { border-bottom: 0; }
.ms-products-select-cell { width: 34px; text-align: center !important; }
.ms-products-select-cell input { width: 16px; height: 16px; margin: 0; accent-color: var(--ms-accent, #625df5); }
.ms-products-page:not(.is-selection-mode) .ms-products-select-cell { display: none; }
.ms-products-table-wrap tbody > tr.ms-products-row-even > td {
  background: var(--ms-surface-tertiary, #f3f5f8);
  background: color-mix(in srgb, var(--ms-surface-primary, #fff) 94%, var(--ms-text-primary, #182236) 6%);
}
.ms-products-table-wrap tbody > tr:not(.ms-products-category-row):not(.ms-products-section-row):hover > td {
  background: color-mix(in srgb, var(--ms-accent, #625df5) 4%, var(--ms-surface-primary, #fff));
}
.ms-products-table-wrap tbody > tr.is-selected > td,
.ms-products-table-wrap tbody > tr.is-selected:hover > td {
  background: color-mix(in srgb, var(--ms-accent, #625df5) 10%, var(--ms-surface-primary, #fff));
}
.ms-products-table-wrap tbody > tr.is-inline-editing > td,
.ms-products-table-wrap tbody > tr.is-inline-editing:hover > td {
  background: color-mix(in srgb, var(--ms-accent, #625df5) 14%, var(--ms-surface-primary, #fff));
}
.ms-products-table-wrap tbody > tr.is-inline-editing {
  box-shadow: inset 3px 0 var(--ms-accent, #625df5);
}
.ms-products-table-wrap tbody > tr.is-inline-editing.is-dirty {
  box-shadow: inset 3px 0 var(--ms-accent, #625df5), inset 0 0 0 1px color-mix(in srgb, var(--ms-accent, #625df5) 24%, transparent);
}
.ms-products-table-wrap tr.is-inline-editing :is(input, textarea, select) {
  width: 100%;
  min-width: 72px;
  padding: 6px 7px;
  border: 1px solid var(--ms-border-color, #dfe4ee);
  border-radius: 7px;
  background: var(--ms-surface-primary, #fff);
  color: var(--ms-text-primary, #182236);
  font: inherit;
}
.ms-products-table-wrap tr.is-inline-editing textarea { min-width: 240px; resize: vertical; line-height: 1.3; }
.ms-products-table-wrap tr.is-inline-editing .ms-products-money input { min-width: 108px; text-align: right; }
.ms-products-table-wrap tr.is-inline-editing .ms-products-currency input { min-width: 58px; text-transform: uppercase; }
.ms-products-inline-actions { white-space: nowrap; text-align: right !important; }
.ms-products-inline-actions button {
  width: 28px;
  height: 28px;
  margin-left: 4px;
  border: 1px solid var(--ms-border-color, #dfe4ee);
  border-radius: 7px;
  background: var(--ms-surface-primary, #fff);
  color: var(--ms-text-primary, #182236);
  font-weight: 800;
}
.ms-products-inline-actions [data-inline-save] { color: var(--green, #2da66f); }
.ms-products-inline-actions [data-inline-cancel] { color: #c84d5a; }
.ms-products-code, .ms-products-currency, .ms-products-date, .ms-products-money { white-space: nowrap; }
.ms-products-code { font-weight: 800; }
.ms-products-description { width: 55%; min-width: 340px; }
.ms-products-money { text-align: right !important; font-variant-numeric: tabular-nums; }
.ms-products-empty { padding: 34px !important; text-align: center !important; color: var(--ms-text-muted, #8a94a8) !important; }

.ms-products-category-row td {
  padding: 14px 16px;
  background: var(--ms-surface-secondary, #f7f8fc);
  border-top: 1px solid var(--ms-border-color, #dfe4ee);
}
.ms-products-category-row td,
.ms-products-category-row strong { vertical-align: middle; }
.ms-products-category-row img {
  width: 62px;
  height: 34px;
  margin-right: 12px;
  object-fit: contain;
  vertical-align: middle;
}
.ms-products-category-row strong { font-size: 14px; }
[data-omnia-visual-scope="suite"] .ms-products-section-row td {
  padding: 0 !important;
  background: var(--ms-surface-secondary);
  color: var(--ms-text-primary) !important;
}
.ms-products-section-row b,
.ms-products-section-row span { display: inline-block; padding: 8px 12px; }
[data-omnia-visual-scope="suite"] .ms-products-section-row b { min-width: 62px; background: var(--ms-surface-tertiary); color: var(--ms-text-primary); letter-spacing: .08em; }

.ms-products-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--ms-text-secondary, #59657b);
  font-size: 12px;
}
.ms-products-pagination button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ms-border-color, #dfe4ee);
  border-radius: 10px;
  background: var(--ms-surface, #fff);
  color: var(--ms-text-primary, #182236);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.ms-products-pagination button:disabled { cursor: not-allowed; opacity: .45; }
.ms-products-print-document { display: none; }

@media (max-width: 820px) {
  .ms-products-header { grid-template-columns: 1fr; }
  .ms-products-header-media { justify-content: flex-start; }
  .ms-products-header-media img { margin-left: 0; object-position: left center; }
  .ms-products-pagination { justify-content: space-between; }
}

@media print {
  .ms-sidebar,
  .ms-topbar,
  .ms-products-page > :not(.ms-products-print-document),
  [data-print-exclude] { display: none !important; }

  html, body, .ms-main, .ms-content, #workspace, #mainContent {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }
  .ms-products-print-document {
    display: block !important;
    color: #111;
    font: 10pt/1.35 Arial, sans-serif;
  }
  .ms-products-print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #333;
  }
  .ms-products-print-header small { font-size: 8pt; font-weight: 700; letter-spacing: .12em; }
  .ms-products-print-header h1 { margin: 3px 0; font-size: 20pt; }
  .ms-products-print-header p { margin: 0; }
  .ms-products-print-header img { width: 180px; height: 72px; object-fit: contain; }
  .ms-products-print-document table { width: 100%; border-collapse: collapse; }
  .ms-products-print-document th,
  .ms-products-print-document td { padding: 5px 7px; border-bottom: 1px solid #bbb; text-align: left; vertical-align: top; }
  .ms-products-print-document th:last-child,
  .ms-products-print-document td:last-child { text-align: right; white-space: nowrap; }
  .ms-products-print-category td { padding: 10px 7px; background: #e7e8eb !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .ms-products-print-category img { width: 70px; height: 36px; margin-right: 10px; object-fit: contain; vertical-align: middle; }
  .ms-products-print-category strong { vertical-align: middle; }
  .ms-products-print-section td { padding: 0; background: #343b49 !important; color: #fff !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .ms-products-print-section b,
  .ms-products-print-section span { display: inline-block; padding: 6px 8px; }
  .ms-products-print-section b { background: #232936 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .ms-products-print-document tr { break-inside: avoid; page-break-inside: avoid; }
}

/* Consume canonical wide-short density without changing portrait or normal tablets. */
@media screen and (min-width:700px) and (max-height:500px) {
  .ms-products-page { gap:var(--ms-density-section-gap,8px); }
  .ms-products-header {
    min-height:0;
    padding:var(--ms-density-panel-padding,8px 14px);
    gap:12px;
    grid-template-columns:minmax(0,1fr) minmax(140px,24%);
  }
  .ms-products-header h1 { margin-block:2px; font-size:26px; }
  .ms-products-header-media { height:64px; }
  .ms-products-header-media img { max-height:60px; }
  .ms-products-toolbar { padding:4px 8px; }
  html:is(.ms-theme-light,.ms-theme-dark) .ms-products-toolbar .ms-canonical-toolbar { padding-block:0 !important; margin-bottom:0 !important; }
  /* Match the canonical shell control geometry authority (which uses !important). */
  html:is(.ms-theme-light,.ms-theme-dark) .ms-products-toolbar .ms-canonical-toolbar-button,
  html:is(.ms-theme-light,.ms-theme-dark) .ms-products-toolbar .ms-canonical-toolbar-search { height:44px !important; min-height:44px !important; }
  .ms-products-pagination button { min-height:44px; }
  html table[data-products-table][data-ms-responsive-list] .ms-list-secondary { display:table-cell; }
  html table[data-products-table][data-ms-responsive-list] .ms-list-tertiary { display:none; }
  html table[data-products-table][data-ms-responsive-list] :is(th,td) { padding:6px 10px; }
  html table[data-products-table][data-ms-responsive-list] th[data-ms-i18n="ui.code"] { width:18%; }
  html table[data-products-table][data-ms-responsive-list] th[data-ms-i18n="contacts.fields.description"] { width:44%; }
  html table[data-products-table][data-ms-responsive-list] th[data-ms-i18n="ui.family"] { width:20%; }
  html table[data-products-table][data-ms-responsive-list] th[data-ms-i18n="ui.list_price"] { width:18%; }
}
