<?php $__env->startSection('title', 'Hasil Analisis - FIN-ANALYSIS PRO'); ?>

<?php $__env->startPush('styles'); ?>
<style>
/* ═══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN — Mobile First
═══════════════════════════════════════════════════════════ */

body, html { margin: 0; padding: 0; box-sizing: border-box; }
* { box-sizing: border-box; }

.max-w-5xl {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem;
}
@media (min-width: 768px)  { .max-w-5xl { padding: 0 1rem; } }
@media (min-width: 1024px) { .max-w-5xl { max-width: 65rem !important; padding: 0; } }

div[style*="display:grid"],
div[style*="display:flex"] { overflow-x: auto; }

img, canvas, video { max-width: 100%; height: auto; }

/* ── Gauge wrapper ── */
#gaugeWrapper { position: relative; width: 100%; }
#gaugeSvg     { width: 100%; display: block; overflow: visible; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE GRID OVERRIDES
═══════════════════════════════════════════════════════════ */
@media (max-width: 639px) {
    [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2,1fr) !important; gap: .75rem !important; }
    [style*="grid-template-columns:repeat(5,1fr)"] { grid-template-columns: 1fr !important; gap: .75rem !important; }
    [style*="font-size:3.5rem"]    { font-size: 2.5rem !important; }
    [style*="font-size:1.5rem"]    { font-size: 1.25rem !important; }
    [style*="font-size:1.25rem"]   { font-size: 1rem !important; }
    [style*="font-size:.9375rem"]  { font-size: .875rem !important; }
    [style*="padding:1rem 1.25rem"]{ padding: .75rem 1rem !important; }
    [style*="padding:1.5rem"]      { padding: 1rem !important; }
    [style*="padding:2rem"]        { padding: 1.25rem !important; }
    [style*="gap:1rem"],[style*="gap:1.5rem"] { gap: .75rem !important; }
    [style*="margin-bottom:1.5rem"]{ margin-bottom: 1rem !important; }
    [style*="display:flex"][style*="justify-content:space-between"] { flex-direction: column !important; gap: 1rem !important; }
    [style*="display:flex"][style*="gap:.75rem"][style*="justify-content:center"] { flex-direction: column !important; }
    [style*="display:inline-flex"][style*="gap:"] { width: 100% !important; justify-content: center !important; }
}
@media (min-width: 640px) and (max-width: 1023px) {
    [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }
    [style*="grid-template-columns:repeat(5,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }
}
@media (min-width: 1024px) {
    [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(4,1fr) !important; }
    [style*="grid-template-columns:repeat(5,1fr)"] { grid-template-columns: repeat(5,1fr) !important; }
}
@media (max-width: 1023px) {
    [style*="grid-template-columns:1fr 2fr"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 767px) {
    [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="display:flex"][style*="gap:1.5rem"],
    [style*="display:flex"][style*="gap:1.25rem"] { flex-direction: column !important; gap: .5rem !important; }
    table { font-size: .8rem !important; }
    table td, table th { padding: .5rem !important; }
}
@media (max-width: 480px) {
    [style*="display:inline-flex"][style*="gap:"] { font-size: .7rem !important; }
}

/* ═══════════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════════ */
.dark [style*="background:#F8FAFF"],
.dark [style*="background: #F8FAFF"],
.dark [style*="background:#fff"],
.dark [style*="background: #fff"] {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}
.dark [style*="color:#1E293B"],
.dark [style*="color:#0F172A"],
.dark [style*="color:#64748B"],
.dark [style*="color:#94A3B8"] { color: #f1f5f9 !important; }

.dark a[style*="background:#fff"] {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}
.dark button[style*="background:#1A56DB"],
.dark button[style*="background: #1A56DB"] { background-color: #3b82f6 !important; }
.dark button[style*="background:#1A56DB"]:hover { background-color: #2563eb !important; }
.dark button[style*="background:#2563eb"] { background-color: #3b82f6 !important; color: #fff !important; }

.dark table { color: #f1f5f9 !important; }
.dark table td, .dark table th { border-color: #475569 !important; color: #f1f5f9 !important; }
.dark table thead { border-color: #475569 !important; }

.dark [style*="background:#D1FAE5"] { background: #064e3b !important; border-color: #065f46 !important; color: #86efac !important; }
.dark [style*="color:#065F46"],.dark [style*="color:#059669"],.dark [style*="color:#10B981"] { color: #86efac !important; }
.dark [style*="background:#FEF3C7"] { background: #78350f !important; border-color: #92400e !important; color: #fcd34d !important; }
.dark [style*="color:#D97706"],.dark [style*="color:#F59E0B"],.dark [style*="color:#92400E"] { color: #fcd34d !important; }
.dark [style*="background:#FEE2E2"] { background: #7f1d1d !important; border-color: #991b1b !important; color: #fca5a5 !important; }
.dark [style*="background:#FCA5A5"],
.dark [style*="color:#DC2626"],.dark [style*="color:#EF4444"],.dark [style*="color:#991B1B"] { color: #fca5a5 !important; }

.dark [style*="background:#D1FAE5"] svg { stroke: #86efac !important; }
.dark [style*="background:#FEF3C7"] svg { stroke: #fcd34d !important; }
.dark [style*="background:#FEE2E2"] svg { stroke: #fca5a5 !important; }

.dark .page-title   { color: #f1f5f9 !important; }
.dark .page-subtitle{ color: #cbd5e1 !important; }
.dark p[style*="color:#1E293B"]   { color: #f1f5f9 !important; }
.dark li[style*="color:#1E293B"]  { color: #f1f5f9 !important; }
.dark li[style*="color:#64748B"]  { color: #cbd5e1 !important; }
.dark div[style*="color:#1E293B"] { color: #f1f5f9 !important; }
.dark div[style*="color:#64748B"] { color: #cbd5e1 !important; }
.dark h2[style*="color:#1E293B"],.dark h3[style*="color:#1E293B"] { color: #f1f5f9 !important; }

.dark .card { background-color: #1e293b !important; border-color: #334155 !important; color: #f1f5f9 !important; }
.dark .card [style*="border-left"] { border-left-color: inherit !important; }

.dark [style*="border-left:4px solid #10B981"] { border-left-color: #86efac !important; }
.dark [style*="border-left:4px solid #F59E0B"] { border-left-color: #fcd34d !important; }
.dark [style*="border-left:4px solid #EF4444"] { border-left-color: #fca5a5 !important; }

.dark strong[style*="color:#059669"],
.dark strong[style*="color:#D97706"],
.dark strong[style*="color:#DC2626"] { color: inherit !important; }

.dark [style*="background:#F8FAFF"],
.dark [style*="background: #F8FAFF"],
.dark [style*="background:#f1f5f9"],
.dark [style*="background: #f1f5f9"] { background-color: #0f172a !important; border-color: #334155 !important; }

.dark [style*="background:#D1FAE5"] p,.dark [style*="background:#D1FAE5"] strong,.dark [style*="background:#D1FAE5"] span { color: #86efac !important; }
.dark [style*="background:#FEF3C7"] p,.dark [style*="background:#FEF3C7"] strong,.dark [style*="background:#FEF3C7"] span { color: #fcd34d !important; }
.dark [style*="background:#FEE2E2"] p,.dark [style*="background:#FEE2E2"] strong,.dark [style*="background:#FEE2E2"] span { color: #fca5a5 !important; }

/* Dark mode gauge element classes */
.dark #gaugeSvg .g-bg    { fill: #1a2335; }
.dark #gaugeSvg .g-bdr   { stroke: rgba(255,255,255,.05); }
.dark #gaugeSvg .g-track { fill: #243047; }
.dark #gaugeSvg .g-tick  { stroke: rgba(255,255,255,.22) !important; }
.dark #gaugeSvg .g-lbl   { fill: rgba(255,255,255,.42) !important; }
.dark #gaugeSvg .g-zlbl  { fill: rgba(255,255,255,.82) !important; }
.dark #gaugeSvg .g-ndl   { fill: #e8edf5; }
.dark #gaugeSvg .g-hub1  { fill: #243047; }
.dark #gaugeSvg .g-hub2  { fill: #e8edf5; }
.dark #gaugeSvg .g-stxt  { fill: #f1f5f9; }
.dark #gaugeSvg .g-ssub  { fill: rgba(255,255,255,.5); }

/* Light mode gauge element classes */
.light #gaugeSvg .g-bg    { fill: #f3f6fb; }
.light #gaugeSvg .g-bdr   { stroke: rgba(0,0,0,.06); }
.light #gaugeSvg .g-track { fill: #dfe4ee; }
.light #gaugeSvg .g-tick  { stroke: rgba(0,0,0,.18) !important; }
.light #gaugeSvg .g-lbl   { fill: rgba(0,0,0,.38) !important; }
.light #gaugeSvg .g-zlbl  { fill: rgba(255,255,255,.88) !important; }
.light #gaugeSvg .g-ndl   { fill: #1e293b; }
.light #gaugeSvg .g-hub1  { fill: #d8dde8; }
.light #gaugeSvg .g-hub2  { fill: #1e293b; }
.light #gaugeSvg .g-stxt  { fill: #1e293b; }
.light #gaugeSvg .g-ssub  { fill: #64748b; }

/* ═══════════════════════════════════════════════════════════
   LIGHT MODE
═══════════════════════════════════════════════════════════ */
.light [style*="background:#064e3b"] { background: #D1FAE5 !important; border-color: #A7F3D0 !important; color: #065F46 !important; }
.light [style*="color:#86efac"],.light [style*="color: #86efac"],
.light [style*="color:#065F46"],.light [style*="color: #065F46"] { color: #065F46 !important; }
.light [style*="background:#D1FAE5"] svg { stroke: #10B981 !important; }

.light [style*="background:#78350f"] { background: #FEF3C7 !important; border-color: #FCD34D !important; color: #92400E !important; }
.light [style*="color:#fcd34d"],.light [style*="color: #fcd34d"],
.light [style*="color:#D97706"],.light [style*="color: #D97706"],
.light [style*="color:#F59E0B"],.light [style*="color: #F59E0B"] { color: #D97706 !important; }
.light [style*="background:#FEF3C7"] svg { stroke: #F59E0B !important; }

.light [style*="background:#7f1d1d"] { background: #FEE2E2 !important; border-color: #FECACA !important; color: #991B1B !important; }
.light [style*="color:#fca5a5"],.light [style*="color: #fca5a5"],
.light [style*="color:#DC2626"],.light [style*="color: #DC2626"],
.light [style*="color:#EF4444"],.light [style*="color: #EF4444"] { color: #DC2626 !important; }
.light [style*="background:#FEE2E2"] svg { stroke: #EF4444 !important; }

.light .card { background: #ffffff !important; border-color: #E2E8F0 !important; color: #1E293B !important; }
.light [style*="background:#1e293b"],.light [style*="background: #1e293b"],
.light [style*="background:#334155"],.light [style*="background: #334155"] { background: #ffffff !important; border-color: #E2E8F0 !important; }
.light [style*="color:#f1f5f9"],.light [style*="color: #f1f5f9"],
.light [style*="color:#cbd5e1"],.light [style*="color: #cbd5e1"] { color: #1E293B !important; }
.light [style*="color:#1A56DB"],.light [style*="color:#3b82f6"] { color: #1A56DB !important; }
.light [style*="color:#64748B"],.light [style*="color: #64748B"] { color: #475569 !important; }
.light [style*="color:#94A3B8"],.light [style*="color: #94A3B8"] { color: #64748B !important; }
.light [style*="color:#0F172A"],.light [style*="color: #0F172A"],
.light [style*="color:#1E293B"],.light [style*="color: #1E293B"] { color: #1E293B !important; }
.light table { color: #1E293B !important; }
.light table td,.light table th { border-color: #E2E8F0 !important; color: #1E293B !important; }
.light .page-title   { color: #1E293B !important; }
.light .page-subtitle{ color: #64748B !important; }
.light [style*="background:#F8FAFF"],.light [style*="background: #F8FAFF"],
.light [style*="background:#f1f5f9"],.light [style*="background: #f1f5f9"] { background-color: #f8fafc !important; border-color: #e2e8f0 !important; }
.light a[style*="background:#fff"],.light a[style*="background: #fff"] { background-color: #ffffff !important; color: #1E293B !important; border-color: #E2E8F0 !important; }
.light button[style*="background:#1A56DB"],.light button[style*="background: #1A56DB"],
.light button[style*="background:#2563eb"],.light button[style*="background: #2563eb"] { background-color: #1A56DB !important; color: #ffffff !important; }
.light button[style*="background:#334155"],.light button[style*="background: #334155"] { background-color: #f3f4f6 !important; color: #374151 !important; border-color: #d1d5db !important; }

.light [style*="background:#064e3b"] p,.light [style*="background:#064e3b"] strong,.light [style*="background:#064e3b"] span { color: #065F46 !important; }
.light [style*="background:#78350f"] p,.light [style*="background:#78350f"] strong,.light [style*="background:#78350f"] span { color: #92400E !important; }
.light [style*="background:#7f1d1d"] p,.light [style*="background:#7f1d1d"] strong,.light [style*="background:#7f1d1d"] span { color: #991B1B !important; }

.light [style*="border-left:4px solid #86efac"] { border-left-color: #10B981 !important; }
.light [style*="border-left:4px solid #fcd34d"] { border-left-color: #F59E0B !important; }
.light [style*="border-left:4px solid #fca5a5"] { border-left-color: #EF4444 !important; }
.light [style*="border-left:4px solid #10B981"] { border-left-color: #10B981 !important; }
.light [style*="border-left:4px solid #F59E0B"] { border-left-color: #F59E0B !important; }
.light [style*="border-left:4px solid #EF4444"] { border-left-color: #EF4444 !important; }

.light strong[style*="color:#86efac"] { color: #065F46 !important; }
.light strong[style*="color:#fcd34d"] { color: #92400E !important; }
.light strong[style*="color:#fca5a5"] { color: #991B1B !important; }
.light [style*="color:#92400E"],.light [style*="color: #92400E"],
.light [style*="color:#065F46"],.light [style*="color: #065F46"],
.light [style*="color:#991B1B"],.light [style*="color: #991B1B"] { color: inherit !important; }
.light li[style*="color:#64748B"] { color: #475569 !important; }
.light h2[style*="color:#1E293B"],.light h3[style*="color:#1E293B"] { color: #1E293B !important; }

/* dark SVG stroke overrides */
.dark svg[style*="stroke:#086b3f"] { stroke: #86efac !important; }
.dark svg[style*="stroke:#064e3b"] { stroke: #86efac !important; }
.dark svg[style*="stroke:#78350f"] { stroke: #fcd34d !important; }
.dark svg[style*="stroke:#92400e"] { stroke: #fcd34d !important; }
.dark svg[style*="stroke:#7f1d1d"] { stroke: #fca5a5 !important; }
.dark svg[style*="stroke:#991b1b"] { stroke: #fca5a5 !important; }
.light svg[style*="stroke:#86efac"] { stroke: #10B981 !important; }
.light svg[style*="stroke:#fcd34d"] { stroke: #F59E0B !important; }
.light svg[style*="stroke:#fca5a5"] { stroke: #EF4444 !important; }

/* dark mode button/link fixes */
.dark button[style*="background:#fff"],.dark a[style*="background:#fff"] {
    background-color: #334155 !important; color: #f1f5f9 !important; border-color: #475569 !important;
}
.dark button[style*="background:#1A56DB"],.dark button[style*="background: #1A56DB"],
.dark button[style*="background:#2563eb"],.dark button[style*="background: #2563eb"] {
    background-color: #3b82f6 !important; color: #ffffff !important;
}
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-5xl mx-auto">

    
    <div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:1rem;margin-bottom:2rem">
        <div>
            <h1 class="page-title" style="margin-bottom:4px">Hasil Analisis Z-Score</h1>
            <p class="page-subtitle"><?php echo e($companyData['company_name']); ?> &mdash; <?php echo e($companyData['period']); ?></p>
        </div>
        <div style="display:flex;gap:.75rem;flex-wrap:wrap">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(isset($analysisResult)): ?>
            <a href="<?php echo e(route('report.download', $analysisResult->id)); ?>"
               style="display:inline-flex;align-items:center;gap:6px;padding:9px 18px;border-radius:8px;border:1.5px solid #E2E8F0;background:#fff;font-size:.875rem;font-weight:600;color:#1E293B;text-decoration:none">
                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
                Unduh PDF
            </a>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <form action="<?php echo e(route('analysis.reset')); ?>" method="POST" style="display:inline">
                <?php echo csrf_field(); ?>
                <button type="submit"
                        style="display:inline-flex;align-items:center;gap:6px;padding:9px 18px;border-radius:8px;border:none;background:#1A56DB;font-size:.875rem;font-weight:600;color:#fff;cursor:pointer">
                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
                    Analisis Baru
                </button>
            </form>
        </div>
    </div>

    
    <div style="background:#F8FAFF;border:1px solid #E2E8F0;border-radius:12px;padding:1rem 1.25rem;margin-bottom:1.5rem">
        <div style="display:grid;grid-template-columns:repeat(4,1fr);gap:1rem">
            <div>
                <div style="font-size:.75rem;color:#64748B;font-weight:500;margin-bottom:2px">Perusahaan</div>
                <div style="font-weight:700;color:#1E293B"><?php echo e($companyData['company_name']); ?></div>
            </div>
            <div>
                <div style="font-size:.75rem;color:#64748B;font-weight:500;margin-bottom:2px">Bidang Usaha</div>
                <div style="font-weight:700;color:#1E293B">
                    <?php echo e($companyData['business_field'] === 'Lainnya' ? ($companyData['other_field'] ?? 'Lainnya') : $companyData['business_field']); ?>

                </div>
            </div>
            <div>
                <div style="font-size:.75rem;color:#64748B;font-weight:500;margin-bottom:2px">Periode</div>
                <div style="font-weight:700;color:#1E293B"><?php echo e($companyData['period']); ?></div>
            </div>
            <div>
                <div style="font-size:.75rem;color:#64748B;font-weight:500;margin-bottom:2px">Mata Uang</div>
                <div style="font-weight:700;color:#1E293B"><?php echo e($companyData['currency']); ?></div>
            </div>
        </div>
    </div>

    
    <?php
        $zCategory = $category ?? 'grey';
        $zColors = [
            'safe'     => ['bg'=>'#D1FAE5','border'=>'#6EE7B7','text'=>'#065F46','label'=>'ZONA AMAN',     'desc'=>'Perusahaan dalam kondisi keuangan yang sehat'],
            'grey'     => ['bg'=>'#FEF3C7','border'=>'#FCD34D','text'=>'#92400E','label'=>'ZONA WASPADA',  'desc'=>'Perusahaan perlu perhatian pada kondisi keuangannya'],
            'distress' => ['bg'=>'#FEE2E2','border'=>'#FCA5A5','text'=>'#991B1B','label'=>'ZONA BERBAHAYA','desc'=>'Perusahaan berpotensi mengalami kesulitan keuangan'],
        ];
        $zc = $zColors[$zCategory] ?? $zColors['grey'];
        $zoneAccent = $zCategory === 'safe' ? '#1D9E75' : ($zCategory === 'grey' ? '#EF9F27' : '#E24B4A');

        /* ════════════════════════════════════════════════
           GAUGE GEOMETRY
           ViewBox: 440 × 260
           Hub centre: CX=220, CY=220
           Arc band: R_OUT=168, R_IN=112
           Gauge sweeps from the left (score=0) clockwise
           to the right (score=5), i.e. a 180° half-circle.

           Convention: "gauge-degree" gd ∈ [0,180]
             gd=0   → leftmost (score 0)
             gd=180 → rightmost (score 5)
           Standard math angle = gd − 180   (so gd=0 → −180° = left)
        ════════════════════════════════════════════════ */
        $GCX = 220; $GCY = 220;
        $R_OUT = 168; $R_IN = 112;
        $MAX_S = 5;

        /* score → gauge-degree */
        $s2g = fn($s) => ($s / $MAX_S) * 180.0;

        /* gauge-degree → SVG x,y */
        $xy = fn($r, $gd) => [
            round($GCX + $r * cos(deg2rad($gd - 180.0)), 2),
            round($GCY + $r * sin(deg2rad($gd - 180.0)), 2),
        ];

        /* annular segment between gd1 and gd2, rOut / rIn */
        $seg = function($gd1, $gd2, $rO, $rI) use ($xy) {
            [$ox1,$oy1] = $xy($rO, $gd1);
            [$ox2,$oy2] = $xy($rO, $gd2);
            [$ix2,$iy2] = $xy($rI, $gd2);
            [$ix1,$iy1] = $xy($rI, $gd1);
            $lg = (($gd2 - $gd1) > 180) ? 1 : 0;
            return "M $ox1 $oy1 A $rO $rO 0 $lg 1 $ox2 $oy2 L $ix2 $iy2 A $rI $rI 0 $lg 0 $ix1 $iy1 Z";
        };

        /* key angles */
        $gd0   = $s2g(0);     // 0
        $gd123 = $s2g(1.23);  // 44.28
        $gd29  = $s2g(2.9);   // 104.4
        $gd5   = $s2g(5);     // 180

        /* needle geometry for initial PHP render */
        $ndlGd   = $s2g(min(max($zScore, 0), $MAX_S));
        $ndlRad  = deg2rad($ndlGd - 180.0);
        $NL = $R_IN - 8;  // tip reaches inner edge of arc − 8px
        $NT = 24;         // tail behind hub
        $NW = 5.5;        // half-width at hub
        [$ntx,$nty] = [$GCX + $NL * cos($ndlRad), $GCY + $NL * sin($ndlRad)];
        [$nbx,$nby] = [$GCX - $NT * cos($ndlRad), $GCY - $NT * sin($ndlRad)];
        $npx = -sin($ndlRad) * $NW;
        $npy =  cos($ndlRad) * $NW;
        $initPts = implode(' ', [
            round($ntx,2).','.round($nty,2),
            round($GCX+$npx,2).','.round($GCY+$npy,2),
            round($nbx,2).','.round($nby,2),
            round($GCX-$npx,2).','.round($GCY-$npy,2),
        ]);

        /* tick marks */
        $R_T1 = $R_OUT + 5;
        $R_T2_MAJ = $R_OUT + 18;
        $R_T2_MIN = $R_OUT + 11;
        $R_LBL = $R_OUT + 30;
        $ticks = [];
        for ($i = 0; $i <= 10; $i++) {
            $gd  = $i / 10 * 180.0;
            $maj = ($i % 2 === 0);
            [$x1,$y1] = $xy($R_T1, $gd);
            [$x2,$y2] = $xy($maj ? $R_T2_MAJ : $R_T2_MIN, $gd);
            [$lx,$ly] = $xy($R_LBL, $gd);
            $ticks[] = ['x1'=>$x1,'y1'=>$y1,'x2'=>$x2,'y2'=>$y2,
                        'lx'=>$lx,'ly'=>$ly,'lv'=>number_format($i/10*5,1),'maj'=>$maj];
        }

        /* zone label mid-points */
        $R_ZL = ($R_OUT + $R_IN) / 2;
        $zLabels = [
            ['gd'=>$s2g(0.615), 'txt'=>'Bahaya'],
            ['gd'=>$s2g(2.065), 'txt'=>'Waspada'],
            ['gd'=>$s2g(3.95),  'txt'=>'Aman'],
        ];
        foreach ($zLabels as &$zl) {
            [$zl['x'],$zl['y']] = $xy($R_ZL, $zl['gd']);
        }
        unset($zl);

        /* boundary dividers at 1.23 and 2.9 */
        $divGds = [$gd123, $gd29];
    ?>

    <div style="display:grid;grid-template-columns:1fr 2fr;gap:1.5rem;margin-bottom:1.5rem">

        
        <div style="background:<?php echo e($zc['bg']); ?>;border:2px solid <?php echo e($zc['border']); ?>;border-radius:16px;padding:2rem;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center">
            <div style="font-size:.8125rem;font-weight:700;color:<?php echo e($zc['text']); ?>;text-transform:uppercase;letter-spacing:.08em;margin-bottom:.5rem">
                Altman Z'-Score
            </div>
            <div style="font-size:3.5rem;font-weight:800;color:<?php echo e($zc['text']); ?>;line-height:1;margin-bottom:.75rem;font-family:'Syne',sans-serif">
                <?php echo e(number_format($zScore, 4)); ?>

            </div>
            <div style="display:inline-block;padding:5px 16px;border-radius:20px;background:<?php echo e($zc['text']); ?>;color:white;font-size:.8125rem;font-weight:700;letter-spacing:.04em;margin-bottom:.625rem">
                <?php echo e($zc['label']); ?>

            </div>
            <div style="font-size:.8rem;color:<?php echo e($zc['text']); ?>;opacity:.8;text-align:center">
                <?php echo e($zc['desc']); ?>

            </div>
        </div>

        
        <div class="card" style="display:flex;flex-direction:column;align-items:center;justify-content:center;padding:1.5rem;width:100%">
            <div style="font-size:.8125rem;font-weight:600;color:#64748B;margin-bottom:.75rem;text-transform:uppercase;letter-spacing:.06em">Skala Z-Score</div>

            <div id="gaugeWrapper">
                <svg id="gaugeSvg" viewBox="0 0 440 260" xmlns="http://www.w3.org/2000/svg">

                    
                    <rect class="g-bg"  x="0"   y="0"   width="440" height="260" rx="14" fill="#f3f6fb"/>
                    <rect class="g-bdr" x=".5"  y=".5"  width="439" height="259" rx="13.5"
                          fill="none" stroke="rgba(0,0,0,.06)" stroke-width="1"/>

                    
                    <path class="g-track" fill="#dfe4ee"
                          d="<?php echo e($seg($gd0, $gd5, $R_OUT, $R_IN)); ?>"/>

                    
                    <path fill="#E24B4A" opacity=".93"
                          d="<?php echo e($seg($gd0 + .9, $gd123 - .9, $R_OUT - 1, $R_IN + 1)); ?>"/>

                    
                    <path fill="#EF9F27" opacity=".93"
                          d="<?php echo e($seg($gd123 + .9, $gd29 - .9, $R_OUT - 1, $R_IN + 1)); ?>"/>

                    
                    <path fill="#1D9E75" opacity=".93"
                          d="<?php echo e($seg($gd29 + .9, $gd5 - .9, $R_OUT - 1, $R_IN + 1)); ?>"/>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $divGds; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dg): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <?php [$dx1,$dy1] = $xy($R_IN + 2, $dg); [$dx2,$dy2] = $xy($R_OUT - 2, $dg); ?>
                        <line x1="<?php echo e($dx1); ?>" y1="<?php echo e($dy1); ?>" x2="<?php echo e($dx2); ?>" y2="<?php echo e($dy2); ?>"
                              stroke="white" stroke-width="2.5" stroke-linecap="round" opacity=".92"/>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $ticks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <line class="g-tick"
                          x1="<?php echo e($t['x1']); ?>" y1="<?php echo e($t['y1']); ?>"
                          x2="<?php echo e($t['x2']); ?>" y2="<?php echo e($t['y2']); ?>"
                          stroke="rgba(0,0,0,.18)"
                          stroke-width="<?php echo e($t['maj'] ? 2 : 1); ?>"
                          stroke-linecap="round"/>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($t['maj']): ?>
                    <text class="g-lbl"
                          x="<?php echo e($t['lx']); ?>" y="<?php echo e($t['ly']); ?>"
                          text-anchor="middle" dominant-baseline="middle"
                          font-size="10" font-family="monospace"
                          fill="rgba(0,0,0,.38)"><?php echo e($t['lv']); ?></text>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $zLabels; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $zl): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <text class="g-zlbl"
                          x="<?php echo e($zl['x']); ?>" y="<?php echo e($zl['y']); ?>"
                          text-anchor="middle" dominant-baseline="middle"
                          font-size="10.5" font-weight="600"
                          fill="rgba(255,255,255,.88)"><?php echo e($zl['txt']); ?></text>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>

                    
                    <g id="needleGroup">
                        <polygon class="g-ndl" id="needlePoly"
                                 points="<?php echo e($initPts); ?>"
                                 fill="#1e293b" opacity=".95"/>
                        
                        <circle class="g-hub1" cx="<?php echo e($GCX); ?>" cy="<?php echo e($GCY); ?>" r="16" fill="#d8dde8"/>
                        <circle class="g-hub2" cx="<?php echo e($GCX); ?>" cy="<?php echo e($GCY); ?>" r="10" fill="#1e293b"/>
                        <circle cx="<?php echo e($GCX); ?>" cy="<?php echo e($GCY); ?>" r="4.5" fill="<?php echo e($zoneAccent); ?>"/>
                    </g>

                    
                    <text class="g-stxt"
                          x="<?php echo e($GCX); ?>" y="<?php echo e($GCY + 34); ?>"
                          text-anchor="middle" dominant-baseline="middle"
                          font-size="22" font-weight="700"
                          fill="#1e293b"><?php echo e(number_format($zScore, 2)); ?></text>
                    <text class="g-ssub"
                          x="<?php echo e($GCX); ?>" y="<?php echo e($GCY + 52); ?>"
                          text-anchor="middle" dominant-baseline="middle"
                          font-size="10.5" letter-spacing=".04em"
                          fill="#64748b">Z-Score</text>

                </svg>
            </div>

            
            <div style="display:flex;gap:1.25rem;margin-top:.875rem;flex-wrap:wrap;justify-content:center;width:100%">
                <div style="display:flex;align-items:center;gap:5px;font-size:.75rem;color:#64748B">
                    <span style="width:10px;height:10px;border-radius:2px;background:#E24B4A;display:inline-block;flex-shrink:0"></span>
                    &lt; 1.23 Berbahaya
                </div>
                <div style="display:flex;align-items:center;gap:5px;font-size:.75rem;color:#64748B">
                    <span style="width:10px;height:10px;border-radius:2px;background:#EF9F27;display:inline-block;flex-shrink:0"></span>
                    1.23–2.9 Waspada
                </div>
                <div style="display:flex;align-items:center;gap:5px;font-size:.75rem;color:#64748B">
                    <span style="width:10px;height:10px;border-radius:2px;background:#1D9E75;display:inline-block;flex-shrink:0"></span>
                    &gt; 2.9 Aman
                </div>
            </div>
        </div>
    </div>

    
    <div class="card" style="margin-bottom:1.5rem">
        <div style="font-size:.8125rem;font-weight:700;color:#64748B;text-transform:uppercase;letter-spacing:.05em;margin-bottom:1.25rem">
            Komponen Z-Score
        </div>
        <div style="display:grid;grid-template-columns:repeat(5,1fr);gap:1rem">
            <?php
                $components = [
                    'X1' => ['val'=>$zScoreComponents['x1'], 'weight'=>'× 0.717', 'desc'=>'Modal Kerja / Total Aset'],
                    'X2' => ['val'=>$zScoreComponents['x2'], 'weight'=>'× 0.847', 'desc'=>'Laba Ditahan / Total Aset'],
                    'X3' => ['val'=>$zScoreComponents['x3'], 'weight'=>'× 3.107', 'desc'=>'EBIT / Total Aset'],
                    'X4' => ['val'=>$zScoreComponents['x4'], 'weight'=>'× 0.420', 'desc'=>'Ekuitas / Total Utang'],
                    'X5' => ['val'=>$zScoreComponents['x5'], 'weight'=>'× 0.998', 'desc'=>'Pendapatan / Total Aset'],
                ];
            ?>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $components; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $name => $comp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <div style="background:#F8FAFF;border-radius:10px;padding:.875rem;text-align:center">
                <div style="font-size:.8rem;font-weight:700;color:#1A56DB;margin-bottom:4px"><?php echo e($name); ?></div>
                <div style="font-size:1.25rem;font-weight:800;color:#1E293B;font-family:monospace">
                    <?php echo e(number_format($comp['val'], 4)); ?>

                </div>
                <div style="font-size:.7rem;color:#94A3B8;margin-top:2px"><?php echo e($comp['weight']); ?></div>
                <div style="font-size:.7rem;color:#64748B;margin-top:4px;line-height:1.3"><?php echo e($comp['desc']); ?></div>
            </div>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
        </div>

        
        <div style="margin-top:1rem;padding:.875rem;background:#F1F5F9;border-radius:8px;font-size:.8125rem;color:#475569;text-align:center">
            Z' = 0.717(<?php echo e(number_format($zScoreComponents['x1'],4)); ?>) + 0.847(<?php echo e(number_format($zScoreComponents['x2'],4)); ?>) + 3.107(<?php echo e(number_format($zScoreComponents['x3'],4)); ?>) + 0.420(<?php echo e(number_format($zScoreComponents['x4'],4)); ?>) + 0.998(<?php echo e(number_format($zScoreComponents['x5'],4)); ?>)
            = <strong style="color:#1A56DB"><?php echo e(number_format($zScore, 4)); ?></strong>
        </div>
    </div>

    
    <div class="card" style="margin-bottom:1.5rem">
        <div style="font-size:.8125rem;font-weight:700;color:#64748B;text-transform:uppercase;letter-spacing:.05em;margin-bottom:1.25rem">
            Detail Laporan Keuangan
        </div>
        <?php
            $cur = $companyData['currency'];
            $fd  = $financialData;
            $fmt = fn($v) => $cur . ' ' . number_format($v, 0, ',', '.');
        ?>
        <div style="display:grid;grid-template-columns:1fr 1fr;gap:1.5rem">

            
            <div>
                <div style="font-size:.8125rem;font-weight:700;color:#1E293B;margin-bottom:.75rem;padding-bottom:.5rem;border-bottom:1px solid #E2E8F0">Neraca</div>
                <table style="width:100%;font-size:.875rem;border-collapse:collapse">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = [
                        ['label'=>'Aset Lancar',          'value'=>$fd['aset_lancar']??0,          'bold'=>false],
                        ['label'=>'Aset Tetap',            'value'=>$fd['aset_tetap']??0,            'bold'=>false],
                        ['label'=>'Total Aset',            'value'=>$fd['total_aset']??0,            'bold'=>true],
                        ['label'=>'Utang Lancar',          'value'=>$fd['utang_lancar']??0,          'bold'=>false],
                        ['label'=>'Utang Jangka Panjang',  'value'=>$fd['utang_jangka_panjang']??0,  'bold'=>false],
                        ['label'=>'Total Utang',           'value'=>$fd['total_utang']??0,           'bold'=>true],
                        ['label'=>'Nilai Buku Ekuitas',    'value'=>$fd['nilai_buku_ekuitas']??0,    'bold'=>true],
                    ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <tr style="<?php echo e($row['bold'] ? 'background:#F8FAFF;' : ''); ?>">
                        <td style="padding:7px 8px;color:<?php echo e($row['bold']?'#1E293B':'#475569'); ?>;font-weight:<?php echo e($row['bold']?'700':'400'); ?>"><?php echo e($row['label']); ?></td>
                        <td style="padding:7px 8px;text-align:right;font-weight:<?php echo e($row['bold']?'700':'400'); ?>;color:<?php echo e(($row['value']<0)?'#DC2626':($row['bold']?'#1A56DB':'#1E293B')); ?>">
                            <?php echo e($fmt($row['value'])); ?>

                        </td>
                    </tr>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </table>
            </div>

            
            <div>
                <div style="font-size:.8125rem;font-weight:700;color:#1E293B;margin-bottom:.75rem;padding-bottom:.5rem;border-bottom:1px solid #E2E8F0">Laba Rugi</div>
                <table style="width:100%;font-size:.875rem;border-collapse:collapse">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = [
                        ['label'=>'Pendapatan',                  'value'=>$fd['pendapatan']??0,         'bold'=>false],
                        ['label'=>'Biaya Operasional',           'value'=>$fd['biaya_operasional']??0,  'bold'=>false],
                        ['label'=>'Laba Sebelum Pajak',          'value'=>$fd['laba_sebelum_pajak']??0, 'bold'=>true],
                        ['label'=>'Pengambilan Pribadi (Prive)', 'value'=>$fd['prive']??0,              'bold'=>false],
                        ['label'=>'Laba Ditahan',                'value'=>$fd['laba_ditahan']??0,       'bold'=>true],
                    ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <tr style="<?php echo e($row['bold'] ? 'background:#F8FAFF;' : ''); ?>">
                        <td style="padding:7px 8px;color:<?php echo e($row['bold']?'#1E293B':'#475569'); ?>;font-weight:<?php echo e($row['bold']?'700':'400'); ?>"><?php echo e($row['label']); ?></td>
                        <td style="padding:7px 8px;text-align:right;font-weight:<?php echo e($row['bold']?'700':'400'); ?>;color:<?php echo e(($row['value']<0)?'#DC2626':($row['bold']?'#7C3AED':'#1E293B')); ?>">
                            <?php echo e($fmt($row['value'])); ?>

                        </td>
                    </tr>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </table>
            </div>
        </div>
    </div>

    
    <div class="card" style="margin-bottom:1.5rem;border-left:4px solid <?php echo e($zCategory==='safe'?'#10B981':($zCategory==='grey'?'#F59E0B':'#EF4444')); ?>">
        <div style="font-size:.8125rem;font-weight:700;color:#64748B;text-transform:uppercase;letter-spacing:.05em;margin-bottom:1rem">
            Interpretasi &amp; Rekomendasi
        </div>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($zCategory === 'safe'): ?>
        <p style="font-size:.9375rem;color:#1E293B;margin-bottom:1rem">
            Dengan Z-Score <strong><?php echo e(number_format($zScore, 4)); ?></strong>, perusahaan <strong><?php echo e($companyData['company_name']); ?></strong> berada di <strong style="color:#059669">Zona Aman</strong>. Kondisi keuangan perusahaan dinilai sehat dan tidak menunjukkan tanda-tanda kesulitan finansial dalam waktu dekat.
        </p>
        <ul style="list-style:none;padding:0;display:flex;flex-direction:column;gap:6px">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['Pertahankan rasio likuiditas yang baik','Terus optimalkan efisiensi operasional','Pertimbangkan ekspansi bisnis yang terencana','Jaga struktur modal yang sehat']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <li style="display:flex;align-items:flex-start;gap:8px;font-size:.875rem;color:#1E293B">
                <span style="width:18px;height:18px;border-radius:50%;background:#D1FAE5;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:1px">
                    <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="3"><polyline points="20 6 9 17 4 12"/></svg>
                </span>
                <?php echo e($item); ?>

            </li>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
        </ul>

        <?php elseif($zCategory === 'grey'): ?>
        <p style="font-size:.9375rem;color:#1E293B;margin-bottom:1rem">
            Dengan Z-Score <strong><?php echo e(number_format($zScore, 4)); ?></strong>, perusahaan <strong><?php echo e($companyData['company_name']); ?></strong> berada di <strong style="color:#D97706">Zona Waspada (Grey Zone)</strong>. Diperlukan perhatian khusus terhadap kondisi keuangan dan langkah perbaikan.
        </p>
        <ul style="list-style:none;padding:0;display:flex;flex-direction:column;gap:6px">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['Evaluasi dan efisiensi biaya operasional','Tingkatkan pendapatan melalui strategi pemasaran','Kelola utang dengan hati-hati dan hindari penambahan utang baru','Perkuat modal kerja perusahaan']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <li style="display:flex;align-items:flex-start;gap:8px;font-size:.875rem;color:#1E293B">
                <span style="width:18px;height:18px;border-radius:50%;background:#FEF3C7;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:1px">
                    <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#D97706" stroke-width="3"><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
                </span>
                <?php echo e($item); ?>

            </li>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
        </ul>

        <?php else: ?>
        <p style="font-size:.9375rem;color:#1E293B;margin-bottom:1rem">
            Dengan Z-Score <strong><?php echo e(number_format($zScore, 4)); ?></strong>, perusahaan <strong><?php echo e($companyData['company_name']); ?></strong> berada di <strong style="color:#DC2626">Zona Berbahaya (Financial Distress)</strong>. Diperlukan tindakan segera untuk mencegah kebangkrutan.
        </p>
        <ul style="list-style:none;padding:0;display:flex;flex-direction:column;gap:6px">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['Segera lakukan restrukturisasi keuangan','Konsultasikan dengan konsultan keuangan profesional','Kurangi utang dan negosiasikan ulang syarat pembayaran','Cari sumber pendanaan baru atau investor','Evaluasi aset yang dapat dijual untuk meningkatkan likuiditas']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
            <li style="display:flex;align-items:flex-start;gap:8px;font-size:.875rem;color:#1E293B">
                <span style="width:18px;height:18px;border-radius:50%;background:#FEE2E2;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:1px">
                    <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#DC2626" stroke-width="3"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
                </span>
                <?php echo e($item); ?>

            </li>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
        </ul>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>

    
    <div style="display:flex;gap:.75rem;justify-content:center;flex-wrap:wrap;padding-bottom:1rem">
        <a href="<?php echo e(route('history.index')); ?>"
           style="display:inline-flex;align-items:center;gap:7px;padding:10px 22px;border-radius:8px;border:1.5px solid #E2E8F0;background:#fff;font-size:.9rem;font-weight:600;color:#1E293B;text-decoration:none">
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
            Lihat Riwayat
        </a>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(isset($analysisResult)): ?>
        <a href="<?php echo e(route('report.preview', $analysisResult->id)); ?>"
           style="display:inline-flex;align-items:center;gap:7px;padding:10px 22px;border-radius:8px;border:1.5px solid #E2E8F0;background:#fff;font-size:.9rem;font-weight:600;color:#1E293B;text-decoration:none">
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>
            Preview Laporan
        </a>
        <a href="<?php echo e(route('report.download', $analysisResult->id)); ?>"
           style="display:inline-flex;align-items:center;gap:7px;padding:10px 22px;border-radius:8px;border:none;background:#1A56DB;font-size:.9rem;font-weight:600;color:#fff;text-decoration:none">
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
            Unduh PDF
        </a>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>

</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
/**
 * ═════════════════════════════════════════════════════
 *  Gauge Needle Animator — pure JS, no Chart.js needed
 *  Geometry mirrors PHP exactly: viewBox 440×260, CX=220, CY=220
 *  gauge-degree gd ∈ [0,180]: gd=0→left (score 0), gd=180→right (score 5)
 *  SVG coordinate: x = CX + r·cos(gd−180°),  y = CY + r·sin(gd−180°)
 * ═════════════════════════════════════════════════════
 */
document.addEventListener('DOMContentLoaded', function () {
    const Z_SCORE = <?php echo e($zScore); ?>;
    const MAX_S   = 5;
    const GCX = 220, GCY = 220;
    const NL = <?php echo e($R_IN); ?> - 8;   // tip radius (mirrors PHP $NL)
    const NT = 24;                 // tail length
    const NW = 5.5;                // half-width

    const poly = document.getElementById('needlePoly');
    if (!poly) return;

    function toXY(r, gd) {
        const rad = (gd - 180) * Math.PI / 180;
        return [GCX + r * Math.cos(rad), GCY + r * Math.sin(rad)];
    }

    function buildPoints(gd) {
        const [tx, ty]   = toXY(NL,  gd);
        const [bx, by]   = toXY(-NT, gd);   // negative r = opposite direction
        const rad = (gd - 180) * Math.PI / 180;
        const px  = -Math.sin(rad) * NW;
        const py  =  Math.cos(rad) * NW;
        return [
            tx.toFixed(2)  + ',' + ty.toFixed(2),
            (GCX+px).toFixed(2) + ',' + (GCY+py).toFixed(2),
            bx.toFixed(2)  + ',' + by.toFixed(2),
            (GCX-px).toFixed(2) + ',' + (GCY-py).toFixed(2),
        ].join(' ');
    }

    const targetGD = (Math.min(Math.max(Z_SCORE, 0), MAX_S) / MAX_S) * 180;
    const DUR = 1500;
    const t0  = performance.now();

    /* easeOutBack: slight overshoot then settle */
    function ease(t) {
        const c1 = 1.70158, c3 = c1 + 1;
        return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
    }

    poly.setAttribute('points', buildPoints(0)); // start at far-left

    (function animate(now) {
        const t = Math.min((now - t0) / DUR, 1);
        poly.setAttribute('points', buildPoints(ease(t) * targetGD));
        if (t < 1) requestAnimationFrame(animate);
    })(performance.now());
});
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/roky/projects/V1/resources/views/analysis/result.blade.php ENDPATH**/ ?>