/* AiB Platform — paper documents: the invoice / proposal sheet, its BG
   requisites, the generated official document, and their print rules. */

.paper-stage { display: flex; justify-content: center; padding: clamp(16px, 3vh, 32px) 0; }
.paper {
  width: min(760px, 100%);
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(13, 14, 19, 0.08);
  padding: clamp(28px, 4vw, 56px);
}
/* wraps on narrow paper: the mark keeps the first line, the doc type drops
   under it without pushing the sheet wide */
.paper-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 34px; }
.doc-type {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 760;
  font-size: clamp(26px, 4.5vw, 34px);
  letter-spacing: -0.02em;
  text-align: right;
}
.doc-meta { margin-top: 6px; text-align: right; color: var(--grey); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; }
.paper h3 { font-family: var(--font-display); font-weight: 640; font-size: 15px; margin: 0 0 8px; }
.paper .addr { color: var(--grey); font-size: 13.5px; line-height: 1.5; margin: 0; }
table.doc-items { width: 100%; border-collapse: collapse; margin: 28px 0 8px; }
table.doc-items th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grey);
  padding: 9px 10px;
  border-bottom: 1px solid var(--hairline-strong);
}
table.doc-items td { padding: 11px 10px; border-bottom: 1px solid var(--hairline); font-size: 13.5px; }
table.doc-items .num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-totals { margin-left: auto; width: min(300px, 100%); margin-top: 12px; }
.doc-totals .row { display: flex; justify-content: space-between; padding: 7px 10px; font-size: 13.5px; }
.doc-totals .row.grand { border-top: 1px solid var(--hairline-strong); font-weight: 600; margin-top: 4px; padding-top: 11px; }
.sign-box {
  margin-top: 30px;
  padding: 18px 20px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.sign-line {
  height: 54px;
  border: 1px dashed var(--hairline-strong);
  border-radius: 8px;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-dark);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sign-note { margin: 10px 0 0; text-align: center; color: var(--grey); font-size: 11.5px; }

/* ---------- invoice requisites (BG-standard paper) ---------- */
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; }
.doc-parties .party-name { margin: 2px 0 6px; font-weight: 600; font-size: 14px; }
dl.req { margin: 0; }
dl.req > div { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.7; }
dl.req dt { color: var(--grey); min-width: 92px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; padding-top: 2px; }
dl.req dd { margin: 0; overflow-wrap: anywhere; }
.doc-parties .addr { margin-top: 6px; }
.doc-note { margin: 14px 0 0; color: var(--grey); font-size: 12.5px; }
.doc-foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--hairline); }
@media (max-width: 560px) { .doc-parties { grid-template-columns: 1fr; } }

/* ---------- generated official document (document generator) ---------- */
/* The finished document as a paper sheet: serif, pre-wrap (templates carry
   their own line breaks), reads as print. */
.doc-sheet {
  background: var(--paper);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: clamp(22px, 3vw, 40px);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-x: auto;
}
/* The Print button stamps body.print-doc, prints, removes it — only the
   sheet is visible on paper (visibility, not display: the ancestor chain
   must keep its boxes). */
@media print {
  body.print-doc * { visibility: hidden; }
  body.print-doc .doc-sheet, body.print-doc .doc-sheet * { visibility: visible; }
  body.print-doc .doc-sheet {
    position: absolute; left: 0; top: 0; width: 100%;
    border: 0; background: #fff; color: #000;
  }
}
