.wcms-metered-box{
  direction:rtl;
  border:1px solid rgba(0,0,0,.08);
  border-radius:14px;
  padding:16px;
  margin:0 0 16px;
  background:#fff;
  box-sizing:border-box;
  width:100%!important;
  max-width:100%!important;
  flex:0 0 100%!important;
  order:-10!important;
}
.wcms-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.wcms-title{font-weight:700;font-size:15px}
.wcms-unit-price{font-size:13px;opacity:.72}
.wcms-control{display:flex;align-items:center;gap:8px;margin:14px 0;max-width:100%}
.wcms-control button{width:42px;height:42px;min-width:42px;border:1px solid rgba(0,0,0,.1);border-radius:10px;background:#f7f7f7;cursor:pointer;font-size:22px;line-height:1;display:inline-flex;align-items:center;justify-content:center;padding:0!important;box-sizing:border-box}
.wcms-control button:hover{background:#efefef}
.wcms-length{width:100px!important;max-width:100px!important;height:42px!important;text-align:center;border:1px solid rgba(0,0,0,.12)!important;border-radius:10px!important;padding:0 8px!important;box-sizing:border-box!important}
.wcms-unit{font-weight:600;margin-right:2px;white-space:nowrap}
.wcms-summary{border-top:1px dashed rgba(0,0,0,.12);padding-top:11px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:7px 12px;align-items:center}
.wcms-summary .wcms-label{font-size:13px;opacity:.72;min-width:0}
.wcms-summary .wcms-value{font-size:14px;font-weight:700;text-align:left;direction:rtl;white-space:nowrap}
.wcms-summary .wcms-grand-label{font-size:15px;font-weight:700;margin-top:4px}
.wcms-summary .wcms-total{font-size:18px;font-weight:800;margin-top:4px;text-align:left;white-space:nowrap}
.wcms-total-note{grid-column:1/-1;display:block;font-size:11px;opacity:.58;margin-top:1px}

/* Desktop: box on its own row, Woo quantity + add-to-cart below. */
form.cart.wcms-metered-cart-form{
  display:flex!important;
  flex-wrap:wrap!important;
  align-items:center!important;
  gap:10px!important;
  min-width:0!important;
}
form.cart.wcms-metered-cart-form > .wcms-metered-box{
  width:100%!important;
  max-width:100%!important;
  flex:0 0 100%!important;
}
form.cart.wcms-metered-cart-form .quantity{
  order:1!important;
  align-self:center!important;
  flex:0 0 auto!important;
  margin:0!important;
  max-width:130px!important;
}
form.cart.wcms-metered-cart-form .single_add_to_cart_button,
form.cart.wcms-metered-cart-form button.single_add_to_cart_button,
form.cart.wcms-metered-cart-form .button.single_add_to_cart_button{
  order:2!important;
  width:auto!important;
  min-width:180px!important;
  max-width:100%!important;
  min-height:52px!important;
  height:52px!important;
  padding:0 24px!important;
  margin:0!important;
  align-self:center!important;
  flex:0 1 auto!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  line-height:1.2!important;
  box-sizing:border-box!important;
  white-space:normal!important;
}

/* Mobile: use a real 2-column grid so the button can never leave the form. */
@media(max-width:767px){
  form.cart.wcms-metered-cart-form{
    display:grid!important;
    grid-template-columns:minmax(92px,auto) minmax(0,1fr)!important;
    column-gap:10px!important;
    row-gap:12px!important;
    width:100%!important;
    max-width:100%!important;
    box-sizing:border-box!important;
  }
  form.cart.wcms-metered-cart-form > .wcms-metered-box{
    grid-column:1 / -1!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    margin-bottom:0!important;
  }
  form.cart.wcms-metered-cart-form .quantity{
    grid-column:1!important;
    width:auto!important;
    min-width:0!important;
    max-width:120px!important;
    justify-self:start!important;
    margin:0!important;
  }
  form.cart.wcms-metered-cart-form .single_add_to_cart_button,
  form.cart.wcms-metered-cart-form button.single_add_to_cart_button,
  form.cart.wcms-metered-cart-form .button.single_add_to_cart_button{
    grid-column:2!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    padding:0 14px!important;
    box-sizing:border-box!important;
    overflow:hidden!important;
  }
  .wcms-metered-box{padding:14px!important}
  .wcms-head{gap:7px}
  .wcms-control{gap:6px;flex-wrap:nowrap}
  .wcms-length{width:82px!important;max-width:82px!important}
  .wcms-control button{width:40px;height:40px;min-width:40px}
  .wcms-summary{grid-template-columns:minmax(0,1fr) auto;gap:7px 8px}
  .wcms-summary .wcms-total{font-size:16px}
}

/* Very narrow phones: stack quantity and CTA for maximum compatibility. */
@media(max-width:380px){
  form.cart.wcms-metered-cart-form{
    grid-template-columns:1fr!important;
  }
  form.cart.wcms-metered-cart-form > .wcms-metered-box,
  form.cart.wcms-metered-cart-form .quantity,
  form.cart.wcms-metered-cart-form .single_add_to_cart_button,
  form.cart.wcms-metered-cart-form button.single_add_to_cart_button,
  form.cart.wcms-metered-cart-form .button.single_add_to_cart_button{
    grid-column:1!important;
  }
  form.cart.wcms-metered-cart-form .single_add_to_cart_button,
  form.cart.wcms-metered-cart-form button.single_add_to_cart_button,
  form.cart.wcms-metered-cart-form .button.single_add_to_cart_button{
    width:100%!important;
  }
}
