/* —— Products catalogue: same window fit as Purchase orders —— */
.hub-main:has(#products-panel:not([hidden])) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 4px;
  padding-bottom: 8px;
}

.hub-main:has(#products-panel:not([hidden])) > .subnav {
  flex: 0 0 auto;
  padding-top: 2px;
  padding-bottom: 4px;
}

.hub-main:has(#products-panel:not([hidden])) > .stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-top: 4px;
  padding-bottom: 0;
}

#products-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#products-panel .ord {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#products-panel .ord > .list-head,
#products-panel .ord > .due,
#products-panel .list-head .due {
  margin: 0;
}

#products-panel .list-head .due {
  display: flex;
  align-items: center;
  gap: 10px;
}

#products-panel .ord-po-workspace {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
}

#products-panel .ord-po-layout {
  width: 100%;
  min-width: 0;
}

#products-panel .ord-po-detail-pane {
  min-width: 0;
  overflow: auto;
}

#products-panel .ord-po-list {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

#products-panel .ord-po-filters,
#products-panel .ord-po-row {
  width: 100%;
  min-width: var(--ord-po-min, 0px);
  justify-content: start;
}

/* One scroller (the list). The header stays only as tall as its words, and the rows start directly under it. */
#products-panel .ord-po-table {
  display: grid;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-content: start;
  overflow: auto;
}

#products-panel .cat-list-sticky {
  position: sticky;
  top: 0;
  z-index: 3;
  height: auto;
  align-self: start;
  background: var(--surface-2);
  width: max-content;
  min-width: 100%;
}

#products-panel .ord-po-table-body {
  align-content: start;
}

#products-panel .cat-list-sticky .ord-po-list-tools,
#products-panel .cat-list-sticky .ord-po-filters {
  position: static;
  top: auto;
  background: var(--surface-2);
}

#products-panel .cat-list-sticky .ord-po-list-tools {
  width: 100%;
}

#products-panel .ord-po-filters input {
  height: var(--list-row-height);
  min-height: var(--list-row-height);
  max-height: var(--list-row-height);
  padding: 0 12px 0 6px;
  font-size: 0.86rem;
  line-height: 1.2;
  box-sizing: border-box;
}

#products-panel .ord-po-filters .ord-po-col-drag {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

#products-panel .ord-po-filters .ord-po-col,
#products-panel .ord-po-filters .ord-sort-head {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

#products-panel .ord-po-filters .ord-sort-head {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#products-panel .ord-po-row,
#products-panel .ord-po-row .ord-po-col {
  font-size: 0.96rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

#products-panel .ord-po-row .ord-po-col,
#products-panel .ord-po-row .ord-po-col strong {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#products-panel .ord-po-row .ord-po-col strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 600;
}

#products-panel .ord-po-row .ord-po-col:has(.ord-pill) {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#products-panel .ord-po-row .ord-pill {
  display: inline-block;
  width: auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* One vertical scroller so a sticky header cannot sit over the row you click. */
#products-panel .ord-po-list.is-pack-review .ord-po-table {
  overflow: visible;
}

#products-panel .ord-po-list.is-pack-review .ord-po-filters {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
}



#products-panel .ord-po-row.is-inactive {
  opacity: 0.6;
}

#products-panel .ord-po-detail-pane > .cat-product-detail {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
}

.cat-product-detail {
  padding: var(--nav-gap) var(--nav-gap) var(--nav-gap) 0;
  overflow: auto;
  height: auto;
  align-content: start;
  box-sizing: border-box;
  font-size: 0.78rem;
  gap: var(--nav-gap);
  background: var(--bg);
}

.cat-product-detail .ord-po-detail-head {
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.cat-product-detail .ord-po-detail-head > div {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  overflow: hidden;
}

.cat-product-detail .ord-po-number {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.cat-price-readout {
  margin: 0;
  padding: 7px 0 0;
  font-size: 0.86rem;
  line-height: 1.3;
  color: var(--ink);
}

.cat-active-select {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 0;
  padding: 4px 24px 4px 8px;
  width: auto;
  border-radius: var(--field-radius);
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 6px center;
}

.cat-product-detail .ord-po-detail-sub {
  display: block;
  margin: 1px 0 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cat-product-detail .due {
  margin: 0;
  padding: 4px 8px 0;
}

.cat-product-form-wrap {
  display: grid;
  gap: var(--nav-gap);
  align-content: start;
  width: 100%;
  max-width: none;
}

.cat-detail-section {
  border: 0;
  background: var(--surface);
  border-radius: var(--radius);
  min-width: 0;
}

.cat-detail-section-title {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border-bottom: 0;
}

#products-panel fieldset,
#suppliers-panel fieldset,
#stock-panel fieldset,
#site-database-panel fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.cat-product-form-wrap > fieldset,
.cat-supplier-form-wrap > fieldset {
  display: grid;
  gap: var(--nav-gap);
  align-content: start;
}

.account-form.cat-product-form,
.cat-product-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-items: start;
  align-content: start;
  padding: 6px 8px;
  box-sizing: border-box;
}

.cat-product-form .field {
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

.cat-product-form .field span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  min-height: 1.2em;
}

.cat-product-form .field input:not([type="checkbox"]),
.cat-product-form .field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.92rem;
  color: var(--ink);
  min-height: 32px;
  height: 32px;
  padding: 4px 8px;
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  background-clip: padding-box;
  color-scheme: dark;
}

.cat-product-form .field input[type="number"] {
  appearance: auto;
  -webkit-appearance: auto;
}

.cat-product-form .field select {
  padding-right: 28px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.cat-product-form .field input:not([type="number"]):not([type="checkbox"]) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-purchase-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.3fr);
  gap: 6px 10px;
  min-width: 0;
}

.cat-contains-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 0;
  background: transparent;
  box-sizing: border-box;
}

#products-panel .cat-contains-row input,
#products-panel .cat-contains-row select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  background-color: var(--surface-2);
  min-height: 32px;
  height: 32px;
  padding: 4px 8px;
  color-scheme: dark;
}

#products-panel .cat-contains-row input[type="number"] {
  appearance: auto;
  -webkit-appearance: auto;
}

#products-panel .cat-contains-row select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 8px center;
}

#products-panel .cat-contains-row input:focus,
#products-panel .cat-contains-row select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: none;
}

.cat-contains-row input {
  flex: 1 1 5rem;
  min-width: 0;
}

.cat-contains-row select {
  flex: 0 1 8rem;
  width: auto;
  border-left: 1px solid var(--line);
}

#products-panel .cat-product-form .field input:not([type="checkbox"]):focus,
#products-panel .cat-product-form .field select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: none;
}

html[data-theme="light"] #products-panel .cat-product-form .field input:not([type="checkbox"]),
html[data-theme="light"] #products-panel .cat-product-form .field select,
html[data-theme="light"] #products-panel .cat-contains-row input,
html[data-theme="light"] #products-panel .cat-contains-row select {
  background-color: #ffffff;
  border-color: rgba(0, 0, 0, 0.18);
  color-scheme: light;
}

html[data-theme="light"] #products-panel .cat-product-form .field input:focus,
html[data-theme="light"] #products-panel .cat-product-form .field select:focus,
html[data-theme="light"] #products-panel .cat-contains-row input:focus,
html[data-theme="light"] #products-panel .cat-contains-row select:focus {
  border-color: rgba(0, 0, 0, 0.35);
}

.cat-product-form .field-span-2 {
  grid-column: span 2;
}

.cat-product-form .field-span-3 {
  grid-column: span 3;
}

.cat-product-form .error,
.cat-product-form .check-inline,
.cat-product-form-wrap > .error {
  grid-column: 1 / -1;
  margin: 0;
}

.cat-product-form .check-inline {
  font-size: 0.84rem;
  padding-top: 4px;
}

.cat-product-form .cat-check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  cursor: pointer;
}

#products-panel .ord-po-detail-pane {
  min-width: 0;
}

#products-panel .cat-product-detail,
#products-panel .cat-product-form-wrap,
#products-panel .cat-detail-section {
  min-width: 0;
  max-width: 100%;
}

#products-panel .ord-po-actions-rail .ord-po-action-btn.is-selected {
  background: var(--brand, var(--teal));
  color: var(--brand-ink);
  border-color: var(--brand, var(--teal));
}

@media (max-width: 900px) {
  #products-panel .ord-po-workspace .ord-po-layout.is-split {
    grid-template-columns: 1fr !important;
  }

  #products-panel .ord-po-workspace .ord-po-split {
    display: none;
  }
}

