<?php $e=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); $b=$business; $money=static fn($v)=>number_format((float)$v,2); ?>
<!doctype html><html><head><meta charset="utf-8"><style>
@page{margin:32px}body{font-family:DejaVu Sans,sans-serif;font-size:11px;color:#20252b}.header{border-bottom:2px solid #176b5b;padding-bottom:16px;margin-bottom:22px}.row{display:flex;justify-content:space-between}.title{font-size:24px;font-weight:bold}.logo{max-width:120px;max-height:55px;margin-bottom:6px}.muted{color:#667085}.box{border:1px solid #d9dee5;padding:12px;margin-bottom:15px}table{width:100%;border-collapse:collapse}th,td{padding:9px;border-bottom:1px solid #e5e7eb;text-align:left}th{width:55%;background:#f3f4f6}.amount{font-size:18px;font-weight:bold}.footer{margin-top:35px;border-top:1px solid #ddd;padding-top:10px;text-align:center;font-size:9px;color:#667085}
</style></head><body><div class="header"><div class="row"><div><?php if(!empty($b['logo'])): ?><img class="logo" src="<?= $e($b['logo']) ?>" alt="Logo"><br><?php endif; ?><div class="title"><?= $e($b['name']) ?></div><div><?= $e($b['tagline']) ?></div><div class="muted"><?= $e($b['address']) ?><?= $b['phone']?' · '.$e($b['phone']):'' ?><?= $b['email']?' · '.$e($b['email']):'' ?></div></div><div style="text-align:right"><div class="title">RECEIPT</div><strong><?= $e($receipt_number) ?></strong></div></div></div>
<div class="box"><strong>Received From</strong><br><?= $e($invoice['first_name'].' '.$invoice['last_name']) ?><br><?= $e($invoice['patient_reference']) ?></div>
<table><tr><th>Invoice</th><td><?= $e($invoice['invoice_number']) ?></td></tr><tr><th>Payment date</th><td><?= $e($payment['payment_date']) ?></td></tr><tr><th>Payment method</th><td><?= $e($payment['payment_method']) ?></td></tr><tr><th>Reference</th><td><?= $e($payment['payment_reference']??'—') ?></td></tr><tr><th>Amount received</th><td class="amount"><?= $e($b['currency']) ?> <?= $money($payment['amount']) ?></td></tr><tr><th>Remaining invoice balance</th><td><?= $e($b['currency']) ?> <?= $money($invoice['balance']) ?></td></tr></table>
<?php if(!empty($payment['notes'])): ?><div class="box" style="margin-top:15px"><strong>Notes</strong><br><?= nl2br($e($payment['notes'])) ?></div><?php endif; ?><div class="footer">Official payment receipt · <?= $e($b['name']) ?></div></body></html>
