<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Relatório Financeiro — <?php echo e($mes); ?></title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'DejaVu Sans', sans-serif; font-size: 11px; color: #1e3a5f; background: #fff; }
        .header { background: #1e3a5f; color: #fff; padding: 24px 32px; margin-bottom: 24px; }
        .header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
        .header p { font-size: 11px; color: rgba(255,255,255,0.7); }
        .kpis { display: flex; gap: 12px; margin: 0 32px 24px; }
        .kpi { flex: 1; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; }
        .kpi-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; margin-bottom: 4px; }
        .kpi-value { font-size: 16px; font-weight: 800; color: #1e3a5f; }
        .kpi-value.green { color: #25b87e; }
        .kpi-value.amber { color: #d97706; }
        .kpi-value.red   { color: #dc2626; }
        .section { margin: 0 32px 24px; }
        table { width: 100%; border-collapse: collapse; }
        thead tr { background: #1e3a5f; color: #fff; }
        thead th { padding: 8px 10px; text-align: left; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
        tbody tr:nth-child(even) { background: #f8fafc; }
        tbody td { padding: 7px 10px; font-size: 10px; border-bottom: 1px solid #f1f5f9; }
        .badge { display: inline-block; padding: 2px 7px; border-radius: 20px; font-size: 8px; font-weight: 700; text-transform: capitalize; }
        .badge-pago     { background: #ecfdf5; color: #065f46; }
        .badge-pendente { background: #fffbeb; color: #92400e; }
        .badge-vencido  { background: #fef2f2; color: #dc2626; }
        .footer { text-align: center; font-size: 9px; color: #94a3b8; padding: 16px 32px; border-top: 1px solid #e2e8f0; margin-top: 24px; }
    </style>
</head>
<body>

<div class="header">
    <h1>Relatório Financeiro</h1>
    <p>Referência: <?php echo e(\Carbon\Carbon::parse($mes . '-01')->translatedFormat('F \d\e Y')); ?> &nbsp;·&nbsp; Gerado em <?php echo e(now()->format('d/m/Y H:i')); ?></p>
</div>

<div class="kpis">
    <div class="kpi">
        <div class="kpi-label">Total faturado</div>
        <div class="kpi-value">R$ <?php echo e(number_format($totais['total'], 2, ',', '.')); ?></div>
    </div>
    <div class="kpi">
        <div class="kpi-label">Recebido</div>
        <div class="kpi-value green">R$ <?php echo e(number_format($totais['pago'], 2, ',', '.')); ?></div>
    </div>
    <div class="kpi">
        <div class="kpi-label">A receber</div>
        <div class="kpi-value amber">R$ <?php echo e(number_format($totais['pendente'], 2, ',', '.')); ?></div>
    </div>
    <div class="kpi">
        <div class="kpi-label">Vencidas</div>
        <div class="kpi-value <?php echo e($totais['vencidas'] > 0 ? 'red' : ''); ?>"><?php echo e($totais['vencidas']); ?></div>
    </div>
</div>

<div class="section">
    <table>
        <thead>
            <tr>
                <th>#</th>
                <th>Contrato</th>
                <th>Referência</th>
                <th>Valor</th>
                <th>Status</th>
                <th>Pago em</th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $cobrancas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr>
                <td><?php echo e($c->id); ?></td>
                <td><?php echo e($c->contrato?->razao_social ?? '—'); ?></td>
                <td><?php echo e($c->mes_referencia->format('m/Y')); ?></td>
                <td><strong>R$ <?php echo e(number_format($c->valor, 2, ',', '.')); ?></strong></td>
                <td><span class="badge badge-<?php echo e($c->status); ?>"><?php echo e($c->status); ?></span></td>
                <td><?php echo e($c->pago_em?->format('d/m/Y') ?? '—'); ?></td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="6" style="text-align:center; padding:16px; color:#94a3b8;">Nenhuma cobrança no período.</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>

<div class="footer">
    OPCON Soluções Contábeis &middot; Relatório gerado automaticamente pelo sistema &middot; <?php echo e(now()->format('d/m/Y')); ?>

</div>

</body>
</html>
<?php /**PATH C:\ProjetosWeb\OPCON\resources\views\pdf\financeiro.blade.php ENDPATH**/ ?>