<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Tree Export</title>
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 12px; color: #111; }
        h1 { font-size: 16px; margin-bottom: 10px; }
        table { width: 100%; border-collapse: collapse; margin-top: 12px; }
        th, td { border: 1px solid #e2e8f0; padding: 6px; text-align: left; }
        th { background: #f8fafc; }
    </style>
</head>
<body>
    <h1>Tree Export ({{ ucfirst($mode) }})</h1>
    <div>Member: {{ $member->member_code }} - {{ $member->name }}</div>
    <div>Filters: Status {{ ucfirst($status) }}, Leg {{ ucfirst($leg) }}, Max Depth {{ $depth }}</div>
    <div>Left BV: {{ number_format($legTotals['left'], 2) }} | Right BV: {{ number_format($legTotals['right'], 2) }}</div>

    <table>
        <thead>
            <tr>
                <th>Depth</th>
                <th>Leg</th>
                <th>Member</th>
                <th>Mobile</th>
                <th>Email</th>
                <th>Status</th>
            </tr>
        </thead>
        <tbody>
            @foreach($rows as $child)
                <tr>
                    <td>{{ $child->depth }}</td>
                    <td>{{ $child->path_leg }}</td>
                    <td>{{ $child->member_code }} - {{ $child->name }}</td>
                    <td>{{ $child->mobile ?: '-' }}</td>
                    <td>{{ $child->email ?: '-' }}</td>
                    <td>{{ $child->status }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>
</body>
</html>
