<div class="space-y-5">
    <div class="animate-rise">
        <h1 class="text-2xl font-bold tracking-tight text-ink">{{ __('admin.nav.revenue') }}</h1>
        <p class="mt-1 text-sm text-muted">{{ __('admin.revenue_sub') }}</p>
    </div>

    @php $rd = ['[animation-delay:40ms]', '[animation-delay:80ms]', '[animation-delay:120ms]', '[animation-delay:160ms]']; @endphp
    <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
        @foreach ($kpis as $i => $kpi)
            <div class="rounded-lg border border-line bg-surface p-5 shadow-xs animate-rise {{ $rd[$i] ?? '' }}">
                <p class="text-xs font-semibold text-muted">{{ $kpi['label'] }}</p>
                <p class="mt-2 font-mono text-2xl font-semibold text-ink">{{ $kpi['value'] }}</p>
                <p class="mt-1 text-xs text-muted">{{ $kpi['sub'] }}</p>
            </div>
        @endforeach
    </div>

    <div class="grid grid-cols-1 gap-4 lg:grid-cols-3">
        <div class="rounded-lg border border-line bg-surface p-5 shadow-xs animate-rise [animation-delay:60ms]">
            <h2 class="font-semibold text-ink">{{ __('admin.mrr_by_plan') }}</h2>
            @forelse ($planCharts as $chart)
                {{-- One ring per currency: a doughnut sums its slices, and a
                     total mixing euros with francs is not an amount. --}}
                @if (count($planCharts) > 1)
                    <p class="mt-3 font-mono text-xs font-semibold text-muted">{{ $chart['currency'] }}</p>
                @endif
                <div class="mt-3 h-56" wire:ignore><x-ui.chart :config="$chart['config']" class="h-56" :label="__('admin.mrr_by_plan').' — '.$chart['currency']" /></div>
            @empty
                <p class="mt-8 text-center text-sm text-muted">{{ __('admin.no_data_yet') }}</p>
            @endforelse
        </div>

        <div class="overflow-hidden rounded-lg border border-line bg-surface shadow-xs animate-rise [animation-delay:120ms] lg:col-span-2">
            <div class="border-b border-line px-5 py-3"><h2 class="font-semibold text-ink">{{ __('admin.recent_payments') }}</h2></div>
            <ul class="divide-y divide-line">
                @forelse ($payments as $p)
                    <li class="flex items-center gap-3 px-5 py-3 text-sm">
                        <span class="grid size-8 shrink-0 place-items-center rounded-lg bg-surface-2 text-success"><x-ui.icon name="check" class="size-4" /></span>
                        <span class="min-w-0 flex-1 truncate font-medium text-ink">{{ $p['customer'] }}</span>
                        <span class="font-mono text-xs text-muted">{{ $p['when'] }}</span>
                        <span class="font-mono text-body">{{ $p['amount'] }}</span>
                    </li>
                @empty
                    <li class="px-5 py-8 text-center text-sm text-muted">{{ __('admin.no_payments_yet') }}</li>
                @endforelse
            </ul>
        </div>
    </div>
</div>
