<div class="shop-row">
    <div class="shop-info">
        <strong>CI upgrade</strong>
        <span>{% if farm.ci_next_tier %}Upgrade to {{ farm.ci_next_label }} for faster builds{% else %}CI is at the top tier.{% endif %}</span>
    </div>
    {% if farm.ci_next_tier %}
    <form method="post" action="/game/upgrade" data-game-action="upgrade">
        <button type="submit" class="btn btn-sm btn-primary">Upgrade ({{ format_coins(farm.ci_next_cost) }})</button>
    </form>
    {% endif %}
</div>
<div class="shop-row">
    <div class="shop-info">
        <strong>Refactor (prestige {{ farm.prestige }})</strong>
        <span>{% if not farm.prestige_available %}Reach level {{ farm.prestige_min_level }} to refactor.{% elif farm.refactor_affordable %}Pay {{ format_coins(farm.refactor_cost) }} to reset your farm for a permanent +25% coin bonus. You keep {{ farm.refactor_carryover_pct }}% of what remains ({{ format_coins(farm.refactor_carryover_preview) }}) plus your Stars and Legacy upgrades.{% else %}Refactoring costs {{ format_coins(farm.refactor_cost) }} right now - keep farming to afford it.{% endif %}</span>
    </div>
    {% if farm.refactor_affordable %}
    <form method="post" action="/game/prestige" data-game-action="prestige">
        <button type="submit" class="btn btn-sm btn-primary" data-confirm="Refactoring costs {{ format_exact(farm.refactor_cost) }} coins and resets coins, level, CI, extra plots, and perks for a permanent +25% coin bonus. You carry over {{ format_exact(farm.refactor_carryover_preview) }} coins and keep your Stars and Legacy upgrades. Continue?">Refactor ({{ format_coins(farm.refactor_cost) }})</button>
    </form>
    {% endif %}
</div>
