const STAGES = ["No DR", "Mild", "Moderate", "Severe", "Proliferative"]; Promise.all([ fetch('/stats').then(r => r.json()), fetch('/history').then(r => r.json()) ]).then(([s, h]) => { document.getElementById('mTotal').textContent = s.total; document.getElementById('mRefer').textContent = s.referable; document.getElementById('mNormal').textContent = s.normal; document.getElementById('mRate').textContent = (s.total ? Math.round(s.referable / s.total * 100) : 0) + '%'; const max = Math.max(1, ...STAGES.map(c => s.dist[c] || 0)); document.getElementById('dist').innerHTML = STAGES.map((c, i) => { const v = s.dist[c] || 0; return `