/* Sunds Industrier — kvalitetsdokument-stil. A4-utskrift via weasyprint. */

@page {
  size: A4;
  margin: 20mm 18mm 22mm 18mm;

  @bottom-right {
    content: counter(page) " / " counter(pages);
    font-family: "DejaVu Sans", Arial, sans-serif;
    font-size: 9pt;
    color: #555;
  }

  @bottom-left {
    content: string(doctype);
    font-family: "DejaVu Sans", Arial, sans-serif;
    font-size: 9pt;
    color: #555;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "DejaVu Sans", Arial, sans-serif;
  font-size: 10.5pt;
  color: #111;
  line-height: 1.4;
}

/* Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 2px solid #003a6b;
  padding-bottom: 6mm;
  margin-bottom: 8mm;
}

.logo {
  height: 16mm;
  width: auto;
  display: block;
}

.header-meta {
  font-size: 9pt;
  color: #555;
  text-align: right;
}

/* Document title */
.doc-title {
  font-size: 20pt;
  font-weight: 700;
  margin: 0 0 8mm 0;
  color: #003a6b;
  /* Plockar doctype-strängen ur H1:ans text-innehåll → @page footer */
  string-set: doctype content();
}

/* Field tables */
table.fields {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6mm;
}

table.fields th {
  text-align: left;
  width: 45%;
  padding: 2mm 3mm 2mm 0;
  font-weight: 600;
  vertical-align: top;
  border-bottom: 1px solid #ccc;
}

table.fields td {
  padding: 2mm 0;
  border-bottom: 1px solid #ccc;
  vertical-align: top;
}

.statement {
  font-style: italic;
  margin: 6mm 0;
  padding: 4mm 5mm;
  background: #f4f6f9;
  border-left: 3px solid #003a6b;
}

.cert-lead {
  margin: 4mm 0 2mm;
}

table.goods-table {
  margin: 0 0 2mm 0;
  width: 60%;
}

/* Signature section */
.signature-section {
  margin-top: 14mm;
  page-break-inside: avoid;
}

.signature-section h2 {
  font-size: 12pt;
  font-weight: 600;
  border-bottom: 1px solid #003a6b;
  padding-bottom: 1.5mm;
  margin-bottom: 6mm;
}

.signature-block {
  margin-bottom: 10mm;
  page-break-inside: avoid;
}

.signature-block:last-child {
  margin-bottom: 0;
}

.signature-block .signature-role {
  font-weight: 600;
  font-size: 11pt;
  color: #003a6b;
  margin-bottom: 2mm;
}

.signature-place {
  font-size: 11pt;
  margin-bottom: 2mm;
}

.signature-date {
  border-bottom: 1px solid #444;
  padding: 0 6mm;
  display: inline-block;
  min-width: 50mm;
}

.signature-image-row {
  margin: 4mm 0;
  min-height: 18mm;
  display: flex;
  align-items: flex-end;
}

.signature-image {
  max-height: 18mm;
  max-width: 70mm;
}

.signature-unsigned {
  font-weight: 700;
  letter-spacing: 2pt;
  color: #b00020;
  border: 2px dashed #b00020;
  padding: 3mm 6mm;
  display: inline-block;
}

.signature-name-row {
  margin-top: 1mm;
}

.signature-line {
  border-top: 1px solid #444;
  width: 70mm;
  margin-bottom: 1.5mm;
}

.signature-name {
  font-size: 10.5pt;
  font-weight: 600;
}


/* Footer (CSS @page is the real footer; this is fallback) */
.page-footer {
  display: none;
}

/* Section heading (för dokumenttyper med sektioner) */
.section-heading {
  font-size: 12pt;
  font-weight: 600;
  color: #003a6b;
  border-bottom: 1px solid #003a6b;
  padding-bottom: 1mm;
  margin: 6mm 0 3mm 0;
}

/* Grid-tabeller med flera kolumner per rad */
table.fields-grid th {
  width: auto;
  font-size: 9.5pt;
  padding-right: 2mm;
}

table.fields-grid td {
  font-size: 10pt;
  padding-right: 4mm;
}

/* Checkbox-rader (Test regarding, Accepted/Rejected) */
ul.checkbox-row {
  list-style: none;
  padding: 0;
  margin: 2mm 0 4mm 0;
  display: flex;
  gap: 8mm;
  flex-wrap: wrap;
}

ul.checkbox-row li {
  display: flex;
  align-items: center;
  gap: 2mm;
  font-size: 10.5pt;
}

ul.checkbox-row li.checked {
  font-weight: 600;
}

ul.checkbox-row .checkbox {
  display: inline-block;
  width: 4mm;
  height: 4mm;
  border: 1.5px solid #444;
  text-align: center;
  line-height: 3.5mm;
  font-weight: 700;
  color: #003a6b;
}

.result-detail {
  margin: 2mm 0;
  padding: 2mm 4mm;
  background: #f4f6f9;
  border-left: 3px solid #003a6b;
  font-size: 10pt;
}

/* Visual inspection: två signaturer sida vid sida */
.signatures-side-by-side {
  display: flex;
  gap: 12mm;
}

.signatures-side-by-side .signature-block {
  flex: 1;
}

/* Item-tabell (Heat treatment items etc.) */
table.item-table thead th {
  background: #003a6b;
  color: #fff;
  font-weight: 600;
  font-size: 9.5pt;
  padding: 2mm 3mm;
  text-align: left;
  width: auto;
}

table.item-table tbody td {
  padding: 2mm 3mm;
  border-bottom: 1px solid #ccc;
}

.procedure-sv {
  margin: 2mm 0 1mm 0;
}

.procedure-en {
  margin: 0 0 4mm 0;
  font-style: italic;
  color: #333;
}

/* Welding plan: sekvens-lista + fritext-avsnitt */
ol.seq-list {
  margin: 1mm 0 4mm 0;
  padding-left: 7mm;
  font-size: 9.5pt;
}
ol.seq-list li { margin: 1mm 0; }
.plan-text {
  margin: 1mm 0 4mm 0;
  font-size: 9.5pt;
  white-space: pre-line;
}

.company-block {
  margin: 4mm 0;
  padding: 3mm 4mm;
  background: #f4f6f9;
  border-left: 3px solid #003a6b;
  font-size: 10pt;
  line-height: 1.5;
}

/* Hand-signatur (utförande företag skriver under på utskriften) */
.hand-sign-row { display: flex; gap: 14mm; margin-top: 10mm; }
.hand-sign-field { flex: 1; max-width: 80mm; }
.hand-sign-field .signature-line { width: 100%; margin-bottom: 1mm; }
.hand-sign-label { font-size: 9pt; color: #555; }

/* Check-tabell (Manufacturing protocol, Workshop inspection) */
table.check-table thead th {
  background: #003a6b;
  color: #fff;
  font-weight: 600;
  font-size: 9.5pt;
  padding: 2mm 3mm;
  text-align: left;
  width: auto;
}

table.check-table tbody td {
  padding: 1.8mm 3mm;
  border-bottom: 1px solid #ccc;
  font-size: 9.5pt;
  vertical-align: top;
}

table.check-table .not-applicable {
  color: #888;
  font-style: italic;
}

table.check-table .row-unsigned {
  background: #fdf3f3;
}

.mini-unsigned {
  color: #b00020;
  font-weight: 700;
  font-size: 8.5pt;
  letter-spacing: 1pt;
}

.drawing-box {
  margin: 4mm 0 6mm;
  text-align: center;
  padding: 4mm;
  border: 1px solid #ddd;
  background: #fafbfc;
}

.drawing-image {
  max-width: 120mm;
  max-height: 70mm;
  width: auto;
  height: auto;
}

table.check-table .check-box {
  text-align: center;
  font-size: 13pt;
  color: #003a6b;
  width: 18mm;
}

/* Workshop inspection: kompakt, en sida */
.wic-compact .doc-title { font-size: 17pt; margin-bottom: 3mm; }
.wic-compact .fixed-statement {
  font-weight: 600;
  color: #003a6b;
  margin: 0 0 4mm;
  padding: 2mm 3mm;
  background: #eef3f8;
  border-left: 3px solid #003a6b;
  font-size: 10pt;
}
.wic-compact table.fields { margin-bottom: 3mm; }
.wic-compact table.fields th,
.wic-compact table.fields td { padding: 1.2mm 3mm 1.2mm 0; font-size: 9.5pt; }
.wic-compact table.check-table thead th { padding: 1.5mm 3mm; }
.wic-compact table.check-table tbody td { padding: 1.2mm 3mm; font-size: 9pt; }
.wic-compact .check-box { font-size: 12pt; width: 12mm; }
.wic-compact .signature-section { margin-top: 6mm; }
.wic-compact .signature-section h2 { font-size: 11pt; margin-bottom: 3mm; }
.wic-compact .sig-line, .wic-compact .signature-line { margin-top: 8mm; }

/* Material certificate index: kompakt för många positioner (15-20 rader, en sida) */
.mci-compact .doc-title { font-size: 16pt; margin-bottom: 2mm; }
.mci-compact .section-heading { margin: 3mm 0 1.5mm; font-size: 11pt; }
.mci-compact table.fields th,
.mci-compact table.fields td { padding: 0.8mm 3mm 0.8mm 0; font-size: 9pt; }
.mci-compact table.check-table thead th { padding: 1mm 2.5mm; font-size: 8.5pt; }
.mci-compact table.check-table tbody td { padding: 0.7mm 2.5mm; font-size: 8.5pt; }
.mci-compact .muted { font-size: 8pt; }
.mci-compact .signature-section { margin-top: 5mm; }
.mci-compact .signature-section h2 { font-size: 10.5pt; margin-bottom: 2mm; padding-bottom: 1mm; }
.mci-compact .signature-image-row { min-height: 12mm; }
.mci-compact .signature-image { max-height: 12mm; }
.mci-compact .signature-line { margin-top: 6mm; }

/* Penetrant: extra tät för att rymmas på en sida */
.pen-compact .doc-title { font-size: 15pt; margin-bottom: 2mm; }
.pen-compact .section-heading { margin: 2mm 0 1mm; font-size: 10.5pt; padding-bottom: 0.5mm; }
.pen-compact table.fields { margin-bottom: 2mm; }
.pen-compact table.fields th,
.pen-compact table.fields td { padding: 0.6mm 3mm 0.6mm 0; font-size: 8.5pt; }
.pen-compact .checkbox-row { margin: 1mm 0 2mm; gap: 5mm; }
.pen-compact .checkbox-row li { font-size: 9pt; }
.pen-compact .result-detail { margin: 1mm 0; padding: 1.5mm 3mm; font-size: 9pt; }
.pen-compact .signature-section { margin-top: 4mm; }
.pen-compact .signature-section h2 { font-size: 10.5pt; margin-bottom: 2mm; }
.pen-compact .signature-image-row { min-height: 10mm; }
.pen-compact .signature-line { margin-top: 5mm; }

.muted {
  color: #777;
  font-size: 8.5pt;
}

.article-entry {
  margin-bottom: 5mm;
  padding-bottom: 3mm;
  border-bottom: 1px solid #ddd;
  page-break-inside: avoid;
}

ul.doc-list {
  margin: 1mm 0 0 0;
  padding-left: 6mm;
  font-size: 9.5pt;
  color: #333;
}

ul.doc-list li {
  margin: 0.5mm 0;
}

/* DRAFT watermark — diagonal across page */
.draft-watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 96pt;
  font-weight: 900;
  color: rgba(176, 0, 32, 0.12);
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: 4pt;
}

/* Contract Review — kompakt enkelsidig layout */
.cr-compact h1.doc-title { font-size: 16pt; margin-bottom: 2mm; }
.cr-compact .sub-info { font-size: 9pt; color: #555; margin: 0 0 4mm; font-style: italic; }
.cr-compact .section-heading { font-size: 11pt; margin-top: 4mm; margin-bottom: 2mm; padding-bottom: 1mm; }
.cr-compact table.fields th, .cr-compact table.fields td { padding: 1mm 2mm; font-size: 9.5pt; }
.cr-compact .signature-section { margin-top: 5mm; }
.cr-compact .signature-section h2 { font-size: 10.5pt; margin-bottom: 2mm; padding-bottom: 1mm; }

table.checklist-table {
  width: 100%; border-collapse: collapse; font-size: 9.5pt; margin-bottom: 3mm;
}
table.checklist-table thead th {
  background: #003a6b; color: #fff; padding: 1.5mm 2mm; font-weight: 600;
  font-size: 9pt; text-align: left;
}
table.checklist-table tbody td {
  padding: 1.5mm 2mm; border-bottom: 1px solid #e0e0e0; vertical-align: top;
}
table.checklist-table .cl-num { width: 6mm; text-align: center; color: #666; }
table.checklist-table .cl-q { width: auto; }
table.checklist-table .cl-a { width: 22mm; font-weight: 600; }
table.checklist-table .cl-a-yes { color: #1b5e20; }
table.checklist-table .cl-a-no { color: #b71c1c; }
table.checklist-table .cl-a-na { color: #6c757d; font-weight: 400; font-style: italic; }
table.checklist-table .cl-c { width: 60mm; color: #333; font-size: 9pt; }

.gap-list { margin: 1mm 0 1mm 5mm; padding: 0; font-size: 9.5pt; }
.gap-list li { margin-bottom: 0.5mm; }
.gap-note { font-size: 9pt; font-style: italic; color: #b71c1c; margin: 1mm 0 0; }

/* ============================================================ */
/* Prestandadeklaration (DoP) — CPR Bilaga III layout            */
/* ============================================================ */
.dop-doc h1.doc-title { font-size: 18pt; margin-bottom: 2mm; letter-spacing: 2pt; }
.dop-doc .dop-number { font-size: 12pt; color: #003a6b; margin: 0 0 6mm; font-weight: 600; }
table.dop-fields { width: 100%; border-collapse: collapse; margin-bottom: 5mm; font-size: 10pt; }
table.dop-fields th { text-align: left; vertical-align: top; padding: 2mm 4mm 2mm 0; width: 38%; color: #003a6b; font-weight: 600; border-bottom: 1px solid #ccc; }
table.dop-fields td { padding: 2mm 0; border-bottom: 1px solid #ccc; vertical-align: top; }
.dop-doc .section-heading { font-size: 12pt; margin-top: 5mm; margin-bottom: 2mm; padding-bottom: 1mm; border-bottom: 2px solid #003a6b; }
table.dop-performance { width: 100%; border-collapse: collapse; font-size: 10pt; margin-bottom: 5mm; }
table.dop-performance thead th { background: #003a6b; color: #fff; padding: 2mm 3mm; text-align: left; font-weight: 600; }
table.dop-performance tbody td { padding: 2mm 3mm; border-bottom: 1px solid #ddd; vertical-align: top; }
table.dop-performance .perf { font-weight: 600; }
table.dop-performance .hts { font-style: italic; color: #555; width: 32mm; }
.dop-statement { font-style: italic; margin: 5mm 0; padding: 3mm 5mm; background: #f4f6f9; border-left: 3px solid #003a6b; font-size: 10pt; }
.dop-doc .signature-name-printed { font-weight: 700; font-size: 11pt; }
.dop-doc .signature-section h2 { font-size: 11pt; }

/* ============================================================ */
/* CE-märkning — EN 1090-1 ZA.3 layout                          */
/* ============================================================ */
.ce-doc { font-size: 10pt; }
.ce-symbol-row { display: flex; align-items: center; gap: 8mm; margin: 6mm 0 8mm; }
.ce-symbol-img { width: 35mm; height: auto; flex: 0 0 auto; }
.ce-nb-id { font-size: 24pt; font-weight: 700; letter-spacing: 1pt; }
table.ce-fields { width: 100%; border-collapse: collapse; margin-bottom: 5mm; font-size: 10pt; }
table.ce-fields th { text-align: left; vertical-align: top; padding: 2mm 4mm 2mm 0; width: 38%; color: #003a6b; font-weight: 600; border-bottom: 1px solid #ccc; }
table.ce-fields td { padding: 2mm 0; border-bottom: 1px solid #ccc; vertical-align: top; }
.ce-doc .section-heading { font-size: 11pt; margin-top: 4mm; margin-bottom: 2mm; padding-bottom: 1mm; border-bottom: 2px solid #003a6b; }
table.ce-performance { width: 100%; border-collapse: collapse; font-size: 10pt; }
table.ce-performance thead th { background: #003a6b; color: #fff; padding: 2mm 3mm; text-align: left; font-weight: 600; }
table.ce-performance tbody td { padding: 1.5mm 3mm; border-bottom: 1px solid #ddd; }
table.ce-performance .perf { font-weight: 600; }

/* ============================================================ */
/* Metso manufacturing protocols — kompakt, en sida per dokument */
/* ============================================================ */
.mp-compact h1.doc-title { font-size: 15pt; margin-bottom: 3mm; }
.mp-compact .section-heading { font-size: 11pt; margin-top: 3mm; margin-bottom: 1.5mm; padding-bottom: 1mm; }
.mp-compact table.fields th, .mp-compact table.fields td { padding: 1mm 3mm; font-size: 9.5pt; }
.mp-compact table.check-table th, .mp-compact table.check-table td { padding: 1mm 3mm; font-size: 9.5pt; }
.mp-compact .signature-section { margin-top: 4mm; }
.mp-compact .signature-section h2 { font-size: 11pt; margin-bottom: 2mm; padding-bottom: 1mm; }
.mp-drawing-box {
  text-align: center; margin: 3mm 0; border: 1px solid #ccc;
  padding: 3mm; background: #fff;
}
.mp-drawing-image { max-width: 100%; max-height: 70mm; height: auto; }

/* Metso MP — strama signatur + ritning så allt ryms på en sida */
.mp-compact .signature-block { margin-bottom: 0; }
.mp-compact .signature-block .signature-role { font-size: 10pt; margin-bottom: 1mm; }
.mp-compact .signature-place { font-size: 10pt; margin-bottom: 1mm; }
.mp-compact .signature-image-row { margin: 2mm 0; min-height: 12mm; }
.mp-compact .signature-image { max-height: 12mm; }
.mp-compact .mp-drawing-image { max-height: 55mm; }
.mp-compact .mp-drawing-box { margin: 2mm 0; padding: 2mm; }

/* Metso MP — sista finjustering för en sida */
.mp-compact .mp-drawing-image { max-height: 42mm; }
.mp-compact table.fields th, .mp-compact table.fields td,
.mp-compact table.check-table th, .mp-compact table.check-table td { padding: 0.6mm 3mm; font-size: 9pt; }
.mp-compact table.fields, .mp-compact table.check-table { margin-bottom: 2mm; }
.mp-compact .section-heading { margin-top: 2mm; }
.mp-compact .signature-section { margin-top: 2mm; }
.mp-compact .signature-image-row { min-height: 10mm; margin: 1.5mm 0; }

/* Metso MP — ritning + stycklista (BOM) i två kolumner */
.mp-drawing-row { display: flex; gap: 4mm; align-items: flex-start; margin: 2mm 0; }
.mp-drawing-col { flex: 0 0 52%; margin: 0; }
.mp-parts-table { flex: 1; margin: 0; align-self: stretch; }
.mp-parts-table thead th { background: #003a6b; color: #fff; font-size: 8.5pt; padding: 1mm 2mm; }
.mp-parts-table td { font-size: 8.5pt; padding: 1mm 2mm; vertical-align: top; }
