<%- include('../partials/header') %><div class="approval-hero mb-4"><div><span class="eyebrow">INTELLIGENCE</span><h3 class="mb-1">Root Cause Intelligence</h3><p class="text-muted mb-0"><strong><%= capa.capa_no %></strong> · <%= capa.title %></p></div><form method="post" action="/root-cause/analyze/<%= capa.id %>"><button class="btn btn-primary"><i class="bi bi-stars me-1"></i> Run Analysis</button></form></div><div class="card panel-card"><div class="card-header"><div><h5>Ranked Recommendations</h5><small>Historical CAPA + Fishbone + Pareto evidence. Human acceptance is required.</small></div><span class="badge text-bg-light"><%= analysis?.status||'Not analysed' %></span></div><div class="card-body"><% if(!candidates.length){ %><div class="approval-empty"><i class="bi bi-search"></i><div><strong>No recommendations yet</strong><span>Run the deterministic analysis engine.</span></div></div><% } candidates.forEach((c,i)=>{ %><div class="border rounded-3 p-3 mb-3 <%= c.recommended?'border-primary':'' %>"><div class="d-flex justify-content-between gap-3"><div><strong>#<%= i+1 %> · <%= c.cause_text %></strong><div class="small text-muted"><%= c.category||'Evidence' %> · <%= c.source_summary %></div></div><div class="text-end"><strong><%= Number(c.confidence).toFixed(0) %>%</strong><div class="small text-muted">confidence</div></div></div><div class="progress mt-3" style="height:7px"><div class="progress-bar" style="width:<%= Math.min(100,Number(c.confidence)) %>%"></div></div><% if(c.decision){ %><div class="mt-2 small"><strong>Decision:</strong> <%= c.decision %></div><% } else { %><form method="post" action="/root-cause/accept/<%= analysis.id %>/<%= c.id %>" class="mt-3"><input class="form-control form-control-sm mb-2" name="review_comment" placeholder="Review comment"><button class="btn btn-sm btn-primary">Accept as CAPA root cause</button></form><% } %></div><% }) %><% if(analysis&&candidates.length){ %><form method="post" action="/root-cause/reject/<%= analysis.id %>" class="mt-2"><input class="form-control mb-2" name="review_comment" placeholder="Reason for rejecting recommendations"><button class="btn btn-sm btn-outline-danger">Reject analysis</button></form><% } %></div></div><%- include('../partials/footer') %>
