.quantity {
    display: flex;
    align-items: stretch;
    gap: 0;
    min-width: 110px;
    flex-wrap: wrap;
}

.quantity > .qty-btn,
.quantity > input.qty,
.quantity > .unit-suffix {
    flex-shrink: 0;
}

.quantity.per-oz {
    align-items: center;
}

.quantity input.qty {
    width: 60px !important;
    height: 36px !important;
    padding: 0 6px !important;
    border: 1px solid #bfe2dc !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    font-size: 15px !important;
    font-family: brandon-grotesque, sans-serif !important;
    font-weight: 600 !important;
    text-align: center !important;
    background: #fff !important;
    color: #1f2937 !important;
    box-sizing: border-box !important;
}

.quantity input.qty:focus {
    border-color: #a5ccbc;
    outline: none;
    box-shadow: 0 0 0 2px rgba(165, 204, 188, 0.3);
}

.quantity input.qty {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    touch-action: manipulation;
}

.quantity input.qty::-webkit-inner-spin-button,
.quantity input.qty::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0;
    display: none !important;
}

.quantity input.qty[type=number] {
    -moz-appearance: textfield;
}

.quantity .qty-btn {
    width: 30px !important;
    height: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid #bfe2dc !important;
    background: #f5f9f6 !important;
    border-radius: 6px 0 0 6px !important;
    font-size: 18px !important;
    font-family: brandon-grotesque, sans-serif !important;
    line-height: 1 !important;
    cursor: pointer !important;
    color: #2c5e54 !important;
    user-select: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s, border-color 0.15s !important;
}

.quantity .qty-btn:last-of-type {
    border-radius: 0 6px 6px 0 !important;
}

.quantity .qty-btn:hover {
    background: #eaf2ee !important;
    border-color: #2c5e54 !important;
}

.quantity .qty-btn:active {
    background: #dde8e2 !important;
}

.quantity .unit-suffix {
    margin-left: 6px;
    margin-right: 6px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

.quantity .eg-lbs-conversion {
    font-size: 12px;
    color: #6b7280;
    flex-basis: 100%;
    margin-top: 4px;
    text-align: left;
    width: 100%;
    order: 100; /* Push to end of flex container */
}

/* Single product: keep lbs conversion on same line as quantity + oz (right after oz) */
.single-product .quantity.per-oz .eg-lbs-conversion {
    flex-basis: auto;
    width: auto;
    order: unset;
    margin-top: 0;
    margin-left: 4px;
    white-space: nowrap;
}

.quantity .eg-subtotal {
    color: #1a1a1a !important;
    font-style: italic;
    font-weight: 400;
    margin-top: 8px;
    text-align: left;
}

.quantity .eg-subtotal:not(:last-child) {
    display: none !important;
}

/* Hide eg-subtotal everywhere - use mlvf-subtotal-container instead */
.quantity .eg-subtotal {
  display: none !important;
}

/* Product loop: hide any subtotal in the quantity row so only action-row subtotal shows */
.woocommerce ul.products li.product .mlvf-quantity-row .mlvf-subtotal-container,
.woocommerce ul.products li.product .mlvf-quantity-row .eg-subtotal {
  display: none !important;
}

/* Archive layout: keep quantity controls, arrows, and unit suffix inline */
.woocommerce ul.products li.product .mlvf-quantity-box .quantity {
    display: grid;
    grid-template-columns: auto minmax(50px, 1fr) auto auto;
    column-gap: 0;
    row-gap: 4px;
    align-items: center;
    min-width: 0;
}

.woocommerce ul.products li.product .mlvf-quantity-box .quantity input.qty {
    width: 100% !important;
    min-width: 48px;
    max-width: 65px;
}

.woocommerce ul.products li.product .mlvf-quantity-box .quantity .qty-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 30px !important;
    height: 36px !important;
    border-radius: 6px 0 0 6px !important;
}

.woocommerce ul.products li.product .mlvf-quantity-box .quantity .qty-btn:last-of-type {
    border-radius: 0 6px 6px 0 !important;
}

.woocommerce ul.products li.product .mlvf-quantity-box .quantity .unit-suffix {
    margin-left: 2px;
    font-size: 12px;
    color: #4b5563;
    white-space: nowrap;
}

.woocommerce ul.products li.product .mlvf-quantity-box .quantity .eg-lbs-conversion,
.woocommerce ul.products li.product .mlvf-quantity-box .quantity .eg-low-stock {
    grid-column: 1 / -1;
}

@media (max-width: 540px) {
    .woocommerce ul.products li.product .mlvf-quantity-box .quantity {
        grid-template-columns: auto minmax(46px, 1fr) auto auto;
        column-gap: 3px;
    }

    .woocommerce ul.products li.product .mlvf-quantity-box .quantity .qty-btn {
        width: 30px !important;
        height: 34px !important;
        font-size: 16px !important;
    }
    
    .woocommerce ul.products li.product .mlvf-quantity-box .quantity input.qty {
        max-width: 58px;
        font-size: 15px !important;
    }
}

/* Unified styling for the mlvf subtotal container */
.mlvf-subtotal-container {
    margin-top: 8px;
    font-size: 14px;
    text-align: left;
    color: #555;
    font-style: italic;
    font-weight: 500;
    height: 1.2em;
    display: block !important;
}

.quantity .eg-low-stock {
    color: #436342 !important;
    border-radius: 4px;
    display: inline-block;
    font-style: italic;
    font-weight: 500;
    font-size: 0.85em;
    flex-basis: 100%;
    margin-top: 2px;
    text-align: left;
}

@media (max-width: 480px) {
    .quantity {
        flex-wrap: wrap;
    }
    .quantity input.qty {
        max-width: 100%;
    }
}

/* --- Loop specific overrides --- */

.woocommerce ul.products li.product .mlvf-quantity-box .quantity .eg-lbs-conversion {
    flex-basis: auto;
    margin-top: 0;
    margin-left: 4px;
    white-space: nowrap;
    text-align: left;
}

/* Single product layout adjustments */
.single-product .quantity {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
}

.single-product .mlvf-subtotal-container {
    margin-top: 0.3em;
    font-size: 0.95em;
    clear: both;
    text-align: right;
}

/* Always show subtotals for simple products */
body.product-type-simple .mlvf-subtotal-container {
    display: block !important;
}

/* Tighten variation overlay spacing */
.mlvf-var-overlay .woocommerce-variation-add-to-cart {
    margin-top: 4px !important;
}
.mlvf-var-overlay .value {
    margin-bottom: 4px !important;
}

@media (max-width: 420px) {
    .woocommerce ul.products li.product .mlvf-quantity-box .quantity .eg-lbs-conversion {
        flex-basis: 100%;
        margin-left: 0;
        margin-top: 2px;
        text-align: right;
    }
    /* Hide lbs conversion in loops on very small screens */
    .woocommerce ul.products li.product .mlvf-quantity-box .quantity.per-oz .eg-lbs-conversion {
        display: none;
    }
}

/* Suggested starting amount indicator */
.eg-suggested-amount {
    display: inline-block;
    font-size: 11px;
    color: #436342;
    font-style: italic;
    font-weight: 400;
    margin-left: 6px;
    padding: 2px 8px;
    background: rgba(67, 99, 66, 0.08);
    border-radius: 10px;
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: 0.01em;
    transition: opacity 0.4s ease;
}

.eg-suggested-amount.eg-amount-changed {
    opacity: 0;
    pointer-events: none;
}

.single-product .quantity .eg-suggested-amount {
    flex-basis: 100%;
    margin-left: 0;
    margin-top: 4px;
    text-align: left;
    order: 99;
}

.woocommerce ul.products li.product .eg-suggested-amount {
    display: none !important;
}
