document.addEventListener('DOMContentLoaded',()=>{const base=window.APP_BASE||'',number=v=>Number(String(v??0).replace(/,/g,''))||0,money=v=>`£${number(v).toLocaleString(undefined,{minimumFractionDigits:2,maximumFractionDigits:2})}`;fetch(`${base}/wallet_data.php`).then(r=>r.json()).then(d=>{if(!d.success)return;const x=d.data;document.getElementById('availableBalance').textContent=money(x.balance);document.getElementById('totalInvested').textContent=money(x.invested);document.getElementById('totalWithdrawn').textContent=money(x.withdrawn);const list=document.querySelector('.list-group');list.innerHTML=(x.activities||[]).length?x.activities.map(a=>`<li class="action"><i class="bi bi-receipt"></i><span><b>${a.type}</b>${money(a.usd_amount)} · ${a.status}</span></li>`).join(''):'<li class="empty-state">No wallet activity yet.</li>'}).catch(()=>{})});