<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">Owner Statement</h1></div>

<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4 mb-6">
    <form method="GET" class="flex flex-wrap items-end gap-3"><input type="hidden" name="page" value="reports"><input type="hidden" name="action" value="ownerStatement">
        <div class="flex-1 min-w-[200px]"><label class="block text-xs font-medium text-gray-600 mb-1">Select Owner</label>
            <select name="owner_id" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-indigo-500"><option value="">Choose an owner</option>
            <?php foreach ($owners as $o): ?><option value="<?= $o['id'] ?>" <?= ($_GET['owner_id'] ?? '') == $o['id'] ? 'selected' : '' ?>><?= htmlspecialchars($o['first_name'].' '.$o['last_name']) ?></option><?php endforeach; ?></select></div>
        <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 text-sm font-medium">Generate</button>
    </form>
</div>

<?php if ($statement): ?>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-8">
    <div class="flex justify-between items-start mb-8">
        <div><h2 class="text-xl font-bold text-gray-900"><?= htmlspecialchars($statement['owner']['first_name'].' '.$statement['owner']['last_name']) ?></h2><p class="text-sm text-gray-500">Statement for <?= date('F Y') ?></p></div>
        <div class="text-right"><p class="text-sm text-gray-500">Generated</p><p class="font-medium"><?= date('M j, Y') ?></p></div>
    </div>
    <div class="grid grid-cols-3 gap-6 mb-8">
        <div class="text-center p-6 bg-green-50 rounded-xl"><p class="text-sm text-green-700 mb-1">Income</p><p class="text-3xl font-bold text-green-700"><?= formatMoney($statement['income']) ?></p></div>
        <div class="text-center p-6 bg-red-50 rounded-xl"><p class="text-sm text-red-700 mb-1">Expenses</p><p class="text-3xl font-bold text-red-700"><?= formatMoney($statement['expenses']) ?></p></div>
        <div class="text-center p-6 bg-indigo-50 rounded-xl"><p class="text-sm text-indigo-700 mb-1">Net Distribution</p><p class="text-3xl font-bold text-indigo-700"><?= formatMoney($statement['net']) ?></p></div>
    </div>
</div>
<?php elseif (isset($_GET['owner_id'])): ?>
<div class="bg-yellow-50 rounded-xl border border-yellow-200 p-6 text-center"><p class="text-yellow-700">Owner not found or no data available.</p></div>
<?php endif; ?>
