<div class="flex items-center gap-3 mb-6"><a href="?page=reports" class="text-gray-400 hover:text-gray-600"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg></a><h1 class="text-2xl font-bold text-gray-900">Occupancy Report</h1></div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-x-auto">
    <table class="w-full text-sm">
        <thead class="bg-gray-50 text-left"><tr><th class="px-4 py-3 font-medium text-gray-600">Property</th><th class="px-4 py-3 font-medium text-gray-600">Total Units</th><th class="px-4 py-3 font-medium text-gray-600">Occupied</th><th class="px-4 py-3 font-medium text-gray-600">Vacant</th><th class="px-4 py-3 font-medium text-gray-600">Occupancy Rate</th><th class="px-4 py-3 font-medium text-gray-600">Visual</th></tr></thead>
        <tbody class="divide-y divide-gray-100">
            <?php $totalU=0; $totalO=0; foreach ($properties as $p): $vacant=$p['total_units']-$p['occupied']; $rate=$p['total_units']>0?round($p['occupied']/$p['total_units']*100):0; $totalU+=$p['total_units']; $totalO+=$p['occupied']; ?>
            <tr class="hover:bg-gray-50">
                <td class="px-4 py-3 font-medium text-gray-900"><?= htmlspecialchars($p['name']) ?></td>
                <td class="px-4 py-3"><?= $p['total_units'] ?></td>
                <td class="px-4 py-3 text-green-700 font-medium"><?= $p['occupied'] ?></td>
                <td class="px-4 py-3 text-red-600 font-medium"><?= $vacant ?></td>
                <td class="px-4 py-3 font-semibold <?= $rate >= 90 ? 'text-green-700' : ($rate >= 70 ? 'text-yellow-600' : 'text-red-600') ?>"><?= $rate ?>%</td>
                <td class="px-4 py-3"><div class="w-32 h-2 bg-gray-200 rounded-full overflow-hidden"><div class="h-full rounded-full <?= $rate >= 90 ? 'bg-green-500' : ($rate >= 70 ? 'bg-yellow-500' : 'bg-red-500') ?>" style="width:<?= $rate ?>%"></div></div></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
        <tfoot class="bg-gray-50"><tr><td class="px-4 py-3 font-semibold">Portfolio Total</td><td class="px-4 py-3 font-bold"><?= $totalU ?></td><td class="px-4 py-3 font-bold text-green-700"><?= $totalO ?></td><td class="px-4 py-3 font-bold text-red-600"><?= $totalU-$totalO ?></td><td class="px-4 py-3 font-bold"><?= $totalU>0?round($totalO/$totalU*100):0 ?>%</td><td></td></tr></tfoot>
    </table>
</div>
