/* =========================================================
   A4 document styling + print rules
   Sheet: 210 × 297 mm, 12 mm margins
   ========================================================= */

:root {
  --doc-w: 210mm;
  --doc-h: 297mm;
  --doc-pad: 12mm;
  --doc-ink: #10242c;
  --doc-muted: #5b7178;
  --doc-line: #dde5e8;
  --doc-brand: #00a2b9;
  --doc-brand-dark: #0b8b99;
}

/* ---------------------------------- sheet ---------------------------------- */

.doc {
  position: relative;
  width: var(--doc-w);
  min-height: var(--doc-h);
  margin: 0 auto;
  padding: var(--doc-pad);
  background: #fff;
  color: var(--doc-ink);
  font-size: 10.5pt;
  line-height: 1.45;
  font-family: var(--font);
  box-shadow: 0 10px 34px rgba(16, 36, 44, .28);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.doc + .doc { margin-top: 22px; }

.doc::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 6.5mm;
  background: linear-gradient(115deg, var(--doc-brand-dark), var(--doc-brand) 55%, #7ed0db);
}

.doc a { color: var(--doc-brand-dark); }

/* ---------------------------------- letterhead ---------------------------------- */

.doc__head {
  position: relative;
  text-align: center;
  padding: 0 0 2.5mm;
  border-bottom: .8pt solid var(--doc-line);
}

/* white "bookmark" card centred over the top band */
.doc__bookmark {
  width: 17mm;
  height: 17mm;
  margin: -9.5mm auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: .6pt solid var(--doc-line);
  border-radius: 3.8mm;
}
.doc__logo {
  width: 13mm;
  height: 13mm;
  object-fit: contain;
}
.doc__mark {
  font-size: 16pt;
  font-weight: 800;
  color: var(--doc-brand-dark);
  line-height: 1;
}

.doc__brandname {
  margin-top: 1.5mm;
  font-size: 13.5pt;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  line-height: 1.1;
}
.doc__brandname span { color: var(--doc-brand-dark); }
.doc__tagline {
  margin-top: .5mm;
  font-size: 7.4pt;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--doc-muted);
}
.doc__tagline--bin {
  margin-top: .3mm;
  font-size: 8pt;
  letter-spacing: .04em;
  text-transform: none;
}

.doc__contact {
  font-size: 11pt;
  color: var(--doc-muted);
  line-height: 1.55;
}
.doc__contact strong { color: var(--doc-ink); font-weight: 700; }
.doc__contact--bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5mm;
  margin-top: 1.5mm;
  font-size: 8.2pt;
}
.doc__contactrow { display: flex; align-items: center; gap: 1.6mm; }
.doc__contactrow svg { flex: none; color: var(--doc-brand-dark); }

.doc__social {
  display: flex;
  justify-content: center;
  gap: 2mm;
  margin-top: 1.5mm;
}
.doc__social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 6.5mm;
  height: 6.5mm;
  border-radius: 50%;
  background: var(--doc-brand);
  color: #fff;
}
.doc__social a:hover { background: var(--doc-brand-dark); }
.doc__social a.doc__social--fb,
.doc__social a.doc__social--item {
  width: auto;
  gap: 1.4mm;
  background: transparent;
  color: var(--doc-ink);
}
.doc__social a.doc__social--fb:hover,
.doc__social a.doc__social--item:hover { background: transparent; }
.doc__socialbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 6.5mm;
  height: 6.5mm;
  border-radius: 50%;
  background: var(--doc-brand);
  color: #fff;
}
.doc__handle {
  font-size: 8.5pt;
  font-weight: 600;
  color: var(--doc-ink);
}

/* ---------------------------------- title bar ---------------------------------- */

.doc__titlerow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8mm;
  margin-top: 7mm;
}

.doc__title {
  font-size: 24pt;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--doc-ink);
  line-height: 1;
}
.doc__title em {
  display: block;
  margin-top: 1.5mm;
  font-size: 8.5pt;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .16em;
  color: var(--doc-brand-dark);
}

.doc__meta {
  min-width: 62mm;
  border-collapse: collapse;
}
.doc__meta td {
  padding: 1.1mm 0;
  font-size: 9.3pt;
}
.doc__meta td:first-child {
  padding-inline-end: 5mm;
  color: var(--doc-muted);
  text-transform: uppercase;
  font-size: 8.2pt;
  font-weight: 700;
  letter-spacing: .05em;
}
.doc__meta td:last-child { text-align: end; font-weight: 700; }
.doc__status {
  display: inline-block;
  padding: .6mm 2.6mm;
  border-radius: 99px;
  font-size: 7.6pt;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  background: #eef2f4;
  color: var(--doc-muted);
}
.doc__status.is-paid { background: #dff3ea; color: #1c8a5a; }
.doc__status.is-unpaid { background: #fbe7e5; color: #c8443c; }
.doc__status.is-partial { background: #fdf1dd; color: #b0771a; }

/* ---------------------------------- parties ---------------------------------- */

.doc__parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6mm;
  margin-top: 7mm;
}
.doc__parties--single { grid-template-columns: 1fr 1fr; }

.party {
  padding: 4mm;
  background: #f6fafb;
  border-inline-start: 2.5pt solid var(--doc-brand);
  border-radius: 2mm;
}
.party__label {
  font-size: 7.6pt;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--doc-brand-dark);
  margin-bottom: 1.6mm;
}
.party__name { font-size: 11.5pt; font-weight: 800; line-height: 1.25; }
.party__lines { margin-top: 1mm; font-size: 9pt; color: var(--doc-muted); white-space: pre-line; }

/* ---------------------------------- items table ---------------------------------- */

.doc__table {
  width: 100%;
  margin-top: 7mm;
  border-collapse: collapse;
  font-size: 9.4pt;
}
.doc__table thead { display: table-header-group; }
.doc__table th {
  padding: 2.4mm 2.6mm;
  background: var(--doc-ink);
  color: #fff;
  font-size: 8pt;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  text-align: start;
}
.doc__table th.right, .doc__table td.right { text-align: end; }
.doc__table th.center, .doc__table td.center { text-align: center; }

.doc__table td {
  padding: 2.6mm;
  border-bottom: .5pt solid var(--doc-line);
  vertical-align: top;
}
.doc__table tbody tr:nth-child(even) td { background: #fafcfc; }
.doc__table td:first-child, .doc__table th:first-child { width: 9mm; text-align: center; color: var(--doc-muted); }

.doc__item { font-weight: 600; }
.doc__itemdesc { display: block; margin-top: .8mm; font-size: 8.3pt; font-weight: 400; color: var(--doc-muted); }
.doc__num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------- totals ---------------------------------- */

.doc__bottom {
  display: grid;
  grid-template-columns: 1fr 74mm;
  gap: 6mm;
  margin-top: 5mm;
  align-items: start;
}

.doc__notes h4 {
  margin-bottom: 1.6mm;
  font-size: 7.8pt;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--doc-brand-dark);
}
.doc__notes p, .doc__notes li { font-size: 8.8pt; color: var(--doc-muted); }
.doc__notes ol { margin: 0; padding-inline-start: 4.5mm; }
.doc__notes li { margin-bottom: .8mm; }
.doc__paymethods {
  display: flex;
  flex-wrap: wrap;
  gap: 1.8mm;
  margin-top: 1mm;
}
.doc__paymethods span {
  padding: .9mm 2.6mm;
  border: .5pt solid var(--doc-line);
  border-radius: 99px;
  background: #f6fafb;
  font-size: 8.2pt;
  font-weight: 600;
  color: var(--doc-muted);
}

.doc__totals {
  border: .5pt solid var(--doc-line);
  border-radius: 2mm;
  overflow: hidden;
}
.doc__trow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4mm;
  padding: 2.3mm 4mm;
  font-size: 9.3pt;
  border-bottom: .5pt solid var(--doc-line);
}
.doc__trow:last-child { border-bottom: 0; }
.doc__trow span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc__trow--muted { color: var(--doc-muted); }
.doc__trow--grand {
  padding: 3.4mm 4mm;
  background: var(--doc-ink);
  color: #fff;
  font-size: 12pt;
}
.doc__trow--grand span:last-child { font-weight: 800; color: #7ed0db; }

.doc__words {
  margin-top: 3mm;
  padding: 2.6mm 4mm;
  background: #f6fafb;
  border: .5pt dashed var(--doc-line);
  border-radius: 2mm;
  font-size: 8.8pt;
}
.doc__words b { color: var(--doc-ink); }

/* ---------------------------------- signature ---------------------------------- */

.doc__signs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10mm;
  margin-top: 12mm;
}
.doc__sign {
  padding-top: 12mm;
  border-bottom: .7pt solid var(--doc-ink);
  font-size: 9pt;
}
.doc__signlabel {
  margin-top: 1.6mm;
  font-size: 8pt;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--doc-muted);
  text-align: center;
}

.doc__foot {
  position: absolute;
  inset-inline: var(--doc-pad);
  bottom: 6mm;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
  padding-top: 2mm;
  border-top: .5pt solid var(--doc-line);
  font-size: 8.6pt;
  color: var(--doc-muted);
}
.doc__footrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4mm;
}
.doc__pageno {
  font-weight: 700;
  color: var(--doc-ink);
  letter-spacing: .03em;
  text-align: end;
}
.doc__footaddr {
  display: flex;
  align-items: center;
  gap: 1.8mm;
  min-width: 0;
}
.doc__footaddr svg { flex: none; color: var(--doc-brand-dark); width: 10.6pt; height: 10.6pt; }

/* footers stamped on continuation pages by Documents.paginate() —
   white band masks whatever content flows behind them */
.doc__foot--pg { background: #fff; }

/* clones for pages 1..n-1: anchored to the bottom of page --pg */
.doc__foot--cont {
  bottom: auto;
  top: calc(var(--pg, 1) * var(--doc-h));
  transform: translateY(calc(-100% - 6mm));
}

/* ---------------------------------- print rules ---------------------------------- */

@page {
  size: A4;
  margin: 0;
}

@media print {
  body {
    background: #fff;
  }
  .login, .app, .toasts, .modal-root, .noprint { display: none !important; }

  .printstage {
    position: static;
    display: block !important;
    padding: 0;
    background: #fff;
    overflow: visible;
  }

  .doc {
    margin: 0;
    padding: var(--doc-pad);
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }
  .doc + .doc { margin-top: 0; } /* override the screen gap — pages must stay aligned */
  .doc:last-child { page-break-after: auto; break-after: auto; }

  .doc__table tr, .doc__trow, .party, .doc__signs { break-inside: avoid; }
}

/* screen-only helpers for the full-screen document view */
.docstage {
  overflow: auto;
  padding: 26px 16px 60px;
  background: #c9d4d8;
  border-radius: var(--r-lg);
}
