/* ===== Invoice template (A4 width 794px) — plain CSS so html2canvas can capture it exactly ===== */

.inv,
.inv * { box-sizing: border-box; }

.inv {
  width: 794px;
  background: #ffffff;
  color: #1f2937;
  font-family: 'Sarabun', 'Leelawadee UI', Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.inv-band {
  height: 9px;
  background: #0f766e;
  border-bottom: 3px solid #f59e0b;
  margin-bottom: 26px;
}

.inv-body {
  padding: 0 44px 30px;
}

/* ---------- header ---------- */
.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid #e2e8f0;
}

.inv-brand { min-width: 0; }

.inv-place {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  color: #0f172a;
}

.inv-addr,
.inv-tel {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 2px;
  white-space: pre-line;
}

.inv-doctl { text-align: right; flex: 0 0 auto; }

.inv-doc {
  font-size: 20px;
  font-weight: 700;
  color: #0f766e;
  line-height: 1.2;
}

.inv-no {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* บรรทัดวันที่ออกเอกสาร — อยู่ติดใต้เลขที่ในบล็อกเดียวกัน ไม่ปนกัน */
.inv-date {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---------- บล็อกหัวเรื่องเอกสาร (แยกจากหัวบิล ย้าย/ซ่อนได้เอง) ---------- */
.inv-blk.is-doctl {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 10px;
}


/* ---------- meta grid ---------- */
.inv-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
}

.meta-row {
  display: flex;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid #e6edf5;
  min-width: 0;
}

.meta-row:nth-child(odd) { border-right: 1px solid #e6edf5; }
.meta-row:nth-last-child(-n+2) { border-bottom: 0; }

.meta-k {
  color: #64748b;
  flex: 0 0 74px;
}

.meta-v {
  font-weight: 600;
  color: #0f172a;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- table ---------- */
.inv-table {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  table-layout: fixed;
}

.inv-table th {
  background: #0f766e;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 9px 10px;
  border: 1px solid #0f766e;
}

.inv-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  font-size: 13.5px;
  vertical-align: top;
  color: #1f2937;
}

.inv-table .c-no { width: 6%; text-align: center; }
.inv-table .c-item { width: 42%; }
.inv-table .c-unit { width: 12%; text-align: right; }
.inv-table .c-rate { width: 16%; text-align: right; }
.inv-table .c-amt { width: 24%; text-align: right; }

.inv-table td.c-no,
.inv-table td.c-unit,
.inv-table td.c-rate,
.inv-table td.c-amt { font-variant-numeric: tabular-nums; }

.inv-table td.c-amt { font-weight: 600; }

.inv-table .sub {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.inv-table .row-total td {
  background: #f0fdfa;
  border-top: 2px solid #0f766e;
  padding: 11px 10px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.inv-table .row-total td.lbl { text-align: right; font-size: 14.5px; }

.inv-table .row-words td {
  border-top: 0;
  text-align: center;
  font-size: 12.5px;
  color: #334155;
  font-style: italic;
  padding: 8px 10px;
}

.inv.is-negative .row-total td { background: #fef2f2; border-top-color: #b91c1c; }

/* ---------- payment ---------- */
.inv-pay {
  margin-top: 16px;
  border: 1px solid #dbe3ec;
  border-left: 4px solid #0f766e;
  border-radius: 8px;
  background: #f8fafc;
  padding: 11px 15px 12px;
}

.pay-h {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 6px;
}

.pay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 20px;
  font-size: 13px;
}

.pay-k { color: #64748b; margin-right: 8px; }
.pay-v { font-weight: 600; color: #0f172a; }
.pay-v.strong {
  font-size: 15px;
  letter-spacing: .4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- note ---------- */
.inv-note {
  margin-top: 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #78350f;
  white-space: pre-line;
}

.note-k {
  font-weight: 700;
  margin-right: 6px;
  color: #92400e;
}

/* ---------- signatures ---------- */
.inv-sign {
  display: flex;
  gap: 56px;
  margin-top: 30px;
}

.sign-slot {
  flex: 1;
  text-align: center;
  font-size: 12.5px;
  color: #475569;
}

.sign-line {
  height: 36px;
  border-bottom: 1px dotted #94a3b8;
  margin-bottom: 6px;
}

.sign-name { font-size: 13px; font-weight: 600; color: #0f172a; }
.sign-date { font-size: 11.5px; color: #64748b; margin-top: 3px; }

/* ---------- footer ---------- */
.inv-foot {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 10.5px;
  color: #64748b;
  text-align: center;
}

.inv [hidden] { display: none !important; }

/* ---------- บล็อกข้อความอิสระที่ผู้ใช้เพิ่มเอง ---------- */
.inv-text { margin-top: 14px; }

.text-h {
  font-size: 13px;
  font-weight: 700;
  color: #0f766e;
}

.text-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: #334155;
  margin-top: 2px;
  white-space: pre-line;
}

/* ---------- รอบบิล (อยู่ในกรอบเดียวกับตาราง) ---------- */
.inv-period-blk { margin-top: 18px; }

.inv-period {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px 8px 0 0;
  border-bottom: 0;
}

.period-k { font-size: 12.5px; font-weight: 700; color: #0f766e; }

.period-v {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

/* แถบรอบบิลต่อกับตารางพอดี: ตารางไม่ต้องเว้นระยะบนอีก */
.inv-period-blk:not([hidden]) + .inv-table { margin-top: 0; }
.inv-period-blk[hidden] + .inv-table { margin-top: 18px; }

/* ---------- กำหนดชำระ (บล็อกของตัวเอง) ---------- */
.inv-due {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 13px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
}

.due-k { font-size: 12.5px; font-weight: 700; color: #92400e; }

.due-v {
  font-size: 13px;
  font-weight: 600;
  color: #78350f;
  font-variant-numeric: tabular-nums;
}
