Inventory in Shopify lives on the variant, not the product. A coffee comes in 250g, 500g, 1kg sizes; each size has its own count. One product-level warning hides which size is running out.
The pattern: over product.variants, with an inside that gates the badge on the threshold:
{% for variant in product.variants %}
<label>
<input type="radio" name="variant" value="{{ variant.id }}">
{{ variant.title }}
{% if variant.inventory_quantity < 10 %}
<span class="variant-stock">Only {{ variant.inventory_quantity }} left</span>
{% endif %}
</label>
{% endfor %}
Don't lift this to the product level. product.variants.first.inventory_quantity answers a different question (the first variant's stock) and misleads the moment any other variant goes low.