// Reports center screen — all 6 reports generate from real Supabase data. (() => { const { Card, Badge } = window.TechyFuelOSDesignSystem_be0222; const REPORTS = [ { id: 'clients', name: 'Client performance report', desc: 'Per-client retainer, deliverables & satisfaction', icon: 'users', tone: ['var(--blue-50)', 'var(--blue-600)'], runs: 'Auto · monthly' }, { id: 'team', name: 'Team productivity report', desc: 'Tasks completed, hours logged and time by task per member', icon: 'gauge', tone: ['var(--violet-50)', 'var(--violet-600)'], runs: 'Auto · weekly' }, { id: 'revenue', name: 'Revenue & profit report', desc: 'MRR, net profit, expenses and forecast', icon: 'trending-up', tone: ['var(--green-50)', 'var(--green-600)'], runs: 'Auto · monthly' }, { id: 'ads', name: 'Ads performance report', desc: 'Spend, ROAS, CPL and leads across ad accounts', icon: 'megaphone', tone: ['var(--amber-50)', 'var(--amber-600)'], runs: 'Manual' }, { id: 'projects', name: 'Project status report', desc: 'Milestones, budget burn and risk flags', icon: 'folder-kanban', tone: ['var(--teal-50)', 'var(--teal-600)'], runs: 'Auto · weekly' }, { id: 'content', name: 'Content engagement report', desc: 'Reach, engagement and best-performing posts', icon: 'heart', tone: ['var(--red-50)', 'var(--red-600)'], runs: 'Manual' }, { id: 'sales', name: 'Sales pipeline report', desc: 'Deals by stage, pipeline value and won revenue', icon: 'filter', tone: ['var(--blue-50)', 'var(--blue-600)'], runs: 'Manual' }, { id: 'attendance', name: 'Attendance report', desc: 'Present, absent, late, hours & overtime this month', icon: 'clock', tone: ['var(--teal-50)', 'var(--teal-600)'], runs: 'Auto · monthly' }, ]; function fmtDate(ds) { if (!ds) return '—'; return new Date(ds).toLocaleDateString('en', { month: 'short', day: 'numeric', year: 'numeric' }); } function fmtAmt(n, currency) { const syms = { USD: '$', EUR: '€', GBP: '£', PKR: '₨', AED: 'AED ', SAR: 'SAR ', CAD: 'CA$', AUD: 'A$' }; return (syms[currency || 'PKR'] || '₨') + Number(n || 0).toLocaleString(); } function getSaved() { try { return JSON.parse(localStorage.getItem('tf_settings') || '{}'); } catch { return {}; } } // Home/reporting currency is PKR — every invoice total in these reports // converts through live FX rates before summing, same as the Finance screen. function toPKR(amount, currency, rates) { const n = Number(amount); if (!n) return 0; if (!currency || currency === 'PKR') return n; if (!rates) return 0; const usd = currency === 'USD' ? n : (rates[currency] ? n / rates[currency] : null); if (usd === null) return 0; return rates.PKR ? usd * rates.PKR : 0; } /* ── PDF print window ──────────────────────────────────────────── */ function openPDF(title, bodyHtml) { const agency = getSaved().agencyName || 'TechyFuel OS'; const date = new Date().toLocaleDateString('en', { month: 'long', day: 'numeric', year: 'numeric' }); const html = `