<div class="mx-auto max-w-[1500px]"><div class="mb-6"><p class="text-sm text-slate-500">Real-time operational view across TibaLeta care delivery.</p></div>
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6"><?php foreach([['Active Visits',$stats['active'],'activity','teal'],['Available',$stats['available'],'stethoscope','emerald'],['En Route',$stats['enroute'],'car-front','sky'],['Waiting',$stats['waiting'],'clock-3','amber'],['Unassigned',$stats['unassigned'],'circle-help','orange'],['Escalated',$stats['escalated'],'triangle-alert','rose']] as $s): ?><div class="rounded-2xl border border-slate-100 bg-white p-4 shadow-card"><div class="flex items-start justify-between"><div><p class="text-[10px] font-bold uppercase tracking-wider text-slate-400"><?= $s[0] ?></p><div class="mt-2 font-display text-3xl font-extrabold"><?= $s[1] ?></div></div><span class="grid h-9 w-9 place-items-center rounded-xl bg-slate-50 text-teal-600"><i data-lucide="<?= $s[2] ?>" class="h-4 w-4"></i></span></div></div><?php endforeach; ?></div>
<div class="mt-6 grid gap-6 xl:grid-cols-[1.3fr_.7fr]"><section class="overflow-hidden rounded-2xl border border-slate-100 bg-white shadow-card"><div class="flex items-center justify-between border-b border-slate-100 px-5 py-4"><div><h3 class="font-display text-lg font-extrabold">Live Operations</h3><p class="mt-1 text-xs text-slate-400">Current care activity across the service area.</p></div><a href="/admin/requests" class="text-xs font-bold text-teal-600">Open dispatch</a></div><div class="relative h-[430px] map-grid"><div class="absolute left-[10%] top-[22%] w-[75%] map-road rotate-3"></div><div class="absolute left-[8%] top-[55%] w-[80%] map-road -rotate-12"></div><div class="absolute left-[42%] top-[8%] h-[72%] w-[7px] map-road rotate-6"></div><?php foreach([[16,20,'P'],[28,48,'V'],[42,32,'V'],[61,23,'P'],[74,52,'V'],[51,66,'!'],[82,31,'P']] as $pin): ?><div class="pin" style="left:<?= $pin[0] ?>%;top:<?= $pin[1] ?>%"><span><?= $pin[2] ?></span></div><?php endforeach; ?><div class="absolute bottom-4 left-4 rounded-xl border border-slate-200 bg-white/95 p-3 text-[11px] text-slate-500 shadow-card"><span class="mr-3"><b class="text-teal-600">P</b> practitioner</span><span><b class="text-teal-600">V</b> active visit</span></div></div></section>
<aside class="rounded-2xl border border-slate-100 bg-white p-5 shadow-card"><div class="flex items-center justify-between"><h3 class="font-display text-lg font-extrabold">Recent Activity</h3><a href="/admin/audit" class="text-xs font-bold text-teal-600">Audit log</a></div><div class="mt-4 space-y-4"><?php if(!$activity): ?><p class="py-10 text-center text-sm text-slate-400">Activity will appear here.</p><?php endif; ?><?php foreach($activity as $a): ?><div class="flex gap-3"><span class="mt-1 h-2 w-2 shrink-0 rounded-full bg-teal-500"></span><div><p class="text-xs font-bold text-navy"><?= esc(str_replace('.',' ',ucwords($a['action']))) ?></p><p class="mt-1 text-[11px] text-slate-400"><?= esc($a['entity_type']) ?> #<?= esc((string)$a['entity_id']) ?></p><p class="mt-1 text-[10px] text-slate-300"><?= date('M j, g:i A',strtotime($a['created_at'])) ?></p></div></div><?php endforeach; ?></div></aside></div>
<section class="mt-6 overflow-hidden rounded-2xl border border-slate-100 bg-white shadow-card"><div class="flex items-center justify-between border-b border-slate-100 px-5 py-4"><h3 class="font-display text-lg font-extrabold">Latest care requests</h3><a href="/admin/requests" class="text-xs font-bold text-teal-600">Manage requests</a></div><div class="overflow-x-auto"><table class="data-table w-full min-w-[800px]"><thead><tr class="border-b border-slate-100 bg-slate-50"><th class="px-5 py-3 text-left">ID</th><th class="px-5 py-3 text-left">Service</th><th class="px-5 py-3 text-left">Location</th><th class="px-5 py-3 text-left">Status</th><th class="px-5 py-3 text-left">Scheduled</th><th class="px-5 py-3 text-left">Amount</th></tr></thead><tbody><?php foreach($requests as $r): ?><tr class="border-b border-slate-50"><td class="px-5 py-4 font-semibold">#<?= $r['id'] ?></td><td class="px-5 py-4"><?= esc($r['service_name']) ?></td><td class="max-w-xs truncate px-5 py-4"><?= esc($r['address_text']) ?></td><td class="px-5 py-4"><span class="rounded-full bg-slate-100 px-2.5 py-1 text-[10px] font-bold"><?= esc(ucwords(str_replace('_',' ',$r['status']))) ?></span></td><td class="px-5 py-4"><?= $r['scheduled_for']?date('M j, g:i A',strtotime($r['scheduled_for'])):'ASAP' ?></td><td class="px-5 py-4"><?= money($r['estimated_amount']) ?></td></tr><?php endforeach; ?></tbody></table></div></section></div>
