<% @opportunities_by_stage[stage].each do |opp| %>
<%= link_to opp.organization.name, opp.organization, class: "font-medium text-zinc-900 hover:underline dark:text-zinc-50", data: { turbo: false } %>
<%= opp.name %>
<%= format_money(opp.estimated_value) %>
<%= opp.organization.primary_contact&.full_name || opp.organization.contacts.first&.full_name || "—" %>
<% next_task = opp.next_pending_task || opp.organization.next_pending_task %>
<%= next_task ? "Next: #{next_task.title}" : "Nessuna next action" %>
Ultima attività: <%= opp.organization.days_since_last_activity ? "#{opp.organization.days_since_last_activity}gg fa" : "—" %>
<%= form_with url: update_stage_opportunity_path(opp), method: :patch, class: "mt-2" do %>
<%= select_tag :pipeline_stage, options_for_catalog(Catalog::PIPELINE_STAGES, opp.pipeline_stage), class: "#{input_class} text-xs py-1", onchange: "this.form.requestSubmit()" %>
<% if stage != "lost" %>
<%= select_tag :lost_reason, options_for_catalog(Catalog::LOST_REASONS), include_blank: "Motivo se perso", class: "#{input_class} mt-1 text-xs py-1" %>
<% end %>
<% end %>