<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ $report['closing_number'] }}</title>
</head>
<body style="margin:0;background:#f4f5f7;color:#172033;font-family:Arial,sans-serif;">
<div style="max-width:720px;margin:0 auto;padding:24px 12px;">
    <div style="background:#ffffff;border:1px solid #e5e7eb;border-radius:8px;overflow:hidden;">
        <div style="padding:20px 22px;border-bottom:1px solid #e5e7eb;">
            <div style="font-size:12px;color:#667085;text-transform:uppercase;letter-spacing:.06em;">Daily branch report</div>
            <h1 style="margin:6px 0 0;font-size:22px;line-height:1.25;">{{ $report['branch_name'] }}</h1>
            <div style="margin-top:6px;color:#667085;font-size:14px;">{{ $report['business_name'] }} · {{ $report['report_date'] }} · {{ $report['closing_number'] }}</div>
        </div>

        <div style="padding:20px 22px;">
            <table role="presentation" style="width:100%;border-collapse:collapse;font-size:14px;">
                @foreach([
                    'Opening funds' => $report['opening_funds'],
                    'Collections' => $report['collections'],
                    'Cash collections' => $report['cash_collections'],
                    'Mobile money collections' => $report['mobile_money_collections'],
                    'Bank collections' => $report['bank_collections'],
                    'Other collections' => $report['other_collections'],
                    'Disbursements' => $report['disbursements'],
                    'Expenses' => $report['expenses'],
                    'Net transfers' => $report['transfers'],
                    'Capital inflows' => $report['capital_inflows'],
                    'Other inflows' => $report['other_inflows'],
                    'Other outflows' => $report['other_outflows'],
                    'Closing funds' => $report['closing_funds'],
                ] as $label => $value)
                    <tr>
                        <td style="padding:9px 0;border-bottom:1px solid #eef0f3;color:#667085;">{{ $label }}</td>
                        <td style="padding:9px 0;border-bottom:1px solid #eef0f3;text-align:right;font-weight:600;">{{ number_format((float) $value, 2) }}</td>
                    </tr>
                @endforeach
            </table>

            <div style="margin-top:20px;padding:14px;background:#f8fafc;border:1px solid #e5e7eb;border-radius:6px;">
                <div style="font-size:12px;font-weight:700;text-transform:uppercase;color:#667085;">Reconciliation</div>
                <table role="presentation" style="width:100%;margin-top:6px;border-collapse:collapse;font-size:14px;">
                    <tr><td style="padding:5px 0;color:#667085;">Expected reconciled balance</td><td style="text-align:right;font-weight:600;">{{ number_format((float) $report['expected_balance'], 2) }}</td></tr>
                    <tr><td style="padding:5px 0;color:#667085;">Actual reconciled balance</td><td style="text-align:right;font-weight:600;">{{ number_format((float) $report['actual_balance'], 2) }}</td></tr>
                    <tr><td style="padding:5px 0;color:#667085;">Variance</td><td style="text-align:right;font-weight:700;">{{ number_format((float) $report['variance'], 2) }}</td></tr>
                </table>
            </div>

            <div style="margin-top:20px;font-size:13px;color:#475467;line-height:1.6;">
                <div><strong>Prepared by:</strong> {{ $report['prepared_by'] ?: '—' }}</div>
                <div><strong>Confirmed by:</strong> {{ $report['confirmed_by'] ?: '—' }}</div>
                @if($report['manager_comments'])
                    <div style="margin-top:8px;"><strong>Manager comments:</strong> {{ $report['manager_comments'] }}</div>
                @endif
            </div>
        </div>

        <div style="padding:14px 22px;background:#f8fafc;border-top:1px solid #e5e7eb;color:#667085;font-size:12px;line-height:1.5;">
            This report was generated from a manager-confirmed daily closing and an immutable copy is retained in the system for audit.
        </div>
    </div>
</div>
</body>
</html>
