/* Sotofix — เครื่องมือหนังสือรับรองการหักภาษี ณ ที่จ่าย (50 ทวิ) · สไตล์ของฟอร์ม (ตัวเอกสารอยู่ใน src/tawi.js → DOC_CSS)
   ต้นฉบับ: doc-system/static-tools/50-tawi/tawi.css → build_tawi.py ก๊อปเป็น site/50-tawi.css (ห้ามแก้ใน site/)
   ทุก class ขึ้นต้น stw- และอยู่ใต้ .stw-root (ไม่ชนเครื่องมือเอกสาร sd- · เครื่องคำนวณ sc- · ธีม WordPress)
   สีชุดเดียวกับ _core/core.css (ชุด A ของ sotofix) · ฟอนต์ฟอร์ม Prompt ของเว็บ ไม่มีก็ใช้ชุดในโฟลเดอร์ fonts/ */

@font-face { font-family: "SD Prompt"; src: url("fonts/prompt-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "SD Prompt"; src: url("fonts/prompt-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "SD Prompt"; src: url("fonts/prompt-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

.stw-root {
  --stw-primary: #002C2F;
  --stw-second: #1E646E;
  --stw-text: #023459;
  --stw-accent: #FDD301;
  --stw-red: #B3261E;
  --stw-muted: #5B6B78;
  --stw-line: #D9E2E6;
  --stw-soft: #F3F7F8;
  --stw-warn-bg: #FFF8D6;
  --stw-warn-ink: #5A4A00;
  container-type: inline-size;
  container-name: stw;
  display: block;
  font-family: "Prompt", "SD Prompt", "Leelawadee UI", "Tahoma", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--stw-text);
  text-align: left;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.stw-root *, .stw-root *::before, .stw-root *::after { box-sizing: border-box; }
.stw-root [hidden] { display: none !important; }
.stw-root p { margin: 0 0 8px; }

.stw-root .stw-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.stw-root .stw-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stw-root .stw-out { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
@container stw (min-width: 980px) {
  .stw-root .stw-layout { grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); gap: 28px; }
  .stw-root .stw-out { position: sticky; top: 12px; }
}

/* ---------- การ์ด ---------- */
.stw-root .stw-card { display: block; background: #fff; border: 1px solid var(--stw-line); border-radius: 12px; padding: 16px 16px 6px; margin: 0; }
.stw-root .stw-card-t { display: block; font-size: 16.5px; font-weight: 600; color: var(--stw-primary); line-height: 1.35; margin: 0 0 12px; padding: 0; font-family: inherit; text-transform: none; letter-spacing: normal; }
.stw-root .stw-card-s { font-size: 12.5px; font-weight: 500; color: var(--stw-second); background: var(--stw-soft); border-radius: 99px; padding: 1px 10px; margin-left: 6px; white-space: nowrap; }
.stw-root details.stw-card > summary { cursor: pointer; list-style: revert; }
.stw-root details.stw-card:not([open]) > summary { margin-bottom: 10px; }

.stw-root .stw-field { margin: 0 0 12px; min-width: 0; }
.stw-root .stw-lbl { display: block; font-size: 13.5px; font-weight: 500; color: var(--stw-text); margin: 0 0 4px; line-height: 1.4; }
.stw-root .stw-hint { font-size: 12.5px; color: var(--stw-muted); margin: 5px 0 0; line-height: 1.5; }
.stw-root .stw-hint-b { margin: -4px 0 12px; }
.stw-root .stw-row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
@container stw (max-width: 520px) {
  .stw-root .stw-row2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- ช่องกรอก (class ซ้ำ 3 ชั้นให้ชนะสไตล์ช่องกรอกของธีม/Elementor kit) ---------- */
.stw-root .stw-in.stw-in.stw-in {
  display: block; width: 100%; max-width: 100%; min-height: 44px; margin: 0; padding: 9px 12px;
  font: inherit; font-size: 16px; line-height: 1.45; color: #0F2430; letter-spacing: normal; text-transform: none;
  background: #fff; border: 1px solid #B9C7CE; border-radius: 8px; box-shadow: none; outline: none;
  -webkit-appearance: none; appearance: none;
}
.stw-root select.stw-in.stw-in.stw-in {
  padding-right: 34px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  background-image: linear-gradient(45deg, transparent 50%, #5B6B78 50%), linear-gradient(135deg, #5B6B78 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.stw-root textarea.stw-in.stw-in.stw-in { resize: vertical; overflow: hidden; }
.stw-root .stw-in.stw-in.stw-in:focus { border-color: var(--stw-second); box-shadow: 0 0 0 3px rgba(30, 100, 110, .18); }
.stw-root .stw-in.stw-in.stw-in::placeholder { color: #93A3AB; opacity: 1; }
.stw-root .stw-num.stw-num.stw-num { text-align: right; }
.stw-root .stw-taxout { display: block; min-height: 44px; padding: 9px 12px; font-size: 16px; font-weight: 600; text-align: right;
  background: var(--stw-soft); border: 1px dashed #B9C7CE; border-radius: 8px; color: var(--stw-primary); }

.stw-root .stw-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; margin: 0 0 10px; cursor: pointer; line-height: 1.5; }
.stw-root .stw-check input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--stw-second); }

/* ---------- ปุ่ม (ธีม Hello Elementor ตั้ง button { white-space: nowrap } — ต้องคืนเป็น normal ไม่งั้นล้นจอมือถือ) ---------- */
.stw-root .stw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stw-root .stw-chip.stw-chip.stw-chip {
  display: inline-flex; align-items: center; min-height: 40px; margin: 0; padding: 7px 14px; max-width: 100%;
  font: inherit; font-size: 14px; line-height: 1.35; text-align: left; white-space: normal; text-transform: none; letter-spacing: normal;
  color: var(--stw-text); background: #fff; border: 1px solid #B9C7CE; border-radius: 99px; box-shadow: none; cursor: pointer;
}
.stw-root .stw-chip.stw-chip.stw-chip[aria-pressed="true"] { color: #fff; background: var(--stw-second); border-color: var(--stw-second); }
.stw-root .stw-chip.stw-chip.stw-chip:focus-visible { outline: 3px solid rgba(30, 100, 110, .35); outline-offset: 2px; }

.stw-root .stw-btn.stw-btn.stw-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin: 0; padding: 9px 16px; max-width: 100%;
  font: inherit; font-size: 15px; font-weight: 500; line-height: 1.35; text-align: center; white-space: normal; text-transform: none; letter-spacing: normal;
  color: var(--stw-primary); background: #fff; border: 1px solid var(--stw-second); border-radius: 10px; box-shadow: none; cursor: pointer;
}
.stw-root .stw-btn.stw-btn.stw-btn:hover { background: var(--stw-soft); }
.stw-root .stw-btn.stw-btn.stw-btn.stw-btn-main { color: var(--stw-primary); background: var(--stw-accent); border-color: var(--stw-accent); font-weight: 600; }
.stw-root .stw-btn.stw-btn.stw-btn.stw-btn-main:hover { filter: brightness(.96); }
.stw-root .stw-btn.stw-btn.stw-btn.stw-btn-ghost { border-style: dashed; width: 100%; margin: 0 0 12px; }
.stw-root .stw-btn.stw-btn.stw-btn.stw-btn-link { border: 0; min-height: 36px; padding: 4px 6px; color: var(--stw-red); background: none; text-decoration: underline; }

/* ---------- รายการเงินได้ ---------- */
.stw-root .stw-line { border: 1px solid var(--stw-line); background: #FBFCFD; border-radius: 10px; padding: 10px 12px 2px; margin: 0 0 12px; }
.stw-root .stw-line-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 14px; color: var(--stw-primary); }
.stw-root .stw-sum { background: var(--stw-soft); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.stw-root .stw-sum > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.stw-root .stw-sum b { font-size: 16px; color: var(--stw-primary); white-space: nowrap; }
.stw-root .stw-sum-w { margin: 4px 0 0; font-size: 13px; color: var(--stw-second); text-align: right; overflow-wrap: anywhere; }

.stw-root .stw-foot { font-size: 12.5px; color: var(--stw-muted); }
.stw-root .stw-foot-b { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stw-root .stw-foot-b .stw-btn.stw-btn.stw-btn.stw-btn-ghost { width: auto; margin: 0; }

/* ---------- ตัวอย่างเอกสาร + ปุ่ม ---------- */
.stw-root .stw-views { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: var(--stw-muted); }
.stw-root .stw-preview { width: 100%; min-width: 0; }
.stw-root .stw-box { position: relative; overflow: hidden; margin: 0 auto; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 6px 22px rgba(2, 52, 89, .10); }
.stw-root .stw-box > .stw-sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stw-root .stw-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stw-root .stw-actions .stw-btn.stw-btn.stw-btn { flex: 1 1 140px; }
.stw-root .stw-actions .stw-btn.stw-btn.stw-btn.stw-btn-main { flex: 1 1 100%; }
.stw-root .stw-status { min-height: 1.5em; font-size: 13.5px; color: var(--stw-second); margin: 0; }
.stw-root .stw-status.stw-bad { color: var(--stw-red); }

.stw-root .stw-warn { background: var(--stw-warn-bg); color: var(--stw-warn-ink); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.stw-root .stw-warn-h { font-weight: 600; margin: 0 0 4px; }
.stw-root .stw-warn-l { margin: 0; padding: 0 0 0 18px; }
.stw-root .stw-warn-l li { margin: 2px 0; }
.stw-root .stw-wlink.stw-wlink.stw-wlink {
  display: inline; vertical-align: top; margin: 0; padding: 0; min-height: 0; font: inherit; font-size: 13.5px; line-height: 1.5; text-align: left; white-space: normal;
  color: var(--stw-warn-ink); background: none; border: 0; box-shadow: none; text-decoration: underline; text-transform: none; cursor: pointer;
}

/* แผ่นเอกสารชั่วคราวตอนวัดความสูงก่อนวาดไฟล์ (นอกจอ) */
.stw-measure { position: absolute; left: -10000px; top: 0; width: 794px; visibility: hidden; pointer-events: none; }

/* ---------- หน้าเดี่ยว /engine/50-tawi/ (หน้าทดสอบ ไม่มีธีม) ---------- */
body.stw-standalone { margin: 0; background: #F6F9FA; font-family: "SD Prompt", "Leelawadee UI", "Tahoma", sans-serif; color: #023459; }
.stw-standalone-wrap { max-width: 1240px; margin: 0 auto; padding: 18px 14px 40px; }
.stw-standalone-hd h1 { font-size: 24px; margin: 0 0 4px; color: #002C2F; }
.stw-standalone-hd p { margin: 0 0 16px; color: #5B6B78; font-size: 14px; }
.stw-standalone-ft { text-align: center; padding: 0 0 30px; font-size: 13px; }
.stw-standalone-ft a { color: #1E646E; }
.stw-noscript { padding: 12px; background: #FFF8D6; }

/* ---------- พิมพ์: ซ่อนทุกอย่าง เหลือ 2 แผ่น (ฉบับที่ 1 + ฉบับที่ 2) ---------- */
#stw-print-root { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html.stw-printing, html.stw-printing body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  html.stw-printing body > *:not(#stw-print-root) { display: none !important; }
  html.stw-printing #stw-print-root { display: block !important; }
  html.stw-printing #stw-print-root .stw-sheet { width: 210mm; height: 296.5mm; break-after: page; page-break-after: always; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html.stw-printing #stw-print-root .stw-sheet:last-child { break-after: auto; page-break-after: auto; }
}
