<div class="card border-0 shadow-sm">
    <div class="card-body">
        <h4 class="fw-bold mb-4">Estimated Value by Funding Tranche</h4>

        <table class="table table-sm table-hover align-middle">
            <thead>
                <tr>
                    <th>Funding Tranche</th>
                    <th>Clients</th>
                    <th>Total Estimated Value</th>
                    <th>Average Estimated Value</th>
                </tr>
            </thead>

            <tbody>
                @forelse($rows as $row)
                    <tr>
                        <td>{{ $row->tranche_name }}</td>
                        <td>{{ number_format($row->client_count) }}</td>
                        <td>
                            £{{ number_format($row->total_min) }}
                            @if($row->total_max != $row->total_min)
                                - £{{ number_format($row->total_max) }}
                            @endif
                        </td>
                        <td>
                            £{{ number_format($row->average_min) }}
                            @if($row->average_max != $row->average_min)
                                - £{{ number_format($row->average_max) }}
                            @endif
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="4" class="text-center text-muted py-4">
                            No estimated values found.
                        </td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>