src/Private/Write-ReclaimReportConsole.ps1

function Write-ReclaimReportConsole {
    <#
    .SYNOPSIS
        Writes the headline summary (and, in Full mode, the named list) to the console.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory)] [object] $Report
    )

    $s = $Report.Summary
    $money = '${0:N0}/mo (${1:N0}/yr)' -f $s.TotalMonthlyUsd, $s.TotalAnnualUsd

    Write-Host ''
    Write-Host ' Optera LicenseReclaim' -ForegroundColor Cyan
    Write-Host (' Tenant: {0} Scanned: {1:yyyy-MM-dd} Stale threshold: {2} days' -f $Report.TenantId, $Report.GeneratedAt, $Report.StaleDays) -ForegroundColor DarkGray
    Write-Host ''
    Write-Host (' LICENSE SPEND TO REVIEW: {0}' -f $money) -ForegroundColor Yellow
    Write-Host (' {0} dead/stale accounts still holding {1} paid licenses - review candidates, verify before reclaiming.' -f $s.ReclaimableAccountCount, $s.ReclaimableLicenseCount)
    Write-Host ''

    if ($Report.Inventory -and @($Report.Inventory).Count) {
        Write-Host ' Reclaimable licenses by type (Owned/Assigned = seats you own/assign for that license; Dead = seats on dead/stale accounts):' -ForegroundColor DarkGray
        Write-Host (' {0,-32}{1,8}{2,10}{3,8}{4,14}' -f 'License', 'Owned', 'Assigned', 'Dead', '$/mo') -ForegroundColor DarkGray
        foreach ($row in $Report.Inventory) {
            $owned    = if ($null -ne $row.PrepaidUnits)  { '{0:N0}' -f $row.PrepaidUnits }  else { 'n/a' }
            $assigned = if ($null -ne $row.ConsumedUnits) { '{0:N0}' -f $row.ConsumedUnits } else { 'n/a' }
            Write-Host (' {0,-32}{1,8}{2,10}{3,8}{4,14}' -f $row.Name, $owned, $assigned, $row.ReclaimableUnits, ('${0:N2}' -f $row.ReclaimableMonthlyUsd))
        }
        Write-Host ''
    }
    elseif ($s.BySku.Count) {
        Write-Host ' By license type:' -ForegroundColor DarkGray
        foreach ($row in $s.BySku) {
            Write-Host (' {0,-34} x{1,-4} ${2,8:N2}/mo' -f $row.Name, $row.Count, $row.MonthlyTotalUsd)
        }
        Write-Host ''
    }

    if ($Report.Mode -eq 'Full') {
        Write-Host ' Accounts to remediate:' -ForegroundColor DarkGray
        foreach ($candidate in ($Report.Reclaimable | Sort-Object MonthlyWasteUsd -Descending)) {
            Write-Host (' {0,-28} {1,-22} ${2,7:N2}/mo [{3}]' -f `
                $candidate.DisplayName, $candidate.UserPrincipalName, $candidate.MonthlyWasteUsd, $candidate.Reason)
        }
    }
    else {
        Write-Host ' >> Unlock the named per-account remediation list (CSV) with Unlock-OpteraLicenseReclaim.' -ForegroundColor Green
        Write-Host ' https://opteraai.com/products' -ForegroundColor DarkGray
    }

    if ($s.UnknownPriceSkuCount -gt 0) {
        Write-Host (' Note: {0} license(s) had no price in the list and counted as $0 - supply -PriceListPath to include them.' -f $s.UnknownPriceSkuCount) -ForegroundColor DarkYellow
    }
    Write-Host ''
    Write-Host ' Before you act (see docs/accuracy.md):' -ForegroundColor DarkGray
    Write-Host ' - "Stale" measures on-prem AD logon age, not cloud sign-in; a cloud-active user can look stale here.' -ForegroundColor DarkGray
    Write-Host ' - Disabled + licensed is sometimes intentional (litigation hold / shared mailbox) - suppress with -ExcludeOu.' -ForegroundColor DarkGray
    Write-Host ' - Correlation can undercount (alternate UPNs / unsynced objects); a false positive is never invented.' -ForegroundColor DarkGray
    Write-Host (' {0}' -f $Report.Disclaimer) -ForegroundColor DarkGray
    Write-Host ''
}