<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Goods Receipt Note - {{GRN_NUMBER}}</title>
  <style>
    /* ====================================
       GLOBAL STYLES (matching PO template)
    ==================================== */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: Arial, sans-serif;
    }

    body {
      background: #f2f2f2;
      padding: 20px;
    }

    .grn-container {
      width: 1000px;
      margin: auto;
      background: #fff;
      padding: 20px;
      border: 1px solid #000;
    }

    /* ====================================
       COMMON
    ==================================== */
    table {
      width: 100%;
      border-collapse: collapse;
    }

    td, th {
      border: 1px solid #000;
      padding: 3px 6px;
      vertical-align: top;
      font-size: 13px;
    }

    .text-center {
      text-align: center;
    }

    .text-right {
      text-align: right;
    }

    .text-left {
      text-align: left;
    }

    /* ====================================
       HEADER
    ==================================== */
    .top-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      margin-bottom: 10px;
    }

    .logo {
      width: 100px;
      height: auto;
      display: block;
    }

    .company-details {
      flex: 1;
      text-align: center;
      margin-right: 70px;
    }

    .company-details h1 {
      font-size: 18px;
      margin-bottom: 2px;
      font-weight: 700;
    }

    .company-details p {
      font-size: 13px;
      line-height: 1.3;
    }

    /* ====================================
       TITLE
    ==================================== */
    .grn-title {
      text-align: center;
      font-size: 26px;
      font-weight: 700;
      margin: 10px 0;
    }

    /* ====================================
       DATE ROW
    ==================================== */
    .grn-date-row {
      text-align: right;
      font-size: 13px;
      margin-bottom: 8px;
      color: #333;
    }
    .grn-date-row span {
      font-weight: 600;
      color: #111;
    }

    /* ====================================
       3-COLUMN INFO SECTION
    ==================================== */
    .address-table {
      width: 100%;
      border-collapse: collapse;
      table-layout: fixed;
      margin-top: 10px;
    }

    .address-card {
      width: 33.33%;
      vertical-align: top;
      border: 1px solid #cfcfcf;
      padding: 8px 8px;
    }

    .address-title {
      font-size: 13px;
      font-weight: 700;
      color: #666;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      margin-bottom: 5px;
    }

    .company-name {
      font-size: 14px;
      font-weight: 700;
      color: #111;
      line-height: 20px;
      margin-bottom: 6px;
    }

    .address-text {
      font-size: 13px;
      color: #333;
      line-height: 18px;
    }

    .gst-text {
      margin-top: 5px;
      font-size: 13px;
      color: #222;
    }

    /* ====================================
       PRODUCT TABLE
    ==================================== */
    .product-table {
      width: 100%;
      border-collapse: collapse;
      table-layout: fixed;
      margin-top: 12px;
    }

    .product-table th {
      background: #f3f3f3;
      border: 1px solid #cfcfcf;
      padding: 8px 10px;
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      text-align: center;
      color: #444;
      letter-spacing: 0.5px;
    }

    .product-table td {
      border: 1px solid #d8d8d8;
      padding: 8px 10px;
      font-size: 12px;
      color: #222;
      line-height: 18px;
    }

    /* Column widths */
    .col-sl   { width: 5%; }
    .col-name { width: 20%; }
    .col-qty  { width: 7%; }
    .col-rec  { width: 7%; }
    .col-acc  { width: 7%; }
    .col-rej  { width: 7%; }
    .col-rate { width: 9%; }
    .col-aval { width: 10%; }
    .col-rrate { width: 9%; }
    .col-rval { width: 10%; }
    .col-total { width: 10%; }
    .col-loc  { width: 9%; }

    /* ====================================
       TERMS & SUMMARY (matching PO)
    ==================================== */
    .invoice-summary-wrapper {
      width: 100%;
      margin-top: 14px;
      display: table;
      table-layout: fixed;
    }

    .terms-box {
      display: table-cell;
      vertical-align: top;
      border: 1px solid #cfcfcf;
      width: 55%;
      padding: 12px 14px;
    }

    .summary-box {
      display: table-cell;
      vertical-align: top;
      border: 1px solid #cfcfcf;
      width: 45%;
    }

    .summary-title {
      font-size: 13px;
      font-weight: 700;
      text-transform: uppercase;
      color: #666;
      letter-spacing: 0.7px;
      margin-bottom: 10px;
    }

    .terms-content {
      font-size: 13px;
      line-height: 20px;
      color: #333;
    }

    .summary-table {
      width: 100%;
      border-collapse: collapse;
    }

    .summary-table td {
      padding: 8px 12px;
      font-size: 13px;
      color: #222;
      border: 1px solid #d8d8d8;
    }

    .summary-highlight td {
      font-weight: 700;
    }

    .total-row td {
      font-size: 14px;
      font-weight: 700;
      background: #f5f5f5;
      color: #111;
    }

    /* ====================================
       AMOUNT WORDS
    ==================================== */
    .amount-words-box {
      margin-top: 14px;
      border: 1px solid #cfcfcf;
      padding: 10px 14px;
      font-size: 13px;
      line-height: 20px;
    }
    .amount-label {
      font-weight: 700;
      color: #111;
    }
    .amount-text {
      color: #333;
    }

    /* ====================================
       SIGNATURE
    ==================================== */
    .signature-table {
      width: 100%;
      border-collapse: collapse;
      table-layout: fixed;
      margin-top: 14px;
    }

    .signature-col {
      width: 25%;
      border: 1px solid #cfcfcf;
      padding: 12px;
      vertical-align: top;
      text-align: center;
    }

    .signature-name {
      font-size: 13px;
      font-weight: 700;
      color: #111;
      margin-bottom: 6px;
    }

    .signature-role {
      font-size: 13px;
      color: #666;
      text-transform: uppercase;
      letter-spacing: 0.6px;
    }

    .company-sign {
      font-size: 12px;
      font-weight: 700;
      color: #111;
      line-height: 18px;
    }

    .signature-space {
      height: 40px;
    }

    /* ====================================
       FOOTER
    ==================================== */
    .footer-note {
      margin-top: 12px;
      text-align: center;
      font-size: 12px;
      color: #666;
      border-top: 1px solid #dcdcdc;
      padding-top: 8px;
    }

    /* ====================================
       PRINT
    ==================================== */
    @media print {
      body {
        background: #fff;
        padding: 0;
      }
      .grn-container {
        border: none;
      }
    }
  </style>
</head>
<body>
<div class="grn-container">

  <!-- HEADER -->
  <div class="top-header">
    <img src="{{COMPANY_LOGO}}" class="logo" alt="logo" onerror="this.style.display='none'" />
    <div class="company-details">
      <h1>{{COMPANY_NAME}}</h1>
      <p>{{COMPANY_ADDRESS}}</p>
      <p>GSTIN : {{COMPANY_GST}} | CIN : {{COMPANY_CIN}}</p>
      <p>{{COMPANY_EMAIL}} | {{COMPANY_PHONE}}</p>
    </div>
  </div>

  <!-- TITLE -->
  <div class="grn-title">GOODS RECEIPT NOTE</div>
  <div class="grn-date-row">Date : <span>{{GRN_DATE}}</span></div>

  <!-- Address Section (3 columns) -->
  <table class="address-table">
    <tr>
      <!-- Vendor Details -->
      <td class="address-card">
        <div class="address-title">Vendor Details</div>
        <div class="company-name">{{VENDOR_NAME}}</div>
        <div class="address-text">{{VENDOR_ADDRESS}}</div>
        <div class="gst-text"><strong>GSTIN :</strong> {{VENDOR_GSTIN}}</div>
        <div class="gst-text"><strong>Contact :</strong> {{VENDOR_CONTACT}}</div>
        <div class="gst-text"><strong>Phone :</strong> {{VENDOR_PHONE}}</div>
        <div class="gst-text"><strong>Email :</strong> {{VENDOR_EMAIL}}</div>
      </td>

      <!-- GRN Details -->
      <td class="address-card">
        <div class="address-title">GRN Details</div>
        <div class="gst-text"><strong>GRN No :</strong> {{GRN_NUMBER}}</div>
        <div class="gst-text"><strong>GRN Date :</strong> {{GRN_DATE}}</div>
        <div class="gst-text"><strong>PO Reference :</strong> {{PO_REFERENCE}}</div>
        <div class="gst-text"><strong>Gate Entry No :</strong> {{GATE_ENTRY_NO}}</div>
        <div class="gst-text"><strong>Vehicle No :</strong> {{VEHICLE_NO}}</div>
      </td>

      <!-- Document Details -->
      <td class="address-card">
        <div class="address-title">Document Details</div>
        <div class="gst-text"><strong>Invoice No :</strong> {{INVOICE_NO}}</div>
        <div class="gst-text"><strong>Delivery Challan :</strong> {{DELIVERY_CHALLAN}}</div>
      </td>
    </tr>
  </table>

  <!-- Product Table -->
  <table class="product-table">
    <thead>
      <tr>
        <th class="col-sl">Sl.</th>
        <th class="col-name">Item Name</th>
        <th class="col-qty">Ordered Qty</th>
        <th class="col-rec">Received Qty</th>
        <th class="col-acc">Accepted Qty</th>
        <th class="col-rej">Rejected Qty</th>
        <th class="col-rate">Unit Price (₹)</th>
        <th class="col-aval">Accepted Value (₹)</th>
        <th class="col-rrate">Rej. Price (₹)</th>
        <th class="col-rval">Rejected Value (₹)</th>
        <th class="col-total">Total Value (₹)</th>
        <th class="col-loc">Store Location</th>
      </tr>
    </thead>
    <tbody>
      {{ITEMS_ROWS}}
    </tbody>
  </table>

  <!-- Terms and Summary (like PO) -->
  <div class="invoice-summary-wrapper">
    <!-- Terms Section -->
    <div class="terms-box">
      <div class="summary-title">Terms & Conditions</div>
      <div class="terms-content">
        1. Goods once accepted cannot be returned.<br/>
        2. Subject to {{COMPANY_CITY}} jurisdiction.<br/>
        3. Payment to be made as per agreed terms.<br/>
        4. Rejected goods to be taken back within 7 days.<br/>
        5. Quality check to be done at the time of receipt.
      </div>
    </div>

    <!-- Summary Section -->
    <div class="summary-box">
      <table class="summary-table">
        <tr class="summary-highlight">
          <td>Total Ordered Quantity</td>
          <td class="text-right">{{TOTAL_ORDERED_QTY}}</td>
        </tr>
        <tr class="summary-highlight">
          <td>Total Received Quantity</td>
          <td class="text-right">{{TOTAL_RECEIVED_QTY}}</td>
        </tr>
        <tr class="summary-highlight">
          <td>Total Accepted Quantity</td>
          <td class="text-right">{{TOTAL_ACCEPTED_QTY}}</td>
        </tr>
        <tr class="summary-highlight">
          <td>Total Rejected Quantity</td>
          <td class="text-right">{{TOTAL_REJECTED_QTY}}</td>
        </tr>
        <tr>
          <td>Total Accepted Value</td>
          <td class="text-right">₹ {{TOTAL_ACCEPTED_VALUE}}</td>
        </tr>
        <tr>
          <td>Total Rejected Value</td>
          <td class="text-right">₹ {{TOTAL_REJECTED_VALUE}}</td>
        </tr>
        <tr class="total-row">
          <td>Grand Total Value</td>
          <td class="text-right">₹ {{GRAND_TOTAL}}</td>
        </tr>
      </table>
    </div>
  </div>

  <!-- Amount in Words -->
  <div class="amount-words-box">
    <span class="amount-label">Rupees in Words :</span>
    <span class="amount-text">{{AMOUNT_IN_WORDS}} Only</span>
  </div>

  <!-- Signature Section -->
  <table class="signature-table">
    <tr>
      <td class="signature-col">
        <div class="signature-name">{{RECEIVED_BY}}</div>
        <div class="signature-role">Received By</div>
      </td>
      <td class="signature-col">
        <div class="signature-name">{{VERIFIED_BY}}</div>
        <div class="signature-role">Verified By</div>
      </td>
      <td class="signature-col">
        <div class="signature-name">{{STORE_KEEPER}}</div>
        <div class="signature-role">Store Keeper</div>
      </td>
      <td class="signature-col">
        <div class="company-sign">For {{COMPANY_NAME}}</div>
        <div class="signature-space"></div>
        <div class="signature-role">Authorised Signatory</div>
      </td>
    </tr>
  </table>

  <!-- Footer Note -->
  <div class="footer-note">
    This is a computer generated document and does not require a physical signature.
  </div>

</div>
</body>
</html>