<?php
$page_title = 'Advanced Finance';
require_once __DIR__ . '/../config.php';
if (session_status() === PHP_SESSION_NONE) { session_start(); }
if (!isset($_SESSION['admin_id'])) { redirect(SITE_URL . '/admin/login.php'); }
require_once __DIR__ . '/header.php';
?>

<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:24px;">
    <div>
        <h2 style="font-family:'Outfit', sans-serif; font-size:1.8rem; color:#0f172a; margin:0;">Advanced Finance & Treasury</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Cash flow forecasting, cost center accounting, and scenario planning.</p>
    </div>
</div>

<div class="grid-4" style="margin-bottom:24px;">
    <div style="background:linear-gradient(135deg, #1e3a5f, #0f172a); padding:20px; border-radius:12px; color:#fff;">
        <div style="color:#94a3b8; font-size:0.8rem; font-weight:600; margin-bottom:8px;">CASH IN BANK</div>
        <div style="font-size:1.8rem; font-weight:700;">₹8.4 Cr</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-arrow-up"></i> +₹42L from yesterday</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">RECEIVABLES</div>
        <div style="font-size:1.8rem; font-weight:700; color:#0f172a;">₹3.2 Cr</div>
        <div style="color:#d97706; font-size:0.8rem; margin-top:5px;"><i class="fas fa-clock"></i> ₹85L overdue &gt;30 days</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">PAYABLES</div>
        <div style="font-size:1.8rem; font-weight:700; color:#0f172a;">₹2.1 Cr</div>
        <div style="color:#ef4444; font-size:0.8rem; margin-top:5px;"><i class="fas fa-exclamation-circle"></i> ₹32L due this week</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">NET PROFIT MARGIN</div>
        <div style="font-size:1.8rem; font-weight:700; color:#10b981;">14.2%</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-arrow-up"></i> +1.1% QoQ</div>
    </div>
</div>

<div class="grid-2">
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
        <h3 style="margin:0 0 20px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-water" style="color:#3b82f6; margin-right:8px;"></i> 6-Month Cash Flow Forecast</h3>
        <div style="display:flex; justify-content:space-between; align-items:flex-end; height:120px; padding:10px 0; border-bottom:1px solid #e2e8f0;">
            <div style="width:14%; background:#10b981; height:60%; border-radius:4px 4px 0 0;"></div>
            <div style="width:14%; background:#10b981; height:70%; border-radius:4px 4px 0 0;"></div>
            <div style="width:14%; background:#10b981; height:75%; border-radius:4px 4px 0 0;"></div>
            <div style="width:14%; background:#10b981; height:80%; border-radius:4px 4px 0 0;"></div>
            <div style="width:14%; background:#10b981; height:88%; border-radius:4px 4px 0 0;"></div>
            <div style="width:14%; background:#10b981; height:95%; border-radius:4px 4px 0 0;"></div>
        </div>
        <div style="display:flex; justify-content:space-between; font-size:0.75rem; color:#94a3b8; margin-top:5px;">
            <span>May</span><span>Jun</span><span>Jul</span><span>Aug</span><span>Sep</span><span>Oct</span>
        </div>
        <p style="margin:10px 0 0; font-size:0.85rem; color:#10b981;"><i class="fas fa-chart-line"></i> Projected net surplus of ₹6.3 Cr by Oct 2026.</p>
    </div>

    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
        <h3 style="margin:0 0 20px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-rupee-sign" style="color:#10b981; margin-right:8px;"></i> Profitability by SKU</h3>
        <table style="width:100%; border-collapse:collapse; font-size:0.9rem;">
            <thead>
                <tr style="background:#f8fafc; text-align:left;">
                    <th style="padding:10px 12px; border-bottom:1px solid #e2e8f0;">SKU / Product</th>
                    <th style="padding:10px 12px; border-bottom:1px solid #e2e8f0;">Revenue</th>
                    <th style="padding:10px 12px; border-bottom:1px solid #e2e8f0;">Margin</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td style="padding:10px 12px; border-bottom:1px solid #f1f5f9; font-weight:500;">SS-304 Double Bowl Sink</td>
                    <td style="padding:10px 12px; border-bottom:1px solid #f1f5f9;">₹1.8 Cr</td>
                    <td style="padding:10px 12px; border-bottom:1px solid #f1f5f9; color:#10b981; font-weight:bold;">22%</td>
                </tr>
                <tr>
                    <td style="padding:10px 12px; border-bottom:1px solid #f1f5f9; font-weight:500;">Premium Pull-down Faucet</td>
                    <td style="padding:10px 12px; border-bottom:1px solid #f1f5f9;">₹95L</td>
                    <td style="padding:10px 12px; border-bottom:1px solid #f1f5f9; color:#10b981; font-weight:bold;">28%</td>
                </tr>
                <tr>
                    <td style="padding:10px 12px; font-weight:500;">SS-202 Sheet (1mm)</td>
                    <td style="padding:10px 12px;">₹3.4 Cr</td>
                    <td style="padding:10px 12px; color:#d97706; font-weight:bold;">8%</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

<?php require_once __DIR__ . '/footer.php'; ?>
