/* RUN Catalog UI Polish R5 — PREVIEW ONLY, layout + brand asset correction.
   DO NOT change data, pricing, Add to Project/Delivery handlers, OTP or PDF logic.
   Loaded after R1/R2/R3; targets catalog table and mobile cards only. */
@media (min-width:701px) {
  #catalog .table-wrap table {table-layout:fixed!important;width:100%!important;min-width:0!important;}
  #catalog .table-wrap thead th:nth-child(2),
  #productTableBody > tr > td:nth-child(2) {width:39%!important;}
  #catalog .table-wrap thead th:nth-child(3),
  #productTableBody > tr > td:nth-child(3) {width:17%!important;}
  #catalog .table-wrap thead th:nth-child(4),
  #productTableBody > tr > td:nth-child(4) {width:14%!important;}
  #catalog .table-wrap thead th:nth-child(5),
  #productTableBody > tr > td:nth-child(5) {width:30%!important;}
  #productTableBody > tr > td:nth-child(2) {vertical-align:middle!important;text-align:left!important;}
  #productTableBody > tr > td:nth-child(3),
  #productTableBody > tr > td:nth-child(4) {vertical-align:middle!important;text-align:center!important;}
  #productTableBody > tr > td:nth-child(3) .category-pill {margin-inline:auto!important;}
  #productTableBody > tr > td:nth-child(5) {vertical-align:middle!important;padding-inline:12px!important;}
  #productTableBody td:nth-child(5) .price-brand-cell,
  #productTableBody td:nth-child(5) .price-brand-cell.run-rc3a1-digital-aligned {
    box-sizing:border-box!important;display:grid!important;
    grid-template-columns:minmax(0,1fr) 82px!important;
    grid-template-rows:auto!important;
    gap:clamp(8px,1vw,15px)!important;
    justify-content:stretch!important;justify-items:center!important;
    align-items:center!important;width:100%!important;min-width:0!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell > .run-price-stack,
  #productTableBody td:nth-child(5) .price-brand-cell > .run-rc3a1-price-stack {
    box-sizing:border-box!important;grid-column:1!important;
    display:flex!important;flex-direction:column!important;
    justify-content:center!important;align-items:center!important;
    width:100%!important;min-width:0!important;gap:8px!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell > .run-price-stack:empty {display:none!important;}
  #productTableBody td:nth-child(5) .price-brand-cell > .brand-logo-mark,
  #productTableBody td:nth-child(5) .price-brand-cell > .brand-logo-mark.has-asset {
    box-sizing:border-box!important;grid-column:2!important;grid-row:1!important;
    justify-self:center!important;align-self:center!important;
    display:flex!important;align-items:center!important;justify-content:center!important;
    width:82px!important;min-width:0!important;height:48px!important;
    padding:0 3px!important;margin:0!important;overflow:hidden!important;
  }
  #productTableBody td:nth-child(5) .brand-logo-img {
    display:block!important;width:100%!important;max-width:76px!important;
    height:44px!important;object-fit:contain!important;object-position:center!important;
    margin:0 auto!important;
  }
  #productTableBody td:nth-child(5) .price-badge {
    box-sizing:border-box!important;justify-self:center!important;min-width:0!important;
    width:min(170px,100%)!important;max-width:100%!important;
    margin:0 auto!important;white-space:nowrap!important;
    display:inline-flex!important;justify-content:center!important;text-align:center!important;
  }
  #productTableBody td:nth-child(5) .run-row-actions,
  #productTableBody td:nth-child(5) .run-row-actions-digital {
    box-sizing:border-box!important;display:flex!important;flex-direction:row!important;
    justify-content:center!important;align-items:stretch!important;
    flex-wrap:wrap!important;gap:8px!important;margin:0 auto!important;
    width:100%!important;min-width:0!important;
  }
  #productTableBody td:nth-child(5) .run-row-actions button {
    box-sizing:border-box!important;min-height:44px!important;
    font:700 clamp(12px,.9vw,14px)/1.2 Arial,sans-serif!important;
    padding:9px 10px!important;border-radius:10px!important;
    white-space:nowrap!important;max-width:100%!important;
    display:inline-flex!important;justify-content:center!important;align-items:center!important;
    text-align:center!important;
  }
  #productTableBody td:nth-child(5) .run-row-actions [data-run-action="delivery"] {flex:0 1 106px!important;}
  #productTableBody td:nth-child(5) .run-row-actions [data-run-action="add"] {flex:0 1 164px!important;}
  #productTableBody td:nth-child(5) .run-row-actions-digital [data-run-action="add"] {flex:0 1 174px!important;}
}
@media (min-width:701px) and (max-width:1180px) {
  #productTableBody td:nth-child(5) .price-brand-cell,
  #productTableBody td:nth-child(5) .price-brand-cell.run-rc3a1-digital-aligned {
    grid-template-columns:minmax(0,1fr) 60px!important;gap:5px!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell > .brand-logo-mark,
  #productTableBody td:nth-child(5) .price-brand-cell > .brand-logo-mark.has-asset {width:60px!important;height:40px!important;}
  #productTableBody td:nth-child(5) .brand-logo-img {max-width:58px!important;height:36px!important;}
  #productTableBody td:nth-child(5) .run-row-actions button {min-height:40px!important;font-size:12px!important;}
}
/* Mobile: reclaim the full card width; the PRICE label is a small independent row.
   Buttons no longer live inside the narrow right-of-label column. */
@media (max-width:700px) {
  #productTableBody > tr > td:nth-child(5) {
    box-sizing:border-box!important;display:block!important;
    width:100%!important;min-width:0!important;max-width:100%!important;
    padding:12px 0 0!important;margin:0!important;
  }
  #productTableBody > tr > td:nth-child(5)::before {
    content:"Price"!important;position:static!important;display:block!important;
    width:auto!important;min-width:0!important;
    margin:0 0 7px!important;padding:0!important;
    font:900 11px/1.2 Arial,sans-serif!important;color:#64748b!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell {
    box-sizing:border-box!important;display:grid!important;
    grid-template-columns:minmax(0,1fr) 72px!important;
    grid-template-rows:auto auto!important;
    gap:10px 10px!important;align-items:center!important;justify-content:stretch!important;
    width:100%!important;min-width:0!important;max-width:100%!important;
    padding:0!important;margin:0!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell .run-price-stack,
  #productTableBody td:nth-child(5) .price-brand-cell .run-rc3a1-price-stack {display:contents!important;}
  #productTableBody td:nth-child(5) .price-brand-cell .price-badge {
    grid-column:1!important;grid-row:1!important;
    box-sizing:border-box!important;display:inline-flex!important;
    justify-self:center!important;align-self:center!important;justify-content:center!important;
    max-width:100%!important;width:max-content!important;min-width:118px!important;
    min-height:38px!important;margin:0!important;text-align:center!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell > .brand-logo-mark,
  #productTableBody td:nth-child(5) .price-brand-cell > .brand-logo-mark.has-asset {
    grid-column:2!important;grid-row:1!important;
    box-sizing:border-box!important;width:72px!important;min-width:0!important;
    height:44px!important;margin:0!important;padding:2px!important;
    display:flex!important;align-items:center!important;justify-content:center!important;
    justify-self:center!important;align-self:center!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell .brand-logo-img {
    max-width:70px!important;width:100%!important;height:38px!important;
    object-fit:contain!important;object-position:center!important;margin:0 auto!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell .run-row-actions,
  #productTableBody td:nth-child(5) .price-brand-cell .run-row-actions-digital {
    grid-column:1/-1!important;grid-row:2!important;
    box-sizing:border-box!important;display:grid!important;
    grid-template-columns:minmax(0,.85fr) minmax(0,1.4fr)!important;
    gap:9px!important;align-items:stretch!important;justify-content:center!important;
    width:100%!important;max-width:100%!important;margin:0 auto!important;
  }
  #productTableBody td:nth-child(5) .price-brand-cell .run-row-actions-digital {
    display:flex!important;justify-content:center!important;align-items:center!important;
  }
  #productTableBody td:nth-child(5) .run-row-actions button {
    box-sizing:border-box!important;width:100%!important;min-width:0!important;
    min-height:46px!important;max-width:100%!important;
    font:700 14px/1.2 Arial,sans-serif!important;
    padding:10px 7px!important;border-radius:10px!important;
    white-space:nowrap!important;justify-content:center!important;align-items:center!important;
  }
  #productTableBody td:nth-child(5) .run-row-actions-digital [data-run-action="add"] {
    width:min(210px,100%)!important;max-width:210px!important;flex:0 1 210px!important;
  }
}
@media (min-width:346px) and (max-width:700px) {
  /* Override earlier <=400px rule so normal phones keep two full, centered CTAs. */
  #productTableBody td:nth-child(5) .price-brand-cell .run-price-stack .run-row-actions:not(.run-row-actions-digital) {
    grid-template-columns:minmax(0,.85fr) minmax(0,1.4fr)!important;
  }
}
@media (max-width:345px) {
  #productTableBody td:nth-child(5) .price-brand-cell .run-row-actions:not(.run-row-actions-digital) {
    grid-template-columns:minmax(0,1fr)!important;
  }
}
@media print { #productTableBody .run-row-actions {display:none!important;} }

/* ===============================================================
   RUN UI Polish R6 — COSMETIC OVERRIDES ONLY / PREVIEW ONLY
   NO changes to engine, data, rules, event handlers, OTP, PDF or APIs.
   Applies only to #catalog listing rows; keeps original DOM/SKU.
   =============================================================== */
@media (min-width:701px) {
  /* Four visible columns, including an explicit right-side logo slot inside
     the Price & Actions cell. The original hidden SKU cell stays in DOM. */
  #catalog .table-wrap table {table-layout:fixed!important;width:100%!important;}
  #catalog .table-wrap thead th:nth-child(2),
  #catalog #productTableBody > tr > td:nth-child(2) {width:35%!important;}
  #catalog .table-wrap thead th:nth-child(3),
  #catalog #productTableBody > tr > td:nth-child(3) {width:17%!important;}
  #catalog .table-wrap thead th:nth-child(4),
  #catalog #productTableBody > tr > td:nth-child(4) {width:14%!important;}
  #catalog .table-wrap thead th:nth-child(5),
  #catalog #productTableBody > tr > td:nth-child(5) {width:34%!important;}
  #catalog .table-wrap thead th:nth-child(3),
  #catalog .table-wrap thead th:nth-child(4),
  #catalog .table-wrap thead th:nth-child(5) {text-align:center!important;vertical-align:middle!important;}
  #catalog #productTableBody > tr > td:nth-child(2),
  #catalog #productTableBody > tr > td:nth-child(3),
  #catalog #productTableBody > tr > td:nth-child(4),
  #catalog #productTableBody > tr > td:nth-child(5) {vertical-align:middle!important;}
  #catalog #productTableBody > tr > td:nth-child(3),
  #catalog #productTableBody > tr > td:nth-child(4) {text-align:center!important;}
  #catalog #productTableBody > tr > td:nth-child(3) .category-pill {
    box-sizing:border-box!important;display:inline-flex!important;
    align-items:center!important;justify-content:center!important;
    text-align:center!important;max-width:min(230px,100%)!important;
    margin-inline:auto!important;line-height:1.4!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell {
    display:grid!important;grid-template-columns:minmax(0,1fr) 106px!important;
    align-items:center!important;justify-items:center!important;gap:clamp(8px,1.1vw,20px)!important;
    width:100%!important;min-width:0!important;margin:0 auto!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-price-stack,
  #catalog #productTableBody > tr > td:nth-child(5) .run-rc3a1-price-stack {
    grid-column:1!important;display:flex!important;flex-direction:column!important;
    align-items:center!important;justify-content:center!important;
    width:100%!important;min-width:0!important;gap:8px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .price-badge {
    width:min(190px,100%)!important;min-height:42px!important;
    display:inline-flex!important;justify-content:center!important;align-items:center!important;
    text-align:center!important;margin:0 auto!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions,
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions-digital {
    display:flex!important;flex-wrap:wrap!important;
    align-items:center!important;justify-content:center!important;
    width:min(320px,100%)!important;max-width:100%!important;
    gap:8px!important;margin:0 auto!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions button {
    box-sizing:border-box!important;min-width:0!important;min-height:46px!important;
    font:700 clamp(12px,0.93vw,14px)/1.2 Arial,sans-serif!important;
    padding:10px 11px!important;border-radius:10px!important;
    display:inline-flex!important;align-items:center!important;justify-content:center!important;
    text-align:center!important;white-space:nowrap!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions button[data-run-action="delivery"] {
    flex:1 1 90px!important;max-width:125px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions button[data-run-action="add"] {
    flex:1 1 136px!important;max-width:190px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions-digital button[data-run-action="add"] {
    flex:0 1 200px!important;width:min(200px,100%)!important;max-width:100%!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell > .brand-logo-mark,
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell > .brand-logo-mark.has-asset {
    box-sizing:border-box!important;grid-column:2!important;grid-row:1!important;
    justify-self:center!important;align-self:center!important;
    width:106px!important;max-width:100%!important;height:56px!important;
    display:flex!important;align-items:center!important;justify-content:center!important;
    padding:3px!important;margin:0!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-img {
    width:100%!important;max-width:102px!important;height:50px!important;
    object-fit:contain!important;object-position:center!important;
    display:block!important;margin:auto!important;
  }
}
@media (min-width:701px) and (max-width:1050px) {
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell {
    grid-template-columns:minmax(0,1fr) 72px!important;gap:6px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell > .brand-logo-mark,
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell > .brand-logo-mark.has-asset {
    width:72px!important;height:43px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-img {max-width:68px!important;height:39px!important;}
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions button {
    min-height:42px!important;font-size:12px!important;padding:8px 7px!important;
  }
}
@media (max-width:700px) {
  /* Final PRICE line uses a three-cell grid: label, price and brand.
     Action buttons sit in the NEXT compact, full-width row. We use
     display:contents on display-only wrappers so nested existing DOM and
     ALL JS event handlers are unchanged. */
  #catalog #productTableBody > tr {
    display:flex!important;flex-direction:column!important;
    align-items:stretch!important;justify-content:flex-start!important;
    min-height:0!important;gap:9px!important;padding:15px 14px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(2),
  #catalog #productTableBody > tr > td:nth-child(3),
  #catalog #productTableBody > tr > td:nth-child(4) {
    display:grid!important;grid-template-columns:80px minmax(0,1fr)!important;
    align-items:start!important;gap:10px!important;min-height:0!important;
  }
  #catalog #productTableBody > tr > td:nth-child(3) .category-pill {
    max-width:100%!important;display:inline-flex!important;
    justify-self:start!important;justify-content:center!important;
    text-align:center!important;line-height:1.35!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) {
    box-sizing:border-box!important;display:grid!important;
    grid-template-columns:80px minmax(0,1fr) minmax(64px,84px)!important;
    grid-template-rows:auto auto!important;
    gap:10px!important;align-items:center!important;
    padding:2px 0 0!important;margin:0!important;
    width:100%!important;min-height:0!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5)::before {
    grid-column:1!important;grid-row:1!important;
    align-self:center!important;margin:0!important;padding:0!important;
    width:auto!important;display:block!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .price-brand-cell,
  #catalog #productTableBody > tr > td:nth-child(5) .run-price-stack,
  #catalog #productTableBody > tr > td:nth-child(5) .run-rc3a1-price-stack {
    display:contents!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .price-badge {
    grid-column:2!important;grid-row:1!important;
    justify-self:start!important;align-self:center!important;
    box-sizing:border-box!important;display:inline-flex!important;
    align-items:center!important;justify-content:center!important;
    width:auto!important;min-width:0!important;max-width:100%!important;
    min-height:40px!important;padding:8px 14px!important;
    text-align:center!important;margin:0!important;
    white-space:nowrap!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark,
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark.has-asset {
    grid-column:3!important;grid-row:1!important;
    box-sizing:border-box!important;display:flex!important;
    justify-self:end!important;align-self:center!important;
    align-items:center!important;justify-content:center!important;
    width:84px!important;max-width:100%!important;height:49px!important;
    padding:2px!important;margin:0!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-img {
    width:100%!important;max-width:80px!important;height:45px!important;
    display:block!important;object-fit:contain!important;object-position:center!important;margin:auto!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions,
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions-digital {
    box-sizing:border-box!important;grid-column:1/-1!important;grid-row:2!important;
    justify-self:stretch!important;align-self:center!important;
    display:grid!important;grid-template-columns:minmax(0,.85fr) minmax(0,1.4fr)!important;
    width:100%!important;max-width:100%!important;gap:9px!important;
    margin:0!important;align-items:stretch!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions-digital {
    display:flex!important;justify-content:center!important;align-items:center!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions button {
    box-sizing:border-box!important;width:100%!important;max-width:100%!important;
    min-width:0!important;min-height:46px!important;
    display:inline-flex!important;align-items:center!important;justify-content:center!important;
    border-radius:10px!important;padding:10px 7px!important;
    font:700 14px/1.2 Arial,sans-serif!important;
    white-space:nowrap!important;text-align:center!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions-digital button[data-run-action="add"] {
    flex:0 1 210px!important;width:min(210px,100%)!important;max-width:210px!important;
  }
}
@media (max-width:355px) {
  #catalog #productTableBody > tr > td:nth-child(5) {
    grid-template-columns:74px minmax(0,1fr) minmax(52px,65px)!important;gap:8px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark,
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark.has-asset {
    width:65px!important;height:40px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-img {
    max-width:61px!important;height:36px!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions button {
    font-size:12px!important;
  }
}
/* R6 final: protect two-across physical CTA layout whenever the desktop
   action column can reasonably fit both buttons (no JS or DOM change). */
@media (min-width:1051px) {
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions:not(.run-row-actions-digital) {
    display:flex!important;flex-wrap:nowrap!important;gap:7px!important;
    width:100%!important;max-width:100%!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions:not(.run-row-actions-digital) button[data-run-action="delivery"] {
    flex:1 1 38%!important;max-width:none!important;
  }
  #catalog #productTableBody > tr > td:nth-child(5) .run-row-actions:not(.run-row-actions-digital) button[data-run-action="add"] {
    flex:1 1 62%!important;max-width:none!important;
  }
}

/* ===============================================================
   RUN UI Polish R7 — MICRO LOGO SCALE ONLY / PREVIEW ONLY
   Visual 8% reduction for brand marks in PRODUCT catalog rows.
   Preserve the existing layout slot, logo centering, aspect ratio,
   clickable elements, and all source data, rules and JS handlers.
   Screen only: PDF/print is unaffected.
   =============================================================== */
@media screen {
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark,
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark.has-asset {
    transform:scale(0.92)!important;
    transform-origin:center center!important;
  }
}


/* RUN R8 FINAL COSMETIC — only a further 5% visual reduction from R7.
   Keep brand logo box/layout, data, links, handlers, and My Project unchanged.
   Scope: main catalog table only; no print/PDF impact. */
@media screen {
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark,
  #catalog #productTableBody > tr > td:nth-child(5) .brand-logo-mark.has-asset {
    transform:scale(0.874)!important;
    transform-origin:center center!important;
  }
}
/* Single-SKU cost estimator is a reference view, not a service-picking flow.
   The old individual selection/add controls remain in source for compatibility
   but are not offered to users. Multi-product planning is via My Project. */
#deliveryEstimatorResultView .delivery-service-card .run-rc3b-choose,
#deliveryEstimatorResultView .delivery-result-actions #runRC3BAddDelivery,
#deliveryEstimatorResultView #runRC3BStatus {
  display:none!important;
}
/* Avoid a blank two-column action footer once the selection action is hidden. */
html.run-rc3b3-project-ready #deliveryEstimatorResultView .delivery-result-actions {
  grid-template-columns:minmax(0,1fr)!important;
}
