/* ==========================================================
   Quarter · printed documents. A4, black ink first:
   everything still reads on a cheap office laser printer.
   ========================================================== */
.docpage { max-width: 900px; margin: 0 auto; }
.doc-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.doc-bar .t { font-weight: 700; }
.doc-bar .sp { flex: 1; }
.sheet-wrap { background: #D9D4CA; border-radius: 14px; padding: 26px; overflow: hidden; }
.sheet-fit { width: 210mm; margin: 0 auto; transform-origin: top right; }

.sheet {
  --d-ink: #111922; --d-line: #CBD2D9; --d-soft: #F3F5F7; --d-mut: #5B6773;
  width: 210mm; min-height: 297mm; background: #fff; color: var(--d-ink);
  padding: 13mm 14mm 11mm; position: relative; display: flex; flex-direction: column;
  box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 18px 40px -14px rgba(0,0,0,.35);
  font-size: 10.5pt; line-height: 1.55; overflow: hidden;
}
.sheet + .sheet { margin-top: 18px; }
.sheet .num { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* letterhead */
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 10px; border-bottom: 2.5px solid var(--d-ink); position: relative; }
.d-head::after { content: ""; position: absolute; left: 0; bottom: -6px; width: 34%; height: 3px; background: var(--accent); }
.d-co { display: flex; gap: 12px; align-items: center; }
.d-logo { width: 15mm; height: 15mm; border-radius: 3mm; background: var(--d-ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20pt; flex: none; box-shadow: inset 0 -2.5mm 0 var(--accent); }
.d-logo-img { width: 17mm; height: 17mm; object-fit: contain; flex: none; }
.d-name { font-size: 16pt; font-weight: 700; line-height: 1.25; }
.d-tag { font-size: 9pt; color: var(--d-mut); }
.d-ids { font-size: 8.5pt; color: var(--d-mut); margin-top: 2px; }
.d-ids i { font-style: normal; margin: 0 6px; }
.d-contact { text-align: left; font-size: 9pt; color: var(--d-mut); line-height: 1.7; padding-top: 4px; }

.d-body { flex: 1; display: flex; flex-direction: column; }

/* title + number box */
.d-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 18px 0 12px; }
.d-title h1 { font-size: 19pt; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.d-sub { font-size: 10pt; color: var(--d-mut); margin-top: 3px; }
.d-no { display: flex; border: 1.5px solid var(--d-ink); border-radius: 2mm; overflow: hidden; flex: none; }
.d-no > div { padding: 4px 12px; text-align: center; min-width: 26mm; }
.d-no > div + div { border-right: 1.5px solid var(--d-ink); }
.d-no span { display: block; font-size: 7.5pt; color: var(--d-mut); font-weight: 600; }
.d-no b { font-size: 12pt; }

/* info boxes */
.d-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(38mm, 1fr)); border: 1px solid var(--d-line); border-radius: 2mm; margin-bottom: 14px; background: var(--d-soft); }
.d-info > div { padding: 6px 10px; }
.d-info > div + div { border-right: 1px solid var(--d-line); }
.d-info span { display: block; font-size: 7.5pt; color: var(--d-mut); font-weight: 600; }
.d-info b { font-size: 10.5pt; }

.d-h { font-size: 10.5pt; font-weight: 700; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.d-h::before { content: ""; width: 3px; height: 12px; background: var(--accent); border-radius: 2px; }

/* tables */
.d-table { width: 100%; border-collapse: collapse; font-size: 9.8pt; }
.d-table thead { display: table-header-group; }
.d-table th { background: var(--d-ink); color: #fff; font-weight: 600; font-size: 8.5pt; padding: 6px 8px; text-align: right; white-space: nowrap; }
.d-table th:first-child { border-radius: 0 1.5mm 0 0; }
.d-table th:last-child { border-radius: 1.5mm 0 0 0; }
.d-table td { padding: 6px 8px; border-bottom: 1px solid var(--d-line); vertical-align: top; }
.d-table tr { break-inside: avoid; }
.d-table .n { text-align: left; direction: ltr; white-space: nowrap; }
.d-table th.n { text-align: left; }
.d-table .c { text-align: center; color: var(--d-mut); }
.d-table th.c { color: #fff; }
.d-table small { color: var(--d-mut); font-size: 8pt; }
.d-table tfoot td { border-top: 2px solid var(--d-ink); border-bottom: 2px solid var(--d-ink); font-weight: 700; background: var(--d-soft); padding: 7px 8px; }
.d-table.zebra tbody tr:nth-child(even) td { background: #FAFBFC; }
.d-table.sm { font-size: 9pt; }
.d-table.sm td { padding: 4px 8px; }
.d-table.half { width: 55%; }
.d-table .d-open td { background: #FFF8EF; font-style: italic; }
.d-mini { font-size: 8pt; color: var(--d-mut); }
.d-empty { text-align: center; color: var(--d-mut); padding: 18px !important; }

/* totals */
.d-split { display: grid; grid-template-columns: 1fr 78mm; gap: 14px; margin-top: 12px; align-items: start; }
.d-totals { width: 100%; border-collapse: collapse; font-size: 10pt; border: 1px solid var(--d-line); border-radius: 2mm; overflow: hidden; }
.d-totals th { text-align: right; font-weight: 500; padding: 6px 10px; color: var(--d-mut); border-bottom: 1px solid var(--d-line); }
.d-totals td { text-align: left; direction: ltr; padding: 6px 10px; font-weight: 600; border-bottom: 1px solid var(--d-line); white-space: nowrap; }
.d-totals tr.grand th, .d-totals tr.grand td { background: var(--d-ink); color: #fff; font-weight: 700; font-size: 12pt; border: 0; padding: 9px 10px; }
.d-words { margin-top: 10px; border: 1px dashed var(--d-mut); border-radius: 2mm; padding: 7px 12px; font-weight: 600; font-size: 10pt; background: #FFFCF7; }
.d-words span { display: inline-block; font-size: 8pt; color: var(--d-mut); margin-left: 10px; font-weight: 600; }
.d-hint { font-size: 8.5pt; color: var(--d-mut); margin-top: 4px; }
.d-notes { border-right: 3px solid var(--accent); background: var(--d-soft); padding: 6px 10px; font-size: 9.5pt; margin-bottom: 8px; }
.d-notes b { display: block; font-size: 8pt; color: var(--d-mut); }
.d-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.d-kpis > div { border: 1px solid var(--d-line); border-radius: 2mm; padding: 7px 10px; }
.d-kpis span { display: block; font-size: 8pt; color: var(--d-mut); font-weight: 600; }
.d-kpis b { font-size: 12pt; }
.d-kpis .in b { color: #1E6B51; }
.d-kpis .out b { color: #B4321F; }
.d-kpis .end { background: var(--d-ink); color: #fff; border-color: var(--d-ink); }
.d-kpis .end span { color: #AEB8C2; }

/* signatures */
.d-signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(30mm, 1fr)); gap: 10mm; margin-top: auto; padding-top: 16mm; break-inside: avoid; }
.d-signs div { text-align: center; font-size: 9pt; }
.d-signs span { font-weight: 700; display: block; }
.d-signs i { display: block; height: 12mm; border-bottom: 1px solid var(--d-ink); margin: 0 4mm; }
.d-signs small { color: var(--d-mut); font-size: 7.5pt; }

/* footer */
.d-foot { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--d-line); margin-top: 8mm; padding-top: 5px; font-size: 8pt; color: var(--d-mut); }

/* draft watermark / approved stamp */
.d-wm { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110pt; font-weight: 700; color: rgba(194, 100, 28, .07); transform: rotate(-28deg); pointer-events: none; z-index: 0; }
.d-stamp {
  position: absolute; left: 66mm; top: 14mm; transform: rotate(-7deg); z-index: 2; background: rgba(255,255,255,.6);
  border: 2.5px double #1E6B51; color: #1E6B51; border-radius: 3mm; padding: 2mm 6mm; font-weight: 700; font-size: 15pt; opacity: .8;
}
.sheet > *:not(.d-wm):not(.d-stamp) { position: relative; z-index: 1; }
.sheet td.num, .sheet th.num { display: table-cell; }
.d-table td.u { color: var(--d-mut); font-size: 8.5pt; text-align: center; white-space: nowrap; }

/* receipt: half-page voucher */
.sheet.receipt { min-height: 148mm; }
.r-amount { display: inline-flex; align-items: baseline; gap: 10px; border: 2px solid var(--d-ink); border-radius: 2mm; padding: 6px 16px; margin-bottom: 12px; align-self: flex-start; }
.r-amount span { font-size: 9pt; color: var(--d-mut); font-weight: 600; }
.r-amount b { font-size: 18pt; }
.r-amount small { color: var(--d-mut); }
.r-box { display: flex; flex-direction: column; flex: 1; }
.r-lines > div { display: flex; gap: 10px; align-items: baseline; border-bottom: 1px dotted #9AA4AE; padding: 7px 0; }
.r-lines span { font-size: 9.5pt; color: var(--d-mut); white-space: nowrap; min-width: 34mm; }
.r-lines b { font-weight: 600; }
.r-lines .two { gap: 26px; }
.r-lines .two > div { display: flex; gap: 10px; align-items: baseline; }
.r-lines .two span { min-width: 0; }
.sheet.receipt .d-signs { padding-top: 10mm; }

/* ---------------- print ---------------- */
@media print {
  @page { size: A4; margin: 9mm 0; }
  html, body { background: #fff !important; }
  .side, .top, .mob-nav, .doc-bar, .toast, #layer, .no-print { display: none !important; }
  .shell, .main { display: block !important; }
  .view { padding: 0 !important; max-width: none !important; margin: 0 !important; animation: none !important; }
  .docpage { max-width: none; }
  .sheet-wrap { background: none; padding: 0; border-radius: 0; }
  .sheet-fit { zoom: 1 !important; width: auto; }
  .sheet { box-shadow: none; margin: 0 !important; min-height: 278mm; width: 210mm; padding-top: 3mm; padding-bottom: 0; break-after: page; }
  .sheet.receipt { min-height: 0; }
  .sheet:last-child { break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* sources & uses: two columns, grouped rows */
.d-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-table tr.d-grp td { background: var(--d-soft); font-weight: 700; font-size: 8.5pt; color: var(--d-mut); padding: 4px 8px; }
.d-notes b + * { display: inline; }
/* totals row prints once, at the end — not repeated at the foot of every page */
.d-table tfoot { display: table-row-group; }
