/* Quote document.
   ============================================================================
   This file builds the printable A4 quote. Why a separate file? It is loaded
   only on the quote page to avoid pushing print layouts, tables, and signature
   boxes down to the other 500 pages where they are useless weight.
   
   Why local --qdoc-* colours? A physical piece of paper is always white and
   its ink is always dark, no matter what theme the visitor currently uses on
   the site. The root block here defines its own custom properties copied from
   the light theme, isolating the document from dark mode inversions. A lime
   fill never appears on paper; it is reserved for lines.
   
   Why is the footer the table's <tfoot>? A table footer is repeated by the
   browser on every printed sheet, so the LiczMat line and QR close every page
   of a multi-page quote. It was position: fixed until 2026-10-01, when the
   owner's Chrome print preview dropped it. */

.qdoc {
  /* Local color tokens derived from the light theme in styles.css */
  --qdoc-ink: #14181c;          
  --qdoc-muted: #5c6570;        
  --qdoc-accent: #91d206;       
  --qdoc-accent-strong: #476c00;
  --qdoc-line: #e0dacd;         
  --qdoc-surface: #ffffff;      

  color-scheme: light;
  background: var(--qdoc-surface);
  color: var(--qdoc-ink);
  font-family: var(--font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  /* The approved standalone sheet uses the browser's normal leading. The site shell is
     deliberately roomier (1.6), which otherwise adds a second A4 page to the same rows. */
  line-height: normal;
  
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  box-sizing: border-box;
  padding: 14mm 14mm 16mm;
  margin: 0 auto;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  outline: 1px solid var(--qdoc-line);
  position: relative;
}

.qdoc *, .qdoc *::before, .qdoc *::after {
  box-sizing: border-box;
}

.qdoc [hidden] {
  display: none !important;
}

.qdoc.pdf-download-stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 794px;
  max-width: none;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: none;
  z-index: -1;
}

/* Print Container to reserve footer space */
.qdoc-print-wrap {
  width: 100%;
  height: 267mm;
  border-collapse: collapse;
  border: none;
}

.qdoc-print-wrap > tbody > tr > td {
  padding: 0;
}

/* Header Section */
.qdoc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12pt;
}

.qdoc-seller {
  font-size: 9.5pt;
  line-height: 1.4;
}

.qdoc-company-name {
  font-size: 14pt;
  font-weight: 700;
  margin-bottom: 2pt;
}

.qdoc-label {
  color: var(--qdoc-muted);
}

.qdoc-head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.qdoc-logo-box {
  width: 60mm;
  height: 22mm;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}

.qdoc-logo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.qdoc-logo-name {
  display: none;
  font-size: 16pt;
  font-weight: 700;
  color: var(--qdoc-ink);
}

.qdoc.qdoc--no-logo .qdoc-logo {
  display: none;
}

.qdoc.qdoc--no-logo .qdoc-logo-name {
  display: block;
}

/* Title Section */
.qdoc-title {
  text-align: right;
  font-size: 26pt;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--qdoc-accent-strong);
  margin-top: 6pt;
  text-transform: uppercase;
}

/* Meta Data Section */
.qdoc-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12pt;
}

.qdoc-for {
  font-size: 10pt;
  line-height: 1.4;
}

.qdoc-meta-label {
  font-size: 9pt;
  font-weight: 700;
  color: var(--qdoc-accent-strong);
  margin-bottom: 2pt;
  text-transform: uppercase;
}

.qdoc-for-name {
  font-size: 12pt;
  font-weight: 700;
  margin-bottom: 2pt;
}

.qdoc-project-name {
  margin-top: 4pt;
}

.qdoc-details {
  text-align: right;
}

.qdoc-details-list {
  display: table;
  margin: 0 0 0 auto;
}

.qdoc-details-row {
  display: table-row;
}

.qdoc-details-row dt,
.qdoc-details-row dd {
  display: table-cell;
  padding: 2pt 0;
  font-size: 10pt;
}

.qdoc-details-row dt {
  font-weight: 700;
  color: var(--qdoc-accent-strong);
  padding-right: 10pt;
}

.qdoc-details-row dd {
  color: var(--qdoc-ink);
  margin: 0;
}

/* Tables Section */
.qdoc-caption {
  font-size: 11pt;
  font-weight: 700;
  color: var(--qdoc-accent-strong);
  margin-top: 10pt;
  margin-bottom: 4pt;
}

.qdoc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12pt;
  font-size: 10pt;
}

.qdoc-table thead {
  display: table-header-group;
}

.qdoc-table tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

.qdoc-table th {
  font-weight: 700;
  color: var(--qdoc-accent-strong);
  text-align: left;
  border-bottom: 2px solid var(--qdoc-accent);
  padding: 4pt;
}

.qdoc-table td {
  padding: 3pt 4pt;
  border-bottom: 1px solid var(--qdoc-line);
}

.qdoc-col-lp { width: 6%; }
.qdoc-col-desc { width: 44%; }
.qdoc-col-qty { width: 16%; text-align: right; }
.qdoc-col-price { width: 16%; text-align: right; }
.qdoc-col-val { width: 18%; text-align: right; }

.qdoc-table th.qdoc-col-qty,
.qdoc-table th.qdoc-col-price,
.qdoc-table th.qdoc-col-val {
  text-align: right;
}

.qdoc-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Summary Section */
.qdoc-sum-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10mm;
  margin-top: 4pt;
  margin-bottom: 10pt;
  break-inside: avoid;
  page-break-inside: avoid;
}

.qdoc-sum {
  width: 85mm;
  flex: none;
  /* Right-hand, under the Wartość column, also when there are no notes beside it — the
     owner's quote without notes printed it on the left (2026-10-01). */
  margin-left: auto;
  border-collapse: collapse;
  font-size: 10pt;
}

.qdoc-sum td {
  padding: 2pt 4pt;
}

.qdoc-sum th {
  padding: 2pt 4pt;
  text-align: left;
  font-weight: 400;
}

.qdoc-total th,
.qdoc-total td {
  font-weight: 700;
  color: var(--qdoc-accent-strong);
  border-top: 2px solid var(--qdoc-accent);
  border-bottom: 2px solid var(--qdoc-accent);
  padding: 4pt;
  font-size: 11pt;
}

/* Notes Section */
.qdoc-notes {
  flex: 1;
  margin-top: 2pt;
  margin-bottom: 0;
  font-size: 10pt;
  line-height: 1.4;
  break-inside: avoid;
  page-break-inside: avoid;
}

.qdoc-notes-label {
  font-weight: 700;
  color: var(--qdoc-accent-strong);
  margin-bottom: 4pt;
}

.qdoc-notes-text {
  margin-bottom: 8pt;
}

/* Signatures Section */
.qdoc-sign {
  display: flex;
  justify-content: space-between;
  margin-top: 8pt;
  padding: 0 10mm;
  break-inside: avoid;
  page-break-inside: avoid;
}

/* The content row consumes spare paper, leaving the natural-height signature row at its
   bottom. That row occurs once, while the following <tfoot> still repeats on every page. */
.qdoc-print-wrap > tbody > tr:first-child {
  height: 100%;
}

/* A table cell centres by default, which in the downloaded PDF floated a short quote to the
   middle of the sheet. The content starts at the top on screen, on paper and in the file. */
.qdoc-print-wrap > tbody > tr:first-child > td {
  vertical-align: top;
}

.qdoc-sign-row > td {
  padding: 0;
  vertical-align: bottom;
}

.qdoc-sign-box {
  width: 50mm;
  text-align: center;
}

.qdoc-sign-line {
  border-bottom: 1px solid var(--qdoc-accent);
  margin-bottom: 3pt;
  height: 22pt;
}

.qdoc-sign-caption {
  font-size: 9pt;
  color: var(--qdoc-muted);
}

/* Footer Section */
.qdoc-foot {
  border-top: 1px solid var(--qdoc-accent);
  /* 3mm + a 14mm QR: at 4mm + 16mm (2026-09-30) a 5 + 3 line quote with VAT no longer
     fitted one sheet. */
  padding-top: 3mm;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-sizing: border-box;
}

.qdoc-foot-left {
  display: flex;
  align-items: flex-start;
}

.qdoc-foot-mark {
  height: 6mm;
  width: auto;
  margin-right: 8pt;
  margin-top: 1pt;
}

.qdoc-foot-primary {
  font-size: 9pt;
  color: var(--qdoc-ink);
}

.qdoc-foot-secondary {
  font-size: 8pt;
  color: var(--qdoc-muted);
  margin-top: 2pt;
}

.qdoc-foot-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.qdoc-qr {
  width: 14mm;
  height: 14mm;
}

.qdoc-qr-caption {
  font-size: 7pt;
  color: var(--qdoc-ink);
  margin-top: 2pt;
}


/* Narrow screens logic for maximum 390px (and generally below 600px) */
@media screen and (max-width: 600px) {
  .qdoc {
    padding: 16px;
  }
  .qdoc-head {
    flex-direction: column;
    gap: 16px;
  }
  .qdoc-head-right {
    align-items: flex-start;
  }
  .qdoc-logo-box {
    justify-content: flex-start;
  }
  .qdoc-meta {
    flex-direction: column;
    gap: 16px;
  }
  .qdoc-details-list {
    margin: 0;
  }
  .qdoc-table {
    font-size: 8.5pt;
    table-layout: fixed;
  }
  .qdoc-table th,
  .qdoc-table td {
    padding: 3pt 2pt;
    overflow-wrap: anywhere;
    hyphens: auto;
    min-width: 0;
  }
  .qdoc-col-lp { width: 8%; }
  .qdoc-col-desc { width: 34%; }
  .qdoc-col-qty { width: 16%; }
  .qdoc-col-price { width: 20%; }
  .qdoc-col-val { width: 22%; }
  .qdoc-sum-container {
    flex-direction: column;
  }
  .qdoc-sum {
    width: 100%;
  }
  .qdoc-sign {
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 0;
  }
  .qdoc-foot {
    position: static;
    margin-top: 24px;
    flex-direction: column;
    gap: 16px;
  }
  .qdoc-foot-right {
    align-items: flex-start;
  }
}

/* html2canvas cannot ask its clone for print media, so download mode carries the same
   paper switches as print through variables. The layout declarations below are shared. */
.qdoc {
  --qdoc-paper-width: 210mm;
  --qdoc-paper-min-height: 297mm;
  --qdoc-paper-padding: 14mm 14mm 16mm;
  --qdoc-paper-margin: 0 auto;
  --qdoc-paper-shadow: 0 4px 10px rgba(0,0,0,0.1);
  --qdoc-paper-outline: 1px solid var(--qdoc-line);
  --qdoc-paper-background: var(--qdoc-surface);
  --qdoc-paper-wrap-height: 267mm;
  --qdoc-paper-head-space: 0;
  --qdoc-paper-caption-top: 10pt;
  --qdoc-paper-table-bottom: 12pt;
  --qdoc-paper-th-y: 4pt;
  --qdoc-paper-td-y: 3pt;
  --qdoc-paper-foot-padding: 0;
}

.qdoc.qdoc--paper {
  --qdoc-paper-min-height: auto;
  --qdoc-paper-padding: 0 14mm;
  --qdoc-paper-margin: 0;
  --qdoc-paper-shadow: none;
  --qdoc-paper-outline: none;
  --qdoc-paper-background: none;
  --qdoc-paper-wrap-height: 296mm;
  --qdoc-paper-head-space: 12mm;
  --qdoc-paper-caption-top: 6pt;
  --qdoc-paper-table-bottom: 7pt;
  --qdoc-paper-th-y: 3pt;
  --qdoc-paper-td-y: 2pt;
  --qdoc-paper-foot-padding: 3mm 0 10mm;
}

.qdoc {
  width: var(--qdoc-paper-width);
  min-height: var(--qdoc-paper-min-height);
  padding: var(--qdoc-paper-padding);
  margin: var(--qdoc-paper-margin);
  box-shadow: var(--qdoc-paper-shadow);
  outline: var(--qdoc-paper-outline);
  background: var(--qdoc-paper-background);
}

.qdoc-head-space { height: var(--qdoc-paper-head-space); }
.qdoc-caption { margin-top: var(--qdoc-paper-caption-top); }
.qdoc-table { margin-bottom: var(--qdoc-paper-table-bottom); }
.qdoc-table th { padding-top: var(--qdoc-paper-th-y); padding-bottom: var(--qdoc-paper-th-y); }
.qdoc-table td { padding-top: var(--qdoc-paper-td-y); padding-bottom: var(--qdoc-paper-td-y); }
.qdoc-print-wrap { height: var(--qdoc-paper-wrap-height); }
.qdoc-foot-cell { vertical-align: bottom; padding: var(--qdoc-paper-foot-padding); }

@media print {
  @page {
    size: A4;
    margin: 0;
  }
  .qdoc {
    --qdoc-paper-min-height: auto;
    /* The page margin is 0 so the browser has nowhere to print its own date, title and URL
       (2026-10-01: they landed on the owner's quote). The side margins live here instead —
       not on .qdoc-print-wrap, whose collapsed borders make its padding a no-op. */
    --qdoc-paper-padding: 0 14mm;
    --qdoc-paper-margin: 0;
    --qdoc-paper-shadow: none;
    --qdoc-paper-outline: none;
    --qdoc-paper-background: none;
    --qdoc-paper-wrap-height: 296mm;
    --qdoc-paper-head-space: 12mm;
    --qdoc-paper-caption-top: 6pt;
    --qdoc-paper-table-bottom: 7pt;
    --qdoc-paper-th-y: 3pt;
    --qdoc-paper-td-y: 2pt;
    --qdoc-paper-foot-padding: 3mm 0 10mm;
    display: block;
  }
  /* 12mm top and bottom, not the 14/16mm of the old @page margins: the Inne koszty table
     (2026-10-01) made a 5 + 1 + 3 line quote with VAT and margin 4mm too tall for one sheet. */
  /* Why the footer is the table's <tfoot> and not position: fixed (2026-10-01): in the
     owner's Chrome print preview the fixed footer was simply not there, though every
     headless print had it. A table footer is repeated on every sheet by the browser
     itself. The table is one sheet tall, so on a one-page quote the footer sits at the
     bottom of the paper; on a longer one it closes every sheet and follows the last row. */
  .qdoc-print-wrap > tbody > tr > td {
    vertical-align: top;
  }
  .qdoc-print-wrap > tbody > .qdoc-sign-row > td {
    vertical-align: bottom;
  }
}

/*
=============================================================================
MARKUP SKELETON
=============================================================================
<article class="qdoc">
  <table class="qdoc-print-wrap">
    <thead>
      <tr><td><div class="qdoc-head-space"></div></td></tr>
    </thead>
    <tbody>
      <tr><td>
        <div class="qdoc-main">
          
          <header class="qdoc-head">
            <div class="qdoc-seller">
              <div class="qdoc-company-name">Remonty Kowalczyk</div>
              <div>ul. Lipowa 12/3</div>
              <div>31-000 Kraków</div>
              <div><span class="qdoc-label">NIP</span> 677-123-45-67</div>
              <div><span class="qdoc-label">tel.</span> 600 100 200</div>
              <div><span class="qdoc-label">e-mail</span> biuro@remonty-kowalczyk.pl</div>
              <div>remonty-kowalczyk.pl</div>
            </div>
            <div class="qdoc-head-right">
              <div class="qdoc-logo-box">
                <img class="qdoc-logo" src="logo.png" alt="Logo firmy">
                <div class="qdoc-logo-name">Remonty Kowalczyk</div>
              </div>
              <div class="qdoc-title">WYCENA</div>
            </div>
          </header>

          <div class="qdoc-meta">
            <div class="qdoc-for">
              <div class="qdoc-meta-label">Dla</div>
              <div class="qdoc-for-name">Anna Nowak</div>
              <div>ul. Słoneczna 5</div>
              <div>30-300 Kraków</div>
              <div>tel. 501 222 333</div>
              <div>anna.nowak@example.pl</div>
              <div class="qdoc-project-name"><span class="qdoc-label">Projekt:</span> Łazienka, ul. Słoneczna</div>
            </div>
            <div class="qdoc-details">
              <dl class="qdoc-details-list">
                <div class="qdoc-details-row"><dt>Nr wyceny</dt><dd>W/2026/007</dd></div>
                <div class="qdoc-details-row"><dt>Data</dt><dd>30.09.2026</dd></div>
                <div class="qdoc-details-row"><dt>Ważna do</dt><dd>30.10.2026</dd></div>
              </dl>
            </div>
          </div>

          <div class="qdoc-caption">Materiały</div>
          <table class="qdoc-table">
            <thead>
              <tr>
                <th class="qdoc-col-lp">Lp.</th>
                <th class="qdoc-col-desc">Opis</th>
                <th class="qdoc-col-qty">Ilość</th>
                <th class="qdoc-col-price">Cena jedn. (zł)</th>
                <th class="qdoc-col-val">Wartość (zł)</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>1</td>
                <td>Płytki gresowe 60×60</td>
                <td class="qdoc-num">12,5 m²</td>
                <td class="qdoc-num">89,00</td>
                <td class="qdoc-num">1 112,50</td>
              </tr>
            </tbody>
          </table>

          <div class="qdoc-sum-container">
            <div class="qdoc-notes">
              <div class="qdoc-notes-label">Uwagi</div>
              <div class="qdoc-notes-text">Cena obejmuje transport materiałów. Termin realizacji: 5 dni roboczych od akceptacji wyceny.</div>
              <div class="qdoc-notes-payment">Płatność przelewem na konto: <strong style="white-space:nowrap">PL 12 3456 7890 1234 5678 9012 3456</strong></div>
            </div>
            <table class="qdoc-sum">
              <tbody>
                <tr><td>Materiały</td><td class="qdoc-num">1 951,50 zł</td></tr>
                <tr><td>Robocizna</td><td class="qdoc-num">2 380,00 zł</td></tr>
                <tr><td>Suma</td><td class="qdoc-num">4 331,50 zł</td></tr>
                <tr><td>Marża 10 %</td><td class="qdoc-num">433,15 zł</td></tr>
                <tr><td>Netto</td><td class="qdoc-num">4 764,65 zł</td></tr>
                <tr><td>VAT 8 %</td><td class="qdoc-num">381,17 zł</td></tr>
                <tr class="qdoc-total"><td>Razem (PLN)</td><td class="qdoc-num">5 145,82 zł</td></tr>
              </tbody>
            </table>
          </div>

          <div class="qdoc-sign">
            <div class="qdoc-sign-box">
              <div class="qdoc-sign-line"></div>
              <div class="qdoc-sign-caption">Wykonawca</div>
            </div>
            <div class="qdoc-sign-box">
              <div class="qdoc-sign-line"></div>
              <div class="qdoc-sign-caption">Zleceniodawca</div>
            </div>
          </div>

        </div>
      </td></tr>
    </tbody>
    <tfoot>
      <tr><td class="qdoc-foot-cell">
  <footer class="qdoc-foot">
    <div class="qdoc-foot-left">
      <img src="logo-mark.svg" alt="LiczMat" class="qdoc-foot-mark">
      <div class="qdoc-foot-text">
        <div class="qdoc-foot-primary">Wycena przygotowana w LiczMat · liczmat.com</div>
        <div class="qdoc-foot-secondary">Aplikacja LiczMat na Androida w Google Play</div>
      </div>
    </div>
    <div class="qdoc-foot-right">
      <img src="qr-liczmat.svg" alt="QR code" class="qdoc-qr">
      <div class="qdoc-qr-caption">liczmat.com</div>
    </div>
  </footer>
      </td></tr>
    </tfoot>
  </table>
</article>
*/
/* Public quote: fit the A4 sheet to a phone without horizontal page scrolling. */
.quo-share-panel { width: 100%; padding: 1rem; border: 1px solid var(--outline); border-radius: var(--radius); }
.quo-share-link { display: flex; gap: .5rem; }
.quo-share-link input { flex: 1; min-width: 0; }
.quo-share-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.quote-view-wrap { max-width: 1100px; padding-block: 2rem; }
.quote-view-toolbar { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 1rem; }
.quote-view-download-error { align-self: center; color: var(--error); flex-basis: 100%; }
.quote-view-page #ws-pdf { margin: 0; }
.quote-view-page #pdf-tool { overflow: visible; }
.quote-view-page .qdoc { margin-inline: auto; }
@media (max-width: 800px) {
  .quote-view-page .qdoc { transform: scale(calc((100vw - 24px) / 794)); transform-origin: top left; margin: 0; }
  .quote-view-page #pdf-tool { width: calc(794px * ((100vw - 24px) / 794)); }
}
@media print {
  .quote-view-toolbar, .quote-view-main > .wrap > h1, #quote-view-state { display: none !important; }  .quote-view-page .qdoc { transform: none !important; }
}
