<div class="flex items-center justify-between mb-6">
    <div class="flex items-center gap-3"><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>
        <div><h1 class="text-2xl font-bold text-gray-900">Rent Roll</h1><p class="text-sm text-gray-500 mt-1"><?= count($data) ?> active leases</p></div></div>
    <div class="flex gap-3">
        <div class="bg-white rounded-xl shadow-sm border border-gray-200 px-4 py-2 text-center"><p class="text-xs text-gray-500">Total Rent</p><p class="text-lg font-bold text-gray-900"><?= formatMoney($totalRent) ?></p></div>
        <div class="bg-white rounded-xl shadow-sm border border-gray-200 px-4 py-2 text-center"><p class="text-xs text-gray-500">Market Value</p><p class="text-lg font-bold text-gray-900"><?= formatMoney($totalMarket) ?></p></div>
    </div>
</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">Unit</th><th class="px-4 py-3 font-medium text-gray-600">Tenant</th><th class="px-4 py-3 font-medium text-gray-600">Lease End</th><th class="px-4 py-3 font-medium text-gray-600 text-right">Market Rent</th><th class="px-4 py-3 font-medium text-gray-600 text-right">Actual Rent</th></tr></thead>
        <tbody class="divide-y divide-gray-100">
            <?php foreach ($data as $r): ?>
            <tr class="hover:bg-gray-50">
                <td class="px-4 py-3 font-medium"><?= htmlspecialchars($r['property_name'] ?? '-') ?></td>
                <td class="px-4 py-3"><?= htmlspecialchars($r['unit_number'] ?? '-') ?></td>
                <td class="px-4 py-3"><?= htmlspecialchars($r['first_name'].' '.$r['last_name']) ?></td>
                <td class="px-4 py-3 text-gray-500"><?= formatDate($r['end_date'] ?? '') ?></td>
                <td class="px-4 py-3 text-right"><?= formatMoney($r['market_rent'] ?? 0) ?></td>
                <td class="px-4 py-3 text-right font-semibold"><?= formatMoney($r['rent_amount'] ?? 0) ?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
        <tfoot class="bg-gray-50"><tr><td colspan="4" class="px-4 py-3 font-semibold text-gray-700">Totals</td><td class="px-4 py-3 text-right font-bold text-gray-900"><?= formatMoney($totalMarket) ?></td><td class="px-4 py-3 text-right font-bold text-gray-900"><?= formatMoney($totalRent) ?></td></tr></tfoot>
    </table>
</div>
