/* A4 document styles — used in preview + print window */
.sheet {
  width: 210mm;
  min-height: 0;
  background: #fff;
  color: #1a1a1a;
  padding: 10mm 11mm 12mm;
  box-sizing: border-box;
  font-family: "Source Sans 3", Arial, Helvetica, sans-serif;
  position: relative;
}

.sheet-header {
  display: grid;
  grid-template-columns: 48mm 1fr;
  gap: 6mm;
  align-items: start;
  margin-bottom: 4mm;
  padding-bottom: 3mm;
  border-bottom: 1px solid #e4eceb;
}

.logo-box {
  width: 62mm;
  min-height: 22mm;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.brand-mark {
  text-align: left;
  line-height: 1.15;
}

.brand-name {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 20px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -0.02em;
  color: #111;
}

.brand-person {
  margin-top: 1.5mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  color: #222;
}

.logo-box img {
  max-width: 100%;
  max-height: 28mm;
  object-fit: contain;
}

.company {
  font-size: 10.5px;
  line-height: 1.45;
  text-align: right;
  color: #222;
}

.company strong {
  display: block;
  font-size: 12px;
  margin-bottom: 1px;
}

.meta-line {
  text-align: right;
  font-size: 11px;
  margin: 3mm 0 3mm;
  color: #444;
}

.title-bar {
  background: #1a4f4a;
  color: #fff;
  padding: 2.5mm 3.5mm;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: flex;
  flex-wrap: wrap;
  gap: 4mm;
  align-items: baseline;
  margin-bottom: 4mm;
}

.title-bar strong {
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.55);
  min-width: 40mm;
  min-height: 1.1em;
  display: inline-block;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3mm;
  margin-bottom: 3.5mm;
}

.info-grid-3 {
  grid-template-columns: 1.1fr 1.2fr 0.9fr;
}

@media screen and (max-width: 700px) {
  .info-grid-3 {
    grid-template-columns: 1fr;
  }
}

.label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #555;
  margin-bottom: 1.5mm;
}

.value {
  border-bottom: 1px solid #222;
  min-height: 7mm;
  font-size: 13px;
  padding-bottom: 1mm;
  word-break: break-word;
}

.arbeiten { margin-bottom: 3.5mm; }

.arbeiten-text {
  border: 1px solid #222;
  min-height: 0;
  padding: 2.2mm 2.8mm;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fcfefe;
}

.continue-bar {
  display: none;
  background: #1a4f4a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2.2mm 3mm;
  margin: 0 0 5mm;
}

.table-scroll { width: 100%; }

.sheet table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
  margin-bottom: 3.5mm;
  table-layout: fixed;
}

.sheet th,
.sheet td {
  border: 1px solid #222;
  padding: 1.6mm 1.4mm;
  vertical-align: middle;
  word-wrap: break-word;
}

.sheet th {
  background: #efefef;
  font-weight: 700;
  text-align: center;
}

.hours-table td:first-child,
.mat-table td:first-child { text-align: left; }

.hours-table td,
.mat-table td {
  text-align: center;
  height: 7mm;
}

.hours-table th:first-child { width: 28%; }
.mat-table th:first-child { width: 44%; }
.mat-table th:nth-child(2) { width: 14%; }
.mat-table th:nth-child(3) { width: 12%; }
.mat-table th:nth-child(4) { width: 15%; }
.mat-table th:nth-child(5) { width: 15%; }

.sheet-footer {
  margin-top: 2mm;
}

.bottom {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 5mm;
  align-items: stretch;
  margin-bottom: 8mm;
}

.legal {
  font-size: 8.5px;
  line-height: 1.4;
  color: #444;
  border: 1px solid #bbb;
  padding: 2.5mm;
  background: #fafafa;
}

.totals {
  border: 1.5px solid #222;
  padding: 2mm 3mm;
  font-size: 12px;
  align-self: start;
}

.totals > div {
  display: flex;
  justify-content: space-between;
  gap: 4mm;
  padding: 1.4mm 0;
  border-bottom: 1px solid #ddd;
}

.totals > div:last-child { border-bottom: none; }

.totals .total {
  margin-top: 1mm;
  font-size: 13px;
}

.signs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12mm;
  font-size: 10.5px;
  color: #333;
}

.sign-line {
  border-bottom: 1px solid #222;
  height: 14mm;
  margin-bottom: 2mm;
}

/* ===== Print / PDF — clean 1 or 2 pages ===== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .print-hint { display: none !important; }

  .sheet {
    width: 100% !important;
    max-width: none !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet-page2 {
    break-before: page;
    page-break-before: always;
    padding-top: 0;
  }

  .sheet-page2 .continue-bar {
    display: block !important;
  }

  .sheet-header,
  .meta-line,
  .title-bar,
  .info-grid,
  .arbeiten,
  .hours-table,
  .sheet-footer,
  .bottom,
  .signs,
  .totals,
  .legal {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .mat-table thead {
    display: table-header-group;
  }

  .mat-table tr,
  .hours-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .arbeiten-text {
    min-height: 0 !important;
  }

  .hours-table td,
  .mat-table td {
    height: auto;
    min-height: 6.5mm;
  }

  .title-bar,
  .continue-bar {
    background: #1a4f4a !important;
    color: #fff !important;
  }

  .sheet th {
    background: #efefef !important;
  }
}
