<?php $fieldIncome = $editingIncome ?? []; $defaultIncomeDate = $month === date('Y-m') ? date('Y-m-d') : $month . '-01'; ?>
<div class="form-grid">
    <label class="span-2">Label<input type="text" name="label" required placeholder="Paycheck, freelance, refund…" value="<?= h($fieldIncome['label'] ?? '') ?>"></label>
    <label>Amount<div class="money-input"><span><?= h($symbol) ?></span><input type="number" name="amount" min="0.01" step="0.01" required value="<?= h((string) ($fieldIncome['amount'] ?? '')) ?>"></div></label>
    <label>Received<input type="date" name="received_on" value="<?= h((string) ($fieldIncome['received_on'] ?? $defaultIncomeDate)) ?>" min="<?= h($month . '-01') ?>" max="<?= h($month . '-' . date('t', strtotime($month . '-01'))) ?>" required></label>
    <label class="span-2">Notes<textarea name="notes" rows="2" placeholder="Optional details"><?= h($fieldIncome['notes'] ?? '') ?></textarea></label>
</div>
