const DashboardUI = { async load() { try { const [status, agents] = await Promise.all([ API.system.status(), API.agents.list(), ]); DashboardUI.updateMetrics(status, agents); DashboardUI.updateRecentActivity(status.executions?.list || []); DashboardUI.updateSystemStatus(status); } catch (err) { Toast.error(`Erro ao carregar dashboard: ${err.message}`); } }, updateMetrics(status, agents) { const metrics = { 'metric-total-agents': status.agents?.total ?? (agents?.length ?? 0), 'metric-active-agents': status.agents?.active ?? 0, 'metric-executions-today': status.executions?.active ?? 0, 'metric-schedules': status.schedules?.total ?? 0, }; for (const [id, target] of Object.entries(metrics)) { const el = document.getElementById(id); if (!el) continue; const current = parseInt(el.textContent, 10) || 0; DashboardUI._animateCount(el, current, target); } }, _animateCount(el, from, to) { const duration = 600; const start = performance.now(); const step = (now) => { const elapsed = now - start; const progress = Math.min(elapsed / duration, 1); const eased = 1 - Math.pow(1 - progress, 3); const value = Math.round(from + (to - from) * eased); el.textContent = value; if (progress < 1) requestAnimationFrame(step); }; requestAnimationFrame(step); }, updateRecentActivity(executions) { const list = document.getElementById('activity-list'); if (!list) return; if (!executions || executions.length === 0) { list.innerHTML = `