
<div class="a4" style="width: 100%; max-width: 760px; min-height: 297mm; height: auto; margin: 0 auto; background: #ffffff; padding: 38px 40px; box-sizing: border-box; position: relative; overflow: visible; font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: #242231; font-size: 10.5px; line-height: 1.5">
    <div class="ph" style="display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2.5px solid #6c3fc5; padding-bottom: 14px; margin-bottom: 16px; gap: 20px">
      <div style="flex: 1; min-width: 0">
        {{#if company.logo}}
        <img class="logo-img" src="{{company.logo}}" alt="{{company.legalName}}" onerror="this.style.display='none'; if(this.nextElementSibling) this.nextElementSibling.style.display='grid';" style="max-height: 48px; max-width: 140px; object-fit: contain; margin-bottom: 6px" />
        <div class="logo-badge" style="width: 48px; height: 48px; border-radius: 10px; background: #6c3fc5; color: #fff; display: none; place-items: center; font-size: 20px; font-weight: 700; font-family: 'DM Serif Display', Georgia, serif; margin-bottom: 8px">{{company.badgeLetter}}</div>
        {{else}}
        <div class="logo-badge" style="width: 48px; height: 48px; border-radius: 10px; background: #6c3fc5; color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 700; font-family: 'DM Serif Display', Georgia, serif; margin-bottom: 8px">{{company.badgeLetter}}</div>
        {{/if}}
        <div class="dn" style="font-family: 'DM Serif Display', Georgia, serif; font-size: 18px; color: #191727; line-height: 1.15">{{company.legalName}}</div>
        <div class="dm" style="font-size: 9.5px; color: #6E6B7C; margin-top: 4px; line-height: 1.55">
          {{company.addr}}<br />
          {{#if company.phone}}{{company.phone}} · {{/if}}{{#if company.email}}{{company.email}} · {{/if}}{{company.web}}<br />
          {{#if company.trn}}TRN {{company.trn}}{{/if}}{{#if company.reraNo}} · {{company.reraNo}}{{/if}}
        </div>
      </div>
      <div style="flex: 1; min-width: 0; flex-shrink: 0; text-align: right">
        <div class="dt" style="font-family: 'DM Serif Display', Georgia, serif; font-size: 24px; color: #6c3fc5; text-align: right; line-height: 1">{{docTitle}}</div>
        <div class="dmeta" style="margin-top: 10px; font-size: 9.5px; text-align: right; color: #6E6B7C; white-space: nowrap">
          <div style="margin-top: 3px; white-space: nowrap">Receipt no <b style="color: #191727; font-family: 'IBM Plex Mono', monospace; font-size: 10px; margin-left: 4px">{{receiptNumber}}</b></div>
          <div style="margin-top: 3px; white-space: nowrap">Issue date <b style="color: #191727; font-family: 'IBM Plex Mono', monospace; font-size: 10px; margin-left: 4px">{{issueDate}}</b></div>
          <div style="margin-top: 3px; white-space: nowrap">Against invoice <b style="color: #191727; font-family: 'IBM Plex Mono', monospace; font-size: 10px; margin-left: 4px">{{against.invoiceNo}}</b></div>
        </div>
      </div>
    </div>

    <div class="two" style="display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 14px">
      <div class="blk">
        <div class="bt" style="font-size: 10px; font-weight: 700; color: #54505E; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; margin-top: 2px">Received from</div>
        <b style="font-size: 11.5px; color: #191727">{{buyer.name}}</b>
        {{#if buyer.addr}}<div style="color: #54505E; margin-top: 2px; font-size: 10px">{{buyer.addr}}</div>{{/if}}
        {{#if buyer.email}}<div style="color: #54505E; margin-top: 2px; font-size: 10px">{{buyer.email}}</div>{{/if}}
      </div>
      <div class="blk">
        <div class="bt" style="font-size: 10px; font-weight: 700; color: #54505E; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; margin-top: 2px">Against document</div>
        <b style="font-size: 11.5px; color: #191727">{{against.invoiceNo}}</b>
        <div style="color: #54505E; margin-top: 2px; font-size: 10px">{{against.sourceLabel}}{{#if against.unit}} · {{against.unit}}{{/if}}</div>
      </div>
    </div>

    {{#if propertyCtx.hasContext}}
    <div class="ctx" style="border: 1px solid #E6E4EC; border-radius: 8px; overflow: hidden; margin-bottom: 14px">
      <div class="ctxh" style="background: #F4F1FE; padding: 6px 12px; font-size: 8px; font-weight: 700; color: #6c3fc5; text-transform: uppercase; letter-spacing: .08em">Property & contract</div>
      <div class="ctxg" style="display: grid; grid-template-columns: repeat(4, 1fr)">
        <div class="ctxc" style="padding: 8px 12px; border-right: 1px solid #EFEEF4">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Project</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 2px">{{propertyCtx.project}}</div>
        </div>
        <div class="ctxc" style="padding: 8px 12px; border-right: 1px solid #EFEEF4">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Unit</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 2px">{{propertyCtx.unit}}</div>
        </div>
        <div class="ctxc" style="padding: 8px 12px; border-right: 1px solid #EFEEF4">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Sale / SPA</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 2px">{{propertyCtx.saleRef}}</div>
        </div>
        <div class="ctxc" style="padding: 8px 12px; border-right: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">{{propertyCtx.transactionLabel}}</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 2px">{{propertyCtx.transactionValue}}</div>
        </div>
      </div>
    </div>
    {{/if}}

    <table class="it" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 14px">
      <thead>
        <tr>
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 7px 10px; text-align: left; font-weight: 700">Description</th>
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 7px 10px; text-align: center; font-weight: 700">Date</th>
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 7px 10px; text-align: center; font-weight: 700">Method</th>
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 7px 10px; text-align: center; font-weight: 700">Reference</th>
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 7px 10px; text-align: center; font-weight: 700; white-space: nowrap"><span class="amt" style="white-space:nowrap;display:inline-flex;align-items:center;gap:2px;line-height:1;justify-content:center">Amount ({{{totals.currencySymbol}}})</span></th>
        </tr>
      </thead>
      <tbody>
        {{#if hasPayments}}
          {{#each payments}}
          <tr>
            <td style="padding: 8px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: left">
              <div class="itd" style="font-weight: 600; color: #191727">{{invoiceDesc}}</div>
              {{#if invoiceSub}}<div class="its" style="font-size: 9px; color: #8A8A93; margin-top: 2px">{{invoiceSub}}</div>{{/if}}
            </td>
            <td style="padding: 8px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: center; font-family: 'IBM Plex Mono', monospace; font-size: 10px">{{date}}</td>
            <td style="padding: 8px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: center; font-family: 'IBM Plex Mono', monospace; font-size: 10px">{{method}}</td>
            <td style="padding: 8px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: center; font-family: 'IBM Plex Mono', monospace; font-size: 10px">{{ref}}</td>
            <td style="padding: 8px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: center; font-family: 'IBM Plex Mono', monospace; font-size: 10px"><b>{{amount}}</b></td>
          </tr>
          {{/each}}
        {{else}}
          <tr>
            <td colspan="5" style="padding: 16px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: center; color: #8A8A93">No cleared payments recorded for this invoice.</td>
          </tr>
        {{/if}}
      </tbody>
    </table>

    <div class="sw" style="display: grid; grid-template-columns: 1fr 260px; gap: 22px; margin-bottom: 14px">
      <div class="sched" style="border: 1px solid #E6E4EC; border-radius: 8px; padding: 10px 12px">
        <div class="bt" style="font-size: 8px; font-weight: 700; color: #6c3fc5; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px">Acknowledgement</div>
        <div class="sl" style="font-size: 9.5px; color: #54505E; line-height: 1.5">
          {{acknowledgement}}
        </div>
      </div>

      <div class="sum">
        <div class="sr" style="display: flex; justify-content: space-between; font-size: 10px; padding: 3.5px 0; color: #54505E"><span>Invoice total</span><b style="font-family: 'IBM Plex Mono', monospace; color: #191727">{{totals.invoiceTotal}}</b></div>
        <div class="sr" style="display: flex; justify-content: space-between; font-size: 10px; padding: 3.5px 0; color: #54505E"><span>Received</span><b style="font-family: 'IBM Plex Mono', monospace; color: #191727">{{totals.receivedTotal}}</b></div>
        <div class="sr t" style="display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 9px 12px; color: #fff; background: #6c3fc5; border-radius: 8px; margin-top: 6px; font-weight: 700">
          <span>Balance</span>
          <b class="amt" style="font-family: 'IBM Plex Mono', monospace; color: #fff; white-space:nowrap;display:inline-flex;align-items:center;gap:2px;line-height:1">{{{totals.currencySymbol}}}&nbsp;{{totals.balance}}</b>
        </div>
      </div>
    </div>

    <div class="pf" style="display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid #EFEEF4; margin-top: 16px; padding-top: 8px; font-size: 8px; color: #8A8A93">
      <div>
        {{footer.legalName}}{{#if footer.reraNo}} · {{footer.reraNo}}{{/if}}{{#if footer.trn}} · TRN {{footer.trn}}{{/if}}<br />
        Document {{footer.receiptNumber}} · generated {{footer.generatedDate}}
      </div>
      <div style="text-align: right">
        <div class="qr" style="width: 48px; height: 48px; border: 1px solid #E6E4EC; border-radius: 6px; display: grid; place-items: center; font-size: 7px; color: #B9B6C4; text-align: center">QR<br />verify</div>
        <div style="margin-top: 3px">Page 1 of 1</div>
      </div>
    </div>
  </div>
