/* ==========================================================================
   Печатные формы
   Документы, которые печатают на бумаге: путевой лист, ведомость парка.
   ========================================================================== */

/* ---------- Экранный просмотр бланка ---------- */

.print-sheet {
  background: #fff;
  color: #111;
  padding: 1.5rem;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  font-size: .875rem;
  line-height: 1.45;
  max-width: 900px;
  margin: 0 auto;
}

.print-sheet h1,
.print-sheet h2,
.print-sheet h3 { color: #000; }

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 2px solid #000;
  margin-bottom: 1rem;
}

.sheet-org { font-size: .8125rem; line-height: 1.4; }
.sheet-org strong { display: block; font-size: .9375rem; margin-bottom: .1875rem; }

.sheet-title {
  text-align: right;
}
.sheet-title .doc-name {
  font-size: 1.125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sheet-title .doc-no { font-size: .75rem; color: #555; margin-top: .1875rem; }

/* Поля бланка */
.sheet-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem 1.5rem;
  margin-bottom: 1rem;
}

.field-row {
  display: flex;
  align-items: baseline;
  gap: .375rem;
  border-bottom: 1px dotted #999;
  padding-bottom: .125rem;
  min-height: 1.5rem;
}

.field-row .field-label {
  font-size: .75rem;
  color: #444;
  white-space: nowrap;
  flex-shrink: 0;
}

.field-row .field-value {
  font-weight: 600;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.field-row.wide { grid-column: 1 / -1; }

/* Таблицы бланка */
.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .75rem;
  margin: .75rem 0;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #666;
  padding: .3125rem .4375rem;
  text-align: left;
  vertical-align: top;
}

.sheet-table th {
  background: #eee;
  font-weight: 700;
  font-size: .6875rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.sheet-table tbody tr:nth-child(even) td { background: #fafafa; }
.sheet-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet-table tfoot td { font-weight: 700; background: #eee; }

/* Место для рукописного ввода */
.sheet-blank {
  display: inline-block;
  min-width: 90px;
  border-bottom: 1px solid #333;
  height: 1.1rem;
}

.sheet-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 1.75rem;
  page-break-inside: avoid;
}

.signature {
  border-top: 1px solid #000;
  padding-top: .3125rem;
  text-align: center;
  font-size: .6875rem;
}

.signature .sign-role { font-weight: 700; display: block; margin-bottom: .125rem; }

.sheet-note {
  font-size: .6875rem;
  color: #555;
  margin-top: .75rem;
  padding-top: .5rem;
  border-top: 1px solid #ddd;
}

.sheet-totals {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
  font-size: .8125rem;
}

.sheet-total {
  display: flex;
  align-items: baseline;
  gap: .375rem;
}

.sheet-total b { font-size: 1.125rem; }

/* Панель действий над бланком */
.print-actions {
  display: flex;
  gap: .625rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.print-actions .spacer { flex: 1; }

/* ---------- Собственно печать ---------- */

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 10mm;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }

  body::before, body::after { display: none !important; }

  /* Скрываем всё, кроме бланка */
  .navbar,
  .footer,
  .flash-stack,
  .mesh-bg,
  .page-head,
  .filter-bar,
  .tabs,
  .no-print,
  .toast-container,
  #cmdkBackdrop,
  .fab,
  .modal-backdrop,
  .skip-link { display: none !important; }

  main { display: block !important; }
  .page { padding: 0 !important; margin: 0 !important; max-width: none !important; }

  .print-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    border-radius: 0 !important;
    font-size: 11pt;
    color: #000 !important;
    background: #fff !important;
  }

  /* Рамки печатаем всегда — иначе таблица «растворяется» */
  .sheet-table th,
  .sheet-table td { border-color: #333 !important; }

  .sheet-table thead { display: table-header-group; }  /* повтор шапки на каждой странице */
  .sheet-table tr { page-break-inside: avoid; }
  .sheet-signatures { page-break-inside: avoid; }
  .sheet-head { page-break-after: avoid; }

  a { color: #000 !important; text-decoration: none !important; }

  /* Ссылка на печать в шапке бланка */
  .print-only { display: block !important; }
}

.print-only { display: none; }

/* Ландшафтная ориентация для широких ведомостей */
@media print {
  .landscape { size: A4 landscape; }
}