{{-- Sales Pipeline analytics — styled to match /analytics. Charts render from the JSON in #dl-report-data (user-deals-reports.js). --}} @php $openDeals = (int) $byStage->sum('count'); $closed = $won + $lost; @endphp {{-- ========== HERO BAND ========== --}}
{{ __('Pipeline · Workspace') }} {{ __('Live') }}

{{ $winRate }}% {{ __('of your closed deals were won.') }}

@if($openDeals || $closed) {{ $openDeals }} {{ __('open deals') }} · {{ $openValue }} {{ __('in play') }} · {{ $forecast }} {{ __('weighted forecast') }}. @else {{ __('No deals yet — create a few on the board and this dashboard fills in.') }} @endif

{{ __('Back to board') }}
{{-- Chart data bridge --}} {{-- ========== HERO KPI ROW ========== --}}
{{-- Hero: dark deep-teal card --}}
{{ __('Open pipeline value') }} {{ $winRate }}% {{ __('win rate') }}
{{ $openValue }}
{{ __('open deals') }}{{ $openDeals }}
{{ __('forecast') }}{{ $forecast }}
{{ __('won (mo)') }}{{ $wonValue }}
{{-- Stat cards --}}
@php $stat = function ($label, $value, $sub, $bar, $iconBg, $svg) { return ['label' => $label, 'value' => $value, 'sub' => $sub, 'bar' => $bar, 'iconBg' => $iconBg, 'svg' => $svg]; }; $cards = [ $stat(__('Weighted forecast'), $forecast, __('by probability'), 'before:bg-wa-teal', '#DFF1ED', ''), $stat(__('Won · this month'), $wonValue, $won . ' ' . __('all-time won'), 'before:bg-wa-green', 'color-mix(in srgb, var(--color-wa-green) 18%, transparent)', ''), $stat(__('Win rate'), $winRate . '%', $won . '/' . $closed . ' ' . __('closed'), 'before:bg-[#7B61FF]', 'rgba(123,97,255,0.18)', ''), $stat(__('Open deals'), $openDeals, __('in pipeline'), 'before:bg-[#13478A]', '#D9E5F2', ''), $stat(__('Lost'), (string) $lost, __('closed lost'), 'before:bg-accent-coral', 'rgba(232,122,93,0.18)', ''), $stat(__('Open value'), $openValue, __('total in play'), 'before:bg-accent-amber', 'rgba(229,160,78,0.22)', ''), ]; @endphp @foreach($cards as $c)
{!! $c['svg'] !!} {{ $c['label'] }}
{{ $c['value'] }}
{{ $c['sub'] }}
@endforeach
{{-- ========== CHARTS ROW ========== --}}
{{ __('Distribution') }}

{{ __('Pipeline value by stage') }}

{{ __('Momentum') }}

{{ __('Won vs lost') }}

{{ __('6 mo') }}
{{-- ========== LEADERBOARD ========== --}}
{{ __('Most won value') }}

{{ __('Top performers') }}

{{ $leaders->count() }} {{ __('agents') }}
@php $grads = ['from-wa-teal to-wa-deep', 'from-accent-coral to-[#A1431F]', 'from-accent-amber to-[#7B5A14]', 'from-[#7B61FF] to-[#5B3D8A]', 'from-[#13478A] to-[#0B1F1C]']; @endphp @forelse($leaders as $i => $l) @php $ini = strtoupper(substr(preg_replace('/[^a-z]/i', '', (string) $l['name']) ?: 'AG', 0, 2)); @endphp
{{ $ini }}
{{ $l['name'] }}
{{ $l['won'] }} {{ __('won') }}
{{ $symbol }}{{ number_format($l['value'], 0) }}
{{ __('won value') }}
@empty
{{ __('No won deals yet — close a few and they show up here.') }}
@endforelse
{{-- Why deals are lost. lost_reason was captured on every lost deal but never reported on, so the field was effectively write-only — you could see one deal's reason on its card and never the pattern across the pipeline. --}}
{{ __('Why deals are lost') }}

{{ __('Loss reasons') }}

{{ $lost }} {{ __('lost') }}
@php $lostMax = max(1, (int) $lostReasons->max('count')); @endphp @forelse($lostReasons as $r)
{{ $r['name'] }} {{ $r['count'] }} · {{ $symbol }}{{ number_format($r['value'], 0) }}
@empty
{{ __('No lost deals yet. Configure a reason list in Pipeline settings so this report can group them.') }}
@endforelse