<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Your Vehicle Report</title>
</head>

<body style="margin:0; padding:0; font-family: Arial, sans-serif; background-color:#ffffff;">
    <?php
    $vehicleMot = isset($leadFormData) && !empty($leadFormData->vehicle_mot_data_json) ? json_decode($leadFormData->vehicle_mot_data_json, true) : [];
    
    $country = $leadFormData->lead?->country ?? null;
    $roadTaxMot = isset($leadFormData) && !empty($leadFormData->mot_taxed_json) ? json_decode($leadFormData->mot_taxed_json, true) : [];
    
    $vehicleData = $vehicleMot['vehicleData'] ?? [];
    $vehicleInformation = $vehicleMot['vehicleInformation'] ?? [];
    $motMileageSummary = $vehicleMot['motMileageSummary'] ?? [];
    $motTestList = $vehicleMot['motTestList'] ?? [];
    $vehicleTaxCo2Emissions = $vehicleMot['vehicleTaxCo2Emissions'] ?? [];
    $general = $vehicleMot['general'] ?? [];
    $consumption = $vehicleMot['consumption'] ?? [];
    $performance = $vehicleMot['performance'] ?? [];
    $dimensions = $vehicleMot['dimensions'] ?? [];
    $safety = $vehicleMot['safety'] ?? [];
    $importExport = $vehicleMot['importExport'] ?? [];
    $classificationDetails = $vehicleMot['classificationDetails'] ?? [];
    $smmtDetails = $vehicleMot['smmtDetails'] ?? [];
    $colourChange = $vehicleMot['colourChange'] ?? [];
    $scrapDestruction = $vehicleMot['scrapDestruction'] ?? [];
    $V5CCertificates = $vehicleMot['V5CCertificates'] ?? [];
    
    ?>
    <!-- Main Wrapper Table -->
    <table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" style="background-color:#ffffff;">
        <tr>
            <td align="center">
                <table width="600" cellpadding="0" cellspacing="0" border="0" align="center"
                    style="width:800px; margin:0 auto;">

                    <!-- Title -->
                    <tr>
                        <td align="center" style="padding:20px 0;">
                            <h2 style="color:#555555; margin:0; font-size:20px;">YOUR VEHICLE DATA</h2>
                        </td>
                    </tr>


                    <!-- SECTION 1: Vehicle Data -->
                    <?php ?>
                    <tr>
                        <td>
                            <table cellpadding="10" cellspacing="10" border="0" style="width:800px;">
                                <tr>

                                    <td
                                        style="border:2px solid <?= !empty($vehicleInformation['Scrapped']) ? '#F44336;' : '#4CAF50;' ?> border-radius:6px; text-align:center; font-size:14px;">
                                        Scrapped<br><span
                                            style="color:<?= !empty($vehicleInformation['Scrapped']) ? '#F44336;' : '#4CAF50;' ?> font-size:18px; margin-top:6px; display: inline-block;"><?php if(!empty($vehicleInformation['Scrapped'])){ ?>
                                            <img style="width: 13px;display: inline;"
                                                src="{{ asset('assets/photo/close.png') }}" alt="">
                                            <?php }else{ ?>

                                            <img style="width: 13px;display: inline;"
                                                src="{{ asset('assets/photo/check.png') }}" alt="">
                                            <?php } ?> </span></td>
                                    <td
                                        style="border:2px solid <?= !empty($vehicleInformation['Exported']) ? '#F44336' : '#4CAF50' ?>; border-radius:6px; text-align:center; font-size:14px;">
                                        Exported
                                        <br>
                                        <span style="font-size:18px; margin-top:6px; display: inline-block;">
                                            <?php if (!empty($vehicleInformation['Exported'])): ?>
                                            <img style="width:13px;  " src="<?= asset('assets/photo/close.png') ?>"
                                                alt="">
                                            <?php else: ?>

                                            <img style="width:13px;display: inline;"
                                                src="<?= asset('assets/photo/check.png') ?>" alt="">
                                            <?php endif; ?>
                                        </span>
                                    </td>

                                    <td
                                        style="border:2px solid <?= !empty($vehicleInformation['Imported']) ? '#F44336;' : '#4CAF50;' ?> border-radius:6px; text-align:center; font-size:14px;">
                                        Imported<br> <span
                                            style="font-size:18px; margin-top:6px; display: inline-block;">
                                            <?php if (!empty($vehicleInformation['Imported'])): ?>
                                            <img style="width:13px;display: inline;"
                                                src="<?= asset('assets/photo/close.png') ?>" alt="Close">
                                            <?php else: ?>
                                            <img style="width:13px;display: inline;"
                                                src="<?= asset('assets/photo/check.png') ?>" alt="Check">
                                            <?php endif; ?>
                                        </span></td>


                                    <td
                                        style="border:2px solid <?= !empty($vehicleData['plateChange']) ? '#f49320;' : '#4caf50;' ?>  border-radius:6px; text-align:center; font-size:14px;">
                                        Plate<br><span
                                            style="color:<?= !empty($vehicleData['plateChange']) ? '#f49320;' : '#4caf50;' ?> font-size:18px; margin-top:6px; display: inline-block;"><?= !empty($vehicleData['plateChange']) ? '<span style="font-size:21px; font-weight:bold;margin-top:6px; display: inline-block;">!</span>' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?></span>
                                    </td>

                                    <td
                                        style="border:2px solid <?= $vehicleData['colourChange'] == true ? '#F44336;' : '#4CAF50;' ?> border-radius:6px; text-align:center; font-size:14px;">

                                        Colour<br><span
                                            style="color:<?= !empty($vehicleData['colourChange']) ? '#F44336;' : '#4CAF50;' ?> font-size:18px; margin-top:6px; display: inline-block;"><?= !empty($vehicleData['colourChange']) ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td
                                        style="border:2px solid <?= !empty($vehicleData['mileage']) ? '#F44336;' : '#4CAF50;' ?> border-radius:6px; text-align:center; font-size:14px;">
                                        Mileage<br><span
                                            style="color:<?= !empty($vehicleData['mileage']) ? '#F44336;' : '#4CAF50;' ?> font-size:18px; margin-top:6px; display: inline-block;"><?= !empty($vehicleData['mileage']) ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?></span>
                                    </td>
                                    <?php
                                    $borderColor = '#4CAF50'; // green by default
                                    $textColor = '#4CAF50';
                                    $displayVal = '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">'; // checkmark
                                    
                                    if ($vehicleData['taxi'] === true) {
                                        // Taxi is true → red
                                        $borderColor = '#F44336';
                                        $textColor = '#F44336';
                                        $displayVal = '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">'; // cross
                                    } elseif ($vehicleData['taxi'] === null) {
                                        // Taxi is null → blank
                                        $borderColor = '#4CAF50';
                                        $textColor = '#999'; // gray for blank
                                        $displayVal = '***';
                                    }
                                    ?>
                                    <td
                                        style="border:2px solid <?= $borderColor ?>; border-radius:6px; text-align:center; font-size:14px;">
                                        Taxi<br>
                                        <span
                                            style="color:<?= $textColor ?>; font-size:18px; margin-top:6px; display: inline-block;"><?= $displayVal ?></span>
                                    </td>

                                    <td
                                        style="border:2px solid <?= isset($motMileageSummary['recall']) && $motMileageSummary['recall'] === 'yes' ? '#F44336;' : '#4CAF50;' ?> border-radius:6px; text-align:center; font-size:14px;">
                                        Recall<br><span
                                            style="color:<?= isset($motMileageSummary['recall']) && $motMileageSummary['recall'] === 'yes' ? '#F44336;' : '#4CAF50;' ?> font-size:18px; margin-top:6px; display: inline-block;"><?= isset($motMileageSummary['recall']) && $motMileageSummary['recall'] === 'yes' ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?></span>
                                    </td>
                                    <?php
                                    $borderColor = '';
                                    if (!empty($vehicleData['totalKeepers']) && !empty($vehicleData['keeperChanged'])) {
                                        if (isset($vehicleData['keeperChanged']) && count($vehicleData['keeperChanged']) <= 3) {
                                            $borderColor = '#4CAF50'; // green
                                        } elseif (isset($vehicleData['keeperChanged']) && count($vehicleData['keeperChanged']) <= 6) {
                                            $borderColor = '#FF9800'; // orange
                                        } else {
                                            $borderColor = '#F44336'; // red
                                        }
                                    }
                                    ?>
                                    <td
                                        style="border:2px solid <?= $borderColor ?: '#ddd' ?>; border-radius:6px; text-align:center; font-size:14px;">
                                        Keepers<br>
                                        <span style="font-weight:bold;font-size:14px;">
                                            <?= htmlspecialchars((string) ($vehicleData['totalKeepers'] ?? '***')) ?>
                                        </span>
                                    </td>
                                    <td rowspan="2"
                                        style="border:2px solid <?= isset($vehicleData['keeperChanged']) && count($vehicleData['keeperChanged']) <= 3 ? '#4CAF50' : (isset($vehicleData['keeperChanged']) && count($vehicleData['keeperChanged']) <= 6 ? '#d9534f' : '#F44336') ?>;
                                        border-radius:6px; 
                                        text-align:center; 
                                        font-size:14px; 
                                        padding:8px; 
                                        vertical-align:top;">
                                        <b>Keepers</b><br>
                                        <?php if (!empty($vehicleData['keeperChanged']) && is_array($vehicleData['keeperChanged'])): ?>
                                        <?php foreach ($vehicleData['keeperChanged'] as $k): ?>
                                        <span style="color:#f49320">
                                            <?= !empty($k['date']) ? date('d-M-y', strtotime($k['date'])) : '' ?>
                                        </span><br>

                                        <?php endforeach; ?>
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>

                    <!-- SECTION 2: Untaxed + MOT -->
                    <?php //if(!empty($roadTaxMot)){
                    ?>
                    <tr>
                        <td>
                            <table cellpadding="10" cellspacing="10" border="0" style="width:800px;">
                                <tr>
                                    <!-- Untaxed -->
                                    <?php
                                    $isTaxed = isset($roadTaxMot['taxStatus']) ? strtolower($roadTaxMot['taxStatus']) === 'sorn' : null;
                                    $taxDueDate = $roadTaxMot['taxDueDate'] ?? null;
                                    $taxDueInDays = $roadTaxMot['taxDueInDays'] ?? null;
                                    ?>
                                    <td valign="top" width="50%"
                                        style="border:2px solid <?= $isTaxed ? '#F44336' : '#4CAF50' ?>; border-radius:6px; padding:10px; text-align:left;">
                                        <h3
                                            style="color:<?= $isTaxed ? '#F44336' : '#4CAF50' ?>; margin:0; font-size:16px;">
                                            <?= $isTaxed ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt=""> Untaxed' : '<img style="width:13px; display: inline;" src="' . asset('assets/photo/check.png') . '" alt=""> Taxed' ?>
                                        </h3>
                                       <p style="margin:0; font-size:12px; color:#777;">
    <?php if ($taxDueDate): ?>
        Tax due: <?= 
            htmlspecialchars((string) $taxDueDate) .
            (isset($taxDueInDays) ? ' – Since ' . htmlspecialchars((string) $taxDueInDays) . ' days' : '')
        ?>
    <?php else: ?>
        Tax due: N/A
    <?php endif; ?>
</p>
                                        <hr style="border:0; border-top:1px solid #ddd; margin:8px 0;">
                                        <table width="100%" cellpadding="4" cellspacing="0" border="0"
                                            style="font-size:13px;">
                                            <tr>
                                                <td><b>Vehicle Make</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['make'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Fuel Type</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['fuelType'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Cylinder Capacity</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['engineCapacity'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Vehicle Colour</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['colour'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Euro Stats</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['euroStatus'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Co2 Emissions</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['co2Emissions'] ?? ($vehicleMot['co2emission'] ?? '***'))) ?> g/km
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Real Driving Emissions</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['euroStatus'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Wheelplan</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['wheelplan'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Ulez Compliance</b></td>
                                                <td align="right"><a
                                                        href="https://tfl.gov.uk/modes/driving/check-your-vehicle/"
                                                        target="_blank" rel="noopener noreferrer">
                                                        Check TFL
                                                    </a></td>
                                            </tr>

                                        </table>
                                    </td>

                                    <!-- MOT -->
                                    <td valign="top" width="50%"
                                        style="border:2px solid #4CAF50; border-radius:6px; padding:10px; text-align:left;">
                                        <?php
                                        $motStatus = $roadTaxMot['motStatus'] ?? null; // e.g., Valid/Invalid
                                        $motExpiryDate = $roadTaxMot['motExpiryDate'] ?? null;
                                        $motExpiryInDays = $roadTaxMot['motExpiryInDays'] ?? null;
                                        ?>

                                        <h3
                                            style="color:<?= $motStatus && strtolower($motStatus) === 'valid' ? '#4CAF50' : '#F44336' ?>; margin:0; font-size:16px;">
                                            <?= $motStatus && strtolower($motStatus) === 'valid' ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt=""> MOT' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt=""> MOT' ?>
                                        </h3>
                                        <p style="margin:0; font-size:12px; color:#777;">
                                            <?php if ($motExpiryDate): ?>
                                            Expired on: <?=
                                            htmlspecialchars((string) $motExpiryDate)
                                            . (isset($motExpiryInDays) ? ' – Since ' . htmlspecialchars((string) $motExpiryInDays) . ' days' : '')
                                            ?>
                                            <?php else: ?>
                                            Expired on: N/A
                                            <?php endif; ?>
                                        </p>
                                        <hr style="border:0; border-top:1px solid #ddd; margin:8px 0;">
                                        <table width="100%" cellpadding="4" cellspacing="0" border="0"
                                            style="font-size:13px;">
                                            <tr>
                                                <td><b>Year Of Manufacture</b></td>
                                                <td align="right">
                                                    <?= !empty($roadTaxMot['yearOfManufacture']) ? $roadTaxMot['yearOfManufacture'] : '' ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Date Of First Registration</b></td>
                                                <td align="right">
                                                    <?= !empty($roadTaxMot['monthOfFirstRegistration']) ? date('M-y', strtotime($roadTaxMot['monthOfFirstRegistration'])) : '' ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Date Of Last V5C(logbook) Issued</b></td>
                                                <td align="right">
                                                    <?= !empty($roadTaxMot['dateOfLastV5CIssued']) ? date('d-M-y', strtotime($roadTaxMot['dateOfLastV5CIssued'])) : '' ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Export Marker</b></td>
                                                <td align="right">
                                                    <?= !empty($roadTaxMot['markedForExport']) ? htmlspecialchars((string) ($roadTaxMot['markedForExport'] ? 'Yes' : 'No')) : '***' ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Vehicle Type Approval</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['typeApproval'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Revenue Weight</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['revenueWeight'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>Vehicle Status</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['taxStatus'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td><b>MOT Status</b></td>
                                                <td align="right">
                                                    <?= htmlspecialchars((string) ($roadTaxMot['motStatus'] ?? ($vehicleMot['motStatus'] ?? '***'))) ?>
                                                </td>
                                            </tr>

                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <?php //}
                    ?>

                    <tr>
                        <td>
                            <table cellpadding="10" cellspacing="10" border="0"
                                style="font-size: 13px;
                                font-family: Arial, sans-serif;
                                color: #333;
                                background: #ffffff;width:800px;">
                                <tr>
                                    <td colspan="2" align="center">
                                        <h3 style="color:#555555; margin:0; font-size:18px;">Mot & Mileage Summary</h3>
                                    </td>
                                </tr>
                                <tr>
                                  <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                      <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                          style="border-collapse:collapse;">
                                          <tr>

                                              <td align="left"
                                                  style="font-family:Arial, sans-serif; color:#333; ">
                                                  <b>Total Test:</b>
                                              </td>
                                              <td align="right"
                                                  style="font-family:Arial, sans-serif; color:#333; font-size:14px;">
                                                  <?= htmlspecialchars((string) ($motMileageSummary['totalTests'] ?? '***')) ?>
                                              </td>
                                          </tr>
                                      </table>
                                  </td>
                                  <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                      <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                          style="border-collapse:collapse;">
                                          <tr>
                                              <!-- Left cell -->
                                              <td align="left"
                                                  style="font-family:Arial, sans-serif; color:#333; ">
                                                  <?php
                                                  if (isset($motMileageSummary['passRatePercentage']) && $motMileageSummary['passRatePercentage'] >= 80) {
                                                      echo '<span style="font-size:21px; color:#4CAF50;"><img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt=""></span>';
                                                  } elseif (isset($motMileageSummary['passRatePercentage']) && $motMileageSummary['passRatePercentage'] >= 70) {
                                                      echo '<span style="font-size:21px; color:#f49320;">!</span>';
                                                  } else {
                                                      echo '<span style="font-size:21px; color:#F44336;"><img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt=""></span>';
                                                  }
                                                  ?>
                                                  <b>Pass Rate:</b>
                                              </td>

                                              <!-- Right cell -->
                                              <td align="right"
                                                  style="font-family:Arial, sans-serif; color:#333; font-size:14px;">
                                                  <?= isset($motMileageSummary['passRatePercentage']) ? htmlspecialchars((string) $motMileageSummary['passRatePercentage']) . '%' : '***' ?>
                                              </td>
                                          </tr>
                                      </table>
                                  </td>

                                </tr>
                                <tr>
                                  <!-- Test Passed -->
                                  <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                      <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                          style="border-collapse:collapse; width:100%;">
                                          <tr>
                                              <!-- Label -->
                                              <td align="left"
                                                  style="font-family:Arial, sans-serif; color:#333; ">
                                                  <span style="color:#4CAF50; font-size:18px;"><img
                                                          style="width:13px;display: inline;"
                                                          src="{{ asset('assets/photo/check.png') }}"
                                                          alt=""></span>
                                                  <b>Test Passed:</b>
                                              </td>
                                              <!-- Value -->
                                              <td align="right"
                                                  style="font-family:Arial, sans-serif; color:#333; ">
                                                  <?= htmlspecialchars((string) ($motMileageSummary['totalPassed'] ?? '***')) ?>
                                              </td>
                                          </tr>
                                      </table>
                                  </td>

                                  <!-- Pass Rate With Advisory -->
                                  <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                      <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                          style="border-collapse:collapse; width:100%;">
                                          <tr>
                                              <!-- Label -->
                                              <td align="left"
                                                  style="font-family:Arial, sans-serif; color:#333; ">
                                                  <span
                                                      style="font-size:21px; font-weight:bold; color:#f49320;">!</span>
                                                  <b>Pass Rate With Advisory:</b>
                                              </td>
                                              <!-- Value -->
                                              <td align="right"
                                                  style="font-family:Arial, sans-serif; color:#333; ">
                                                  <?= isset($motMileageSummary['passRateWithAdvisory']) ? htmlspecialchars((string) $motMileageSummary['passRateWithAdvisory']) . '%' : '***' ?>
                                              </td>
                                          </tr>
                                      </table>
                                  </td>
                                </tr>

                                <tr>
                                    <!-- Passed With Advisory -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left" style="font-family:Arial, sans-serif; color:#333;">
                                                    <span
                                                        style="font-size:21px; font-weight:bold; color:#f49320;">!</span>
                                                    <b>Passed With Advisory:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right" style="font-family:Arial, sans-serif; color:#333;">
                                                    <?= htmlspecialchars((string) ($motMileageSummary['passedWithAdvisory'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>

                                    <!-- Pass Rate Without Advisory -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left" style="font-family:Arial, sans-serif; color:#333;">
                                                    <span style="color:#4CAF50; font-size:18px;"><img
                                                            style="width:13px;display: inline;"
                                                            src="{{ asset('assets/photo/check.png') }}"
                                                            alt=""></span>
                                                    <b>Pass Rate Without Advisory:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right" style="font-family:Arial, sans-serif; color:#333;">
                                                    <?= isset($motMileageSummary['passRateWithoutAdvisory']) ? htmlspecialchars((string) $motMileageSummary['passRateWithoutAdvisory']) . '%' : '***' ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                                <tr>
                                    <!-- Total Items Advised -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left" style="font-family:Arial, sans-serif; color:#333;">
                                                    <span
                                                        style="font-size:21px; font-weight:bold; color:#f49320;">!</span>
                                                    <b>Total Items Advised:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right" style="font-family:Arial, sans-serif; color:#333;">
                                                    <?= htmlspecialchars((string) ($motMileageSummary['totalItemsAdvised'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>

                                    <!-- Mileage Issues -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left" style="font-family:Arial, sans-serif; color:#333;">
                                                    <span
                                                        style="font-size:18px; color:<?= !empty($motMileageSummary['mileageIssue']) ? '#F44336' : '#4CAF50' ?>;">
                                                        <?= !empty($motMileageSummary['mileageIssue']) ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?>
                                                    </span>
                                                    <b>Mileage Issues:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right" style="font-family:Arial, sans-serif; color:#333;">
                                                    <?= !empty($motMileageSummary['mileageIssue']) ? 'Yes' : 'No' ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                                <tr>
                                    <!-- Advisory Average/Per MOT -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left" style="font-family:Arial, sans-serif; color:#333;">
                                                    <span
                                                        style="font-size:21px; font-weight:bold; color:#f49320;">!</span>
                                                    <b>Advisory Average/Per MOT:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right" style="font-family:Arial, sans-serif; color:#333;">
                                                    <?= htmlspecialchars((string) ($motMileageSummary['advisoryAverage'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>

                                    <!-- Last MOT Mileage -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left" style="font-family:Arial, sans-serif; color:#333;">
                                                    <b>Last MOT Mileage:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right" style="font-family:Arial, sans-serif; color:#333;">
                                                    <?= isset($motMileageSummary['lastMileage']) ? htmlspecialchars((string) $motMileageSummary['lastMileage']) . ' ' . htmlspecialchars((string) ($motMileageSummary['lastMileageUnit'] ?? '')) : '***' ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                                <tr>
                                    <!-- Test Failed -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left"
                                                    style="font-family:Arial, sans-serif; color:#333; ">
                                                    <span style="color:#F44336; font-size:18px;"><img
                                                            style="width:13px;display: inline;"
                                                            src="{{ asset('assets/photo/close.png') }}"
                                                            alt=""></span>
                                                    <b>Test Failed:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right"
                                                    style="font-family:Arial, sans-serif; color:#333; ">
                                                    <?= htmlspecialchars((string) ($motMileageSummary['totalFailed'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>

                                    <!-- Est Current Mileage -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left"
                                                    style="font-family:Arial, sans-serif; color:#333; ">
                                                    <b>Est Current Mileage:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right"
                                                    style="font-family:Arial, sans-serif; color:#333; ">
                                                    <?= isset($motMileageSummary['currentMileage']) ? htmlspecialchars((string) $motMileageSummary['currentMileage']) . ' ' . htmlspecialchars((string) ($motMileageSummary['lastMileageUnit'] ?? '')) : '***' ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                                <tr>
                                    <!-- Total Items Failed -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <span style="color:#F44336; font-size:18px;"><img
                                                            style="width:13px;display: inline;"
                                                            src="{{ asset('assets/photo/close.png') }}"
                                                            alt=""></span>
                                                    <b>Total Items Failed:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <?= htmlspecialchars((string) ($motMileageSummary['totalItemsFailed'] ?? '***')) ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>

                                    <!-- Average Mileage -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label -->
                                                <td align="left"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <b>Average Mileage:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <?= isset($motMileageSummary['avgMileagePerYear']) ? htmlspecialchars((string) $motMileageSummary['avgMileagePerYear']) . ' Miles/Year' : '***' ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                                <tr>
                                    <!-- Taxi / Rent a Car Use -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label with Icon -->
                                                <td align="left"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <?php if (!empty($motMileageSummary['taxi'])): ?>
                                                    <span style="color:#F44336; font-size:18px;"><img
                                                            style="width:13px;display: inline;"
                                                            src="{{ asset('assets/photo/close.png') }}"
                                                            alt=""></span>
                                                    <?php else: ?>
                                                    <span style="color:#4CAF50; font-size:18px;"><img
                                                            style="width:13px;display: inline;"
                                                            src="{{ asset('assets/photo/check.png') }}"
                                                            alt=""></span>
                                                    <?php endif; ?>
                                                    <b>Taxi/Rent a Car Use:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <?= !empty($motMileageSummary['taxi']) ? 'Might be' : 'Might not' ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>

                                    <!-- Mileage Status -->
                                    <td style="border:1px solid #ddd; border-radius:6px; padding:6px;">
                                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                                            style="border-collapse:collapse; width:100%;">
                                            <tr>
                                                <!-- Label with Icon -->
                                                <td align="left"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <?php
                                                    $mileage = $motMileageSummary['avgMileagePerYear'] ?? null;
                                                    if ($mileage === null) {
                                                        $mileageStatusValue = '***';
                                                        $mileageStatusIcon = '<span style="color:#f49320; font-weight:bold;">!</span>';
                                                    } elseif ($mileage < 6000) {
                                                        $mileageStatusValue = 'Below Average';
                                                        $mileageStatusIcon = '<span style="color:#4CAF50; font-size:18px;"><img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt=""></span>';
                                                    } elseif ($mileage >= 6000 && $mileage <= 8000) {
                                                        $mileageStatusValue = 'Average';
                                                        $mileageStatusIcon = '<span style="font-size:21px; font-weight:bold; color:#f49320;">!</span>';
                                                    } else {
                                                        $mileageStatusValue = 'Above Average';
                                                        $mileageStatusIcon = '<span style="color:#F44336; font-size:18px;"><img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt=""></span>';
                                                    }
                                                    ?>
                                                    <span
                                                        style="font-size:18px; color:#f49320;"><?= $mileageStatusIcon ?></span>
                                                    <b>Mileage Status:</b>
                                                </td>
                                                <!-- Value -->
                                                <td align="right"
                                                    style="font-family:Arial, sans-serif;  color:#333;">
                                                    <?= htmlspecialchars($mileageStatusValue) ?>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                            </table>
                        </td>
                    </tr>
 
                    <!-- SECTION 5: MOT Test List -->
                    <tr>
                        <td align="center"
                            style="padding-top:20px; padding-bottom:15px; font-size:18px; color:#555555; font-weight:bold;">
                            MOT Test List
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table cellpadding="6" cellspacing="0" border="1"
                                style="border-collapse:collapse; font-size:13px; border-color:#ccc;text-align:center;width:800px; ">
                                <tr style="background:#777; color:#ffffff; font-weight:bold; text-align:center;">
                                    <td>Date</td>
                                    <td>Result</td>
                                    <td>Mileage</td>
                                    <td>Difference</td>
                                    <td>Days</td>
                                    <td>Reason</td>
                                </tr>
                                <?php
                                    // Combine MOT tests and keeper changes into one chronological list
                                    $combinedEvents = [];
                                    $hasKm = false;
$hasMi = false;
$hasMileageRev = false;
$hasTaxi = false;

if (!empty($vehicleMot['mileageHistory'])) {
    foreach ($vehicleMot['mileageHistory'] as $mileage) {
        $unit = strtolower($mileage['unit'] ?? '');
        if ($unit === 'km') $hasKm = true;
        if ($unit === 'mi') $hasMi = true;
        if (!empty($mileage['mileage_reverse'])) $hasMileageRev = true;
        if (!empty($mileage['taxi'])) $hasTaxi = true;
    }
}

$warnKmMixed = $hasKm && $hasMi;
                                    // Add MOT tests
                                    if (!empty($vehicleMot['motTestList']['motList'])) {
                                        foreach ($vehicleMot['motTestList']['motList'] as $test) {
                                            $combinedEvents[] = [
                                                'type' => 'mot',
                                                'data' => $test,
                                                'date' => $test['date'] ?? ''
                                            ];
                                        }
                                    }
                                    
                                    // Add keeper changes
                                    if (!empty($vehicleMot['motTestList']['keepersChange']['data'])) {
                                        foreach ($vehicleMot['motTestList']['keepersChange']['data'] as $keeper) {
                                            $combinedEvents[] = [
                                                'type' => 'keeper',
                                                'data' => $keeper,
                                                'date' => $keeper['date'] ?? ''
                                            ];
                                        }
                                    }
                                    
                                    // Add plate changes
                                    if (!empty($vehicleMot['motTestList']['plateChange'])) {
                                        foreach ($vehicleMot['motTestList']['plateChange'] as $plate) {
                                            $combinedEvents[] = [
                                                'type' => 'plate',
                                                'data' => $plate,
                                                'date' => $plate['date'] ?? ''
                                            ];
                                        }
                                    }
                                    
                                    // Sort by date (newest first)
                                    usort($combinedEvents, function($a, $b) {
                                        $dateA = strtotime($a['date']);
                                        $dateB = strtotime($b['date']);
                                        if ($dateA === false || $dateB === false) {
                                            return 0;
                                        }
                                        return $dateB - $dateA; // Descending order
                                    });
                                    
                                    
                                    foreach ($combinedEvents as $event):
                                        if ($event['type'] === 'mot'):
                                            $test = $event['data'];
                                ?>
                                <tr
                                    style="background:<?= isset($test['result']) && strtoupper($test['result']) === 'PASSED' ? '#f9fff9;' : '#fff5f5' ?>">
                                    <td><?= !empty($k['date']) ? date('d-M-y', strtotime($test['date'])) : '' ?></td>
                                    <td
                                        style="font-weight:bold; color:<?= isset($test['result']) && strtoupper($test['result']) === 'PASSED' ? '#4CAF50' : '#f44336' ?>;">
                                        <?= isset($test['result']) && strtoupper($test['result']) === 'PASSED' ? 'PASS' : 'FAIL' ?>
                                    </td>
                                    <td><?= htmlspecialchars((string) ($test['mileage'] ?? '')) ?>
                                        <?= htmlspecialchars((string) ($test['unit'] ?? '')) ?></td>
                                    <td><?= htmlspecialchars((string) ($test['difference'] ?? '')) ?></td>
                                    <td><?= htmlspecialchars((string) ($test['days'] ?? '')) ?></td>
                                    <td>Fail.(<?= count($test['failure'] ?? []) ?>)&nbsp;&nbsp;
                                        Adv.(<?= count($test['advisory'] ?? []) ?>)</td>
                                </tr>

                                <?php elseif ($event['type'] === 'keeper'): 
                                            $keeper = $event['data'];
                                ?>
                                <tr style="background:#fff3e0;">

                                    <td><?= !empty($keeper['date']) ? date('d-M-y', strtotime($keeper['date'])) : '' ?>
                                    </td>
                                    <td colspan="5" style="font-weight:bold; color:#FF9800;">KEEPER
                                        <?= htmlspecialchars((string) ($keeper['count'] ?? '')) ?></td>
                                </tr>
                                <?php elseif ($event['type'] === 'plate'): 
                                            $plate = $event['data'];
                                ?>
                                <tr style="background:#fff3e0;">
                                    <td><?= !empty($plate['date']) ? date('d-M-y', strtotime($plate['date'])) : '' ?>
                                    </td>
                                    <td style="font-weight:bold; color:#FF9800;">PLATE
                                        <?= htmlspecialchars((string) ($plate['plate_number'] ?? '')) ?></td>
                                    <td colspan="4">
                                        <div style="display:flex;align-items:center;gap: -2px;">
                                            <!-- Left Plate -->
                                            <div
                                                style="display:flex;align-items:center;border: 1px solid #000;border-radius: 4px;overflow:hidden;font-family:Arial, sans-serif;font-weight:bold;">

                                                <div style="padding: 3px 6px;font-size: 10px;">
                                                    <?= $plate['previous'] ?></div>
                                            </div>

                                            <!-- Arrow -->
                                            <span style="font-size: 10px;color:#003399;">→</span>

                                            <!-- Right Plate -->
                                            <div
                                                style="display:flex;align-items:center;border: 1px solid #000;border-radius: 4px;overflow:hidden;font-family:Arial, sans-serif;font-weight:bold;">

                                                <div style="padding: 3px 6px;font-size: 10px;"><?= $plate['current'] ?>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <?php endif; ?>
                                <?php endforeach; ?>
                            </table>
                        </td>
                    </tr>






                    <!-- SECTION 5: Mileage History -->
                    <tr>
                        <td align="center"
                            style="padding-top:20px; font-size:18px; color:#555555; font-weight:bold;padding-bottom: 15px;">
                            Mileage History
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <table cellpadding="6" cellspacing="0" border="1"
                                style="border-collapse:collapse; font-size:13px; border-color:#ccc;text-align: center; width:800px;">
                                <tr style="background:#777; color:#ffffff; font-weight:bold; text-align:center;">
                                    <td>S No.</td>
                                    <td>Date</td>
                                    <td>Mileage</td>
                                    <td>Difference</td>
                                    <td>Days</td>
                                </tr>
                                <?php
                        // Combine mileage history with keeper changes
                       $combinedMileageEvents = [];

// Add mileage history
if (!empty($vehicleMot['mileageHistory'])) {
    $sno = 1;
    foreach ($vehicleMot['mileageHistory'] as $mileage) {
        $date = !empty($mileage['date']) ? date('Y-m-d', strtotime($mileage['date'])) : '';
        $combinedMileageEvents[$date]['mileage'][] = [
            'data' => $mileage,
            'sno'  => $sno++,
            'taxi' => $mileage['taxi'] ?? false
        ];
    }
}

// Add keeper changes
if (!empty($vehicleMot['motTestList']['keepersChange']['data'])) {
    foreach ($vehicleMot['motTestList']['keepersChange']['data'] as $keeper) {
        $date = !empty($keeper['date']) ? date('Y-m-d', strtotime($keeper['date'])) : '';
        $combinedMileageEvents[$date]['keeper'][] = $keeper;
    }
}

// Add plate changes
if (!empty($vehicleMot['motTestList']['plateChange'])) {
    foreach ($vehicleMot['motTestList']['plateChange'] as $plate) {
        $date = !empty($plate['date']) ? date('Y-m-d', strtotime($plate['date'])) : '';
        $combinedMileageEvents[$date]['plate'][] = $plate;
    }
}

// Sort by date DESC
uksort($combinedMileageEvents, function($a, $b) {
    return strtotime($b) - strtotime($a);
});


                   
                        
                        // Sort by date (newest first)
                        // usort($combinedMileageEvents, function($a, $b) {
                        //     $dateA = strtotime($a['date']);
                        //     $dateB = strtotime($b['date']);
                        //     if ($dateA === false || $dateB === false) {
                        //         return 0;
                        //     }
                        //     return $dateB - $dateA; // Descending order
                        // });
                        
                      $sno = count($combinedMileageEvents);
foreach ($combinedMileageEvents as $date => $events) {
    $labels = [];

    if (!empty($events['keeper'])) {
        foreach ($events['keeper'] as $k) {
            $labels[] = 'Keeper';
            // $labels[] = 'Keeper ' . htmlspecialchars((string)($k['count'] ?? ''));
        }
    }

    if (!empty($events['plate'])) {
        foreach ($events['plate'] as $p) {
            $labels[] = 'Plate ' . htmlspecialchars((string)($p['plate_number'] ?? ''));
        }
    }

    // If we have a mileage entry for this date, render a single mileage row and append labels
    if (!empty($events['mileage'])) {
        $mileage = $events['mileage'][0]['data'];
        $isTaxi = !empty($events['mileage'][0]['taxi']);
        $isKm   = strtolower($mileage['unit'] ?? '') === 'km';
        $isRev  = !empty($mileage['mileage_reverse']);

        // Default row style
        $rowStyle = "background:#f9fff9;";

        // Apply conditions
        if ($isTaxi) {
            $rowStyle = "background:#e6f2ff;"; // Taxi = blue
        }
        if ($isRev) {
            $rowStyle = "background:#ffebee; color:#c62828; font-weight:bold;"; // Red for reverse
        }
        if ($isKm) {
            $rowStyle = "background:#fff8e1; color:#ef6c00; font-weight:bold;"; // Orange for KM
        }

        ?>
                                <tr style="<?= $rowStyle ?>">
                                    <td><?= $sno-- ?></td>
                                    <td><?= !empty($mileage['date']) ? date('d-M-y', strtotime($mileage['date'])) : '' ?>
                                    </td>
                                    <td>
                                        <?= htmlspecialchars((string) ($mileage['mileage'] ?? '')) ?>
                                        <?= htmlspecialchars((string) ($mileage['unit'] ?? '')) ?>
                                        <?php if (!empty($labels)): ?>
                                        <div style="margin-top:2px;color:#FF9800;font-weight:bold;">
                                            <?= implode(' • ', $labels) ?></div>
                                        <?php endif; ?>
                                    </td>
                                    <?php if(!empty($events['plate'])){ ?>
                                    <td colspan="4">
                                        <div style="display:flex;align-items:center;gap: -2px;">
                                            <!-- Left Plate -->
                                            <div
                                                style="display:flex;align-items:center;border: 1px solid #000;border-radius: 4px;overflow:hidden;font-family:Arial, sans-serif;font-weight:bold;">

                                                <div style="padding: 3px 6px;font-size: 10px;">
                                                    <?= $plate['previous'] ?></div>
                                            </div>

                                            <!-- Arrow -->
                                            <span style="font-size: 10px;color:#003399;">→</span>

                                            <!-- Right Plate -->
                                            <div
                                                style="display:flex;align-items:center;border: 1px solid #000;border-radius: 4px;overflow:hidden;font-family:Arial, sans-serif;font-weight:bold;">

                                                <div style="padding: 3px 6px;font-size: 10px;"><?= $plate['current'] ?>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <?php }else{ ?>
                                    <td><?= htmlspecialchars((string) ($mileage['difference'] ?? '')) ?></td>
                                    <td><?= htmlspecialchars((string) ($mileage['days'] ?? '')) ?></td>
                                    <?php } ?>
                                </tr>
                                <?php
    } else {
        // No mileage for this date
        ?>
                                <tr style="background:#fff3e0;">
                                    <td><?= $sno-- ?></td>
                                    <td><?= !empty($date) ? date('d-M-y', strtotime($date)) : '' ?></td>
                                    <td colspan="3" style="font-weight:bold; color:#FF9800;">
                                        <?= !empty($labels) ? implode(' • ', $labels) : '' ?>
                                    </td>
                                </tr>
                                <?php
    }
}
?>



                            </table>


                        </td>
                    <tr>
                        <td style="padding: 14px 0px 0px 0px;">
                            <!-- Legend -->
                            <table cellpadding="6" cellspacing="0" border="0"
                                style="font-size:13px;width:800px;">
                                <tr>
                                    <td>
                                        <div
                                            style="display:flex; align-items:center; margin-bottom:6px;justify-content: center;">
                                            <div
                                                style="width:20px; height:20px; background:#fff8e1; border:1px solid #ef6c00; margin-right:8px;">
                                            </div>
                                            Km / Mileage
                                        </div>
                                    </td>
                                    <td>
                                        <div
                                            style="display:flex; align-items:center; margin-bottom:6px;justify-content: center;">
                                            <div
                                                style="width:20px; height:20px; background:#ffebee; border:1px solid #c62828; margin-right:8px;">
                                            </div>
                                            Mileage Reverse
                                        </div>
                                    </td>
                                    <td>
                                        <div
                                            style="display:flex; align-items:center; margin-bottom:6px;justify-content: center;">
                                            <div
                                                style="width:20px; height:20px; background:#e6f2ff; border:1px solid #1565c0; margin-right:8px;">
                                            </div>
                                            Taxi MOT gaps
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>

                    <?php if ($warnKmMixed || $hasMileageRev || $hasTaxi): ?>
                    <tr>
                        <td>
                            <table cellpadding="10" cellspacing="0" border="0"
                                style="font-size:13px;width:800px;">
                                <tr>
                                    <?php if ($warnKmMixed): ?>
                                    <td style="background:#fff8e1; border:1px solid #ef6c00; text-align:center;">
                                        <h5 style="margin:0; color:#ef6c00;">Miles / KMs Warning</h5>
                                        <p style="margin:5px 0;">A mixture of Miles and KMs reading has been detected
                                            in the MOT history.</p>
                                    </td>
                                    <?php endif; ?>

                                    <?php if ($hasMileageRev): ?>
                                    <td style="background:#ffebee; border:1px solid #c62828; text-align:center;">
                                        <h5 style="margin:0; color:#c62828;">Mileage Reverse</h5>
                                        <p style="margin:5px 0;">A discrepancy in mileage has been detected in the MOT
                                            history.</p>
                                    </td>
                                    <?php endif; ?>

                                    <?php if ($hasTaxi): ?>
                                    <td style="background:#e6f2ff; border:1px solid #1565c0; text-align:center;">
                                        <h5 style="margin:0; color:#1565c0;">Taxi MOT gaps</h5>
                                        <p style="margin:5px 0;">This vehicle might have been used as Taxi or
                                            Commercial purposes, as it has three consecutive 6 months MOTs.</p>
                                    </td>
                                    <?php endif; ?>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <?php endif; ?>
        </tr>



        <!-- Legend -->
        {{-- <tr>
                        <td align="center" style="padding:15px;">
                            <table cellpadding="5" cellspacing="0" border="0"
                                style="font-size:12px; color:#555;">
                                <tr>
                                    <td style="padding-right:15px;"><span
                                            style="background:#fffbe6; border:1px solid #FF9800; padding:2px 6px; border-radius:3px;">&nbsp;</span>
                                        Km/Mileage</td>
                                    <td style="padding-right:15px;"><span
                                            style="background:#ffe6e6; border:1px solid #F44336; padding:2px 6px; border-radius:3px;">&nbsp;</span>
                                        Mileage Reverse</td>
                                    <td><span
                                            style="background:#e6f3ff; border:1px solid #2196F3; padding:2px 6px; border-radius:3px;">&nbsp;</span>
                                        Taxi MOT Gaps</td>
                                </tr>
                            </table>
                        </td>
                    </tr> --}}

        <!-- Taxi MOT Gaps Note -->
        {{-- <tr>
                        <td align="center" style="padding:10px;">
                            <table cellpadding="10" cellspacing="0" border="0" width="100%"
                                style="background:#e6f3ff; border:1px solid #2196F3; border-radius:6px; font-size:13px; color:#333;">
                                <tr>
                                    <td align="center" style="font-weight:bold;">Taxi MOT Gaps</td>
                                </tr>
                                <tr>
                                    <td align="center">This vehicle might have been used as Taxi or Commercial
                                        purposes, as it has three consecutive 6 months MOTs.</td>
                                </tr>
                            </table>
                        </td>
                    </tr> --}}

        <!-- Vehicle Information -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                Vehicle Information
                            </td>
                        </tr>

                        <!-- Rows -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Vehicle Registration Mark</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Vrm'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Make &amp; Model</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Make'] ?? '***')) ?>
                                <?= htmlspecialchars((string) ($vehicleInformation['Model'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Make</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Make'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Model</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Model'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Engine Capacity</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['EngineCapacity'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Year of Manufacture</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['YearOfManufacture'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Fuel Type</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['FuelType'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Date First Registered</td>
                            <td style="padding:8px;">
                                <?= !empty($vehicleInformation['DateFirstRegistered']) ? date('d-M-y', strtotime($vehicleInformation['DateFirstRegistered'])) : '***' ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Door Plan</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['DoorPlanLiteral'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Date of 1st Registration in UK</td>
                            <td style="padding:8px;">
                                <?= !empty($vehicleInformation['DateFirstRegisteredUk']) ? date('d-M-y', strtotime($vehicleInformation['DateFirstRegisteredUk'])) : '***' ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Colour</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Colour'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Year-Month 1st Registered</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['YearMonthFirstRegistered'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">CO2 Emissions</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Co2Emissions'] ?? ($vehicleMot['co2emission'] ?? '***'))) ?> g/km
                            </td>
                            <td style="padding:8px; font-weight:bold;">Transmission</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Transmission'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Gear Count</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['GearCount'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Transmission Type</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['TransmissionType'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Engine Number</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['EngineNumber'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Transmission Code</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['TransmissionCode'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Gross Weight</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['GrossWeight'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Door Plan Code</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['DoorPlan'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Maximum Permissable Mass</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['MaxPermissibleMass'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">MVRIS Model Code</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['MVRISModelCode'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Seating Capacity</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['SeatingCapacity'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">MVRIS Make Code</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['MVRISMakeCode'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Wheel Plan</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['WheelPlan'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Used Before First Registration</td>
                            <td style="padding:8px;">
                                <?= !empty($vehicleInformation['UsedBeforeFirstRegistration']) ? 'Yes' : 'No' ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Vehicle Class</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['VehicleClass'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Vin Confirmation Flag</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['VinConfirmationFlag'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Serial Number</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['Vin'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Last 5</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['VinLast5'] ?? '***')) ?></td>
                        </tr>

                        <?php if (!empty($leadFormData->system_detail['version'])) { ?>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Country</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string) ($country ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">System</td>
                            <td style="padding:8px;"><?php
                            if (!empty($leadFormData->system_detail['version'])) {
                                echo ($leadFormData->system_detail['browser'] ?? '') . ' ' . ($leadFormData->system_detail['version'] ?? '') . ', ' . ($leadFormData->system_detail['platform'] ?? '') . ', ' . ($leadFormData->system_detail['device'] ?? '');
                            } else {
                                echo '***';
                            }
                            ?></td>
                        </tr>
                        <?php } ?>

                        <tr>
                            <td style="padding:8px; font-weight:bold;">Date Of Last Update</td>
                            <td style="padding:8px;">
                                <?= !empty($vehicleInformation['DateOfLastUpdate']) ? date('d-M-y h:i:s', strtotime($vehicleInformation['DateOfLastUpdate'])) : '' ?>
                            </td>
                            {{-- Add IP In Case Of Admin --}}
                            <?php if (!empty($leadFormData->system_detail['leadip'])) { ?>
                            <td style="padding:8px; font-weight:bold;">IP</td>
                            <td style="padding:8px;">
                                <?= !empty($leadFormData->system_detail['leadip']) ? $leadFormData->system_detail['leadip'] : '-' ?>
                            </td>
                            <?php } ?>
                        </tr>
                    </table>
            </td>
        </tr>

        <!-- General Information -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                General Information
                            </td>
                        </tr>

                        <!-- Rows -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Make</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['Make'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Euro Status</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['EuroStatus'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Aspiration</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['Aspiration'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Fuel System</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['FuelSystem'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Number Of Cylinders</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['NumberOfCylinders'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Fuel Delivery</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['FuelDelivery'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Valves Per Cylinder</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['ValvesPerCylinder'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Fuel Catalyst</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['FuelCatalyst'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Cylinder Arrangement</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['CylinderArrangement'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Stroke</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['Stroke'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Valve Gear</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['ValveGear'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Location</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['Location'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Description</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['Description'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Bore</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['Bore'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Power Delivery</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['PowerDelivery'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Type Approval Category</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['TypeApprovalCategory'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Driving Axle</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['DrivingAxle'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Primary Fuel Flag</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['Engine']['PrimaryFuelFlag'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Series Description</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['SeriesDescription'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Driver Position</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['DriverPosition'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Data Version Number</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['DataVersionNumber'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Is Limited Edition</td>
                            <td style="padding:8px;"><?= !empty($general['IsLimitedEdition']) ? 'Yes' : 'No' ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">EV Battery Capacity</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['ElectricVehicleBattery']['Capacity'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">EV Battery Charge Port</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['ElectricVehicleBattery']['ChargePort'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">EV Battery Charge Time</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['ElectricVehicleBattery']['ChargeTime'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">EV Battery Type</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($general['ElectricVehicleBattery']['Type'] ?? '***')) ?>
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>

        <!-- Previous Keepers -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                Previous Keepers
                            </td>
                        </tr>

                        <!-- Summary Row -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Total Keepers</td>
                            <td style="padding:8px;">
                                <?= isset($vehicleMot['motTestList']['keepersChange']['total']) ? $vehicleMot['motTestList']['keepersChange']['total'] : '***' ?>
                            </td>

                            <td style="padding:8px; font-weight:bold;">Keeper Data Count</td>
                            <td style="padding:8px;">
                                <?= isset($vehicleMot['motTestList']['keepersChange']['numberofprevioukeeper']) ? htmlspecialchars((string) $vehicleMot['motTestList']['keepersChange']['numberofprevioukeeper']) : '***' ?>
                            </td>
                        </tr>

                        <!-- Dynamic Keeper Rows -->
                        <?php if (!empty($vehicleMot['motTestList']['keepersChange']['data'])): ?>
                        <?php foreach ($vehicleMot['motTestList']['keepersChange']['data'] as $index => $keeper): ?>
                        <tr <?= $index % 2 === 0 ? '' : 'style="background:#f9f9f9;"' ?>>
                            <td style="padding:8px; font-weight:bold;">
                                <?= htmlspecialchars($keeper['keeper_count_text'] ?? '***') ?>
                            </td>
                            <td colspan="3" style="padding:8px; text-align:right;">
                                <?= !empty($keeper['date']) ? date('d-M-y', strtotime($keeper['date'])) : '***' ?>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                        <?php else: ?>
                        <tr>
                            <td colspan="4" align="center" style="padding:8px; color:#999;">
                                No keeper history available
                            </td>
                        </tr>
                        <?php endif; ?>

                    </table>
                </div>
            </td>
        </tr>



        <!-- V5C Certificate issue details -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                V5C Certificate issue details
                            </td>
                        </tr>

                        <!-- Rows -->
                        <tr>
                            <td style="padding:8px; font-weight:bold; white-space:nowrap;">V5C Certificate Count</td>
                            <td style="padding:8px;">
                                <?= $V5CCertificates && is_array($V5CCertificates) ? count($V5CCertificates) : '***' ?>
                            </td>
                            <td style="padding:8px; font-weight:bold; white-space:nowrap;">Certificate Dates:</td>
                            <td style="padding:0;">
                                <?php if (!empty($V5CCertificates) && is_array($V5CCertificates)): ?>
                                <table cellspacing="0" cellpadding="6" style="border-collapse:collapse;">
                                    <?php foreach ($V5CCertificates as $i => $date): ?>
                                    <tr>
                                        <td
                                            style="background-color: <?= $i % 2 == 0 ? '#f9f9f9' : '#ffffff' ?>; padding:6px; text-align:right;">
                                            <?= !empty($date) ? date('d-M-y', strtotime($date)) : '' ?>
                                        </td>
                                    </tr>
                                    <?php endforeach; ?>
                                </table>
                                <?php endif; ?>
                            </td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>






        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                Vehicle Tax &amp; CO₂ Emissions
                            </td>
                        </tr>

                        <!-- Rows -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Standard Six Month</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['StandardSixMonth']['Amount'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Per Month</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['StandardSixMonth']['PerMonth'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Standard Twelve Month</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['StandardTwelveMonth']['Amount'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Per Month</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['StandardTwelveMonth']['PerMonth'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">First Year Six Month</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string)($vehicleTaxCo2Emissions['FirstYearSixMonth']['Amount'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Per Month</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string)($vehicleTaxCo2Emissions['FirstYearSixMonth']['PerMonth'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">First Year Twelve Month</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['First Year Twelve Month']['Amount'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Per Month</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['First Year Twelve Month']['PerMonth'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Premium Vehicle Year 2 to 6 - Six
                                Month</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string)($vehicleTaxCo2Emissions['PremiumVehicleYear2to6-SixMonth']['Amount'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Per Month</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string)($vehicleTaxCo2Emissions['PremiumVehicleYear2to6-SixMonth']['PerMonth'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Premium Vehicle Year 2 to 6 - Twelve
                                Month</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string)($vehicleTaxCo2Emissions['PremiumVehicleYear2to6-Twelve Month']['Amount'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Per Month</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string)($vehicleTaxCo2Emissions['PremiumVehicleYear2to6-Twelve Month']['PerMonth'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">VED CO₂ Emissions</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['VedCo2Emissions'] ?? '***')) ?> g/km
                            </td>
                            <td style="padding:8px; font-weight:bold;">VED Band</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['VedBand'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">VED CO₂ Band</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleTaxCo2Emissions['VedCo2Band'] ?? '***')) ?></td>
                            <td style="padding:8px;"></td>
                            <td style="padding:8px;"></td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>

        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                Performance Information
                            </td>
                        </tr>

                        <!-- Rows -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Torque FtLb</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Torque']['FtLb'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Power Rpm</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Power']['Rpm'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Torque Rpm</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Torque']['Rpm'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Power Bhp</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Power']['Bhp'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Torque Nm</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Torque']['Nm'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Power Kw</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Power']['Kw'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Co2</td>
                            <td style="padding:8px;"><?= htmlspecialchars((string) ($performance['Co2'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">NoiseLevel</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['NoiseLevel'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Max Speed Mph</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['MaxSpeed']['Kph'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Particles</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Particles'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Max Speed Kph</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['MaxSpeed']['Mph'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Data Version Number</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['DataVersionNumber'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Acceleration ZeroTo 60Mph</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Acceleration']['ZeroTo60Mph'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Acceleration Mph</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Acceleration']['Mph'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">Acceleration Zero To 100Kph</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Acceleration']['ZeroTo100Kph'] ?? '***')) ?>
                            </td>
                            <td style="padding:8px; font-weight:bold;">Acceleration Kph</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($performance['Acceleration']['Kph'] ?? '***')) ?></td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>


        <!-- consumption -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4aa3df; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fcff; padding:10px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4aa3df;">
                                Consumption
                            </td>
                        </tr>

                        <!-- Rows -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Combined Mpg</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($consumption['Combined']['Mpg'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Combined Lkm</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($consumption['Combined']['Lkm'] ?? '***')) ?></td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="padding:8px; font-weight:bold;">ExtraUrban Mpg</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($consumption['ExtraUrban']['Mpg'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">ExtraUrban Lkm</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($consumption['ExtraUrban']['Lkm'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="padding:8px; font-weight:bold;">UrbanCold Mpg</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($consumption['UrbanCold']['Mpg'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">UrbanCold Lkm</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($consumption['UrbanCold']['Lkm'] ?? '***')) ?></td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
        <!-- Plate Change History -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid <?= !empty($vehicleData['plateChange']) ? '#FF9800;' : '#4CAF50;' ?> border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->

                        <tr style="background:<?= !empty($vehicleData['plateChange']) ? '#FF9800;' : '#4CAF50;' ?>">
                            <td colspan="2" align="center"
                                style="background:<?= !empty($vehicleData['plateChange']) ? '#f9fff9;' : '#f9fff9;' ?>  padding:12px; font-weight:bold; font-size:16px; color:#555; border-bottom:1px solid <?= !empty($vehicleData['plateChange']) ? '#FF9800;' : '#4CAF50;' ?>">
                                <span
                                    style="color:<?= !empty($vehicleData['plateChange']) ? '#FF9800;' : '#4CAF50;' ?> font-size:18px;"><?= !empty($vehicleData['plateChange']) ? '<span style="font-size:21px; font-weight:bold;">!</span>' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?></span>Plate
                                Change History
                            </td>
                        </tr>

                        <!-- Row -->

                        <tr>
                            <td style="padding:10px; font-weight:bold; width:50%;">Plate Change Count</td>
                            <td style="padding:10px; text-align:center;">
                                <?= isset($vehicleMot['motTestList']['plateChange']) ? count($vehicleMot['motTestList']['plateChange']) : '***' ?>
                            </td>
                        </tr>

                        <?php if (!empty($vehicleMot['motTestList']['plateChange'])): ?>
                        <tr>
                            <td colspan="2" style="padding:10px;">
                                <table cellpadding="6" cellspacing="0" border="0"
                                    style="font-size:13px; border-collapse:collapse;width:800px;">
                                    <tr style="background:#f5f5f5; font-weight:bold; text-align:center;">
                                        <td style="width:25%;">Date</td>
                                        <td style="width:35%;">Previous Plate</td>
                                        <td style="width:5%;"></td>
                                        <td style="width:35%;">Current Plate</td>
                                    </tr>
                                    <?php foreach ($vehicleMot['motTestList']['plateChange'] as $pltchang): ?>
                                    <tr style="text-align:center;">
                                        <td><?= !empty($pltchang['date']) ? date('d-M-y', strtotime($pltchang['date'])) : '' ?>
                                        </td>
                                        <td>
                                            <div
                                                style="display:inline-flex; align-items:center; border:1px solid #000; border-radius:4px; overflow:hidden; font-family:Arial, sans-serif; font-weight:bold; padding:3px 6px; font-size:12px;">
                                                <?= htmlspecialchars($pltchang['previous'] ?? '') ?>
                                            </div>
                                        </td>
                                        <td style="color:#003399; font-weight:bold;">→</td>
                                        <td>
                                            <div
                                                style="display:inline-flex; align-items:center; border:1px solid #000; border-radius:4px; overflow:hidden; font-family:Arial, sans-serif; font-weight:bold; padding:3px 6px; font-size:12px;">
                                                <?= htmlspecialchars($pltchang['current'] ?? '') ?>
                                            </div>
                                        </td>
                                    </tr>
                                    <?php endforeach; ?>
                                </table>
                            </td>
                        </tr>
                        <?php endif; ?>


                    </table>
                </div>
            </td>
        </tr>

        <!-- Import/Export -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <?php
                $hasImportExport = !empty($importExport['exported'] ?? null) || !empty($importExport['imported'] ?? null);
                $color = $hasImportExport ? '#F44336;' : '#4CAF50;';
                $icon = $hasImportExport ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">';
                ?>
                <div
                    style="max-width:800px; border:1px solid <?= $color ?> border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->

                        <tr>
                            <td colspan="4" align="center"
                                style="background:<?= $hasImportExport ? '#fbfafa' : '#f9fff9' ?>; padding:12px; font-weight:bold; font-size:16px; color:#555; border-bottom:1px solid <?= $color ?>">
                                <span style="color: <?= $color ?> font-size:18px;"><?= $icon ?></span>
                                Import/Export
                            </td>
                        </tr>

                        <!-- Exported Row -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Exported</td>
                            <td style="padding:8px;"><?= !empty($importExport['exported']) ? 'Yes' : 'No' ?></td>
                            <td style="padding:8px; font-weight:bold;">Export Date</td>
                            <td style="padding:8px;">
                                <?= $importExport['dateExported'] ? date('d-M-y', strtotime($importExport['dateExported'])) : '***' ?>
                            </td>
                        </tr>

                        <!-- Imported Row -->
                        <tr style="background:#f9f9f9;">
                            <td style="padding:10px; font-weight:bold;">Imported</td>
                            <td style="padding:10px;"><?= !empty($importExport['imported']) ? 'Yes' : 'No' ?></td>
                            <td style="padding:10px;"></td>
                            <td style="padding:10px;"></td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>


        <!-- scrpa destructions -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid <?= !empty($scrapDestruction['scrapped']) ? '#F44336;' : '#4CAF50;' ?> border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background: <?= !empty($scrapDestruction['scrapped']) ? '#fbfafa' : '#f9fff9' ?>; padding:12px; font-weight:bold; font-size:16px; color:#555; border-bottom:1px solid <?= !empty($scrapDestruction['scrapped']) ? '#F44336;' : '#4CAF50;' ?>">
                                <span
                                    style="color:<?= !empty($scrapDestruction['scrapped']) ? '#F44336;' : '#4CAF50;' ?> font-size:18px;"><?= !empty($scrapDestruction['scrapped']) ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?></span>
                                Scrap Destructions
                            </td>
                        </tr>

                        <!-- Exported Row -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Scrapped</td>
                            <td style="padding:8px;"><?= !empty($scrapDestruction['scrapped']) ? 'Yes' : 'No' ?></td>
                            <td style="padding:8px; font-weight:bold;">Date of Scapped</td>
                            <td style="padding:8px;">
                                <?= $scrapDestruction['dateofScapped'] ? date('d-M-y', strtotime($scrapDestruction['dateofScapped'])) : '***' ?>
                            </td>
                        </tr>

                        <!-- Imported Row -->
                        <tr style="background:#f9f9f9;">
                            <td style="padding:10px; font-weight:bold;">Certificate of Destruction Issued
                            </td>
                            <td style="padding:10px;">
                                <?= !empty($scrapDestruction['certificateofDestructionIssued']) ? 'Yes' : 'No' ?></td>
                            <td style="padding:10px;">Vehicle ID Check Count</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($scrapDestruction['vehicleIdCheckCount'] ?? '***')) ?>
                            </td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>


        <!-- color changes -->

        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid <?= $colourChange['NumberOfPreviousColours'] ? '#F44336;' : '#4CAF50;' ?>; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->

                        <tr>
                            <td colspan="4" align="center"
                                style="background:<?= $colourChange['NumberOfPreviousColours'] ? '#fbfafa' : '#f9fff9' ?>; padding:12px; font-weight:bold; font-size:16px; color:#555; border-bottom:1px solid <?= $colourChange['NumberOfPreviousColours'] ? '#F44336;' : '#4CAF50;' ?>">
                                <span
                                    style="color: <?= $colourChange['NumberOfPreviousColours'] ? '#F44336;' : '#4CAF50;' ?>; font-size:18px;">
                                    <?= $colourChange['NumberOfPreviousColours'] ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?>
                                </span>
                                Colour Changes
                            </td>
                        </tr>

                        <!-- Exported Row -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Current Colour
                            </td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($colourChange['CurrentColour'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Number Of Previous Colours</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($colourChange['NumberOfPreviousColours'] ?? '***')) ?>
                            </td>
                        </tr>

                        <!-- Imported Row -->
                        <tr style="background:#f9f9f9;">
                            <td style="padding:10px; font-weight:bold;">Last Colour</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($colourChange['LastColour'] ?? '***')) ?></td>
                            <td style="padding:10px;">Date Of Last Colour Change</td>
                            <td style="padding:10px;">
                                <?= $colourChange['DateOfLastColourChange'] ? date('d-M-y', strtotime($colourChange['DateOfLastColourChange'])) : '***' ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding:10px; font-weight:bold;">Original Colour</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($colourChange['OriginalColour'] ?? '***')) ?></td>
                            <td style="padding:10px;"></td>
                            <td style="padding:10px;"></td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>

        <!-- Previous VRM -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid <?= isset($vehicleInformation['PreviousVrmNi']) ? '#F44336' : '#4CAF50' ?>; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="6" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->

                        <tr>
                            <td colspan="4" align="center"
                                style="background:<?= isset($vehicleInformation['PreviousVrmNi']) ? '#fbfafa' : '#f9fff9' ?>; padding:12px; font-weight:bold; font-size:16px; color:#555; border-bottom:1px solid <?= isset($vehicleInformation['PreviousVrmNi']) ? '#F44336' : '#4CAF50' ?>">
                                <span
                                    style="
        font-size:18px;
        color:<?= isset($vehicleInformation['PreviousVrmNi']) ? '#F44336' : '#4CAF50' ?>">
                                    <?= isset($vehicleInformation['PreviousVrmNi']) ? '<img style="width:13px;display: inline;" src="' . asset('assets/photo/close.png') . '" alt="">' : '<img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt="">' ?>
                                </span>
                                Previous VRM
                            </td>

                        </tr>


                        <!-- Exported Row -->
                        <tr>
                            <td style="padding:8px; font-weight:bold;">Previous Northern Ireland</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['PreviousVrmNi'] ?? '***')) ?></td>
                            <td style="padding:8px; font-weight:bold;">Previous UK VRM</td>
                            <td style="padding:8px;">
                                <?= htmlspecialchars((string) ($vehicleInformation['PreviousVrmGb'] ?? '***')) ?></td>
                        </tr>

                        <!-- Imported Row -->

                    </table>
                </div>
            </td>
        </tr>
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Dimensions
                            </td>
                        </tr>

                        <!-- Data Rows -->
                        <tr>
                            <td style="font-weight:bold;">Gross Vehicle Weight</td>
                            <td><?= htmlspecialchars((string) ($dimensions['GrossVehicleWeight'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Height</td>
                            <td><?= htmlspecialchars((string) ($dimensions['Height'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold;">Gross Combined Weight</td>
                            <td><?= htmlspecialchars((string) ($dimensions['GrossCombinedWeight'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Width</td>
                            <td><?= htmlspecialchars((string) ($dimensions['Width'] ?? '***')) ?></td>
                        </tr>

                        <tr>
                            <td style="font-weight:bold;">Kerb Weight</td>
                            <td><?= htmlspecialchars((string) ($dimensions['KerbWeight'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Car Length</td>
                            <td><?= htmlspecialchars((string) ($dimensions['CarLength'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold;">Unladen Weight</td>
                            <td><?= htmlspecialchars((string) ($dimensions['UnladenWeight'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Wheel Base</td>
                            <td><?= htmlspecialchars((string) ($dimensions['WheelBase'] ?? '***')) ?></td>
                        </tr>

                        <tr>
                            <td style="font-weight:bold;">Fuel Tank Capacity</td>
                            <td><?= htmlspecialchars((string) ($dimensions['FuelTankCapacity'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Pay Load Weight</td>
                            <td><?= htmlspecialchars((string) ($dimensions['PayLoadWeight'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold;">Number Of Doors</td>
                            <td><?= htmlspecialchars((string) ($dimensions['NumberOfDoors'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Gross Train Weight</td>
                            <td><?= htmlspecialchars((string) ($dimensions['GrossTrainWeight'] ?? '***')) ?></td>
                        </tr>

                        <tr>
                            <td style="font-weight:bold;">Number Of Seats</td>
                            <td><?= htmlspecialchars((string) ($dimensions['NumberOfSeats'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Payload Volume</td>
                            <td><?= htmlspecialchars((string) ($dimensions['PayloadVolume'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold;">Rigid Artic</td>
                            <td><?= htmlspecialchars((string) ($dimensions['RigidArtic'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Load Length</td>
                            <td><?= htmlspecialchars((string) ($dimensions['LoadLength'] ?? '***')) ?></td>
                        </tr>

                        <tr>
                            <td style="font-weight:bold;">Number Of Axles</td>
                            <td><?= htmlspecialchars((string) ($dimensions['NumberOfAxles'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Data Version Number</td>
                            <td><?= htmlspecialchars((string) ($dimensions['DataVersionNumber'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold;">Body Shape</td>
                            <td><?= htmlspecialchars((string) ($dimensions['BodyShape'] ?? 'NA')) ?>
                            <td colspan="2">&nbsp;</td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>




        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;width:800px;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Safety
                            </td>
                        </tr>

                        <!-- Data Rows -->
                        <tr>
                            <td style="font-weight:bold;">Adult</td>
                            <td><?= htmlspecialchars((string) ($safety['EuroNcap']['Adult'] ?? '***')) ?></td>
                            <td style="font-weight:bold;">Child</td>
                            <td><?= htmlspecialchars((string) ($safety['EuroNcap']['Child'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold;">Pedestrian</td>
                            <td><?= htmlspecialchars((string) ($safety['EuroNcap']['Pedestrian'] ?? '***')) ?></td>
                            <td style="font-weight:bold;"></td>
                            <td></td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>
        {{-- classificaio n details --}}
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;"
                        width="100%">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Classification Details
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                SMMT Make</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Smmt']['Make'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                DVLA Make</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Dvla']['Make'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                SMMT Range</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Smmt']['Range'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                DVLA Model</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Dvla']['Model'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                SMMT Trim</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Smmt']['Trim'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Is Electric Vehicle</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) (($classificationDetails['Ukvd']['IsElectricVehicle'] ?? false) ? 'YES' : 'NO')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                SMMT Mvris MakeCode</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Smmt']['Mvris']['MakeCode'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Is GB General Format</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['VrmFormat']['IsGBGeneralFormat'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                SMMT Mvris ModelCode</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['Mvris']['ModelCode'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Is NI General Format</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($classificationDetails['VrmFormat']['IsNIGeneralFormat'] ?? '***')) ?>
                            </td>
                        </tr>
                    </table>
            </td>
        </tr>


        <!-- Smmt Details -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Smmt Details
                            </td>
                        </tr>

                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Marque</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['Marque'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Range</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['Range'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Model Variant</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['ModelVariant'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Fuel Type</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['FuelType'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Nominal Engine Capacity</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['NominalEngineCapacity'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Transmission</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['Transmission'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Engine Capacity</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['EngineCapacity'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Number Of Doors</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['NumberOfDoors'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Body Style</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['BodyStyle'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Number Of Gears</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['NumberOfGears'] ?? '***')) ?>
                            </td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                DriveType</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['DriveType'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                SysSetup Date</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= !empty($smmtDetails['SysSetupDate']) ? \Carbon\Carbon::createFromFormat('d/m/Y', $smmtDetails['SysSetupDate'])->format('d-M-y') : '***' ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Country Of Origin</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['CountryOfOrigin'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Visibility Date</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= !empty($smmtDetails['VisibilityDate']) ? \Carbon\Carbon::createFromFormat('d/m/Y', $smmtDetails['VisibilityDate'])->format('d-M-y') : '***' ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Series</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['Series'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Terminate Date</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= !empty($smmtDetails['TerminateDate']) ? \Carbon\Carbon::createFromFormat('d/m/Y', $smmtDetails['TerminateDate'])->format('d-M-y') : '***' ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Marque Code</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['MarqueCode'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Cab Type</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['CabType'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Market Sector Code</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['MarketSectorCode'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Data Version Number</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['DataVersionNumber'] ?? '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                                Model Code</td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                                <?= htmlspecialchars((string) ($smmtDetails['ModelCode'] ?? '***')) ?>
                            </td>
                            <td
                                style="font-weight: bold;padding:10px;width:30%;
                                    font-size:14px;">
                            </td>
                            <td
                                style="text-align:right;padding:10px;width:20%;
                                    font-size:14px;">
                            </td>
                        </tr>
                    </table>
            </td>
        </tr>

        <!-- electirc vehicle -->
        <?php if(!empty($vehicleMot['electricVehicleData'])){ ?>
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Electrical Vehicle Data
                            </td>
                        </tr>

                        <!-- Each row: Label + Value -->
                        <tr>
                            <td style="font-weight: bold; padding:10px; width:50%; font-size:14px;">Watt-Hours / Mile
                            </td>
                            <td style="padding:10px; font-size:14px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['WhMile']) ? $vehicleMot['electricVehicleData']['WhMile'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Max Miles per Charge Hour</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['MaxMilesPerChargeHour']) ? $vehicleMot['electricVehicleData']['MaxMilesPerChargeHour'] : '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Zero Emission Miles</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['ZeroEmissionMiles']) ? $vehicleMot['electricVehicleData']['ZeroEmissionMiles'] : '***')) ?>
                            </td>


                            <td style="font-weight: bold; padding:10px;">Max Miles per Charge Minute</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['MaxMilesPerChargeMinute']) ? $vehicleMot['electricVehicleData']['MaxMilesPerChargeMinute'] : '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; padding:10px;">Manufacturer Warranty Miles</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['ManufacturerWarrantyMiles']) ? $vehicleMot['electricVehicleData']['ManufacturerWarrantyMiles'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Vehicle Type</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['VehicleType']) ? $vehicleMot['electricVehicleData']['VehicleType'] : '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Manufacturer Warranty Months</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['ManufacturerWarrantyMonths']) ? $vehicleMot['electricVehicleData']['ManufacturerWarrantyMonths'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Tesla Supercharger Compatible</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['TeslaSuperchargerCompatible']) ? $vehicleMot['electricVehicleData']['TeslaSuperchargerCompatible'] : '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; padding:10px;">Max Range Miles</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['MaxRangeMiles']) ? $vehicleMot['electricVehicleData']['MaxRangeMiles'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Max KW Charge Input</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['MaxKwChargeInput']) ? $vehicleMot['electricVehicleData']['MaxKwChargeInput'] : '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Max Range Km</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['MaxRangeKm']) ? $vehicleMot['electricVehicleData']['MaxRangeKm'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">OTA Upgradable</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['OtaUpgradable']) ? 'TRUE' : 'FALSE')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; padding:10px;">CO2</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['Co2']) ? $vehicleMot['electricVehicleData']['Co2'] : '***')) ?>
                                g/km</td>

                            <td style="font-weight: bold; padding:10px;">Latest OTA Version</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['LatestOtaVersion']) ? $vehicleMot['electricVehicleData']['LatestOtaVersion'] : '***')) ?>
                            </td>
                        </tr>
                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Drag Coefficient</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['DragCoefficient']) ? $vehicleMot['electricVehicleData']['DragCoefficient'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Hardware Version</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['HwVersion']) ? $vehicleMot['electricVehicleData']['HwVersion'] : '***')) ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; padding:10px;">Drivetrain Version Description</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (isset($vehicleMot['electricVehicleData']['DrivetrainVersionDescription']) ? $vehicleMot['electricVehicleData']['DrivetrainVersionDescription'] : '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Is Electric Vehicle</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) (($vehicleMot['electricVehicleData']['Identification']['IsElectricVehicle'] ?? false) ? 'YES' : 'NO')) ?>
                            </td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>
        <?php } ?>



        <?php if (!empty($vehicleMot['electricVehicleData']['BatteryDetailsList'])): ?>
        <?php foreach ($vehicleMot['electricVehicleData']['BatteryDetailsList'] as $index => $battery): ?>

        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Battery Details - <?= $index + 1 ?>
                            </td>
                        </tr>

                        <!-- Each row: Label + Value -->
                        <tr>
                            <td style="font-weight: bold; padding:10px;">Capacity KWH</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($battery['CapacityKwh'] ?? '***')) ?></td>


                            <td style="font-weight: bold; padding:10px;">Chemistry</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($battery['Chemistry'] ?? '***')) ?></td>
                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Battery Description</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($battery['BatteryDescription'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">Battery Location</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($battery['BatteryLocation'] ?? '***')) ?></td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold; padding:10px;">Voltage</td>
                            <td style="padding:10px;"><?= htmlspecialchars((string) ($battery['Voltage'] ?? '***')) ?>
                            </td>


                            <td style="font-weight: bold; padding:10px;">Battery Warranty Miles</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($battery['BatteryWarrantyMonths'] ?? '***')) ?> months /
                                <?= htmlspecialchars((string) ($battery['BatteryWarrantyMiles'] ?? '***')) ?>
                            </td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Battery Warranty Months</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($battery['BatteryWarrantyMonths'] ?? '***')) ?></td>


                            <?php if ($index === 0): ?>
                            <td style="font-weight: bold; padding:10px;">Battery Details Count</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($vehicleMot['electricVehicleData']['BatteryDetailsCount'] ?? '***')) ?>
                            </td>

                            <?php endif; ?>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>
        <?php endforeach; ?>
        <?php endif; ?>






        <!-- MOT Test List -->


        <?php if (!empty($vehicleMot['electricVehicleData']['ChargePortDetailsList'])): ?>
        <?php foreach ($vehicleMot['electricVehicleData']['ChargePortDetailsList'] as $index => $port): ?>

        <!-- Charge Port Details Card -->
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-family:Arial,sans-serif; font-size:14px; color:#333; border-collapse:collapse;">

                        <!-- Section Title -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; font-weight: bold; font-size:18px; padding:14px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Charge Port Details - <?= $index + 1 ?>
                            </td>
                        </tr>

                        <!-- Key/Value Rows -->
                        <tr>
                            <td style="font-weight:bold; padding:10px;">Port Type</td>
                            <td style="padding:10px;"><?= htmlspecialchars((string) ($port['PortType'] ?? '***')) ?>
                            </td>

                            <td style="font-weight:bold; padding:10px;">Max Charge Power Kw</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($port['MaxChargePowerKw'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight:bold; padding:10px;">Port Location</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($port['PortLocation'] ?? '***')) ?></td>

                            <td style="font-weight:bold; padding:10px;">Charge Port Count</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($vehicleMot['electricVehicleData']['ChargePortCount'] ?? '***')) ?>
                            </td>
                        </tr>

                        <?php if ($index === 0): ?>
                        <tr>
                            <td style="font-weight:bold; padding:10px;">Charge Port Details Count</td>
                            <td style="padding:10px;" colspan="3">
                                <?= htmlspecialchars((string) ($vehicleMot['electricVehicleData']['ChargePortDetailsCount'] ?? '***')) ?>
                            </td>
                        </tr>
                        <?php endif; ?>

                    </table>
                </div>
            </td>
        </tr>

        <!-- Charge Times Table -->
        <?php if (!empty($port['ChargeTimes']['AverageChargeTimes10To80Percent'])): ?>
        <tr>
            <td align="center" style="padding-top:10px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-family:Arial,sans-serif; font-size:14px; color:#333; border-collapse:collapse;">

                        <!-- Sub-header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f2f9ff; font-weight:bold; font-size:16px; padding:12px; color:#444;">
                                Average Charge Times 10 To 80 Percent
                            </td>
                        </tr>

                        <!-- Charge Times -->
                        <?php foreach ($port['ChargeTimes']['AverageChargeTimes10To80Percent'] as $time): ?>
                        <tr>
                            <td style="font-weight:bold; padding:10px;">Charge Port Kw</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($time['ChargePortKw'] ?? '***')) ?></td>

                            <td style="font-weight:bold; padding:10px;">Time In Minutes</td>
                            <td style="padding:10px;"><?= htmlspecialchars((string) ($time['TimeInMinutes'] ?? 0)) ?>
                            </td>
                        </tr>
                        <?php endforeach; ?>

                    </table>
                </div>
            </td>
        </tr>
        <?php endif; ?>

        <?php endforeach; ?>
        <?php endif; ?>


        <?php if (!empty($vehicleMot['electricVehicleData']['MotorDetailsList'])): ?>
        <?php foreach ($vehicleMot['electricVehicleData']['MotorDetailsList'] as $index => $motor): ?>
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Motor Details List - <?= $index + 1 ?>
                            </td>
                        </tr>

                        <!-- Rows: Label + Value -->
                        <tr>
                            <td style="font-weight: bold; padding:10px; width:50%; font-size:14px;">Manufacturer</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($motor['Manufacturer'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">Motor Type</td>
                            <td style="padding:10px;"><?= htmlspecialchars((string) ($motor['MotorType'] ?? '***')) ?>
                            </td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Model</td>
                            <td style="padding:10px;"><?= htmlspecialchars((string) ($motor['Model'] ?? '***')) ?>
                            </td>

                            <td style="font-weight: bold; padding:10px;">Power Kw</td>
                            <td style="padding:10px;"><?= htmlspecialchars((string) ($motor['PowerKw'] ?? '***')) ?>
                            </td>
                        </tr>

                        <tr>
                            <td style="font-weight: bold; padding:10px;">Max Torque Nm</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($motor['MaxTorqueNm'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">Regenerative Braking</td>
                            <td style="padding:10px;">
                                <?= !empty($motor['RegenBraking']) && $motor['RegenBraking'] ? 'Yes' : 'No' ?>
                            </td>
                        </tr>

                        <tr style="background:#f9f9f9;">

                            <td style="font-weight: bold; padding:10px;">Motor Location</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($motor['MotorLocation'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">Max Power RPM</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($motor['MaxPowerRpm'] ?? '***')) ?></td>
                        </tr>

                        <tr style="">
                            <td style="font-weight: bold; padding:10px;">Additional Info</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($motor['AdditionalInformation'] ?? '***')) ?></td>

                            <?php if ($index === 0): ?>

                            <td style="font-weight: bold; padding:10px;">Motor Details Count</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($vehicleMot['electricVehicleData']['MotorDetailsCount'] ?? '***')) ?>
                            </td>
                        </tr>
                        <?php endif; ?>

                    </table>
                </div>
            </td>
        </tr>
        <?php endforeach; ?>
        <?php endif; ?>



        <?php if (!empty($vehicleMot['electricVehicleData']['TransmissionDetailsList'])): ?>
        <?php foreach ($vehicleMot['electricVehicleData']['TransmissionDetailsList'] as $index => $item): ?>
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Transmission Details - <?= $index + 1 ?>
                            </td>
                        </tr>

                        <tr>
                            <td style="font-weight: bold; padding:10px; width:50%; font-size:14px;">Transmission Type
                            </td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($item['TransmissionType'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">Number of Gears</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($item['NumberOfGears'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Transmission Location</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($item['TransmissionLocation'] ?? '***')) ?></td>

                            <?php if ($index === 0): ?>

                            <td style="font-weight: bold; padding:10px;">Transmission Details Count</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($vehicleMot['electricVehicleData']['TransmissionDetailsCount'] ?? '***')) ?>
                            </td>
                        </tr>
                        <?php endif; ?>

                    </table>
                </div>
            </td>
        </tr>
        <?php endforeach; ?>
        <?php endif; ?>

        <?php if (!empty($vehicleMot['electricVehicleData']['RangeFigures']['RangeTestCycleDetailsList'])): ?>
        <?php foreach ($vehicleMot['electricVehicleData']['RangeFigures']['RangeTestCycleDetailsList'] as $index => $range): ?>
        <tr>
            <td align="center" style="padding-top:20px;">
                <div
                    style="max-width:800px; border:1px solid #4DB6E2; border-radius:8px; overflow:hidden; background:#ffffff; margin:0 auto;">
                    <table width="100%" cellpadding="8" cellspacing="0" border="0"
                        style="font-size:13px; font-family:Arial,sans-serif; color:#333; background:#ffffff; border-collapse:collapse;">

                        <!-- Header -->
                        <tr>
                            <td colspan="4" align="center"
                                style="background:#f9fdff; padding:12px; font-weight:bold; font-size:16px; color:#444; border-bottom:1px solid #4DB6E2;">
                                Range Test Cycle Details List
                            </td>
                        </tr>

                        <tr>
                            <td style="font-weight: bold; padding:10px; width:50%; font-size:14px;">Combined Range
                                Miles</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($range['CombinedRangeMiles'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">City Range Miles</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($range['CityRangeMiles'] ?? '***')) ?></td>
                        </tr>

                        <tr style="background:#f9f9f9;">
                            <td style="font-weight: bold; padding:10px;">Combined Range KM</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($range['CombinedRangeKm'] ?? '***')) ?></td>

                            <td style="font-weight: bold; padding:10px;">City Range KM</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($range['CityRangeKm'] ?? '***')) ?></td>
                        </tr>

                        <tr>
                            <td style="font-weight: bold; padding:10px;">EV Range Test Type</td>
                            <td style="padding:10px;">
                                <?= htmlspecialchars((string) ($range['EvRangeTestType'] ?? '***')) ?></td>
                        </tr>

                    </table>
                </div>
            </td>
        </tr>
        <?php endforeach; ?>
        <?php endif; ?>


        <!-- SECTION 4: MOT Test List -->
        <tr>
            <td align="center"
                style="padding-top:20px; padding-bottom:15px; font-size:18px; color:#555555; font-weight:bold;">
                MOT Test List
            </td>
        </tr>

        <tr>
            <td>
                <table cellpadding="6" cellspacing="0" border="1" width="100%"
                    style="border-collapse:collapse; font-size:13px; border-color:#ccc;  max-width: 800px; margin: 0 auto;">
                    <tr style="background:#777; color:#ffffff; font-weight:bold; text-align:center;">
                        <td>Date</td>
                        <td>Result</td>
                        <td>Mileage</td>
                        <td>Test Number</td>
                    </tr>
                    <?php foreach (($vehicleMot['motTestList']['motList'] ?? []) as $test): ?>
                    <tr style="background:#f9fff9;">
                        <td><?= htmlspecialchars(!empty($test['date']??'') ? date('d-M-y', strtotime($test['date'])) : '***') ?></td>
                        <td
                            style="font-weight:bold; color:<?= isset($test['result']) && strtoupper($test['result']) === 'PASSED' ? '#4CAF50' : '#f44336' ?>;">
                            <?= isset($test['result']) && strtoupper($test['result']) === 'PASSED' ? '<span style="color:#4CAF50; font-size:18px;"><img style="width:13px;display: inline;" src="' . asset('assets/photo/check.png') . '" alt=""></span> PASS' : '❌ FAIL' ?>
                        </td>
                        <td><?= htmlspecialchars((string) ($test['mileage'] ?? '')) ?>
                            <?= htmlspecialchars((string) ($test['unit'] ?? '')) ?></td>
                        <td><b><?= htmlspecialchars((string) ($test['motTesNumber'] ?? '')) ?></b></td>
                    </tr>
                    <tr style="padding-bottom: 500px">
                        <?php
                        $isPass = isset($test['result']) && strtoupper($test['result']) === 'PASSED';
                        $year = '';
                        if (!empty($test['date'])) {
                            $ts = strtotime($test['date']);
                            $year = $ts ? date('Y', $ts) : '';
                        }
                        ?>
                        <td colspan="5"
                            style="padding:12px; border:1px solid #eee;background-color:<?= $isPass ? '#f9fff9;' : '#fff5f5;' ?>">
                            <div style=" margin-bottom:8px;">
                                <div
                                    style=" 
                                            border-radius:5px; 
                                            padding: 5px 8px;
                                            display:inline-block; 
                                            background:<?= $isPass ? '#4CAF50' : '#f44336' ?>; 
                                            color:white; 
                                            font-weight:bold; 
                                            font-size:12px;">
                                    <?=
                                    ($isPass ? 'PASS' : 'FAIL')
                                    . ($year ? ' - ' . htmlspecialchars((string) $year) : '')
                                    ?>
                                </div>
                                {{-- </div>
                                        <div style="margin-bottom:6px;"> --}}

                            </div>
                            <?php if (!empty($test['advisory'])): ?>
                            <div style="font-weight:bold; margin-bottom:4px;">Advisories:</div>
                            <?php foreach ($test['advisory'] as $adv): ?>
                            <div style="margin-bottom: 2px;">
                                <?php if (!empty($adv['type'])): ?> <span
                                    style="background-color:<?= htmlspecialchars($adv['type']) == 'USER ENTERED' ? '#16aad6' : ($adv['type'] == 'MINOR' ? '#5ab31b' : '#f19e23;') ?>; color:#fff; padding:1px 6px; border-radius:3px; font-size:11px;"><?= htmlspecialchars((string) $adv['type']) ?></span><?php endif; ?>
                                <?= htmlspecialchars((string) ($adv['text'] ?? '')) ?>
                            </div>
                            <?php endforeach; ?>
                            <?php endif; ?>



                            <?php if (!empty($test['failure'])): ?>
                            <div style="font-weight:bold; margin:6px 0 4px;">Failures:</div>
                            <?php foreach ($test['failure'] as $fail): ?>
                            <div>
                                <?php if (!empty($fail['type'])): ?> <span
                                    style="background-color:#d9534f; color:#fff; padding:1px 6px; border-radius:3px; font-size:11px;"><?= htmlspecialchars((string) $fail['type']) ?></span><?php endif; ?>
                                <?= htmlspecialchars((string) ($fail['text'] ?? '')) ?>
                            </div>
                            <?php endforeach; ?>
                            <?php endif; ?>

                            <?php if (!empty($test['prsText'])): ?>
                            <?php if (empty($test['failure']) && !empty($test['prsText'])){ ?>
                            <div style="font-weight:bold; margin:6px 0 4px;">Failures:</div>
                            <?php } ?>
                            <?php foreach ($test['prsText'] as $prs): ?>
                            <div>
                                <span
                                    style="background-color:#297dc5; color:#fff; padding:1px 6px; border-radius:3px; font-size:11px;">PRS</span>
                                <?= htmlspecialchars((string) ($prs['text'] ?? '')) ?>
                            </div>
                            <?php endforeach; ?>
                            <?php endif; ?>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </table>
            </td>
        </tr>

        <br>


        <!-- Disclaimer Section -->
        <tr>
            <td align="center" style="padding-top:10px;">
                <div
                    style="max-width:753px; background:#f0f8fa; padding:25px; border-radius:8px; margin:0 auto; font-family:Arial, sans-serif; font-size:13px; line-height:1.6; color:#333;">

                    <div style="text-align:center; font-weight:bold; font-size:15px; margin-bottom:15px;">
                        DISCLAIMER
                    </div>

                    <div style="text-align:left;">
                        CarBaBa provides free vehicle data but does not guarantee it's precision. Although we strive to
                        maintain up-to-date and accurate information, we are not responsible for any discrepancies,
                        errors, or omissions. Users should independently verify details before making transactions and
                        assume complete responsibility and liability for how they utilize the data.
                        <br><br>
                        Our platform is intended for general public use and not for commercial purposes. Traders should
                        seek paid data services from providers like Experian or HPI.
                        <br><br>
                        We reserve the right to modify or discontinue vehicle data at any time. Users cannot demand
                        continued access to this free service.
                        <br><br>
                        Additionally, our data cannot be used as legal evidence in any court or official capacity.
                    </div>

                </div>
            </td>
        </tr>

    </table>
    </div>
    </td>
    </tr>
    </table>

</body>

</html>
