<?php $e=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); $b=$business; $c=$content; ?>
<!doctype html><html><head><meta charset="utf-8"><style>
@page{margin:30px 35px}body{font-family:DejaVu Sans,sans-serif;font-size:10.5px;line-height:1.5;color:#20252b}h1{font-size:22px;margin:0}.logo{max-width:120px;max-height:55px;margin-bottom:7px}h2{font-size:14px;margin:18px 0 6px;border-bottom:1px solid #cfd4dc;padding-bottom:5px}.header{border-bottom:2px solid #1f2937;padding-bottom:15px}.meta{margin-top:8px;color:#667085}.patient{display:flex;gap:30px;margin:18px 0}.box{flex:1;border:1px solid #d9dee5;padding:10px}.label{font-size:9px;text-transform:uppercase;color:#667085}.section{margin-top:10px}.footer{margin-top:30px;border-top:1px solid #ddd;padding-top:8px;font-size:8.5px;color:#667085;text-align:center}.approved{display:inline-block;padding:4px 8px;border:1px solid #555;font-size:9px;font-weight:bold;text-transform:uppercase}
</style></head><body><div class="header"><?php if(!empty($b['logo'])): ?><img class="logo" src="<?= $e($b['logo']) ?>" alt="Logo"><br><?php endif; ?><h1><?= $e($b['name']) ?></h1><div><?= $e($b['tagline']) ?></div><div class="meta"><?= $e($report['report_reference']) ?> · Version <?= $e($version['version_number']) ?> · Approved <?= $e($report['approved_at']??'') ?></div></div>
<div class="patient"><div class="box"><div class="label">Patient</div><strong><?= $e($report['first_name'].' '.$report['last_name']) ?></strong><br><?= $e($report['patient_reference']) ?></div><div class="box"><div class="label">Therapist</div><strong><?= $e($report['therapist_name']) ?></strong><br><span class="approved">Approved</span></div></div>
<?php $sections=[['reason','Reason for Referral'],['background','Background'],['observations','Observations'],['findings','Clinical Findings'],['progress','Progress'],['recommendations','Recommendations'],['additional_notes','Additional Notes']]; foreach($sections as [$key,$label]): if(trim((string)($c[$key]??''))!==''): ?><div class="section"><h2><?= $e($label) ?></h2><?= nl2br($e($c[$key])) ?></div><?php endif; endforeach; ?>
<div class="footer">Official approved clinical report · <?= $e($b['name']) ?> · This document represents approved version <?= $e($version['version_number']) ?>.</div></body></html>
