*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Times New Roman', Times, serif; font-size: 12pt; background: #e0e0e0; color: #000; }

/* A4 LANDSCAPE */
.page {
  width: 297mm;
  min-height: 210mm;
  margin: 20px auto;
  background: #fff;
  padding: 8mm;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.nomor-dok { font-size: 8pt; color: #444; text-align: right; margin-bottom: 4px; }

.doc-header {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 10px;
  border-top: none;
  border-bottom: 3px solid #1a365d;
  padding: 7px 15mm;
  margin-bottom: 12px;
}
.logo-box {
  width: 52px; height: 52px;
  border: 1.5px dashed #555;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 6.5pt; color: #555; text-align: center; line-height: 1.3;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-box.has-logo {
  border: none;
}
.doc-title-center { text-align: center; }
.doc-title-center .instansi { font-size: 9.5pt; font-weight: normal; }
.doc-title-center .judul-utama { font-size: 14pt; font-weight: bold; text-transform: uppercase; letter-spacing: 0.05em; margin: 2px 0; }
.doc-title-center .subjudul { font-size: 9.5pt; }

/* IDENTITAS — 2 kolom agar hemat ruang */
.identitas { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 10pt; }
.identitas td { padding: 3px 8px; border: 1px solid #000; vertical-align: top; }
.identitas td.label { font-weight: bold; white-space: nowrap; width: 16%; }

.page .section-title {
  font-size: 10.5pt; font-weight: bold; text-transform: uppercase;
  letter-spacing: 0.04em;  border-left: 4px solid #1a365d;
  padding: 3px 8px; margin: 6px 0; background: #f5f5f5;
  color: #000;
}

/* TABEL LEVEL */
table.level {
  width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9pt; margin-bottom: 10px;
}
table.level th {
  background: #1a365d; color: #ffffff;
  padding: 5px 7px; border: 1px solid #1a365d;
  text-align: center; vertical-align: middle;
  border-bottom: 2px solid #1a365d;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
table.level td {
  padding: 4px 7px; border: 1px solid #1a365d;
  vertical-align: top; line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
table.level td.level-label { font-weight: bold; text-align: center; vertical-align: middle; width: 13%; }
table.level td.level-angka { text-align: center; font-weight: bold; vertical-align: middle; width: 6%; font-size: 11pt; }
table.level tr:nth-child(even) td { background: #fafafa; }

/* TABEL KKTP UTAMA */
table.kktp {
  width: 100%; border-collapse: collapse; font-size: 7.5pt; margin-bottom: 10px;
  table-layout: fixed;
}
table.kktp th {
  background: #1a365d; color: #ffffff;
  padding: 4px 3px; border: 1px solid #1a365d;
  text-align: center; vertical-align: middle; line-height: 1.3;
  border-bottom: 2px solid #1a365d;
}
table.kktp td {
  padding: 4px 3px; border: 1px solid #1a365d;
  vertical-align: top; line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
table.kktp tr:nth-child(even) td { background: #fafafa; }
table.kktp td.no { text-align: center; font-weight: bold; width: 20px; vertical-align: middle; }
table.kktp td.kode {
  font-family: 'Courier New', monospace; font-size: 8pt;
  font-weight: bold; text-align: center; vertical-align: middle; width: 80px;
}
table.kktp td.center { text-align: center; vertical-align: middle; }

table.kktp tr.elemen-header td {
  background: #edf5ff; color: #1a365d;
  font-weight: bold; font-size: 9pt; padding: 4px 7px;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #1a365d;
}

/* Kolom level — border kiri lebih tebal sebagai pemisah visual */
table.kktp td.col-mb    { border-left: 2px solid #1a365d; background: #fff; }
table.kktp td.col-layak { border-left: 2px solid #1a365d; background: #fafafa; }
table.kktp td.col-cakap { border-left: 2px solid #1a365d; background: #fff; }
table.kktp td.col-mahir { border-left: 2px solid #1a365d; background: #fafafa; }
table.kktp tr:nth-child(even) td.col-mb    { background: #f0f0f0; }
table.kktp tr:nth-child(even) td.col-layak { background: #f5f5f5; }
table.kktp tr:nth-child(even) td.col-cakap { background: #f0f0f0; }
table.kktp tr:nth-child(even) td.col-mahir { background: #f5f5f5; }

/* KONVERSI */
table.konversi {
  width: 55%; border-collapse: collapse; table-layout: fixed; font-size: 9.5pt; margin-bottom: 10px;
}
table.konversi th {
  background: #1a365d; color: #ffffff;
  padding: 5px 10px; border: 1px solid #1a365d; text-align: center;
  border-bottom: 2px solid #1a365d;
}
table.konversi td {
  padding: 4px 10px; border: 1px solid #1a365d;
  text-align: center; vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
table.konversi tr:nth-child(even) td { background: #fafafa; }

.catatan {
  font-size: 8pt; color: #333; margin-bottom: 10px;
  padding: 5px 8px; border-left: 3px solid #555;
  line-height: 1.7; background: #fafafa;
  border-top: 1px solid #ccc; border-bottom: 1px solid #ccc;
  /* page-break-before: avoid !important; */
  /* page-break-after: avoid !important; */
  page-break-inside: avoid;
  break-inside: avoid;
  margin-top: 4mm;
  max-width: 100%;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.doc-footer {
  border-top: 2px solid #000; margin-top: 12px; padding-top: 4px;
  display: flex; justify-content: space-between; font-size: 8pt; color: #333;
}

/* HEADING CONTROL - Prevent headings from separating from content */
h1, h2, h3, .section-title {
  page-break-after: avoid;
}

/* PARAGRAPH PRINT TYPOGRAPHY - Prevent orphan/widow lines */
p {
  widows: 2;
  orphans: 2;
}

/* PAGE BREAK */
.page-break { page-break-before: always; }

/* Prevent row from breaking inside during print */
.rubrik-row {
  page-break-inside: avoid;
  break-inside: avoid;
}

/* Ensure table headers repeat on each page */
thead {
  display: table-header-group !important;
}
tfoot {
  display: table-footer-group !important;
}

/* Prevent section from breaking - DISABLED to reduce page waste */
/* .rubrik-section {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
} */

.kop-pemda {
    font-size: 8pt;
    font-weight: normal;
    letter-spacing: 0.04em;
    margin-bottom: 1px;
  }
  .kop-dinas {
    font-size: 9pt;
    font-weight: bold;
    letter-spacing: 0.03em;
    margin-bottom: 1px;
  }
  .kop-sekolah {
    font-size: 12pt;
    font-weight: bold;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
  }
  .kop-alamat {
    font-size: 7.5pt;
    font-weight: normal;
    font-style: italic;
    letter-spacing: 0.01em;
  }
  .doc-title-center {
    text-align: center;
    line-height: 1.25;
  }
  .doc-judul-area {
    text-align: center;
    margin-bottom: 12px;
  }
  .doc-judul-area .judul-utama {
    font-size: 14pt;
    font-weight: bold;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 4px 0 2px 0;
  }
  .doc-judul-area .subjudul {
    font-size: 10pt;
    color: #444;
  }
  .ttd-wrapper {
    margin-top: 20px;
    page-break-inside: avoid;
  }

/* ── Area TTD Pengesahan ── */
.ttd-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 20px;
  page-break-inside: avoid;
}
.ttd-box {
  text-align: center;
  font-size: 10pt;
  padding: 8px 12px;
}
.ttd-box .ttd-jabatan {
  font-weight: bold;
  color: #1a365d;
  font-size: 9.5pt;
  margin-bottom: 4px;
}
.ttd-box .ttd-tanggal {
  font-size: 9.5pt;
  margin-bottom: 44px;
}
.ttd-box .ttd-nama {
  font-weight: bold;
  font-size: 10pt;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ttd-box .ttd-nip {
  font-size: 9pt;
  color: #333;
  margin-top: 3px;
}

@media print {
  body { background: #fff; }
  .page {
    margin: 0;
    box-shadow: none;
    padding: 0 !important;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
