/* Печать A4 */

body.print-mode { background: #E9E2D7; }
body.print-mode #publicApp, body.print-mode #adminApp { display: none !important; }
#printRoot { padding: 92px 20px 50px; }

.print-toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: 64px; padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
  background: rgba(255, 253, 250, .95); backdrop-filter: blur(14px);
  border-bottom: 1px solid #E2D9CB;
  box-shadow: 0 4px 20px rgba(46, 36, 64, .06);
}
.print-back { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; color: #5B4A8C; }
.print-back .icon { width: 16px; height: 16px; }
.print-hint { margin-left: auto; font-size: 10px; color: #8A8094; }
.print-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 999px;
  background: #5B4A8C; color: #fff; font-size: 11px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(91, 74, 140, .22);
}
.print-btn .icon { width: 16px; height: 16px; }
.print-btn:hover { background: #453E6F; }

.p-sheet {
  width: 210mm; min-height: 297mm;
  margin: 0 auto; padding: 16mm 17mm 14mm;
  background: #fff; color: #2E2440;
  font-family: 'Manrope', -apple-system, 'Segoe UI', sans-serif;
  font-size: 9.5pt; line-height: 1.5;
  box-shadow: 0 24px 65px rgba(46, 36, 64, .18);
  display: flex; flex-direction: column;
  position: relative;
}
.p-sheet + .p-sheet { margin-top: 22px; }

.p-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 30px;
  padding-bottom: 9mm; border-bottom: 1px solid #E4DACB;
}
.p-brand { display: flex; align-items: center; gap: 10px; }
.p-brand-mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: #5B4A8C; color: #FBF6EC;
  display: grid; place-items: center;
}
.p-brand-mark svg { width: 29px; height: 29px; }
.p-brand > div { display: flex; flex-direction: column; line-height: 1; }
.p-brand strong { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.p-brand span { margin-top: 3px; font-size: 6.5pt; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: #8A8094; }
.p-title { text-align: right; }
.p-title h1 { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 40px; font-weight: 500; line-height: .9; letter-spacing: -.02em; color: #3D3460; }
.p-title > span { display: block; margin-top: 5px; font-size: 9pt; font-weight: 700; color: #5B4A8C; letter-spacing: .04em; }
.p-ref { font-size: 9pt !important; color: #8A8094 !important; }

.p-meta {
  display: grid; grid-template-columns: 1.15fr 1fr .75fr; gap: 8mm;
  padding: 8mm 0 7mm;
}
.p-company h3, .p-client h3, .p-dates h3, .p-note h3 {
  margin: 0 0 4px; font-size: 6.5pt; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase; color: #9A90A6;
}
.p-company strong, .p-client strong { display: block; font-size: 10pt; font-weight: 800; color: #2E2440; margin-bottom: 2px; }
.p-company span, .p-client span { display: block; font-size: 8.5pt; color: #6E637D; line-height: 1.55; }
.p-dates { display: flex; flex-direction: column; gap: 7px; }
.p-dates > div { display: flex; flex-direction: column; }
.p-dates span { font-size: 6.5pt; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #9A90A6; }
.p-dates strong { font-size: 9pt; font-weight: 700; color: #2E2440; }

.p-table { width: 100%; border-collapse: collapse; margin-top: 2mm; }
.p-table thead th {
  padding: 6px 8px; background: #F4EFE6;
  font-size: 6.5pt; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: #6E637D; text-align: left; border-bottom: 1px solid #E4DACB;
}
.p-table thead th:first-child { border-radius: 5px 0 0 5px; }
.p-table thead th:last-child { border-radius: 0 5px 5px 0; }
.p-table th.num, .p-table td.num { text-align: right; }
.p-table td { padding: 8px; border-bottom: 1px solid #EFE9DF; font-size: 8.5pt; vertical-align: top; }
.p-table tbody tr:last-child td { border-bottom: 1px solid #E4DACB; }

.p-totals-wrap { display: flex; justify-content: space-between; gap: 14mm; margin-top: 7mm; }
.p-note { max-width: 85mm; }
.p-note h3 { margin-top: 5mm; }
.p-note h3:first-child { margin-top: 0; }
.p-note p { margin: 0 0 2mm; font-size: 8pt; color: #6E637D; line-height: 1.55; }
.p-totals { width: 64mm; flex: none; }
.p-totals > div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 8.5pt; color: #6E637D; border-bottom: 1px solid #F0EAE0; }
.p-totals > div strong { color: #2E2440; font-weight: 700; }
.p-totals .grand { margin-top: 2px; padding: 9px 0 7px; border-top: 1.5px solid #3D3460; border-bottom: 0; }
.p-totals .grand span { font-size: 8pt; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #2E2440; }
.p-totals .grand strong { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 24pt; font-weight: 600; color: #453E6F; line-height: 1; }
.p-totals .paid { color: #4F7A5B; border-bottom: 0; }
.p-totals .paid strong { color: #4F7A5B; }
.p-totals .due { padding: 7px 8px; margin-top: 3px; background: #FBF0DD; border: 0; border-radius: 4px; color: #A9742E; }
.p-totals .due strong { color: #A9742E; }
.p-totals > small { display: block; margin-top: 5px; text-align: right; font-size: 6.8pt; color: #9A90A6; }

.p-footer {
  margin-top: auto; padding-top: 7mm; border-top: 1px solid #E4DACB;
  display: flex; justify-content: space-between; gap: 10mm;
  font-size: 7.5pt; color: #8A8094;
}
.p-footer div:last-child { text-align: right; }

.p-empty { margin: auto; text-align: center; color: #8A8094; font-size: 12pt; }

.p-title > .p-paid-badge {
  display: inline-flex; align-items: center;
  margin-top: 2mm; padding: 1.4mm 3.5mm;
  border: 1px solid rgba(79, 122, 91, .35);
  border-radius: 999px;
  background: rgba(79, 122, 91, .08);
  color: #4F7A5B;
  font-family: 'Manrope', sans-serif;
  font-size: 7pt; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
}

/* Report */
.p-report-meta { grid-template-columns: 1fr 1.4fr; align-items: start; }
.p-report-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm 8mm; }
.p-report-kpis > div { padding: 3mm; border: 1px solid #E9E1D5; border-radius: 6px; background: #FBF8F3; }
.p-report-kpis span { display: block; font-size: 6.5pt; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #9A90A6; }
.p-report-kpis strong { display: block; margin-top: 2px; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 18pt; font-weight: 600; color: #453E6F; line-height: 1; }
.p-section-title { margin: 6mm 0 2mm; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 20pt; font-weight: 500; color: #2E2440; }
.p-report-summary { display: flex; gap: 8mm; margin-top: 8mm; padding: 4mm; border-radius: 6px; background: #F7F2E9; }
.p-report-summary > div { flex: 1; }
.p-report-summary span { display: block; font-size: 6.5pt; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #9A90A6; }
.p-report-summary strong { display: block; margin-top: 2px; font-size: 12pt; font-weight: 800; color: #2E2440; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  #publicApp, #adminApp, .print-toolbar, .no-print, #modalRoot, #snackbar { display: none !important; }
  #printRoot { padding: 0 !important; }
  .p-sheet {
    width: 210mm; min-height: 297mm;
    margin: 0; box-shadow: none;
    padding: 14mm 16mm 12mm;
    page-break-after: always;
  }
  .p-sheet:last-child { page-break-after: auto; }
  .p-table tr, .p-totals, .p-header, .p-meta { page-break-inside: avoid; }
  .print-btn, .print-back, .print-hint { display: none !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 900px) {
  #printRoot { padding: 82px 0 30px; overflow-x: auto; }
  .p-sheet { width: 100%; min-width: 700px; padding: 10mm; }
  .print-toolbar { padding: 0 14px; gap: 10px; }
  .print-hint { display: none; }
}
