
<div class="a4" style="width: 100%; max-width: 760px; min-height: 297mm; height: auto; margin: 0 auto; background: #ffffff; padding: 44px 46px; 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">
    <table class="page-root" style="width: 100%; border-collapse: collapse">
      <thead style="display: table-header-group">
        <tr>
          <td style="padding: 0; border: 0; vertical-align: top">
            <div class="ph" style="display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2.5px solid #6c3fc5; padding-bottom: 16px; margin-bottom: 18px; 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: 52px; max-width: 140px; object-fit: contain; margin-bottom: 9px" />
                <div class="logo-badge" style="width: 52px; height: 52px; border-radius: 11px; background: #6c3fc5; color: #fff; display: none; place-items: center; font-size: 19px; font-weight: 700; font-family: 'DM Serif Display', Georgia, serif; margin-bottom: 9px">{{company.badgeLetter}}</div>
                {{else}}
                <div class="logo-badge" style="width: 52px; height: 52px; border-radius: 11px; background: #6c3fc5; color: #fff; display: grid; place-items: center; font-size: 19px; font-weight: 700; font-family: 'DM Serif Display', Georgia, serif; margin-bottom: 9px">{{company.badgeLetter}}</div>
                {{/if}}
                <div class="dn" style="font-family: 'DM Serif Display', Georgia, serif; font-size: 19px; color: #191727; line-height: 1.15">{{company.legalName}}</div>
                <div class="dm" style="font-size: 9.5px; color: #6E6B7C; margin-top: 5px; line-height: 1.6">
                  {{company.addr}}<br />
                  {{#if company.phone}}{{company.phone}} · {{/if}}{{#if company.email}}{{company.email}} · {{/if}}{{company.web}}
                </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: 25px; color: #6c3fc5; text-align: right; line-height: 1">{{docTitle}}</div>
                <div class="dmeta" style="margin-top: 11px; font-size: 9.5px; text-align: right; color: #6E6B7C">
                  <div style="margin-top: 2.5px; 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>
              </div>
            </div>
          </td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td style="padding: 0; border: 0; vertical-align: top">

    <div class="two" style="break-inside: avoid; page-break-inside: avoid; display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-bottom: 16px">
      <div class="blk">
        <div class="bt" style="font-size: 10px; font-weight: 700; color: #54505E; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; margin-top: 2px">Client for</div>
        <b style="font-size: 11.5px; color: #191727">{{buyer.nameLine}}</b>
        {{#if buyer.addr}}<div style="color: #54505E; margin-top: 2px; font-size: 10px">{{buyer.addr}}</div>{{/if}}
      </div>
      <div class="blk">
        <div class="bt" style="font-size: 10px; font-weight: 700; color: #54505E; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; margin-top: 2px">As at</div>
        <b style="font-size: 11.5px; color: #191727">{{asAtDate}}</b>
        <div style="color: #54505E; margin-top: 2px; font-size: 10px">All open and settled documents</div>
      </div>
    </div>

    <div class="ctx" style="break-inside: avoid; page-break-inside: avoid; border: 1px solid #E6E4EC; border-radius: 8px; overflow: hidden; margin-bottom: 16px">
      <div class="ctxh" style="background: #F4F1FE; padding: 7px 12px; font-size: 8px; font-weight: 700; color: #6c3fc5; text-transform: uppercase; letter-spacing: .1em">Property &amp; contract</div>
      <div class="ctxg" style="display: grid; grid-template-columns: repeat(4, 1fr)">
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <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: 3px">{{propertyCtx.project}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <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: 3px">{{propertyCtx.unit}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Sale</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 3px">{{propertyCtx.saleRef}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Anticipated handover</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 3px">{{propertyCtx.handover}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Unit type</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 3px">{{propertyCtx.unitType}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Area</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 3px">{{propertyCtx.area}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Payment scheme</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 3px">{{propertyCtx.paymentScheme}}</div>
        </div>
        <div class="ctxc" style="padding: 9px 12px; border-right: 0; border-bottom: 0">
          <div class="ctxl" style="font-size: 8px; color: #8A8A93; text-transform: uppercase; letter-spacing: .06em">Total sales value</div>
          <div class="ctxv" style="font-size: 10.5px; font-weight: 600; color: #191727; margin-top: 3px">{{{propertyCtx.totalSalesValue}}}</div>
        </div>
      </div>
    </div>

    <table class="it" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0">
      <thead style="display: table-header-group">
        <tr style="break-inside: avoid; page-break-inside: avoid">
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; text-align: left; font-weight: 700">Invoice reference</th>
          <th style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; text-align: left; font-weight: 700">Description</th>
          <th class="r" style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; text-align: right; font-weight: 700">Due</th>
          <th class="r" style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; text-align: right; font-weight: 700">Total</th>
          <th class="r" style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; text-align: right; font-weight: 700">Received</th>
          <th class="r" style="background: #191727; color: #fff; font-size: 8px; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; text-align: right; font-weight: 700">Outstanding</th>
        </tr>
      </thead>
      <tbody>
        {{#if hasDocuments}}
          {{#each documents}}
          <tr style="break-inside: avoid; page-break-inside: avoid">
            <td class="itd" style="font-weight: 600; color: #191727; padding: 9px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top">{{docNo}}</td>
            <td style="padding: 9px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top">
              <div class="its" style="font-size: 9.5px; color: #8A8A93; margin-top: 2px">
                {{description}}{{#if isOverdue}} · <span class="overdue-label" style="color: #B3261E; font-weight: 700">Overdue</span>{{/if}}
              </div>
            </td>
            <td class="r" style="padding: 9px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 10px">{{dueDate}}</td>
            <td class="r" style="padding: 9px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 10px">{{total}}</td>
            <td class="r" style="padding: 9px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 10px">{{received}}</td>
            <td class="r {{#if isOverdue}}overdue-amt{{/if}}" style="padding: 9px 10px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: right; font-family: 'IBM Plex Mono', monospace; font-size: 10px"><b>{{outstanding}}</b></td>
          </tr>
          {{/each}}
        {{else}}
          <tr style="break-inside: avoid; page-break-inside: avoid">
            <td colspan="6" style="padding: 16px; border-bottom: 1px solid #EFEEF4; vertical-align: top; text-align: center; color: #8A8A93">No payment schedule on this sale.</td>
          </tr>
        {{/if}}
      </tbody>
    </table>
    {{#if hasDocuments}}
    <table class="it-totals" style="break-inside: avoid; page-break-inside: avoid; width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 14px">
      <tr class="tfoot-grand">
        <td colspan="3" style="background: #191727; color: #fff; font-weight: 700; padding: 9px 10px; border-bottom: 0">Grand total</td>
        <td class="r" style="background: #191727; color: #fff; font-weight: 700; padding: 9px 10px; border-bottom: 0; font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-align: right">{{{totals.currencySymbol}}} {{totals.grandTotal}}</td>
        <td class="r" style="background: #191727; color: #fff; font-weight: 700; padding: 9px 10px; border-bottom: 0; font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-align: right">{{{totals.currencySymbol}}} {{totals.grandReceived}}</td>
        <td class="r" style="background: #191727; color: #fff; font-weight: 700; padding: 9px 10px; border-bottom: 0; font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-align: right">{{{totals.currencySymbol}}} {{totals.grandOutstanding}}</td>
      </tr>
      <tr class="tfoot-overdue">
        <td colspan="5" style="background: #FCE9E7; color: #B3261E; font-weight: 700; padding: 9px 10px; border-bottom: 0">Total overdue amount</td>
        <td class="r" style="background: #FCE9E7; color: #B3261E; font-weight: 700; padding: 9px 10px; border-bottom: 0; font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-align: right">{{totals.totalOverdue}}</td>
      </tr>
    </table>
    {{/if}}

    <div class="pay" style="break-inside: avoid; page-break-inside: avoid; border: 1px solid #E6E4EC; border-left: 3px solid #6c3fc5; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px">
      <div class="bt" style="font-size: 8px; font-weight: 700; color: #6c3fc5; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px">Payment instructions</div>
      {{#if paymentInstructions.hasAccount}}
      <div class="payg" style="display: grid; grid-template-columns: 1fr 1fr; gap: 5px 20px; margin-top: 7px">
        <div><div class="payl" style="font-size: 8.5px; color: #8A8A93; text-transform: uppercase; letter-spacing: .05em">Bank</div><div class="payv" style="font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #191727; font-weight: 600">{{paymentInstructions.bank}}</div></div>
        <div><div class="payl" style="font-size: 8.5px; color: #8A8A93; text-transform: uppercase; letter-spacing: .05em">Account name</div><div class="payv" style="font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #191727; font-weight: 600">{{paymentInstructions.accountName}}</div></div>
        <div><div class="payl" style="font-size: 8.5px; color: #8A8A93; text-transform: uppercase; letter-spacing: .05em">Account No</div><div class="payv" style="font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #191727; font-weight: 600">{{paymentInstructions.accountNo}}</div></div>
        <div><div class="payl" style="font-size: 8.5px; color: #8A8A93; text-transform: uppercase; letter-spacing: .05em">IBAN</div><div class="payv" style="font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #191727; font-weight: 600">{{paymentInstructions.iban}}</div></div>
        <div><div class="payl" style="font-size: 8.5px; color: #8A8A93; text-transform: uppercase; letter-spacing: .05em">SWIFT / BIC</div><div class="payv" style="font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: #191727; font-weight: 600">{{paymentInstructions.swift}}</div></div>
      </div>
      {{else}}
      <div class="esc err" style="background: #FCE9E7; border-radius: 6px; padding: 7px 10px; margin-top: 9px; font-size: 9px; color: #8E1D17; line-height: 1.5">
        <b>No receiving account could be resolved.</b><br />
        {{paymentInstructions.missingReason}}
      </div>
      {{/if}}
    </div>

          </td>
        </tr>
      </tbody>
      <tfoot style="display: table-footer-group">
        <tr>
          <td style="padding: 0; border: 0; vertical-align: top">
            <div class="pf" style="display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid #EFEEF4; margin-top: 14px; padding-top: 10px; font-size: 8px; color: #8A8A93">
              <div>
                {{footer.legalName}}<br />
                Generated {{footer.generatedDate}}
              </div>
              <div style="text-align: right">
                <div class="qr" style="width: 56px; height: 56px; 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>
            </div>
          </td>
        </tr>
      </tfoot>
    </table>
  </div>
