/* =====================================================================
   ราคากลางงานก่อสร้างอาคาร — เว็บแอป (ระยะ 1)
   ระบบการออกแบบ "แผ่นงานช่างสำรวจ": กระดาษขาว เส้นลายบาง ตัวเลขเป็นพระเอก
   ตัวอักษร: Kanit (เสียงของแบรนด์ — หัวข้อ ปุ่ม ป้าย) · Sarabun (ตัวเลขและเอกสาร — ตารางและแบบ ปร.)
   สี: หมึกน้ำเงินเข้ม 1 สี (brand) + สีสถานะตามความหมาย (ok/warn/bad) + คู่สีกราฟ 2 ชุดที่ผ่านตัวตรวจตาบอดสี
   ฟอนต์ฝังในโฟลเดอร์ (OFL) ไม่โหลดจากภายนอก — ไม่มีข้อมูลออกนอกเครื่อง
   ดูเหตุผลใน design/DESIGN-NOTES.md
   ===================================================================== */

@font-face { font-family: "Kanit"; src: url("../fonts/kanit-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("../fonts/kanit-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("../fonts/kanit-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("../fonts/sarabun-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("../fonts/sarabun-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("../fonts/sarabun-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --paper: #ffffff;
  --bg: #f3f4f8;
  --bg-grid: rgba(47, 54, 144, .055);
  --ink: #161c2d;
  --ink-2: #444d61;
  --ink-3: #5f6b82;
  --line: #dcdfe8;
  --line-2: #c3c8d6;
  --line-3: #9aa2b5;
  --brand: #2f3690;
  --brand-2: #262c7a;
  --brand-soft: #edeffb;
  --brand-line: #c5c9ef;
  --ok: #1b7a3d;      --ok-soft: #e6f4ea;   --ok-line: #b7dcc3;
  --warn: #8a5300;    --warn-soft: #fff3dc; --warn-line: #efd39a; --warn-mark: #bf7a00;
  --bad: #b42318;     --bad-soft: #fdecea;  --bad-line: #f3b9b3;
  --c1: #4f5bd3;  /* กราฟ: ค่าวัสดุ */
  --c2: #15998a;  /* กราฟ: ค่าแรงงาน */
  --c0: #cfd3dd;  /* กราฟ: ส่วนรอง */
  --ui: "Kanit", "Sarabun", system-ui, -apple-system, sans-serif;
  --doc: "Sarabun", "TH Sarabun New", "Kanit", system-ui, sans-serif;
  --r: 6px;
  --r2: 10px;
  --focus: 0 0 0 3px rgba(47, 54, 144, .28);
}

/* ---------- พื้นฐาน ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0; color: var(--ink); font: 15px/1.55 var(--ui);
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
small { color: var(--ink-3); font-weight: 400; }
h2 { margin: 0; font: 500 20px/1.3 var(--ui); }
h3 { margin: 18px 0 8px; font: 500 16px/1.3 var(--ui); }
h3 small { display: block; font-size: 13px; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: var(--r); z-index: 100; }
.skip:focus { left: 8px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.15em; }
.num, .n { font-family: var(--doc); font-variant-numeric: tabular-nums; }

/* ---------- แถบบน + ป้ายประกาศ ---------- */
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 32px; height: 32px; }
.brand-t b { display: block; font: 600 17px/1.15 var(--ui); }
.brand-t small { display: block; font: 400 12px/1.2 var(--ui); color: var(--ink-3); letter-spacing: .02em; }
.topnav { display: flex; align-items: center; gap: 14px; font-size: 13.5px; }
.topnav a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid transparent; }
.topnav a:hover { border-color: var(--ink-3); }
.tag { font: 500 12px/1.4 var(--ui); padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 99px; color: var(--ink-2); white-space: nowrap; }
.legal { background: #f7f8fb; border-bottom: 1px solid var(--line); font: 13.5px/1.4 var(--ui); color: var(--ink-2); padding: 7px 0; }
.legal .wrap { display: flex; gap: 8px; align-items: center; }
.legal .ic { color: var(--brand); width: 16px; height: 16px; }

/* ---------- ตัวบอกขั้นตอน ---------- */
.stepper { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); margin: 20px 0 14px; padding: 0; border: 1px solid var(--line); border-radius: var(--r2); background: var(--paper); overflow: hidden; }
.stepper li { position: relative; }
.stepper li + li::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; border-left: 1px solid var(--line); }
.stepper a { display: flex; gap: 12px; align-items: center; padding: 12px 16px; color: var(--ink-2); text-decoration: none; min-height: 64px; }
.stepper .no { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line-3); display: grid; place-items: center; font: 600 13px var(--ui); color: var(--ink-3); flex: none; }
.stepper .lb { display: flex; flex-direction: column; line-height: 1.25; font-weight: 500; font-size: 14.5px; }
.stepper .lb small { font-weight: 400; font-size: 12.5px; color: var(--ink-3); font-family: var(--doc); margin-top: 2px; }
.stepper .is-done .no { background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper .is-current { background: var(--brand-soft); }
.stepper .is-current a { color: var(--ink); }
.stepper .is-current .no { background: var(--brand); border-color: var(--brand); color: #fff; }
.stepper .is-current::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--brand); }

/* ---------- หมายเหตุสถานะต้นแบบ ---------- */
.proto-note { margin: 0 0 16px; border: 1px solid var(--warn-line); background: var(--warn-soft); border-radius: var(--r2); font-size: 13.5px; color: var(--ink-2); }
.proto-note summary { cursor: pointer; padding: 9px 14px; display: flex; gap: 8px; align-items: center; color: var(--warn); font-weight: 500; list-style: none; }
.proto-note summary::-webkit-details-marker { display: none; }
.proto-note summary .ic { width: 16px; height: 16px; }
.proto-note summary::after { content: "รายละเอียด"; margin-left: auto; font-weight: 400; font-size: 12.5px; text-decoration: underline; }
.proto-note[open] summary::after { content: "ซ่อน"; }
.proto-note summary .short { display: none; }
.proto-note ul { margin: 0; padding: 0 16px 12px 36px; }
.proto-note li { margin: 3px 0; }

/* ---------- แผง (panel) ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r2); padding: 20px 24px 22px; margin-bottom: 18px; min-width: 0; }
.panel-h { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: baseline; margin-bottom: 14px; }
.panel-h p { grid-column: 2; color: var(--ink-2); font-size: 13.5px; }
.step-no { font: 500 12px/1 var(--ui); color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: 4px; padding: 4px 7px; letter-spacing: .02em; white-space: nowrap; }
.panel-h h2 small { font-size: 13.5px; margin-left: 8px; font-family: var(--doc); }

/* รอบหก (ข้อ 4): [hidden] ต้องชนะ display ของทุก class (ปุ่มพิมพ์แบบ · ช่องที่เลือกแล้ว · แผงที่ซ่อน) */
[hidden] { display: none !important; }

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--paper); color: var(--ink); font: 500 14.5px/1.2 var(--ui); cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--line-3); background: #fafbfd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #f1f2f6; }
.btn.big { min-height: 46px; padding: 10px 20px; font-size: 16px; }
.btn.mini { min-height: 34px; padding: 4px 10px; font-size: 13px; gap: 6px; }
@media (pointer: coarse) { .btn.mini { min-height: 40px; } .btn.cell { min-height: 40px; } }
.btn.danger:hover { color: var(--bad); border-color: var(--bad-line); }
.btn:disabled { opacity: .45; cursor: default; }
.btn .ic { width: 16px; height: 16px; }
/* ช่องตัวเลขที่กดเลือกได้ (ราคา/ค่าแรง) */
.btn.cell { font-family: var(--doc); font-weight: 600; font-size: 14.5px; justify-content: flex-end; min-width: 7.5em; font-variant-numeric: tabular-nums; }
.btn.cell.empty { font-family: var(--ui); font-weight: 500; color: var(--brand); border-style: dashed; border-color: var(--brand-line); background: var(--brand-soft); justify-content: center; }
.btn.cell.empty:hover { border-color: var(--brand); }

/* ---------- ช่องกรอก ---------- */
input, select, textarea { font-family: var(--doc); font-size: 15px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 7px 10px; background: var(--paper); max-width: 100%; min-height: 36px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: #7b8497; }
select { font-family: var(--ui); font-size: 14px; }
textarea { width: 100%; resize: vertical; border-style: dashed; border-color: var(--line-3); border-radius: var(--r2); padding: 10px 12px; min-height: 96px; font-size: 14px; line-height: 1.5; }
textarea:focus { border-style: solid; }
textarea.drag { border-color: var(--brand); background: var(--brand-soft); }
label { font-size: 13.5px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.hint { color: var(--ink-3); font-size: 13.5px; margin: 6px 0; }
.hint.bad { color: var(--bad); }
.autosave { font-size: 12.5px; margin: 0 4px; }
#computeMsg { scroll-margin-top: 72px; }
#computeMsg:focus { outline: 0; }
.scroll-hint { display: none; font: 12px var(--ui); color: var(--ink-3); margin: 6px 0 2px; }
#promptBox { width: 100%; font-family: var(--doc); font-size: 13.5px; }
.err { color: var(--bad); margin: 8px 0; font-size: 14px; }
.err ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------- ทางเข้า 3 ทาง ---------- */
.doors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 2px 0 16px; }
.doors button { position: relative; display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; min-height: 78px; border: 1px solid var(--line-2); border-radius: var(--r2); background: var(--paper); color: var(--ink); cursor: pointer; font-family: var(--ui); transition: border-color .15s, background .15s; }
.doors button:hover { border-color: var(--line-3); }
.doors button[aria-selected="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.doors button[aria-selected="true"]::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; background: var(--brand-soft); border-right: 1px solid var(--brand); border-bottom: 1px solid var(--brand); transform: translateX(-50%) rotate(45deg); }
.door-ic { width: 38px; height: 38px; stroke: var(--brand); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; margin-top: 1px; }
.door-t b { display: block; font-weight: 500; font-size: 16px; line-height: 1.25; }
.door-t small { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.4; margin-top: 3px; }
.pane { border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px 16px; background: #fbfbfd; }
.flow { list-style: none; counter-reset: s; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.flow li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flow li::before { counter-increment: s; content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font: 600 12.5px/24px var(--ui); text-align: center; flex: none; }
.flow .hint { margin: 0; }
.finder { position: relative; }
.finder .search { position: relative; }
.finder .search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; pointer-events: none; }
.finder input[type="search"] { width: 100%; font-size: 16px; padding: 10px 12px 10px 38px; min-height: 44px; -webkit-appearance: none; appearance: none; }
#mnResults { list-style: none; margin: 6px 0 0; padding: 0; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--paper); font-family: var(--doc); }
#mnResults:empty { display: none; }
#mnResults li { display: flex; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); align-items: baseline; }
#mnResults li:last-child { border-bottom: 0; }
#mnResults li[aria-selected="true"], #mnResults li:hover { background: var(--brand-soft); }
#mnResults .code { font-weight: 700; color: var(--brand); min-width: 44px; font-variant-numeric: tabular-nums; }
#mnResults .u { margin-left: auto; color: var(--ink-3); white-space: nowrap; }
#mnResults li .m { display: block; color: var(--ink-3); font-size: 12px; font-family: var(--doc); }
.picked { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 10px; padding: 12px 14px; background: var(--ok-soft); border: 1px solid var(--ok-line); border-radius: var(--r2); }
.picked > div { flex: 1 1 240px; }
.picked b { font-weight: 500; }
.picked small { display: block; font-family: var(--doc); }
.picked input { font-size: 16px; width: 9em; text-align: right; }
.free { margin-top: 14px; }
.free summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }

/* ---------- ป้ายและกล่องข้อความ ---------- */
div.sum { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 99px; font: 500 12.5px/1.6 var(--ui); background: #f1f2f6; color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip .ic { width: 12px; height: 12px; }
.chip.ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.chip.blue { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }
.chip.code { font-family: var(--doc); font-weight: 700; color: var(--brand); background: var(--brand-soft); border-color: transparent; border-radius: 4px; padding: 0 7px; }
.box { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 14px; margin: 10px 0; font-size: 14px; background: #f9fafc; }
.box > .ic { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.box > div { min-width: 0; flex: 1; }
.box.bad { background: var(--bad-soft); border-color: var(--bad-line); } .box.bad > .ic { color: var(--bad); }
.box.warn { background: var(--warn-soft); border-color: var(--warn-line); } .box.warn > .ic { color: var(--warn-mark); }
.box.note { background: var(--brand-soft); border-color: var(--brand-line); } .box.note > .ic { color: var(--brand); }
.box.ok { background: var(--ok-soft); border-color: var(--ok-line); } .box.ok > .ic { color: var(--ok); }
.box ul { margin: 2px 0 0; padding-left: 18px; }
.box li { margin: 2px 0; }
.box code { font-family: var(--doc); font-size: 12.5px; word-break: break-all; color: var(--ink-3); }

/* ---------- ตารางแบบสมุดบัญชี (ledger) ---------- */
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r2); background: var(--paper); }
table { border-collapse: collapse; width: 100%; font-family: var(--doc); font-size: 14.5px; }
th { font-family: var(--ui); font-weight: 500; font-size: 12.5px; color: var(--ink-3); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); background: #f7f8fb; white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfe; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .m { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; line-height: 1.4; white-space: normal; }
td .name { font-weight: 600; }
tr.need td:first-child { box-shadow: inset 3px 0 0 var(--warn-mark); }
tr.done td { color: var(--ink-3); }
td.wait { color: var(--line-3); text-align: right; }
td input.q { width: 7.5em; text-align: right; padding: 4px 8px; min-height: 32px; }
td .pl { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 13px; }
td .pl .line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
td .pl input { width: 6.5em; padding: 3px 8px; text-align: right; min-height: 30px; }
td .pl input[size="18"] { width: 12em; text-align: left; }
td .pl select { padding: 3px 8px; font-size: 13px; min-height: 30px; }
td .src { display: flex; gap: 5px; align-items: flex-start; color: var(--ink-3); font-size: 12px; line-height: 1.35; max-width: 320px; }
td .src .ic { width: 12px; height: 12px; margin-top: 2px; color: var(--line-3); }
td .src span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sugg { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sugg .btn { font-family: var(--doc); font-weight: 400; }
.map select { font-size: 13px; padding: 3px 6px; min-height: 30px; font-family: var(--ui); }
.map td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.sec-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0 8px; }
.sec-head b { font-family: var(--ui); font-weight: 500; font-size: 15px; }
.sec-head .code { font-family: var(--doc); font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 1px 8px; border-radius: 4px; }
.sec-head .btn { margin-left: auto; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-3); vertical-align: middle; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.need { background: var(--warn-mark); }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0; }

/* ---------- ข้อมูลโครงการ ---------- */
.info { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; margin: 4px 0 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r2); background: #fbfbfd; }
.info label { flex-direction: column; align-items: stretch; gap: 3px; font-size: 12.5px; }
.info input, .info select { width: 100%; }
.info .wide { grid-column: 1 / -1; }
.info .w2 { grid-column: span 2; }
/* พารามิเตอร์โครงการ (เลือกแถว ว480 ครั้งเดียว) — แถวย่อยในกรอบหัวแบบ */
.params { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 14px; margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.params .params-h { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.params .params-h b { font: 500 13.5px var(--ui); }
.params .params-h small { font-size: 12px; }

/* ---------- แถบข้อเสนอจากตารางจับคู่ (ใต้แต่ละรายการ) ---------- */
.conf { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 4px; font: 500 11.5px/1 var(--ui); letter-spacing: .02em; white-space: nowrap; border: 1px solid transparent; flex: none; }
.conf.high, .conf.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.conf.medium { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.conf.low, .conf.bad, .conf.warn { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.conf.none { background: #f1f2f6; color: var(--ink-2); border-color: var(--line); }
tr.prop td { padding: 0 10px 8px 46px; border-bottom: 1px solid var(--line); background: #fbfbfd; }
tr.prop:hover td { background: #fbfbfd; }
tr.prop.same td { padding-bottom: 4px; }
.rowwarn { margin-top: 4px; }
.rowwarn .pp-t { font-size: 12.5px; }
.props { display: flex; flex-direction: column; gap: 4px; }
.pp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 10px; border: 1px solid var(--line); border-left: 3px solid var(--brand-line); border-radius: var(--r); background: var(--paper); font-size: 13px; color: var(--ink-2); }
.pp.warn { border-left-color: var(--warn-mark); background: var(--warn-soft); }
.pp.bad { border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.pp.muted { border-left-color: var(--line-2); color: var(--ink-3); }
.pp-k { font: 500 12px/1 var(--ui); color: var(--ink-3); min-width: 3.6em; letter-spacing: .02em; }
.pp-t { flex: 1 1 320px; min-width: 0; line-height: 1.45; font-family: var(--doc); font-size: 13.5px; color: var(--ink); }
.pp.muted .pp-t { color: var(--ink-3); }
.pp-t .ic { width: 14px; height: 14px; vertical-align: -2px; color: var(--warn-mark); }
.pp-t small, .pp-why { display: block; color: var(--ink-3); font-size: 12px; line-height: 1.35; }
.pp-t a { color: var(--brand); }
.pp-a { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-left: auto; }
.pp-a .btn { font-family: var(--doc); font-weight: 500; }
.pp-note { flex-basis: 100%; font-size: 12px; color: var(--ink-3); padding-left: 4px; }
.pp-note::before { content: "— "; }
.chip.auto { font-size: 11px; padding: 0 7px; line-height: 1.5; }
.chip.b09 { background: #f1f2f6; color: var(--ink-2); border-color: var(--line-2); font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
#mnResults .chip.b09 { padding: 0 6px; font-size: 11px; vertical-align: 1px; }
tr.test td.n b { color: var(--bad); }
/* รอบห้า A2-02: สถานะการเผื่อปริมาณในช่องปริมาณ (ขั้นที่ 2) — ป้ายเล็กใต้ช่องกรอก สีตามความหมายเดิม (รอตัดสิน = เหลือง · เผื่อแล้ว = เขียว · ยืนยัน = เทา) */
.qchip { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 0 7px; border-radius: 4px; font: 500 11.5px/1.7 var(--ui); white-space: nowrap; background: #f1f2f6; color: var(--ink-3); border: 1px solid var(--line); }
.qchip .ic { width: 12px; height: 12px; }
.qchip.pending { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.qchip.applied { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.qchip.included, .qchip.none { background: #f1f2f6; color: var(--ink-2); border-color: var(--line-2); }
td .cu { display: flex; align-items: center; gap: 5px; margin-top: 4px; font: 400 12px/1.4 var(--ui); color: var(--ink-3); white-space: nowrap; }
td .cu input { margin: 0; }
/* รอบห้า: สถานะการเผื่อในแบบ ปร.1 (ใต้ปริมาณ) และกล่องวิธีหาค่า F ในเอกสารประกอบ */
table.pr td .qal { font-size: 11.5px; white-space: normal; }
table.pr td .qal.pending { color: var(--warn); font-weight: 600; }
table.pr td .qal .ic { width: 11px; height: 11px; vertical-align: -2px; }
.paper .fx { margin: 14px 0 0; padding: 12px 14px; border: 1px solid #333; border-left-width: 4px; font-size: 13.5px; line-height: 1.5; }
.paper .fx p { margin: 6px 0 0; }
.paper .fx > b { font-size: 14.5px; }
.paper .fx.warn { border-color: var(--warn-mark); background: var(--warn-soft); }
/* รอบหก (ข้อ 3): เอกสารประกอบเป็นตารางต่อรายการ + หัวข้อย่อย */
.paper .ax-h { font: 600 14.5px var(--ui); margin: 16px 0 6px; }
.paper table.src { font-size: 13px; }
.paper table.src th, .paper table.src td { padding: 4px 6px; white-space: normal; }
.paper table.src td.c { white-space: nowrap; }
.foot details.tech { font-size: 12px; color: var(--ink-3); }
.foot details.tech summary { cursor: pointer; color: var(--ink-2); }
table.pr2k-t th, table.pr2k-t td { padding: 5px 6px; }
table.pr2k-t td.n { min-width: 5.6em; }
.test-banner { margin: 0 0 12px; font-weight: 400; }
.test-banner[hidden] { display: none; }
.test-banner b { font-weight: 600; }
.test-banner .btn { margin-left: 6px; }
.sub-h { margin: 14px 0 4px; font: 500 14px var(--ui); color: var(--ink-2); }
.popover .recipe td .m { max-width: 420px; }
.popover .recipe td .row { margin: 4px 0 0; }
.popover .recipe td .row input[data-src] { width: 16em; text-align: left; }
.popover .recipe td select { max-width: 420px; font-size: 12.5px; padding: 3px 6px; min-height: 28px; margin-top: 4px; }
.popover ul.inline-list { max-height: 180px; margin: 4px 0 0; font-size: 13px; }
.popover .row .spacer { flex: 1; }
.popover li small.m { display: block; color: var(--ink-3); font-size: 12px; }

/* ---------- สถานะว่าง ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 16px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line-3); border-radius: var(--r2); background: var(--paper); font-size: 14.5px; }
.empty svg { width: 132px; height: 88px; stroke: var(--line-3); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty b { font-weight: 500; color: var(--ink); }

/* ---------- แถบปุ่มท้ายแผ่นงาน ---------- */
.actions { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 0 4px; margin-top: 14px; background: linear-gradient(to top, var(--paper) 78%, rgba(255, 255, 255, 0)); }
.actions .spacer { flex: 1; }
#review:not(:empty) { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
#review .actions { position: static; background: none; padding-top: 6px; }
.sub { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
.sub h3 { margin-top: 4px; }
.sub table input { width: 100%; min-width: 5em; padding: 3px 8px; min-height: 30px; }
.sub table input.n { text-align: right; }
.sub table td { padding: 6px 8px; }
#checks h3 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* ---------- แจ้งเตือนสั้น + หน้าต่างเลือก ---------- */
#toast { position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 8px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font: 14px var(--ui); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 92vw; box-shadow: 0 10px 30px rgba(22, 28, 45, .3); z-index: 40; }
#toast.on { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#toast button { margin-left: 12px; background: none; border: 0; color: #ffd27a; cursor: pointer; text-decoration: underline; font: inherit; }
.popover { position: fixed; inset: 0; background: rgba(22, 28, 45, .5); display: grid; place-items: center; z-index: 30; padding: 16px; }
.popover > div { position: relative; background: var(--paper); border-radius: 12px; padding: 20px 22px; width: min(820px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(22, 28, 45, .35); }
.popover h3 { margin: 0 32px 4px 0; font: 500 18px/1.3 var(--ui); }
.popover h3 small { display: block; font-size: 13px; color: var(--ink-3); font-family: var(--doc); }
.pop-x { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--paper); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.pop-x:hover { border-color: var(--line-3); }
.popover ul { list-style: none; margin: 10px 0; padding: 0; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r2); font-family: var(--doc); }
.popover li { padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 12px; align-items: baseline; }
.popover li:last-child { border-bottom: 0; }
.popover li:hover { background: var(--brand-soft); }
.popover li .u { margin-left: auto; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
/* รอบหก (ถ.2): แถว ว480 ที่ช่วงปริมาณตรงกับรายการอยู่บนสุดและมีป้าย · แถวคนละช่วงจางลง */
.popover li.hit { background: var(--ok-soft); }
.popover li.dim { color: var(--ink-3); }
.popover li .chip { margin-left: 6px; vertical-align: 1px; }
/* รอบหก (ข้อ 9): วัสดุที่ต้องสืบราคาเอง กรอกครั้งเดียวที่หัวตาราง */
.survey { margin: 0 0 14px; }
.survey .tw { margin-top: 8px; background: var(--paper); }
.survey-t td { padding: 5px 8px; }
.survey-t input { min-height: 34px; padding: 3px 8px; }
.survey-t input[data-sv] { width: 7em; text-align: right; }
.popover .recipe td input { width: 7em; text-align: right; }
.popover .actions { position: static; background: none; }

/* ---------- ผลลัพธ์: หัวเรื่อง สรุป กราฟ ---------- */
.results { margin-top: 6px; }
#forms:empty { display: none; }
.rhead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin: 24px 0 14px; }
.rhead .panel-h { margin: 0; }
.rmeta { color: var(--ink-2); font-size: 13.5px; font-family: var(--doc); }
.stamp { font-family: var(--doc); font-size: 12.5px; color: var(--ink-2); border: 1px solid var(--line-3); border-radius: 4px; padding: 6px 10px; line-height: 1.45; max-width: 460px; background: var(--paper); }
.stamp b { font-family: var(--ui); font-weight: 500; color: var(--ink); }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.toc a { font: 500 12.5px/1.6 var(--ui); color: var(--ink-2); background: var(--paper); border: 1px solid var(--line-2); border-radius: 99px; padding: 2px 10px; text-decoration: none; }
.toc a:hover { border-color: var(--brand); color: var(--brand); }
.summary { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 16px; margin-bottom: 22px; }
.hero { background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--brand); border-radius: var(--r2); padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 4px; }
.hero > small { font: 500 13px var(--ui); color: var(--ink-3); }
.hero-n { font: 600 44px/1.1 var(--ui); color: var(--ink); letter-spacing: -.01em; word-break: break-all; }
.hero-n span { font-size: 18px; font-weight: 400; color: var(--ink-2); margin-left: 6px; letter-spacing: 0; }
.hero-t { font-family: var(--doc); font-size: 14px; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-family: var(--doc); font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.figs { display: grid; gap: 14px; }
.fig { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r2); padding: 14px 16px; margin: 0; min-width: 0; }
.fig-t { font: 500 14.5px var(--ui); margin: 0 0 10px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.fig-t small { color: var(--ink-3); font-weight: 400; font-size: 12.5px; }
.bridge { display: grid; font-family: var(--doc); }
.br-row { display: grid; grid-template-columns: minmax(104px, 200px) minmax(0, 1fr) minmax(6.5em, auto); gap: 0 10px; align-items: stretch; min-height: 34px; }
.br-row.total { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 4px; }
.br-k { font-size: 13px; color: var(--ink-2); text-align: right; align-self: center; line-height: 1.3; padding: 3px 0; }
.br-row.total .br-k { color: var(--ink); font-weight: 600; }
.br-t { position: relative; border-left: 1px solid var(--line-2); overflow: hidden; }
.br-b { position: absolute; top: 50%; height: 18px; transform: translateY(-50%); border-radius: 0 4px 4px 0; min-width: 2px; }
.br-row.total .br-b { border-radius: 0; }
.br-b::before, .br-b::after { content: ""; position: absolute; width: 0; height: 200px; border-left: 1px solid var(--line-3); }
.br-b::before { left: 0; bottom: 100%; }
.br-b::after { right: -1px; top: 100%; }
.br-row.first .br-b::before, .br-row.last .br-b::after, .br-row.total .br-b::before, .br-row.total .br-b::after { display: none; }
.br-v { align-self: center; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-top: 10px; }
.legend i, .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.mix { display: grid; gap: 10px; }
.mix-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.mix-l { font-size: 13.5px; color: var(--ink); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mix-l .v { font-family: var(--doc); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mix-l .v b { color: var(--ink); font-weight: 600; }
.bar { display: flex; gap: 2px; height: 14px; border-radius: 0 4px 4px 0; overflow: hidden; background: #f1f2f6; }
.bar i { display: block; height: 100%; flex: 0 0 auto; min-width: 0; }
.bar i.m { background: var(--c1); } .bar i.l { background: var(--c2); }
.bar i.o1 { background: #2f3690; } .bar i.o2 { background: #6b73c9; } .bar i.o3 { background: #b0b6e6; } .bar i.o4 { background: var(--warn-mark); }
.bar i:last-child { border-radius: 0 4px 4px 0; }
.origin-l { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-top: 8px; font-family: var(--doc); }
.origin-l b { color: var(--ink); font-weight: 600; }

/* ---------- แบบ ปร. (กระดาษ) ---------- */
.paper { background: var(--paper); border: 1px solid var(--line-2); box-shadow: 0 1px 2px rgba(22, 28, 45, .06), 0 8px 24px rgba(22, 28, 45, .05); padding: 28px 32px 24px; margin: 0 0 20px; font-family: var(--doc); color: #111; font-size: 15px; line-height: 1.45; }
.paper-h { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; align-items: start; }
.paper-h .form-no { font-weight: 700; font-size: 17px; }
.paper-h .sheet-no { font-size: 14px; }
.paper-t { text-align: center; font-weight: 700; font-size: 17px; line-height: 1.35; margin: 2px 0 12px; }
.fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 14.5px; margin: 0 0 8px; }
.fields dt { white-space: nowrap; }
.fields dd { margin: 0; border-bottom: 1px dotted #666; min-height: 1.35em; padding: 0 4px; }
.unit { text-align: right; font-size: 13.5px; margin: 4px 0 4px; }
.blank { display: inline-block; min-width: 9em; border-bottom: 1px dotted #555; height: 1em; vertical-align: baseline; }
.blank.s { min-width: 2.6em; } .blank.m { min-width: 13em; }
.paper .tw { border: 0; border-radius: 0; }
table.pr { border: 1px solid #333; font-size: 14px; }
table.pr th, table.pr td { border: 1px solid #333; padding: 5px 8px; vertical-align: top; }
table.pr th { background: #f3f4f6; text-align: center; font-family: var(--doc); font-weight: 600; color: #111; font-size: 13.5px; white-space: normal; line-height: 1.3; }
table.pr thead tr:first-child th:first-child { width: 6%; }
table.pr th.note { width: 24%; }
table.pr th.item { min-width: 14em; }
table.pr td.n { min-width: 6.5em; }
table.pr td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.pr td.c { text-align: center; }
table.pr td.sub { padding-left: 24px; }
table.pr tr.sum td { font-weight: 700; background: #fafafa; }
table.pr tr.total td { font-weight: 700; font-size: 15px; background: var(--brand-soft); }
table.pr td .m { color: #444; font-size: 12.5px; }
table.pr tbody tr:hover td { background: inherit; }
table.pr tr.sum:hover td { background: #fafafa; }
table.pr tr.total:hover td { background: var(--brand-soft); }
table.pr .chip { font-size: 11.5px; padding: 0 7px; vertical-align: 1px; }
.paper .cond { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 14px; margin: 10px 0 4px; }
.paper .cond span b { font-weight: 600; }
.paper .note-l { font-size: 14px; margin: 8px 0 0; }
.paper .foot { font-size: 12.5px; color: #333; margin-top: 12px; }
.paper .foot ol { margin: 2px 0 0; padding-left: 20px; }
.paper-foot { font-family: var(--ui); font-size: 11.5px; color: var(--ink-3); margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.paper-foot .test-tag { flex-basis: 100%; color: var(--bad); font-weight: 600; font-size: 12.5px; border: 1px solid var(--bad-line); background: var(--bad-soft); padding: 3px 8px; border-radius: 4px; }
@media print { .paper-foot .test-tag { color: #000; background: #eee !important; border-color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 30px 0 4px; text-align: center; font-size: 14px; }
.sign .line { height: 0; border-bottom: 1px dotted #333; margin: 30px 10px 8px; }
.sign .name { margin-bottom: 2px; }
.paper .detail { margin: 10px 0 0; font-size: 14px; }
.paper .detail summary { cursor: pointer; color: var(--brand); font-family: var(--ui); font-weight: 500; }
.paper .detail ol, .paper .detail ul { margin: 6px 0 0; padding-left: 22px; }
.paper .detail li { margin: 3px 0; }
.paper .box { font-family: var(--ui); }
.paper .mono { font-variant-numeric: tabular-nums; }

/* ---------- ส่วนท้าย ---------- */
.foot { padding: 10px 24px 28px; color: var(--ink-3); font-size: 12.5px; font-family: var(--doc); display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot a { color: var(--ink-2); }
/* รอบแปด: ส่วนพับผู้ตรวจมีลายนิ้วมือไฟล์ 64 ตัวอักษร — ตัดคำได้ ไม่ดันหน้าให้เลื่อนแนวนอนบนมือถือเมื่อกางออก */
.foot #ver, .foot details.tech { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }

/* ---------- จอแคบ ---------- */
@media (max-width: 1100px) {
  .summary { grid-template-columns: 1fr; }
  .info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  body { font-size: 14.5px; }
  .top .wrap { min-height: 52px; }
  .brand-t small { display: none; }
  .brand-t b { white-space: nowrap; }
  .topnav { gap: 8px; }
  .topnav .tag { display: none; }
  .topnav a { white-space: nowrap; font-size: 13px; }
  .topnav a[data-preview-only] { display: none; }
  .legal { font-size: 12.5px; }
  .proto-note summary .long { display: none; }
  .proto-note summary .short { display: inline; }
  .stepper { margin: 14px 0 12px; }
  .stepper a { flex-direction: column; gap: 6px; padding: 10px 4px; text-align: center; min-height: 0; }
  .stepper .lb { font-size: 12px; align-items: center; }
  .stepper .lb small { display: none; }
  .stepper .no { width: 24px; height: 24px; font-size: 12px; }
  .panel { padding: 14px 14px 16px; border-radius: 8px; }
  .panel-h { grid-template-columns: 1fr; gap: 6px; }
  .panel-h p { grid-column: 1; }
  .doors { grid-template-columns: 1fr; gap: 8px; }
  .doors button { min-height: 0; padding: 10px 12px; align-items: center; }
  .doors button[aria-selected="true"]::after { display: none; }
  .door-ic { width: 30px; height: 30px; }
  .door-t b { font-size: 15px; }
  .door-t small { font-size: 12.5px; }
  .pane { padding: 12px; }
  .info { grid-template-columns: 1fr; padding: 12px; }
  .info .w2 { grid-column: auto; }
  /* ตาราง ปร.1 บนมือถือ: แต่ละรายการเป็นการ์ดเรียงลง (ไม่ต้องเลื่อนแนวนอนเพื่อหาช่องราคา/ค่าแรง) */
  #sheetBody table.sheet thead { display: none; }
  #sheetBody table.sheet, #sheetBody table.sheet tbody, #sheetBody table.sheet tr { display: block; min-width: 0; }
  #sheetBody table.sheet tr { position: relative; padding: 10px 12px 12px 12px; border-bottom: 1px solid var(--line); }
  #sheetBody table.sheet tr:last-child { border-bottom: 0; }
  #sheetBody table.sheet tr.need { box-shadow: inset 3px 0 0 var(--warn-mark); }
  #sheetBody table.sheet td { display: block; padding: 2px 0; border: 0; background: none !important; }
  #sheetBody table.sheet td:first-child { position: absolute; left: 12px; top: 10px; box-shadow: none; }
  #sheetBody table.sheet td:nth-child(2) { padding-left: 34px; min-height: 24px; padding-right: 36px; }
  #sheetBody table.sheet td.act { position: absolute; right: 6px; top: 4px; }
  #sheetBody table.sheet tr.prop { padding: 0 8px 10px; border-top: 0; margin-top: -4px; }
  #sheetBody table.sheet tr.prop td, #sheetBody table.sheet tr.prop td:first-child { position: static; display: block; padding: 0; box-shadow: none; min-height: 0; }
  .pp { padding: 6px 8px; }
  .pp-a { margin-left: 0; width: 100%; }
  .pp-a .btn { white-space: normal; text-align: left; }
  .params { grid-template-columns: 1fr; }
  #sheetBody table.sheet td[data-label]::before { content: attr(data-label); display: block; font: 500 11.5px/1.3 var(--ui); color: var(--ink-3); margin-top: 8px; }
  #sheetBody table.sheet td.n { text-align: left; white-space: normal; }
  #sheetBody table.sheet td .pl { width: 100%; }
  #sheetBody table.sheet td .pl .btn.cell { min-width: 9em; }
  #sheetBody table.sheet td .src { max-width: none; }
  #review table { min-width: 640px; }
  .sub table { min-width: 720px; }
  .actions { gap: 6px; position: static; background: none; } /* มือถือ: ไม่ลอยติดขอบล่าง (แถบ 5 ปุ่มบังแถบข้อเสนอ) */
  .actions .btn.big { width: 100%; justify-content: center; }
  .hero-n { font-size: 34px; }
  .paper { padding: 16px 14px 16px; font-size: 14px; }
  .paper-h { grid-template-columns: 1fr; }
  .paper-h .sheet-no { text-align: left; }
  .fields { grid-template-columns: 1fr; gap: 2px; font-size: 13.5px; }
  .fields dt { font-size: 12px; color: #555; }
  table.pr { min-width: 640px; }
  /* รอบหก (ข้อ 5): ที่ ≤ 720 px ซ่อนคอลัมน์หมายเหตุของแบบแนวนอน (อยู่ในเอกสารประกอบ) ให้คอลัมน์เงินอยู่ในจอ + คำใบ้เลื่อนดูตาราง */
  .pr1 table.pr, .pr2 table.pr { min-width: 620px; }
  .paper.wide table.pr th.note, .paper.wide table.pr td:last-child, .paper.wide table.pr td .qal { display: none; }
  .paper .scroll-hint { display: block; }
  input, select, textarea, td .pl input, td .pl select, td input.q, .sub table input, .map select { font-size: 16px; }
  td input.q { width: 6.5em; }
  .sign { grid-template-columns: 1fr; gap: 6px; font-size: 13.5px; }
  .sign .line { margin-top: 26px; }
  .popover > div { padding: 16px; }
  .foot { padding: 8px 16px 24px; }
  /* รอบหก (ข้อ 9): ตารางวัสดุสืบราคาเองบนมือถือ — แถวละกล่อง 2 คอลัมน์ ไม่ใช้กติกาการ์ดของตาราง ปร.1 */
  .survey-t thead { display: none; }
  .survey-t, .survey-t tbody { display: block; }
  .survey-t tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .survey-t td { display: block; padding: 0; border: 0; }
  .survey-t td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .survey-t td:nth-child(5) { grid-column: 1 / -1; }
  .survey-t input[data-svs] { width: 100%; }
  /* รอบหก (ข้อ 5): แบบ ปร.1 บนมือถือ — ตัวหนังสือเล็กลงให้เห็นคอลัมน์เงินมากขึ้น (เลื่อนแนวนอนใน .tw) */
  .paper.wide table.pr { font-size: 12.5px; }
  .paper.wide table.pr th.item { min-width: 10em; }
  .paper.wide table.pr td.n { min-width: 5.2em; }
  .paper.wide table.pr th, .paper.wide table.pr td { padding: 3px 5px; }
  /* รอบเจ็ด (ข้อ ข.): ตรึงคอลัมน์ชื่อรายการเมื่อเลื่อนดูคอลัมน์เงินบนมือถือ */
  .paper.wide table.pr th.item, .paper.wide table.pr td:nth-child(2) { position: sticky; left: 0; background: var(--paper); z-index: 1; box-shadow: 1px 0 0 #333; max-width: 11em; }
  .paper.wide table.pr th.item { background: #f3f4f6; }
  tr.prop.same td { padding-top: 0; }
}

/* ---------- พิมพ์ (A4 · ปร.1 และ ปร.2 แนวนอน) ---------- */
@page { size: A4; margin: 12mm 12mm 14mm; }
@page wide { size: A4 landscape; margin: 8mm 10mm 8mm; } /* รอบหก: ขอบแคบลงให้ ปร.1 12 รายการ + เชิงอรรถลงหน้าเดียว */
@media print {
  body { background: #fff; font-size: 12pt; color: #000; }
  .top, .legal, .stepper, .proto-note, .panel, .rhead, .summary, .toc, .actions, footer, .foot, #toast, #pop, .skip, .no-print, .sprite + .skip { display: none !important; }
  .wrap { max-width: none; padding: 0; margin: 0; }
  .results { margin: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; margin: 0; break-after: page; font-size: 11.5pt; color: #000; }
  .paper:last-child { break-after: auto; }
  .paper.wide { page: wide; }
  table.pr { font-size: 10.5pt; min-width: 0 !important; }
  table.pr th, table.pr td { border-color: #000; padding: 3pt 5pt; }
  table.pr td .m { font-size: 8.5pt; line-height: 1.3; }
  .paper.wide table.pr th.note { width: 22%; }
  /* รอบหก (ข้อ 3): ปร.1 12 รายการให้ลงหน้าเดียว (A4 แนวนอน) — หัวแบบแน่นขึ้น · ตาราง 9.5pt · หมายเหตุ 7.5pt · รหัส B-09 ไม่พิมพ์ (อยู่ในเอกสารประกอบ) */
  /* รอบแปด (R4-02): ท้ายกระดาษผูกกับหมายเหตุท้ายตารางเป็นก้อนเดียว (.keep) ไม่ตกไปหน้าว่าง · ปร.1 12 รายการ+หมายเหตุเต็ม (ชุดเดิน ศพด.2 ของผู้ตรวจ) ต้องลงหน้าเดียวโดยมีที่เหลือ */
  .paper .keep { break-inside: avoid; }
  .paper.pr1 table.pr th, .paper.pr1 table.pr td { padding: 1pt 3pt; }
  .paper.pr1 table.pr { font-size: 9pt; }
  .paper.pr1 { font-size: 10pt; line-height: 1.3; }
  .paper.pr1 .fields { line-height: 1.25; }
  .paper.pr1 .fields dt { font-size: 9.5pt; }
  .paper.pr1 table.pr td .m { font-size: 7.2pt; line-height: 1.18; }
  .paper.pr1 table.pr td small.m { display: none; }
  .paper.pr1 .fields { font-size: 10pt; gap: 0 8pt; margin-bottom: 2pt; }
  .paper.pr1 .paper-t { font-size: 13pt; margin: 0 0 3pt; }
  .paper.pr1 .paper-h .form-no { font-size: 13pt; }
  .paper.pr1 .note-l { font-size: 8pt; margin-top: 1.5pt; line-height: 1.25; }
  .paper.pr1 .paper-foot { font-size: 7.5pt; padding-top: 2pt; margin-top: 3pt; gap: 4px 12px; }
  .paper.pr1 .paper-foot .test-tag { font-size: 8pt; padding: 1pt 6pt; }
  .paper.pr1 .fields dd { min-height: 1.2em; }
  .paper.pr1 .unit { margin: 0 0 2pt; font-size: 9.5pt; }
  .paper .ax-h { font-size: 11.5pt; }
  .paper table.src { font-size: 9pt; }
  .scroll-hint { display: none !important; }
  .paper.wide table.pr th.item { min-width: 16em; }
  table.pr th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.pr tr.total td { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  thead { display: table-header-group; }
  tr, .sign, .fields { break-inside: avoid; }
  .paper .tw { overflow: visible; }
  .paper .detail { display: block; }
  .paper .detail summary { display: none; }
  .paper-foot { color: #444; border-color: #999; font-size: 8.5pt; }
  a { color: inherit; text-decoration: none; }
}
