/* ── Base Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #d93535;
  --red-dim: rgba(217,53,53,0.07);
}

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  background: #dde3ea;
  color: var(--red);
  min-height: 100vh;
}

/* ── Toolbar ── */
.toolbar {
  background: #0f172a;
  padding: 9px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.toolbar-left {
  display: flex; align-items: center; gap: 10px;
  color: #f1f5f9; font-weight: 700; font-size: 14px;
}
.toolbar-right { display: flex; gap: 8px; }
.tbtn {
  padding: 6px 14px; border-radius: 4px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none;
  transition: opacity .15s;
}
.tbtn:hover { opacity: .85; }
.tbtn-outline { background: #1e293b; color: #f1f5f9; border: 1px solid #475569; }
.tbtn-red { background: var(--red); color: #fff; }

/* ── Page wrapper ── */
.page-wrap {
  padding: 28px 20px 40px;
  display: flex;
  justify-content: center;
}

/* ── Form paper (A4-ish proportions) ── */
.form-paper {
  width: 860px;
  background: #fff;
  box-shadow: 0 6px 30px rgba(0,0,0,.14);
  padding: 16px;
  border-radius: 6px;
}

/* ── Outer border box with rounded corners ── */
.outer-box {
  border: 1.8px solid var(--red);
  border-radius: 10px;
  overflow: hidden;
}

/* ── Horizontal dividers ── */
.h-line { border-top: 1.5px solid var(--red); }
.h-line-thick {
  border-top: 1.5px solid var(--red);
  border-bottom: 1.5px solid var(--red);
  height: 5px;
}

/* ══════════════════════════════════════
   HEADER ROW
══════════════════════════════════════ */
.hdr-row {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  gap: 0;
}
.hdr-left {
  width: 140px;
  flex-shrink: 0;
}
.hdr-center {
  flex: 1;
  text-align: left;
}
.hdr-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.hdr-label {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
}

.main-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--red);
}

/* digit box */
.digit-row { display: inline-flex; }
.dbox {
  width: 20px;
  height: 20px;
  border: 1.2px solid var(--red);
  margin-right: -1.2px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #111;
  background: transparent;
  outline: none;
}
.dbox:focus { background: var(--red-dim); }

/* Checkboxes */
.cb-wrap {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; user-select: none;
}
.cb-wrap input { display: none; }
.cbx {
  width: 16px; height: 16px;
  border: 1.5px solid var(--red);
  background: #fff;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}
.cb-wrap input:checked + .cbx::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: 2px solid var(--red);
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
.cbl { font-size: 11.5px; font-weight: 700; white-space: nowrap; }

/* ══════════════════════════════════════
   UPPER BODY
══════════════════════════════════════ */
.upper-body {
  display: flex;
  min-height: 220px;
}

/* LEFT SIDEBAR */
.sidebar {
  width: 150px;
  flex-shrink: 0;
  border-right: 1.5px solid var(--red);
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sb-title {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: 2px;
}
.sb-field { display: flex; flex-direction: column; gap: 1px; }
.sb-label { font-size: 11px; font-weight: 400; }

/* inline label + underline */
.sb-inline { flex-direction: column; }

/* underline input wrapper */
.ul-line {
  border-bottom: 1.2px solid var(--red);
  width: 100%;
}
.iline {
  border: none;
  outline: none;
  width: 100%;
  font-size: 14px;
  font-weight: 700;
  color: #111;
  background: transparent;
  padding: 1px 2px;
  font-family: Arial, sans-serif;
}
.iline:focus { background: var(--red-dim); }
.iline-right { text-align: right; }

/* RIGHT AREA */
.right-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Keperluan Table ── */
.tbl-kep {
  width: 100%;
  border-collapse: collapse;
  flex: 1;
}
.tbl-kep th {
  border-bottom: 1.5px solid var(--red);
  padding: 6px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.th-kep { width: 72%; }
.th-jml {
  width: 28%;
  border-left: 1.5px solid var(--red);
}
.tbl-kep td {
  border-bottom: none;
  height: 18px;
  padding: 0px 8px;
}
.tbl-kep td.td-jml {
  border-left: 1.5px solid var(--red);
}

.icell {
  border: none; outline: none;
  width: 100%; font-size: 14px;
  font-weight: 500; color: #111;
  background: transparent;
  font-family: Arial, sans-serif;
}
.icell:focus { background: var(--red-dim); }

.iamt {
  border: none; outline: none;
  width: 100%; font-size: 14px;
  font-weight: 700; color: #111;
  text-align: right;
  background: transparent;
  font-family: 'Courier New', monospace;
}
.iamt:focus { background: var(--red-dim); }

/* TOTAL row */
.total-row td {
  border-top: 1.5px solid var(--red);
  border-bottom: none;
  padding: 5px 8px;
}
.total-lbl {
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--red);
}
.total-val { border-left: 1.5px solid var(--red); }
.total-iamt {
  border: none; outline: none;
  width: 100%; font-size: 13px;
  font-weight: 700; text-align: right;
  color: #111; background: transparent;
  font-family: 'Courier New', monospace;
  padding: 0 0;
}

/* Terbilang */
.terbilang-area {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1.5px solid var(--red);
}
.terb-lbl {
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  padding-top: 3px;
}
.terb-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ══════════════════════════════════════
   POSTING TABLE
══════════════════════════════════════ */
.tbl-posting {
  width: 100%;
  border-collapse: collapse;
}
.tbl-posting th {
  border-bottom: 1.5px solid var(--red);
  border-right: 1.5px solid var(--red);
  padding: 3px 3px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.tbl-posting th:last-child { border-right: none; }

.th-ket  { width: 36%; text-align: center; }
.th-perk { width: 24%; text-align: center; }
.th-jml-span { width: 40%; }
.th-deb  { width: 20%; border-right: 1.5px solid var(--red); }
.th-kre  { width: 20%; border-right: none; }

.tbl-posting td {
  border-bottom: none;
  border-right: 1.5px solid var(--red);
  padding: 2px 6px;
  height: 28px;
}
.tbl-posting td:last-child { border-right: none; }

/* ══════════════════════════════════════
   RECIPIENT AREA
══════════════════════════════════════ */
.recipient-area {
  display: flex;
  border-top: 1.5px solid var(--red);
}
.rec-left {
  flex: 1;
  border-right: 1.5px solid var(--red);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rec-right {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rec-label {
  font-size: 12px;
  font-weight: 700;
}
.rec-name { width: 100%; }
.rec-tgl-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.rec-tgl-line {
  flex: 1;
}
.tgl-lbl {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.rec-tgl-val {
  flex: 1.5;
}

/* ══════════════════════════════════════
   SIGNATURE SECTION
══════════════════════════════════════ */
/* Signatures */
.sig-table {
  width: 100%;
  border-collapse: collapse;
}
.sig-th {
  border-bottom: 1.5px solid var(--red);
  border-right: 1.5px solid var(--red);
  padding: 4px 6px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
}
.sig-th:last-child { border-right: none; }

.sig-td {
  border-right: 1.5px solid var(--red);
  border-bottom: 1.5px solid var(--red);
  height: 58px;
  vertical-align: bottom;
  padding: 4px 8px;
}
.sig-td-last { border-right: none; }
.sig-input {
  width: 100%;
  border: none;
  outline: none;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #111;
  background: transparent;
  font-family: Arial, sans-serif;
}
.sig-input:focus { background: var(--red-dim); }

/* ══════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════ */
@media print {
  /* Hide all red borders & text in printout */
  :root {
    --red: transparent !important;
    --red-dim: transparent !important;
  }

  /* Hide everything except the form */
  .no-print,
  .toolbar {
    display: none !important;
  }

  /* Strip page chrome */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    width: 100% !important;
    height: auto !important;
  }

  .page-wrap {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
  }

  .form-paper {
    box-shadow: none !important;
    padding: 18px 20px 50px 30px !important;
    margin: 0 !important;
    width: 100% !important;
    border-radius: 0 !important;
  }

  /* Make sure borders & colors print correctly */
  .outer-box {
    padding-top: 10px;
    border-color: var(--red) !important;
  }

  input, textarea {
    color: #000 !important;
    background: transparent !important;
    border-color: var(--red) !important;
    -webkit-appearance: none !important;
  }

  /* A4 paper size portrait: 210mm x 297mm */
  @page {
    margin: 8mm;
    size: 210mm 297mm;
  }
}
