@php $reference = is_array($reference ?? null) ? $reference : []; $tenantSummaries = is_array($tenantSummaries ?? null) ? $tenantSummaries : []; $denseRows = is_array($denseRows ?? null) ? $denseRows : []; $compactResults = is_array($compactResults ?? null) ? $compactResults : []; $policyTypeOptions = is_array($policyTypeOptions ?? null) ? $policyTypeOptions : []; $tenantSortOptions = is_array($tenantSortOptions ?? null) ? $tenantSortOptions : []; $subjectSortOptions = is_array($subjectSortOptions ?? null) ? $subjectSortOptions : []; $stateLegend = is_array($stateLegend ?? null) ? $stateLegend : []; $freshnessLegend = is_array($freshnessLegend ?? null) ? $freshnessLegend : []; $trustLegend = is_array($trustLegend ?? null) ? $trustLegend : []; $emptyState = is_array($emptyState ?? null) ? $emptyState : null; $currentFilters = is_array($currentFilters ?? null) ? $currentFilters : []; $draftFilters = is_array($draftFilters ?? null) ? $draftFilters : []; $presentationState = is_array($presentationState ?? null) ? $presentationState : []; $supportSurfaceState = is_array($supportSurfaceState ?? null) ? $supportSurfaceState : []; $referenceReady = ($reference['referenceState'] ?? null) === 'ready'; $activeFilterCount = $this->activeFilterCount(); $activeFilterSummary = $this->activeFilterSummary(); $stagedFilterSummary = $this->stagedFilterSummary(); $hasStagedFilterChanges = (bool) ($presentationState['hasStagedFilterChanges'] ?? false); $requestedMode = (string) ($presentationState['requestedMode'] ?? 'auto'); $resolvedMode = (string) ($presentationState['resolvedMode'] ?? 'compact'); $visibleTenantCount = (int) ($presentationState['visibleTenantCount'] ?? 0); $autoRefreshActive = (bool) ($presentationState['autoRefreshActive'] ?? false); $lastUpdatedAt = $presentationState['lastUpdatedAt'] ?? null; $compactModeAvailable = (bool) ($presentationState['compactModeAvailable'] ?? false); $hiddenAssignedTenantCount = max(0, (int) ($reference['assignedTenantCount'] ?? 0) - $visibleTenantCount); $stateBadge = static fn (mixed $value) => \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::BaselineCompareMatrixState, $value); $freshnessBadge = static fn (mixed $value) => \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::BaselineCompareMatrixFreshness, $value); $trustBadge = static fn (mixed $value) => \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::BaselineCompareMatrixTrust, $value); $severityBadge = static fn (mixed $value) => \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::FindingSeverity, $value); $profileStatusBadge = static fn (mixed $value) => \App\Support\Badges\BadgeCatalog::spec(\App\Support\Badges\BadgeDomain::BaselineProfileStatus, $value); $profileStatusSpec = $profileStatusBadge($reference['baselineStatus'] ?? null); $modeBadgeColor = match ($resolvedMode) { 'dense' => 'info', 'compact' => 'success', default => 'gray', }; $modeLabel = $this->presentationModeLabel($resolvedMode); @endphp @if ($autoRefreshActive) @endif Compare assigned tenants remains simulation only. This operator view changes presentation density, not compare truth, visible-set scope, or the existing drilldown path.
{{ $profileStatusSpec->label }} {{ $referenceReady ? 'Reference snapshot ready' : 'Reference snapshot blocked' }} {{ $modeLabel }} @if (filled($reference['referenceSnapshotId'] ?? null)) Snapshot #{{ (int) $reference['referenceSnapshotId'] }} @endif @if ($hiddenAssignedTenantCount > 0) {{ $hiddenAssignedTenantCount }} hidden by access scope @endif

{{ $reference['baselineProfileName'] ?? ($profile->name ?? 'Baseline compare matrix') }}

Assigned tenants: {{ (int) ($reference['assignedTenantCount'] ?? 0) }}. Visible tenants: {{ $visibleTenantCount }}. @if (filled($reference['referenceSnapshotCapturedAt'] ?? null)) Reference captured {{ \Illuminate\Support\Carbon::parse($reference['referenceSnapshotCapturedAt'])->diffForHumans() }}. @endif

Auto mode resolves from the visible tenant set. Manual mode stays local to this route and never becomes stored preference truth.

@if (filled($reference['referenceReasonCode'] ?? null))

Reference reason: {{ \Illuminate\Support\Str::headline(str_replace('.', ' ', (string) $reference['referenceReasonCode'])) }}

@endif
Visible tenants
{{ $visibleTenantCount }}
Rendered subjects
{{ $resolvedMode === 'compact' ? count($compactResults) : count($denseRows) }}
Active filters
@if ($activeFilterCount === 0) All visible results @else {{ $activeFilterCount }} active {{ \Illuminate\Support\Str::plural('filter', $activeFilterCount) }} @endif
Resolved mode
{{ $modeLabel }}
Presentation mode

Requested: {{ $this->presentationModeLabel($requestedMode) }}. Resolved: {{ $modeLabel }}.

Auto Dense @if ($compactModeAvailable) Compact @else Compact unlocks at one visible tenant @endif
@if (($supportSurfaceState['showLastUpdated'] ?? true) && filled($lastUpdatedAt)) Last updated {{ \Illuminate\Support\Carbon::parse($lastUpdatedAt)->diffForHumans() }} @endif @if (($supportSurfaceState['showAutoRefreshHint'] ?? false) && $autoRefreshActive) Passive auto-refresh every 5 seconds @endif
Refreshing now
Refresh matrix @if ($hiddenAssignedTenantCount > 0) Visible-set only. Hidden tenants never contribute to summaries or drilldowns. @endif
Heavy filters stage locally first. The matrix keeps rendering the applied scope until you explicitly apply or reset the draft.
Applied matrix scope

@if ($activeFilterCount === 0) No narrowing filters are active. Showing every visible subject and tenant in the current baseline scope. @else {{ $activeFilterCount }} active {{ \Illuminate\Support\Str::plural('filter', $activeFilterCount) }} are already shaping the rendered matrix. @endif

@if ($activeFilterSummary !== [])
@foreach ($activeFilterSummary as $label => $value) {{ $label }}: {{ $value }} @endforeach
@endif
@if ($activeFilterCount === 0) All visible results @else {{ $activeFilterCount }} active {{ \Illuminate\Support\Str::plural('filter', $activeFilterCount) }} @endif Tenant sort: {{ $tenantSortOptions[$currentFilters['tenant_sort'] ?? 'tenant_name'] ?? 'Tenant name' }} Subject sort: {{ $subjectSortOptions[$currentFilters['subject_sort'] ?? 'deviation_breadth'] ?? 'Deviation breadth' }}
@if ($hasStagedFilterChanges)
Draft filters are staged

The controls below differ from the current route state. Apply them when you are ready to redraw the matrix. Refreshing the page discards these unapplied draft edits.

@if ($stagedFilterSummary !== [])
@foreach ($stagedFilterSummary as $label => $value) {{ $label }}: {{ is_string($value) ? \Illuminate\Support\Str::headline(str_replace('_', ' ', $value)) : $value }} @endforeach
@endif
@endif
{{ $this->form }}
Focused subject @if (filled($currentFilters['subject_key'] ?? null)) {{ $currentFilters['subject_key'] }} Clear subject focus @else None set yet. Use Focus subject from a row when you want a subject-first drilldown. @endif

Applied filters and the focused subject are carried by the URL so the current matrix scan can be reopened or shared.

Apply filters Reset filters
Status, legends, and refresh cues stay compact so the matrix body remains the primary working surface.
Current scope

{{ $visibleTenantCount }} visible {{ \Illuminate\Support\Str::plural('tenant', $visibleTenantCount) }}. {{ $resolvedMode === 'dense' ? 'State-first dense scan stays active.' : 'Compact single-tenant review stays active.' }}

@if ($policyTypeOptions !== [])
{{ count($policyTypeOptions) }} searchable governed subjects @if ($hiddenAssignedTenantCount > 0) Visible-set only @endif
@endif
Refresh honesty

Manual refresh shows a blocking state only while you explicitly redraw. Background polling remains a passive hint.

@if ($autoRefreshActive)
Compare work is still queued or running
@endif
Grouped legend

State, freshness, and trust stay available on demand without pushing the matrix down the page.

{{ count($stateLegend) }} states {{ count($freshnessLegend) }} freshness cues {{ count($trustLegend) }} trust cues
State legend
@foreach ($stateLegend as $item) {{ $item['label'] }} @endforeach
Freshness legend
@foreach ($freshnessLegend as $item) {{ $item['label'] }} @endforeach
Trust legend
@foreach ($trustLegend as $item) {{ $item['label'] }} @endforeach
@if ($emptyState !== null)

{{ $emptyState['title'] ?? 'Nothing to show' }}

{{ $emptyState['body'] ?? 'Adjust the current inputs and try again.' }}

@if ($activeFilterCount > 0)
Reset filters
@endif
@elseif ($resolvedMode === 'compact') @php $compactTenant = $tenantSummaries[0] ?? null; $compactTenantFreshnessSpec = $freshnessBadge($compactTenant['freshnessState'] ?? null); $compactTenantTrustSpec = $trustBadge($compactTenant['trustLevel'] ?? null); @endphp One visible tenant remains in scope, so the matrix collapses into a shorter subject-result list instead of a pseudo-grid. @if ($compactTenant)
{{ $compactTenant['tenantName'] }}

Compact mode stays visible-set only. Subject drilldowns and run links still preserve the matrix context.

{{ $compactTenantFreshnessSpec->label }} {{ $compactTenantTrustSpec->label }}
@endif
@foreach ($compactResults as $result) @php $stateSpec = $stateBadge($result['state'] ?? null); $freshnessSpec = $freshnessBadge($result['freshnessState'] ?? null); $trustSpec = $trustBadge($result['trustLevel'] ?? null); $severitySpec = filled($result['severity'] ?? null) ? $severityBadge($result['severity']) : null; $tenantId = (int) ($result['tenantId'] ?? 0); $subjectKey = $result['subjectKey'] ?? null; $primaryUrl = filled($result['findingId'] ?? null) ? $this->findingUrl($tenantId, (int) $result['findingId'], $subjectKey) : $this->tenantCompareUrl($tenantId, $subjectKey); $runUrl = filled($result['compareRunId'] ?? null) ? $this->runUrl((int) $result['compareRunId'], $tenantId, $subjectKey) : null; $attentionClasses = match ((string) ($result['attentionLevel'] ?? 'review')) { 'needs_attention' => 'bg-danger-100 text-danger-700 dark:bg-danger-950/40 dark:text-danger-300', 'refresh_recommended' => 'bg-warning-100 text-warning-700 dark:bg-warning-950/40 dark:text-warning-300', 'aligned' => 'bg-success-100 text-success-700 dark:bg-success-950/40 dark:text-success-300', default => 'bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300', }; $attentionLabel = \Illuminate\Support\Str::headline(str_replace('_', ' ', (string) ($result['attentionLevel'] ?? 'review'))); @endphp
{{ $result['displayName'] ?? $result['subjectKey'] ?? 'Subject' }}
{{ $result['governedSubjectLabel'] ?? ($result['policyType'] ?? 'Unknown governed subject') }}
@if (filled($result['baselineExternalId'] ?? null))
Reference ID: {{ $result['baselineExternalId'] }}
@endif
{{ $stateSpec->label }} {{ $freshnessSpec->label }} {{ $trustSpec->label }} @if ($severitySpec) {{ $severitySpec->label }} @endif {{ $attentionLabel }}
@if (filled($result['reasonSummary'] ?? null) || filled($result['lastComparedAt'] ?? null))
@if (filled($result['reasonSummary'] ?? null))
{{ $result['reasonSummary'] }}
@endif @if (filled($result['lastComparedAt'] ?? null))
Compared {{ \Illuminate\Support\Carbon::parse($result['lastComparedAt'])->diffForHumans() }}
@endif
@endif
Drift breadth {{ (int) ($result['deviationBreadth'] ?? 0) }} Missing {{ (int) ($result['missingBreadth'] ?? 0) }} Ambiguous {{ (int) ($result['ambiguousBreadth'] ?? 0) }}
@if ($primaryUrl) {{ filled($result['findingId'] ?? null) ? 'Open finding' : 'Open tenant compare' }} @endif @if ($runUrl) Open run @endif @if (filled($result['subjectKey'] ?? null)) Focus subject @endif
@endforeach
@else The matrix body is state-first. Row click stays forbidden, the subject column stays pinned, and repeated follow-up actions move behind compact secondary reveals.
@foreach ($tenantSummaries as $tenantSummary) @php $freshnessSpec = $freshnessBadge($tenantSummary['freshnessState'] ?? null); $trustSpec = $trustBadge($tenantSummary['trustLevel'] ?? null); $tenantSeveritySpec = filled($tenantSummary['maxSeverity'] ?? null) ? $severityBadge($tenantSummary['maxSeverity']) : null; $tenantCompareUrl = $this->tenantCompareUrl((int) $tenantSummary['tenantId']); $tenantRunUrl = filled($tenantSummary['compareRunId'] ?? null) ? $this->runUrl((int) $tenantSummary['compareRunId'], (int) $tenantSummary['tenantId']) : null; @endphp
{{ $tenantSummary['tenantName'] }}
{{ $freshnessSpec->label }} {{ $trustSpec->label }} @if ($tenantSeveritySpec) {{ $tenantSeveritySpec->label }} @endif
Aligned
{{ (int) ($tenantSummary['matchedCount'] ?? 0) }}
Drift
{{ (int) ($tenantSummary['differingCount'] ?? 0) }}
Missing
{{ (int) ($tenantSummary['missingCount'] ?? 0) }}
Ambiguous
{{ (int) ($tenantSummary['ambiguousCount'] ?? 0) }}
@if ($tenantCompareUrl) Open tenant compare @endif @if ($tenantRunUrl) Open latest run @endif
@endforeach
@foreach ($tenantSummaries as $tenantSummary) @php $freshnessSpec = $freshnessBadge($tenantSummary['freshnessState'] ?? null); @endphp @endforeach @foreach ($denseRows as $row) @php $subject = is_array($row['subject'] ?? null) ? $row['subject'] : []; $cells = is_array($row['cells'] ?? null) ? $row['cells'] : []; $subjectTrustSpec = $trustBadge($subject['trustLevel'] ?? null); $subjectSeveritySpec = filled($subject['maxSeverity'] ?? null) ? $severityBadge($subject['maxSeverity']) : null; $rowKey = (string) ($subject['subjectKey'] ?? 'subject-'.$loop->index); $rowSurfaceClasses = $loop->even ? 'bg-gray-50/70 dark:bg-gray-950/20' : 'bg-white dark:bg-gray-900/60'; $subjectAttentionClasses = match ((string) ($subject['attentionLevel'] ?? 'review')) { 'needs_attention' => 'bg-danger-100 text-danger-700 dark:bg-danger-950/40 dark:text-danger-300', 'refresh_recommended' => 'bg-warning-100 text-warning-700 dark:bg-warning-950/40 dark:text-warning-300', 'aligned' => 'bg-success-100 text-success-700 dark:bg-success-950/40 dark:text-success-300', default => 'bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300', }; @endphp @foreach ($cells as $cell) @php $cellStateSpec = $stateBadge($cell['state'] ?? null); $cellFreshnessSpec = $freshnessBadge($cell['freshnessState'] ?? null); $cellTrustSpec = $trustBadge($cell['trustLevel'] ?? null); $cellSeveritySpec = filled($cell['severity'] ?? null) ? $severityBadge($cell['severity']) : null; $tenantId = (int) ($cell['tenantId'] ?? 0); $subjectKey = $subject['subjectKey'] ?? ($cell['subjectKey'] ?? null); $primaryUrl = filled($cell['findingId'] ?? null) ? $this->findingUrl($tenantId, (int) $cell['findingId'], $subjectKey) : $this->tenantCompareUrl($tenantId, $subjectKey); $runUrl = filled($cell['compareRunId'] ?? null) ? $this->runUrl((int) $cell['compareRunId'], $tenantId, $subjectKey) : null; $attentionClasses = match ((string) ($cell['attentionLevel'] ?? 'review')) { 'needs_attention' => 'bg-danger-100 text-danger-700 dark:bg-danger-950/40 dark:text-danger-300', 'refresh_recommended' => 'bg-warning-100 text-warning-700 dark:bg-warning-950/40 dark:text-warning-300', 'aligned' => 'bg-success-100 text-success-700 dark:bg-success-950/40 dark:text-success-300', default => 'bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300', }; $cellSurfaceClasses = match ((string) ($cell['attentionLevel'] ?? 'review')) { 'needs_attention' => 'border-danger-300 bg-danger-50/80 ring-1 ring-danger-200/70 dark:border-danger-900/70 dark:bg-danger-950/15 dark:ring-danger-900/40', 'refresh_recommended' => 'border-warning-300 bg-warning-50/80 ring-1 ring-warning-200/70 dark:border-warning-900/70 dark:bg-warning-950/15 dark:ring-warning-900/40', 'aligned' => 'border-success-200 bg-success-50/70 dark:border-success-900/60 dark:bg-success-950/10', default => 'border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-950/40', }; @endphp @endforeach @endforeach
Baseline subject
{{ $tenantSummary['tenantName'] }}
{{ $freshnessSpec->label }}
{{ $subject['displayName'] ?? $subject['subjectKey'] ?? 'Subject' }}
{{ $subject['governedSubjectLabel'] ?? ($subject['policyType'] ?? 'Unknown governed subject') }}
@if (filled($subject['baselineExternalId'] ?? null))
Reference ID: {{ $subject['baselineExternalId'] }}
@endif
Drift breadth {{ (int) ($subject['deviationBreadth'] ?? 0) }} Missing {{ (int) ($subject['missingBreadth'] ?? 0) }} {{ $subjectTrustSpec->label }} @if ($subjectSeveritySpec) {{ $subjectSeveritySpec->label }} @endif {{ \Illuminate\Support\Str::headline(str_replace('_', ' ', (string) ($subject['attentionLevel'] ?? 'review'))) }}
@if (filled($subject['subjectKey'] ?? null))
Focus subject
@endif
{{ $cellStateSpec->label }} @if ($cellSeveritySpec) {{ $cellSeveritySpec->label }} @endif
{{ \Illuminate\Support\Str::headline(str_replace('_', ' ', (string) ($cell['attentionLevel'] ?? 'review'))) }}
{{ $cellFreshnessSpec->label }} {{ $cellTrustSpec->label }}
@if (filled($cell['reasonSummary'] ?? null) || filled($cell['lastComparedAt'] ?? null))
@if (filled($cell['reasonSummary'] ?? null))
{{ $cell['reasonSummary'] }}
@endif @if (filled($cell['lastComparedAt'] ?? null))
Compared {{ \Illuminate\Support\Carbon::parse($cell['lastComparedAt'])->diffForHumans() }}
@endif
@endif
@if ($primaryUrl)
{{ filled($cell['findingId'] ?? null) ? 'Open finding' : 'Open tenant compare' }}
@endif @if ($runUrl || filled($subjectKey))
More follow-up
@if ($runUrl) Open run @endif @if (filled($subjectKey)) Focus subject @endif
@endif
@endif