<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>
    <div><h1 class="text-2xl font-bold text-gray-900">Lease Expirations</h1><p class="text-sm text-gray-500 mt-1"><?= count($data) ?> leases expiring in the next 90 days</p></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">Tenant</th><th class="px-4 py-3 font-medium text-gray-600">Property / Unit</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">Days Left</th><th class="px-4 py-3 font-medium text-gray-600 text-right">Rent</th></tr></thead>
        <tbody class="divide-y divide-gray-100">
            <?php if (empty($data)): ?><tr><td colspan="5" class="px-4 py-12 text-center text-green-600 font-medium">No leases expiring in the next 90 days.</td></tr>
            <?php else: foreach ($data as $l): $days = max(0, (int)((strtotime($l['end_date'])-time())/86400)); ?>
            <tr class="hover:bg-gray-50">
                <td class="px-4 py-3 font-medium"><?= htmlspecialchars($l['first_name'].' '.$l['last_name']) ?></td>
                <td class="px-4 py-3 text-gray-600"><?= htmlspecialchars(($l['property_name'] ?? '-').($l['unit_number'] ? ' / '.$l['unit_number'] : '')) ?></td>
                <td class="px-4 py-3"><?= formatDate($l['end_date']) ?></td>
                <td class="px-4 py-3"><span class="inline-flex px-2 py-0.5 rounded-full text-xs font-medium <?= $days <= 30 ? 'bg-red-50 text-red-700' : ($days <= 60 ? 'bg-yellow-50 text-yellow-700' : 'bg-green-50 text-green-700') ?>"><?= $days ?> days</span></td>
                <td class="px-4 py-3 text-right font-medium"><?= formatMoney($l['rent_amount'] ?? 0) ?></td>
            </tr>
            <?php endforeach; endif; ?>
        </tbody>
    </table>
</div>
