/* One optional top-left badge; exact homepage/card scopes, never the PDP. */
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content .km-catalog-photo {
  position:relative;
  min-height:0;
}
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content .km-catalog-badge,
body.page-id-869 #brx-content :is(#brxe-ae0012,#brxe-ab0010,#brxe-ae0013) .km869-card-badge {
  position:absolute;
  top:12px;
  left:12px;
  z-index:3;
  display:block;
  width:fit-content;
  max-width:calc(100% - 24px);
  padding:7px 10px;
  border:0;
  border-radius:5px;
  background:#FFFFFF;
  color:#127D94;
  font:400 12px/1.35 Arial,sans-serif;
  letter-spacing:0;
  text-transform:none;
  text-align:left;
  white-space:normal;
  overflow-wrap:anywhere;
  box-sizing:border-box;
  pointer-events:none;
}
body.page-id-869 #brx-content :is(#brxe-ae0012,#brxe-ab0010,#brxe-ae0013) .km869-card-badge:empty {
  display:none;
}
/* Give a populated badge its own row inside the photo panel, so long labels
   cannot cover the actual image. Blank cards retain their existing layout. */
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content .km-catalog-photo:has(> .km-catalog-badge),
body.page-id-869 #brx-content :is(#brxe-ae0012,#brxe-ab0010,#brxe-ae0013) .km869-product-photo:has(> .km869-card-badge:not(:empty)) {
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
  grid-template-columns:minmax(0,1fr);
  gap:7px;
  padding:12px;
}
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content .km-catalog-photo > .km-catalog-badge,
body.page-id-869 #brx-content :is(#brxe-ae0012,#brxe-ab0010,#brxe-ae0013) .km869-product-photo > .km869-card-badge:not(:empty) {
  position:relative;
  top:auto;
  left:auto;
  grid-area:1 / 1;
  justify-self:start;
  max-width:100%;
}
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content .km-catalog-photo:has(> .km-catalog-badge) > img,
body.page-id-869 #brx-content :is(#brxe-ae0012,#brxe-ab0010,#brxe-ae0013) .km869-product-photo:has(> .km869-card-badge:not(:empty)) > a {
  grid-area:2 / 1;
  min-height:0;
  min-width:0;
  width:100%;
  height:100%;
}
/* Native sale pills stay separate at the upper right. */
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content li.product.sale > a.woocommerce-loop-product__link > .onsale {
  top:12px;
  right:12px;
  left:auto;
  max-width:64px;
}
body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content li.product.sale .km-catalog-badge {
  max-width:calc(100% - 64px);
}
@media(max-width:479px) {
  body:is(.post-type-archive-product,.tax-product_cat,.tax-product_brand) #brx-content .km-catalog-badge,
  body.page-id-869 #brx-content :is(#brxe-ae0012,#brxe-ab0010,#brxe-ae0013) .km869-card-badge {
    padding:5px 7px;
    font-size:11px;
  }
}
