<?php $__env->startSection('title', 'Operations Command Center'); ?>

<?php $__env->startSection('content'); ?>
<?php
    $statusPalette = [
        'draft' => '#94a3b8', 'new' => '#2563eb', 'in_progress' => '#2563eb',
        'document_check' => '#f97316', 'submitted' => '#10b981', 'approved' => '#16a34a',
        'completed' => '#16a34a', 'returned' => '#f59e0b', 'rejected' => '#ef4444',
        'cancelled' => '#64748b', 'payment_pending' => '#8b5cf6',
    ];
?>

<div class="space-y-5">
    <section class="flex flex-col gap-4 px-1 sm:flex-row sm:items-center sm:justify-between">
        <div>
            <p class="text-[10px] font-bold uppercase tracking-[0.18em] text-orange-600">Live business command center</p>
            <h1 class="mt-1 text-2xl font-bold tracking-tight text-[#0b1f38]">Welcome back, <?php echo e(auth()->user()->name); ?></h1>
            <p class="mt-1 text-xs text-slate-500">Real-time operations across <?php echo e($branches->count()); ?> <?php echo e(Str::plural('branch', $branches->count())); ?> of <?php echo e($tenant->company_name); ?>.</p>
        </div>
        <div class="flex flex-wrap gap-2">
            <?php if(auth()->user()->hasPermission('customers.create')): ?>
                <a href="<?php echo e(route('app.customers.create')); ?>" class="rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-xs font-bold text-slate-700 shadow-sm hover:border-orange-200 hover:text-orange-600">+ Customer</a>
            <?php endif; ?>
            <?php if(auth()->user()->hasPermission('applications.create')): ?>
                <a href="<?php echo e(route('app.applications.create')); ?>" class="rounded-xl bg-gradient-to-r from-orange-500 to-orange-600 px-4 py-2.5 text-xs font-bold text-white shadow-lg shadow-orange-200">+ New Application</a>
            <?php endif; ?>
        </div>
    </section>

    <section class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
        <a href="<?php echo e(route('app.applications.index', ['created'=>'today'])); ?>" class="erp-kpi-card">
            <div class="flex items-start justify-between"><span class="erp-kpi-icon bg-blue-50 text-blue-600">A</span><span class="erp-live-dot">Live</span></div>
            <p class="erp-kpi-label">Today's Applications</p>
            <p class="erp-kpi-value"><?php echo e(number_format($todayApplications)); ?></p>
            <p class="erp-kpi-note">Created since midnight</p>
        </a>
        <a href="<?php echo e(route('app.applications.index', ['status'=>'completed'])); ?>" class="erp-kpi-card">
            <div class="flex items-start justify-between"><span class="erp-kpi-icon bg-emerald-50 text-emerald-600">✓</span><span class="text-[10px] font-bold text-emerald-600">Completed</span></div>
            <p class="erp-kpi-label">Completed Today</p>
            <p class="erp-kpi-value"><?php echo e(number_format($completedToday)); ?></p>
            <p class="erp-kpi-note">Finalised applications</p>
        </a>
        <a href="<?php echo e(route('app.cashier')); ?>" class="erp-kpi-card">
            <div class="flex items-start justify-between"><span class="erp-kpi-icon bg-orange-50 text-orange-600">AED</span><span class="text-[10px] font-bold text-orange-600">Collected</span></div>
            <p class="erp-kpi-label">Revenue Today</p>
            <p class="erp-kpi-value text-[1.35rem]">AED <?php echo e(number_format((float) $todayRevenue, 2)); ?></p>
            <p class="erp-kpi-note">Successful payments</p>
        </a>
        <a href="<?php echo e(route('app.applications.index', ['status'=>'in_progress'])); ?>" class="erp-kpi-card">
            <div class="flex items-start justify-between"><span class="erp-kpi-icon bg-amber-50 text-amber-600">⌛</span><?php if($slaRisk): ?><span class="rounded-full bg-rose-50 px-2 py-1 text-[9px] font-bold text-rose-600"><?php echo e($slaRisk); ?> SLA risk</span><?php endif; ?></div>
            <p class="erp-kpi-label">Pending Applications</p>
            <p class="erp-kpi-value"><?php echo e(number_format($pendingApplications)); ?></p>
            <p class="erp-kpi-note">Across active workflows</p>
        </a>
        <a href="<?php echo e(route('app.renewals.index', ['window'=>30])); ?>" class="erp-kpi-card">
            <div class="flex items-start justify-between"><span class="erp-kpi-icon bg-rose-50 text-rose-600">R</span><span class="text-[10px] font-bold text-rose-600">30 days</span></div>
            <p class="erp-kpi-label">Renewals Due</p>
            <p class="erp-kpi-value"><?php echo e(number_format($renewalsDue)); ?></p>
            <a href="<?php echo e(route('app.renewals.index', ['window' => 30])); ?>" class="erp-kpi-note font-bold text-orange-600">Open pipeline →</a>
        </a>
    </section>

    <section class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
        <?php if(auth()->user()->hasPermission('applications.view')): ?>
        <a href="<?php echo e(route('app.applications.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-amber-50 text-amber-700">D</span><p class="erp-kpi-label">Pending Documents</p><p class="erp-kpi-value"><?php echo e(number_format($pendingDocuments)); ?></p><p class="erp-kpi-note">Mandatory items awaiting verification</p></a>
        <a href="<?php echo e(route('app.applications.index',['status'=>'submitted'])); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-blue-50 text-blue-700">S</span><p class="erp-kpi-label">Submitted</p><p class="erp-kpi-value"><?php echo e(number_format($submittedApplications)); ?></p><p class="erp-kpi-note">With government authorities</p></a>
        <a href="<?php echo e(route('app.applications.index',['status'=>'returned'])); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-rose-50 text-rose-700">R</span><p class="erp-kpi-label">Returned Applications</p><p class="erp-kpi-value"><?php echo e(number_format($returnedApplications)); ?></p><p class="erp-kpi-note">Correction and resubmission required</p></a>
        <?php endif; ?>
        <?php if(auth()->user()->hasPermission('customers.view')): ?>
        <a href="<?php echo e(route('app.customers.index',['created'=>'today'])); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-emerald-50 text-emerald-700">C</span><p class="erp-kpi-label">Customers Added</p><p class="erp-kpi-value"><?php echo e(number_format($customersAddedToday)); ?></p><p class="erp-kpi-note">Created today</p></a>
        <?php endif; ?>
        <?php if(auth()->user()->hasPermission('approvals.view')): ?>
        <a href="<?php echo e(route('app.tasks.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-violet-50 text-violet-700">A</span><p class="erp-kpi-label">Pending Approvals</p><p class="erp-kpi-value"><?php echo e(number_format($pendingApprovalCount)); ?></p><p class="erp-kpi-note">Controlled decisions awaiting action</p></a>
        <?php endif; ?>
    </section>

    <?php if(auth()->user()->hasPermission('payments.view')): ?>
    <section class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
        <a href="<?php echo e(route('app.cashier')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-emerald-50 text-emerald-700">AED</span><p class="erp-kpi-label">Today’s Collection</p><p class="erp-kpi-value text-xl">AED <?php echo e(number_format((float)$todayRevenue,2)); ?></p><p class="erp-kpi-note">Successful payments</p></a>
        <a href="<?php echo e(route('app.reports.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-emerald-50 text-emerald-700">SR</span><p class="erp-kpi-label">Service Revenue</p><p class="erp-kpi-value text-xl">AED <?php echo e(number_format((float)$serviceRevenueToday,2)); ?></p><p class="erp-kpi-note">Company income only</p></a>
        <a href="<?php echo e(route('app.reports.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-violet-50 text-violet-700">GF</span><p class="erp-kpi-label">Government Fees</p><p class="erp-kpi-value text-xl">AED <?php echo e(number_format((float)$governmentFeesToday,2)); ?></p><p class="erp-kpi-note">Pass-through / clearing</p></a>
        <a href="<?php echo e(route('app.reports.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-sky-50 text-sky-700">VAT</span><p class="erp-kpi-label">VAT</p><p class="erp-kpi-value text-xl">AED <?php echo e(number_format((float)$vatToday,2)); ?></p><p class="erp-kpi-note">Tax liability tracked separately</p></a>
        <a href="<?php echo e(route('app.corporate.companies.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-rose-50 text-rose-700">CR</span><p class="erp-kpi-label">Corporate Receivables</p><p class="erp-kpi-value text-xl">AED <?php echo e(number_format((float)$pendingCorporateReceivables,2)); ?></p><p class="erp-kpi-note">Open corporate balances</p></a>
    </section>
    <?php endif; ?>

    <?php if(auth()->user()->hasPermission('attendance.view')): ?>
    <section class="grid gap-3 sm:grid-cols-2 xl:grid-cols-5">
        <a href="<?php echo e(route('app.attendance.index',['date'=>today()->toDateString()])); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-emerald-50 text-emerald-700">P</span><p class="erp-kpi-label">Employees Present</p><p class="erp-kpi-value"><?php echo e($employeesPresent); ?></p><p class="erp-kpi-note">Today’s attendance</p></a>
        <a href="<?php echo e(route('app.attendance.index',['status'=>'absent'])); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-rose-50 text-rose-700">A</span><p class="erp-kpi-label">Employees Absent</p><p class="erp-kpi-value"><?php echo e($employeesAbsent); ?></p><p class="erp-kpi-note">Explicit absence records</p></a>
        <a href="<?php echo e(route('app.attendance.index',['status'=>'late'])); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-amber-50 text-amber-700">L</span><p class="erp-kpi-label">Employees Late</p><p class="erp-kpi-value"><?php echo e($employeesLate); ?></p><p class="erp-kpi-note">Beyond shift grace period</p></a>
        <a href="<?php echo e(route('app.attendance.index')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-blue-50 text-blue-700">OT</span><p class="erp-kpi-label">Overtime Today</p><p class="erp-kpi-value"><?php echo e(intdiv($employeeOvertimeMinutes,60)); ?>h <?php echo e($employeeOvertimeMinutes%60); ?>m</p><p class="erp-kpi-note">Calculated from approved records</p></a>
        <a href="<?php echo e(route('app.employees.expiries')); ?>" class="erp-kpi-card"><span class="erp-kpi-icon bg-amber-50 text-amber-700">EX</span><p class="erp-kpi-label">Employee Documents</p><p class="erp-kpi-value"><?php echo e($employeeDocumentsDue); ?></p><p class="erp-kpi-note">Expired or due within 90 days</p></a>
    </section>
    <?php endif; ?>

    <section class="grid gap-4 xl:grid-cols-[1.7fr_1fr_1.05fr]">
        <article class="erp-panel min-h-[315px]">
            <div class="erp-panel-heading">
                <div><h2>Applications Trend</h2><p>Created versus completed during the last seven days</p></div>
                <div class="flex gap-3 text-[10px] font-semibold text-slate-500"><span><i class="mr-1 inline-block h-2 w-2 rounded-full bg-blue-600"></i>Created</span><span><i class="mr-1 inline-block h-2 w-2 rounded-full bg-emerald-500"></i>Completed</span></div>
            </div>
            <div class="mt-6 flex h-52 items-end justify-between gap-2 border-b border-slate-200 px-1">
                <?php $__currentLoopData = $weeklyTrend; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="flex h-full min-w-0 flex-1 flex-col justify-end text-center">
                        <div class="flex h-[165px] items-end justify-center gap-1">
                            <div class="w-3 rounded-t-md bg-blue-600/90" style="height: <?php echo e(max(4, round(($day['created'] / $maxTrend) * 100))); ?>%" title="<?php echo e($day['created']); ?> created"></div>
                            <div class="w-3 rounded-t-md bg-emerald-500/90" style="height: <?php echo e(max(4, round(($day['completed'] / $maxTrend) * 100))); ?>%" title="<?php echo e($day['completed']); ?> completed"></div>
                        </div>
                        <span class="mt-3 truncate text-[9px] font-semibold text-slate-400"><?php echo e($day['label']); ?></span>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </article>

        <article class="erp-panel">
            <div class="erp-panel-heading"><div><h2>Top Services</h2><p>Application volume</p></div><a href="<?php echo e(route('app.services.dashboard')); ?>">View all</a></div>
            <div class="mt-5 space-y-5">
                <?php $__empty_1 = true; $__currentLoopData = $topServices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $service): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <div>
                        <div class="mb-1.5 flex items-center justify-between gap-3 text-[11px]"><span class="truncate font-semibold text-slate-700"><?php echo e($service['name']); ?></span><strong class="text-[#0b1f38]"><?php echo e($service['total']); ?></strong></div>
                        <div class="h-2 overflow-hidden rounded-full bg-slate-100"><div class="h-full rounded-full bg-gradient-to-r from-blue-600 to-cyan-400" style="width: <?php echo e(max(6, round(($service['total'] / $topServiceTotal) * 100))); ?>%"></div></div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="erp-empty"><span>S</span><strong>No service activity yet</strong><p>Published services will appear here after applications are created.</p></div>
                <?php endif; ?>
            </div>
        </article>

        <article class="erp-panel">
            <div class="erp-panel-heading"><div><h2>Recent Applications</h2><p>Latest customer work</p></div><a href="<?php echo e(route('app.applications.index')); ?>">View all</a></div>
            <div class="mt-3 divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $recentApplications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $application): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <a href="<?php echo e(route('app.applications.show', $application->id)); ?>" class="flex items-center gap-3 py-3 hover:bg-slate-50">
                        <span class="grid h-8 w-8 shrink-0 place-items-center rounded-full bg-slate-100 text-[10px] font-bold text-slate-600"><?php echo e(strtoupper(substr($application->customer?->full_name_en ?? 'NA', 0, 2))); ?></span>
                        <span class="min-w-0 flex-1"><strong class="block truncate text-[11px] text-[#0b1f38]"><?php echo e($application->customer?->full_name_en ?? 'Walk-in customer'); ?></strong><small class="block truncate text-[9px] text-slate-400"><?php echo e($application->service?->name_en ?? $application->application_number); ?></small></span>
                        <span class="erp-status" data-status="<?php echo e($application->status); ?>"><?php echo e(str($application->status)->replace('_', ' ')->title()); ?></span>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="erp-empty py-10"><span>A</span><strong>No applications yet</strong><p>Create the first application from Quick Actions.</p></div>
                <?php endif; ?>
            </div>
        </article>
    </section>

    <section class="grid gap-4 xl:grid-cols-[1.1fr_1.5fr_1fr]">
        <article class="erp-panel">
            <div class="erp-panel-heading"><div><h2>Renewals Due</h2><p>Next 30 days</p></div><a href="<?php echo e(route('app.renewals.index')); ?>">View all</a></div>
            <div class="mt-3 divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $renewalItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $renewal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <a href="<?php echo e(route('app.renewals.show', $renewal->id)); ?>" class="flex items-center gap-3 py-3">
                        <span class="grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-rose-50 text-xs text-rose-600">▣</span>
                        <span class="min-w-0 flex-1"><strong class="block truncate text-[10px] text-[#0b1f38]"><?php echo e($renewal->customer?->full_name_en ?? $renewal->corporateEmployee?->full_name ?? $renewal->employee?->full_name ?? $renewal->company?->name_en ?? 'Renewal record'); ?></strong><small class="block text-[9px] text-slate-400"><?php echo e(str($renewal->document_type)->replace('_', ' ')->title()); ?> · <?php echo e($renewal->document_number ?: $renewal->renewal_number); ?></small></span>
                        <span class="text-right text-[9px] font-bold <?php echo e($renewal->expiry_date->isPast() ? 'text-rose-600' : 'text-orange-600'); ?>"><?php echo e($renewal->expiry_date->isPast() ? 'Expired' : 'Due in '.$renewal->expiry_date->diffInDays(today()) .'d'); ?></span>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="erp-empty py-10"><span>R</span><strong>No urgent renewals</strong><p>The next 30 days are clear.</p></div>
                <?php endif; ?>
            </div>
        </article>

        <article class="erp-panel">
            <div class="erp-panel-heading"><div><h2>Revenue Overview</h2><p>AED collected over seven days</p></div><strong class="text-sm text-[#0b1f38]">AED <?php echo e(number_format($weeklyTrend->sum('revenue'), 2)); ?></strong></div>
            <div class="mt-5 flex h-[190px] items-end justify-between gap-3 border-b border-slate-200 px-2">
                <?php $__currentLoopData = $weeklyTrend; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="flex h-full min-w-0 flex-1 flex-col justify-end text-center">
                        <span class="mb-1 truncate text-[8px] font-bold text-slate-400"><?php echo e($day['revenue'] > 0 ? number_format($day['revenue'] / 1000, 1).'k' : '0'); ?></span>
                        <div class="mx-auto w-full max-w-8 rounded-t-md bg-gradient-to-t from-orange-600 to-orange-400" style="height: <?php echo e(max(4, round(($day['revenue'] / $maxRevenue) * 100))); ?>%"></div>
                        <span class="mt-3 truncate text-[9px] font-semibold text-slate-400"><?php echo e($day['label']); ?></span>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
            <div class="mt-4 flex items-center justify-between rounded-xl bg-rose-50 px-4 py-3"><span class="text-[10px] font-semibold text-rose-700">Outstanding receivables</span><strong class="text-sm text-rose-700">AED <?php echo e(number_format((float) $outstandingReceivables, 2)); ?></strong></div>
        </article>

        <article class="erp-panel">
            <div class="erp-panel-heading"><div><h2>Application Status</h2><p>Current workload mix</p></div><span class="text-[10px] font-bold text-slate-400"><?php echo e(number_format($statusCounts->sum())); ?> total</span></div>
            <div class="mt-5 space-y-4">
                <?php $__empty_1 = true; $__currentLoopData = $statusCounts->sortDesc()->take(6); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status => $count): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <div class="grid grid-cols-[90px_1fr_58px] items-center gap-2 text-[10px]">
                        <span class="truncate font-semibold text-slate-600"><?php echo e(str($status)->replace('_', ' ')->title()); ?></span>
                        <div class="h-1.5 overflow-hidden rounded-full bg-slate-100"><div class="h-full rounded-full" style="width: <?php echo e(round(($count / $statusTotal) * 100)); ?>%; background: <?php echo e($statusPalette[$status] ?? '#2563eb'); ?>"></div></div>
                        <strong class="text-right text-[#0b1f38]"><?php echo e($count); ?> <small class="font-normal text-slate-400">(<?php echo e(round(($count / $statusTotal) * 100)); ?>%)</small></strong>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="erp-empty py-10"><span>✓</span><strong>Your operation is ready</strong><p>Status analytics will populate with live applications.</p></div>
                <?php endif; ?>
            </div>
        </article>
    </section>

    <section class="grid gap-4 lg:grid-cols-2 xl:grid-cols-4">
        <?php if(auth()->user()->hasPermission('employees.view')): ?>
        <article class="erp-panel"><div class="erp-panel-heading"><div><h2>Employee Document Expiry</h2><p>Expired and next 90 days</p></div><a href="<?php echo e(route('app.employees.expiries')); ?>">View all</a></div><div class="mt-3 divide-y divide-slate-100"><?php $__empty_1 = true; $__currentLoopData = $expiringEmployeeDocuments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $document): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><a href="<?php echo e(route('app.employees.show',$document->employee_id)); ?>#documents" class="flex items-center justify-between gap-3 py-3"><span class="min-w-0"><strong class="block truncate text-xs text-slate-900"><?php echo e($document->employee->full_name); ?></strong><small class="text-[10px] text-slate-400"><?php echo e(str($document->document_type)->replace('_',' ')->title()); ?></small></span><span class="text-[10px] font-bold <?php echo e($document->expiry_date->isPast() ? 'text-rose-700' : 'text-amber-700'); ?>"><?php echo e($document->expiry_date->isPast() ? 'Expired' : $document->expiry_date->diffInDays(today()).'d'); ?></span></a><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><div class="erp-empty py-10"><strong>No employee expiries</strong><p>The next 90 days are clear.</p></div><?php endif; ?></div></article>
        <?php endif; ?>
        <?php if(auth()->user()->hasPermission('approvals.view')): ?>
        <article class="erp-panel"><div class="erp-panel-heading"><div><h2>Pending Approvals</h2><p>Controlled decisions</p></div><a href="<?php echo e(route('app.tasks.index')); ?>">View all</a></div><div class="mt-3 divide-y divide-slate-100"><?php $__empty_1 = true; $__currentLoopData = $pendingApprovals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $approval): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><a href="<?php echo e(route('app.tasks.index')); ?>" class="block py-3"><strong class="block text-xs text-slate-900"><?php echo e(str($approval->type)->replace('_',' ')->title()); ?></strong><small class="text-[10px] text-slate-400"><?php echo e($approval->approval_number); ?> · <?php echo e($approval->requester?->name ?? 'System'); ?></small></a><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><div class="erp-empty py-10"><strong>No pending approvals</strong><p>All controlled decisions are current.</p></div><?php endif; ?></div></article>
        <?php endif; ?>
        <?php if(auth()->user()->hasPermission('payments.view')): ?>
        <article class="erp-panel"><div class="erp-panel-heading"><div><h2>Recent Payments</h2><p>Latest successful collections</p></div><a href="<?php echo e(route('app.cashier')); ?>">Cashier</a></div><div class="mt-3 divide-y divide-slate-100"><?php $__empty_1 = true; $__currentLoopData = $recentPayments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><a href="<?php echo e($payment->invoice ? route('app.billing.invoices.show',$payment->invoice_id) : route('app.cashier')); ?>" class="flex items-center justify-between gap-3 py-3"><span><strong class="block text-xs text-slate-900"><?php echo e($payment->payment_number); ?></strong><small class="text-[10px] text-slate-400"><?php echo e($payment->payment_method); ?> · <?php echo e($payment->cashier?->name); ?></small></span><strong class="text-xs text-emerald-700">AED <?php echo e(number_format((float)$payment->amount,2)); ?></strong></a><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><div class="erp-empty py-10"><strong>No recent payments</strong><p>Collections will appear here.</p></div><?php endif; ?></div></article>
        <article class="erp-panel"><div class="erp-panel-heading"><div><h2>Corporate Outstanding</h2><p>Credit exposure</p></div><a href="<?php echo e(route('app.corporate.companies.index')); ?>">View all</a></div><div class="mt-3 divide-y divide-slate-100"><?php $__empty_1 = true; $__currentLoopData = $corporateOutstanding; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $company): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><a href="<?php echo e(route('app.corporate.companies.show',$company->id)); ?>" class="flex items-center justify-between gap-3 py-3"><span><strong class="block text-xs text-slate-900"><?php echo e($company->name_en); ?></strong><small class="text-[10px] text-slate-400"><?php echo e($company->company_code); ?> · <?php echo e($company->credit_status); ?></small></span><strong class="text-xs text-rose-700">AED <?php echo e(number_format((float)$company->credit_used,2)); ?></strong></a><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><div class="erp-empty py-10"><strong>No credit outstanding</strong><p>Corporate credit is within limits.</p></div><?php endif; ?></div></article>
        <?php endif; ?>
    </section>

    <section class="erp-panel">
        <div class="erp-panel-heading"><div><h2>Quick Actions</h2><p>Start common typing-center workflows</p></div><span class="rounded-full bg-emerald-50 px-3 py-1 text-[9px] font-bold text-emerald-600"><?php echo e($employeeCount); ?> active staff · <?php echo e($userCount); ?> ERP users</span></div>
        <div class="mt-4 grid grid-cols-2 gap-2 sm:grid-cols-4 xl:grid-cols-8">
            <?php if(auth()->user()->hasPermission('customers.create')): ?><a class="erp-quick-action" href="<?php echo e(route('app.customers.create')); ?>"><span class="bg-blue-50 text-blue-600">C</span><strong>Add Customer</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('applications.create')): ?><a class="erp-quick-action" href="<?php echo e(route('app.applications.create')); ?>"><span class="bg-emerald-50 text-emerald-600">A</span><strong>Application</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('documents.upload')): ?><a class="erp-quick-action" href="<?php echo e(route('app.customers.documents.index')); ?>"><span class="bg-violet-50 text-violet-600">D</span><strong>Documents</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('payments.collect')): ?><a class="erp-quick-action" href="<?php echo e(route('app.billing.pos')); ?>"><span class="bg-orange-50 text-orange-600">AED</span><strong>Collect Payment</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('renewals.view')): ?><a class="erp-quick-action" href="<?php echo e(route('app.renewals.index')); ?>"><span class="bg-rose-50 text-rose-600">R</span><strong>Renewals</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('customers.view')): ?><a class="erp-quick-action" href="<?php echo e(route('app.corporate.companies.index')); ?>"><span class="bg-cyan-50 text-cyan-600">CO</span><strong>Corporate</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('reports.view')): ?><a class="erp-quick-action" href="<?php echo e(route('app.accounting')); ?>"><span class="bg-indigo-50 text-indigo-600">↗</span><strong>Finance</strong></a><?php endif; ?>
            <?php if(auth()->user()->hasPermission('settings.view')): ?><a class="erp-quick-action" href="<?php echo e(route('app.settings.company.profile')); ?>"><span class="bg-slate-100 text-slate-600">⚙</span><strong>Settings</strong></a><?php endif; ?>
        </div>
    </section>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\typingcenter\resources\views/tenant/dashboard.blade.php ENDPATH**/ ?>