/* Лист сметы A4: 794×1123 px = 210×297 мм при 96 dpi.
   Отступы внутри блоков — только padding, чтобы замеры высоты совпадали со страницей. */
.doc {
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  /* без tabular-nums: html2canvas рисует текст на canvas без этой настройки, и цифры «разъезжаются» */
  font-variant-numeric: normal;
  overflow-wrap: break-word;
  color: #252B30;
  text-align: left;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.doc * { box-sizing: border-box; }
.doc table { border-spacing: 0; }

.a4 {
  position: relative;
  width: 794px;
  height: 1123px;
  padding: 44px 48px 0;
  background: #FFFFFF;
  overflow: hidden;
}
.a4-bar {
  position: absolute; top: 0; left: 0; right: 0;
  height: 6px;
  background-color: #008F87;
}
.a4-foot {
  position: absolute; left: 48px; right: 48px; bottom: 20px;
  display: flex; justify-content: space-between; gap: 20px;
  padding-top: 8px;
  border-top: 1px solid #E2E7E6;
  font-size: 9.5px;
  color: #7C878C;
}

.doc-measure {
  position: absolute; left: -12000px; top: 0;
  visibility: hidden;
}
.doc-measure > div { display: flow-root; }

/* Шапка */
.d-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 28px;
  padding: 4px 0 18px;
  border-bottom: 2px solid #252B30;
}
.d-co { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.d-logo { display: block; max-width: 150px; max-height: 64px; width: auto; height: auto; margin-bottom: 6px; }
.d-logo.is-brand { max-width: 230px; max-height: 54px; margin-bottom: 4px; }
.d-tagline { margin: 0 0 6px; font-size: 9px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #008F87; }
.d-mark {
  width: 50px; height: 50px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: #2357D9; color: #FFFFFF;
  font-size: 22px; font-weight: 700;
}
.d-co-txt { min-width: 0; }
.d-co-name { margin-bottom: 2px; font-size: 17px; font-weight: 800; line-height: 1.25; color: #252B30; }
.d-co-line { font-size: 10px; line-height: 1.55; color: #4E575D; }
.d-title { flex: none; text-align: right; }
.d-title-word { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: 0.04em; color: #252B30; }
.d-title-sub { margin: 5px 0 10px; font-size: 10.5px; color: #7C878C; }
.d-meta { margin-left: auto; border-collapse: collapse; font-size: 10.5px; }
.d-meta td { padding: 1.5px 0 1.5px 14px; }
.d-meta td:first-child { color: #7C878C; text-align: right; }
.d-meta td:last-child { font-weight: 600; text-align: right; white-space: nowrap; }

/* Заказчик / объект */
.d-parties { display: flex; gap: 12px; padding: 18px 0; }
.d-box {
  flex: 1; min-width: 0;
  padding: 11px 14px 12px;
  border-radius: 8px;
  background: #F5F7F6;
  border-left: 3px solid #008F87;
}
.d-box-label, .d-notes-h, .d-sign-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: #7C878C;
}
.d-box-label { margin-bottom: 3px; }
.d-box-main { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.d-box-sub { margin-top: 2px; font-size: 10.5px; color: #4A505C; }

/* Продолжение на следующих страницах */
.d-mini { padding-bottom: 14px; }
.d-mini-in {
  display: flex; justify-content: space-between; gap: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid #E5E7EB;
  font-size: 10px; color: #4A505C;
}
.d-mini-in b { color: #15171C; }

/* Таблица работ */
.d-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.d-table th {
  padding: 7px 6px;
  background: #252B30; color: #FFFFFF;
  border-bottom: 0;
  font-size: 9.5px; font-weight: 600;
  text-align: left; vertical-align: bottom;
}
.d-table th.c-n, .d-table th.c-u { text-align: center; }
.d-table th.c-q, .d-table th.c-p, .d-table th.c-s { text-align: right; }
.d-table td {
  padding: 6px 6px;
  border-bottom: 1px solid #EBEFEE;
  vertical-align: top;
  font-size: 10.5px;
}
.d-table td.c-n { text-align: center; color: #868C98; font-size: 9.5px; line-height: 1.55; }
.d-table td.c-name { word-wrap: break-word; overflow-wrap: break-word; }
.d-table td.c-u { text-align: center; color: #4A505C; }
.d-table td.c-q, .d-table td.c-p, .d-table td.c-s { text-align: right; white-space: nowrap; }
.d-table td.c-s { font-weight: 600; }
.r-cat td {
  padding: 12px 6px 6px;
  border-bottom: 1.5px solid #008F87;
  font-size: 11px; font-weight: 800; color: #252B30;
}
.r-cat-n { margin-right: 8px; color: #008F87; }
.r-sub td {
  padding: 5px 6px 6px;
  border-bottom: 0;
  text-align: right;
  font-size: 9.5px; color: #868C98;
}
.r-sub td.c-s { font-size: 10.5px; font-weight: 700; color: #15171C; }
.r-empty td { padding: 22px; text-align: center; color: #868C98; }

/* Итоги */
.d-totals { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 16px 0 4px; }
.d-totals-note { padding-top: 4px; font-size: 9.5px; line-height: 1.7; color: #868C98; }
.d-totals-box { width: 300px; flex: none; }
.d-tt { width: 100%; border-collapse: collapse; margin-bottom: 7px; font-size: 11px; }
.d-tt td { padding: 2.5px 2px; color: #4A505C; }
.d-tt td:last-child { text-align: right; font-weight: 500; color: #15171C; white-space: nowrap; }
.d-grand {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #E3F1EF;
  color: #006D68;
}
.d-grand span { font-size: 11px; font-weight: 600; }
.d-grand strong { font-size: 18px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.d-grand small { font-size: 11px; font-weight: 600; }

/* Условия */
.d-note { padding-bottom: 3px; }
.d-note.first { padding-top: 18px; }
.d-notes-h { margin-bottom: 6px; }
.d-note p {
  position: relative;
  margin: 0;
  padding-left: 12px;
  font-size: 10px; line-height: 1.5; color: #4A505C;
  white-space: pre-wrap;
}
.d-note p::before {
  content: '';
  position: absolute; left: 1px; top: 5.5px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #008F87;
}

/* Подписи */
.d-sign { display: flex; gap: 44px; padding-top: 30px; }
.d-sign-col { flex: 1; min-width: 0; }
.d-sign-name { margin-top: 3px; min-height: 16px; font-size: 11px; font-weight: 600; }
.d-sign-line { height: 34px; border-bottom: 1px solid #15171C; }
.d-sign-cap { display: flex; justify-content: space-between; margin-top: 4px; font-size: 8.5px; color: #868C98; }

/* Печать и экспорт */
.print-stage { display: none; }
.export-stage { position: fixed; left: -12000px; top: 0; width: 794px; pointer-events: none; }

@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #FFFFFF !important; margin: 0 !important; }
  body > *:not(#print-stage) { display: none !important; }
  #print-stage { display: block !important; }
  #print-stage .a4 { width: 210mm; height: 296mm; break-after: page; page-break-after: always; }
  #print-stage .a4:last-child { break-after: auto; page-break-after: auto; }
}
