/* =========================================================
   ThiCOS Surveying Suite — Theme
   โทนสีของเว็บ (ดินแดง–ส้ม) คงไว้ตามเดิม
   ========================================================= */
:root{
  --brand:      #9E1B32;
  --brand-700:  #82142a;
  --brand-900:  #5E0F1E;
  --brand-050:  #FCEEF0;
  --brand-100:  #F6DCE0;
  --accent:      #F58220;
  --accent-050:  #FFF3E6;
  --gold:        #C9922B;

  --ink:      #23272E;
  --ink-2:    #4A5160;
  --ink-3:    #737C8C;
  --line:     #E1E5EC;
  --line-2:   #EEF1F6;
  --bg:       #F4F6F9;
  --surface:  #FFFFFF;

  --ok:       #1E7F4D;
  --ok-bg:    #E8F6EE;
  --warn:     #B4740A;
  --warn-bg:  #FFF6E3;
  --err:      #C0392B;
  --err-bg:   #FDECEA;

  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --sh-1: 0 1px 2px rgba(24,28,36,.06), 0 1px 3px rgba(24,28,36,.05);
  --sh-2: 0 4px 12px rgba(24,28,36,.09);
  --sh-3: 0 12px 32px rgba(24,28,36,.16);
  --mono: 'Roboto Mono', ui-monospace, Consolas, monospace;
  --header-h: 62px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:'Sarabun',-apple-system,'Segoe UI',sans-serif;
  font-size:14px; line-height:1.55; -webkit-font-smoothing:antialiased;
}
a{color:var(--brand); text-decoration:none}
h1,h2,h3,h4{margin:0; font-weight:600; line-height:1.3}
code{font-family:var(--mono); background:var(--line-2); padding:1px 5px; border-radius:4px; font-size:.92em}
hr{border:0;border-top:1px solid var(--line);margin:12px 0}

/* ---------- Header ---------- */
.app-header{
  height:var(--header-h); display:flex; align-items:center; justify-content:space-between;
  padding:0 18px; background:linear-gradient(100deg,var(--brand-900),var(--brand) 55%,#B02742);
  color:#fff; box-shadow:var(--sh-2); position:sticky; top:0; z-index:60;
  border-bottom:2px solid var(--accent);
}
.brand{display:flex; align-items:center; gap:13px}
/* กรอบขาวรองโลโก้บริษัท เพื่อให้โลโก้สีเข้มอ่านออกบนแถบหัวสีเข้ม */
.brand-mark{
  height:42px; min-width:42px; padding:4px 9px; border-radius:9px; display:grid; place-items:center;
  background:#fff; box-shadow:0 2px 8px rgba(0,0,0,.22); flex:none;
}
.brand-mark img{height:34px; width:auto; display:block}
.brand-text h1{font-size:16px; letter-spacing:.2px}
.brand-text p{margin:1px 0 0; font-size:11.5px; opacity:.85}
.brand-text p b{color:var(--gold); font-weight:600}
.header-actions{display:flex; gap:8px; align-items:center}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:6px; justify-content:center;
  border:1px solid transparent; background:var(--brand); color:#fff;
  padding:8px 14px; border-radius:var(--r-sm); font-family:inherit; font-size:13px; font-weight:500;
  cursor:pointer; transition:.15s; white-space:nowrap;
}
.btn:hover{filter:brightness(1.08)}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.45; cursor:not-allowed}
.btn-sm{padding:5px 10px; font-size:12px}
.btn-lg{padding:11px 20px; font-size:14px}
.btn-ghost{background:rgba(255,255,255,.13); color:#fff; border-color:rgba(255,255,255,.2)}
.btn-ghost:hover{background:rgba(255,255,255,.22)}
.btn-outline{background:transparent; color:#fff; border-color:rgba(255,255,255,.55)}
.btn-outline:hover{background:rgba(255,255,255,.14)}
.content .btn-outline{color:var(--brand); border-color:var(--brand)}
.content .btn-outline:hover{background:var(--brand-050)}
.content .btn-ghost{background:var(--line-2); color:var(--ink-2); border-color:var(--line)}
.content .btn-ghost:hover{background:var(--line)}
.btn-orange{background:var(--accent)}
.btn-neutral{background:#5A6270}
.ico{font-size:14px; line-height:1}

/* ---------- Layout ---------- */
.app-body{display:flex; min-height:calc(100vh - var(--header-h)); align-items:stretch}
.sidebar{
  width:270px; flex:0 0 270px; background:var(--surface); border-right:1px solid var(--line);
  padding:14px 10px 20px; overflow-y:auto; max-height:calc(100vh - var(--header-h));
  position:sticky; top:var(--header-h);
}
.nav-section{margin-bottom:16px}
.nav-title{
  font-size:11px; font-weight:700; letter-spacing:.6px; text-transform:uppercase;
  color:var(--ink-3); padding:4px 10px 7px;
}
.nav-item{
  display:flex; align-items:center; gap:9px; padding:8px 10px; border-radius:8px;
  cursor:pointer; color:var(--ink-2); margin-bottom:2px; transition:.13s; border:1px solid transparent;
}
.nav-item:hover{background:var(--brand-050)}
.nav-item.active{background:var(--brand-050); border-color:var(--brand-100); color:var(--brand-700)}
.nav-item.active .nav-ico{color:var(--brand)}
.nav-item b{display:block; font-size:13.2px; font-weight:600}
.nav-item small{display:block; font-size:11px; color:var(--ink-3); line-height:1.35}
.nav-item > span:nth-child(2){flex:1; min-width:0}
.nav-ico{font-size:13px; color:var(--ink-3); width:14px; text-align:center}
/* หัวข้อ “ช่วยปรับปรุงระบบ” — อยู่บนสุดและเด่นกว่าหัวข้ออื่น */
.nav-feature{
  background:linear-gradient(135deg, var(--accent-050), var(--brand-050));
  border:1.5px solid var(--accent); border-radius:var(--r); padding:6px 6px 4px;
  box-shadow:0 2px 8px rgba(245,130,32,.18);
}
.nav-feature .nav-title{color:var(--brand-700)}
.nav-feature .nav-item{background:var(--surface); border-color:#F7C9A0}
.nav-feature .nav-item:hover, .nav-feature .nav-item.active{background:var(--accent-050); border-color:var(--accent)}
.nav-feature .nav-item b{color:var(--brand-700); font-size:13.6px}
.nav-feature .nav-ico{font-size:17px; width:20px}
.nav-feature-badge{background:var(--accent) !important; color:#fff !important; font-weight:700}
.badge{
  font-size:9.5px; padding:2px 6px; border-radius:20px; background:var(--line-2);
  color:var(--ink-3); font-weight:600; white-space:nowrap;
}
.badge-ok{background:var(--ok-bg); color:var(--ok)}
.sidebar-foot{margin-top:20px; padding:0 8px}
.biz-box{
  background:linear-gradient(160deg,var(--brand-900),var(--brand)); color:#fff;
  border-radius:8px; padding:11px 12px; font-size:11px; margin-bottom:10px;
  border-bottom:2px solid var(--gold);
}
.biz-box b{display:block; font-size:12px; line-height:1.35}
.biz-box .en{display:block; color:var(--gold); font-size:10.5px; margin:2px 0 6px}
.biz-box ul{margin:0; padding-left:15px; opacity:.9}
.biz-box li{margin-bottom:3px; line-height:1.35}
/* ป้ายบอกรุ่นของโปรแกรม + ปุ่มล้างแคช */
.build-box{
  display:flex; flex-direction:column; gap:6px; margin-bottom:10px;
  background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:9px 10px;
}
.build-box .bv{font-family:var(--mono); font-size:11px; color:var(--ink-3)}
.build-box .bw{
  font-size:11px; line-height:1.5; color:var(--warn); background:var(--warn-bg);
  border-radius:6px; padding:6px 7px;
}
.build-box button{
  border:1px solid var(--line); background:#fff; border-radius:6px; padding:6px 8px;
  font:inherit; font-size:11.5px; cursor:pointer; color:var(--ink-2);
}
.build-box button:hover{background:var(--brand-050); border-color:var(--brand-100); color:var(--brand-700)}

.ref-box{background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:10px 11px; font-size:11px; color:var(--ink-3)}
.ref-box b{display:block; color:var(--ink-2); font-size:11.5px; margin-bottom:5px}
.ref-box ul{margin:0; padding-left:15px}
.ref-box li{margin-bottom:4px; line-height:1.4}

.content{flex:1; min-width:0; padding:18px 22px 60px}

/* ---------- Doc panel ---------- */
.doc-panel{
  width:0; flex:0 0 0; background:var(--surface); border-left:1px solid var(--line);
  overflow:hidden; transition:.22s ease; display:flex; flex-direction:column;
  position:sticky; top:var(--header-h); max-height:calc(100vh - var(--header-h));
}
.doc-panel.open{width:46%; flex:0 0 46%; min-width:380px}
.doc-head{display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border-bottom:1px solid var(--line); background:var(--bg)}
.doc-body{flex:1; overflow:auto}
.doc-body iframe{width:100%; height:100%; border:0; display:block}
.doc-head .btn-outline{color:var(--brand); border-color:var(--brand)}
.doc-head .btn-outline:hover{background:var(--brand-050)}
.doc-head .btn-ghost{background:var(--line-2); color:var(--ink-2); border-color:var(--line)}
.doc-empty{padding:22px; font-size:13px; color:var(--ink-2)}
.doc-empty code{display:inline-block; margin:3px 0}
.muted{color:var(--ink-3); font-size:12px}

/* ---------- Module page ---------- */
.page-head{
  display:flex; align-items:flex-start; justify-content:space-between; gap:16px;
  padding-bottom:14px; margin-bottom:14px; border-bottom:2px solid var(--line);
}
.page-head h2{font-size:21px; color:var(--brand-700)}
.page-head .sub{font-size:12.5px; color:var(--ink-3); margin-top:3px}
.page-actions{display:flex; gap:8px; flex-wrap:wrap}

.tabs{display:flex; gap:2px; border-bottom:1px solid var(--line); margin-bottom:18px; flex-wrap:wrap}
.tab{
  padding:9px 16px; cursor:pointer; font-size:13.5px; font-weight:500; color:var(--ink-3);
  border-bottom:3px solid transparent; margin-bottom:-1px; transition:.13s; user-select:none;
}
.tab:hover{color:var(--brand)}
.tab.active{color:var(--brand-700); border-bottom-color:var(--brand); font-weight:600}
.tab-panel{display:none}
.tab-panel.active{display:block; animation:fade .18s ease}
@keyframes fade{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}

/* ---------- Card ---------- */
.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--sh-1); margin-bottom:16px; overflow:hidden}
.card-head{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:11px 15px; border-bottom:1px solid var(--line-2); background:linear-gradient(#fff,#FBFCFE);
}
.card-head h3{font-size:14.5px; color:var(--brand-700); display:flex; align-items:center; gap:8px}
.card-head .n{
  width:21px;height:21px;border-radius:5px;background:var(--brand);color:#fff;
  display:grid;place-items:center;font-size:11px;font-weight:700; flex:none;
}
.card-body{padding:15px}
.card-body.tight{padding:0}
.card.collapsed .card-body{display:none}
.card-head .toggle{cursor:pointer; color:var(--ink-3); font-size:12px; user-select:none}

/* ---------- Forms ---------- */
.grid{display:grid; gap:12px}
.g2{grid-template-columns:repeat(2,1fr)}
.g3{grid-template-columns:repeat(3,1fr)}
.g4{grid-template-columns:repeat(4,1fr)}
@media(max-width:1200px){.g4{grid-template-columns:repeat(2,1fr)} .g3{grid-template-columns:repeat(2,1fr)}}
@media(max-width:760px){.g2,.g3,.g4{grid-template-columns:1fr}}

.field{display:flex; flex-direction:column; gap:4px}
.field label{font-size:11.5px; font-weight:600; color:var(--ink-2)}
.field .hint{font-size:10.5px; color:var(--ink-3); line-height:1.35}
/* คำอธิบายที่เปลี่ยนตามตัวเลือก — ให้อ่านง่ายกว่า hint ธรรมดาเพราะเป็นเนื้อหาการเรียน */
.field .hint.help{
  font-size:11px; line-height:1.55; color:var(--ink-2); margin-top:5px;
  background:var(--brand-050); border-left:3px solid var(--brand-100);
  border-radius:0 6px 6px 0; padding:7px 10px;
}
.field .hint.help:empty{display:none}
.field .hint.help b{color:var(--brand-700)}
input[type=text],input[type=number],input[type=date],select,textarea{
  font-family:inherit; font-size:13px; color:var(--ink);
  border:1px solid var(--line); border-radius:var(--r-sm); padding:7px 9px; background:#fff;
  transition:.12s; width:100%;
}
input:focus,select:focus,textarea:focus{outline:0; border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-050)}
input.num,td input{text-align:right; font-family:var(--mono); font-size:12.5px}
input[readonly]{background:var(--line-2); color:var(--ink-2)}
.check{display:flex; align-items:center; gap:7px; font-size:12.5px; cursor:pointer; user-select:none}
.check input{width:15px;height:15px; accent-color:var(--brand); cursor:pointer}
.inline{display:flex; gap:8px; align-items:flex-end; flex-wrap:wrap}

/* ---------- Table ---------- */
/* กรอบตารางต้องกว้างไม่เกินพื้นที่ที่มี แล้วให้เลื่อนซ้าย–ขวาภายในกรอบเอง
   ถ้าไม่บังคับ max-width ไว้ กรอบจะขยายตามความกว้างตาราง แล้วโดน .card{overflow:hidden}
   ตัดทิ้ง ทำให้คอลัมน์ขวาหายไปบนจอแคบโดยเลื่อนดูไม่ได้ */
.tbl-wrap{
  overflow-x:auto; border-top:1px solid var(--line-2);
  max-width:100%; width:100%; -webkit-overflow-scrolling:touch;
}
.tbl-block{max-width:100%; min-width:0}
.work-b > *{min-width:0; max-width:100%}
.card-body > .tbl-wrap,.card-body.tight > .tbl-wrap{max-width:100%}

/* เงาขอบบอกว่ายังมีคอลัมน์ต่อไปอีกด้านนั้น — หายไปเองเมื่อเลื่อนสุดแล้ว */
.tbl-wrap.is-scrollable,
.report-preview.is-scrollable{
  background:
    linear-gradient(to right, var(--surface) 40%, rgba(255,255,255,0)) left center,
    linear-gradient(to left, var(--surface) 40%, rgba(255,255,255,0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(24,28,36,.16), rgba(0,0,0,0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(24,28,36,.16), rgba(0,0,0,0)) right center;
  background-repeat:no-repeat;
  background-size:30px 100%, 30px 100%, 11px 100%, 11px 100%;
  background-attachment:local, local, scroll, scroll;
}
/* กระดาษรายงานต้องขาวอยู่เหมือนเดิม เงาขอบเป็นแค่ชั้นบนสุด */
.report-preview.is-scrollable{background-color:#fff}
/* คำใบ้ใต้ตาราง — ขึ้นเฉพาะตารางที่กว้างเกินกรอบจริง ๆ เท่านั้น */
.has-scroll{position:relative}
.has-scroll::after{
  content:'⟷ ตารางนี้กว้างกว่าหน้าจอ — ลากซ้าย–ขวาเพื่อดูคอลัมน์ที่เหลือ';
  display:block; text-align:center; padding:5px 6px 2px;
  font-size:11px; color:var(--warn); background:var(--warn-bg);
  border-radius:0 0 6px 6px;
}
table.tbl{width:100%; border-collapse:collapse; font-size:12.5px}
table.tbl th,table.tbl td{border-bottom:1px solid var(--line-2); padding:6px 8px; text-align:center; white-space:nowrap}
table.tbl thead th{
  background:var(--brand-050); color:var(--brand-700); font-weight:600;
  font-size:11.5px; border-bottom:1.5px solid var(--brand-100); position:sticky; top:0; z-index:2;
}
table.tbl thead tr:nth-child(2) th{top:27px}
table.tbl tbody tr:hover{background:#FBFCFE}
table.tbl td.mono,table.tbl td .mono{font-family:var(--mono)}
table.tbl td.l{text-align:left}
table.tbl td.r{text-align:right; font-family:var(--mono)}
table.tbl tfoot td{background:var(--line-2); font-weight:600; border-top:1.5px solid var(--line)}
table.tbl input{border:1px solid transparent; background:transparent; padding:4px 5px; border-radius:4px}
table.tbl input:hover{border-color:var(--line); background:#fff}
table.tbl input:focus{background:#fff}
.w-dms{width:52px} .w-dms-s{width:64px}
/* ปุ่มเครื่องมือในตารางสมุดสนาม — ต้องเห็นชัดว่ากดได้ */
.cell-btn{
  border:1px solid var(--brand-100); background:var(--brand-050);
  color:var(--brand-700); font-family:inherit; font-size:11px; font-weight:600;
  padding:4px 8px; border-radius:5px; cursor:pointer; white-space:nowrap; line-height:1.2;
}
.cell-btn:hover{background:var(--brand); color:#fff; border-color:var(--brand)}
/* แถวที่ 1 ยังไม่ได้กรอกค่าอ่าน R.O. — เน้นให้เห็นว่ายังขาดอยู่ */
.cell-btn.need{background:var(--warn-bg); border-color:#E8C87A; color:var(--warn)}
.cell-btn.need::after{content:' •'; color:var(--warn); font-weight:700}
.cell-btn.need:hover{background:var(--warn); color:#fff; border-color:var(--warn)}
.cell-btn.on{background:var(--ok-bg); border-color:#BFE5CF; color:var(--ok)}
.cell-btn.on::after{content:' ✓'}
/* ปุ่มที่จะเขียนทับค่าซึ่งมาจากสมุดสนาม — ปิดไว้ */
.cell-btn:disabled,.cell-btn:disabled:hover{
  background:#F1F2F4; color:#A7AEB9; border-color:#DDE1E6; cursor:not-allowed
}
.dms-cell{display:flex; gap:2px; justify-content:center; align-items:center}
.dms-cell span{color:var(--ink-3); font-size:10px}
.row-ord{white-space:nowrap}
.row-drag{cursor:grab; color:var(--ink-3); user-select:none}
.mv{
  display:none; width:26px; height:24px; margin:0 1px; padding:0;
  border:1px solid var(--line); background:#fff; color:var(--ink-2);
  border-radius:5px; font-size:10px; line-height:1; cursor:pointer;
}
.mv:active{background:var(--brand-050); border-color:var(--brand-100)}
tr.dragging{opacity:.4}
tr.drop-target td{border-top:2px solid var(--accent)}
/* ปุ่มลบแถว — เดิมเป็นตัวอักษรจาง ๆ กดยากและแทบมองไม่เห็นบนมือถือ */
.tbl .del{
  display:inline-grid; place-items:center; width:26px; height:26px; border-radius:6px;
  color:var(--err); cursor:pointer; font-weight:700; opacity:.72; user-select:none; line-height:1;
}
.tbl .del:hover,.tbl .del:active{opacity:1; background:var(--err-bg)}
@media (max-width:760px){
  .tbl .del{width:38px; height:38px; font-size:16px; opacity:1; border:1px solid #F0C9C4; background:var(--err-bg)}
}
/* แถวที่ลบไม่ได้ (เช่น R.O. ของสถานีแรก) */
.tbl .lock{display:inline-grid; place-items:center; width:26px; height:26px; opacity:.45; font-size:12px; cursor:help}
tr.ctrl-row{background:var(--accent-050)}
tr.ctrl-row:hover{background:#FFEAD2}

/* ---------- Result cards ---------- */
.res-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:12px}
.res{border:1px solid var(--line); border-radius:var(--r); padding:12px 14px; background:var(--surface); position:relative; overflow:hidden}
.res::before{content:''; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--ink-3)}
.res.ok::before{background:var(--ok)} .res.err::before{background:var(--err)} .res.warn::before{background:var(--warn)}
.res h4{font-size:11px; color:var(--ink-3); font-weight:600; text-transform:uppercase; letter-spacing:.4px}
.res .v{font-size:20px; font-weight:600; font-family:var(--mono); margin:3px 0 1px; color:var(--ink)}
.res .s{font-size:11.5px; color:var(--ink-3)}
.res .tag{position:absolute; right:10px; top:10px; font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px}
.tag-ok{background:var(--ok-bg); color:var(--ok)}
.tag-err{background:var(--err-bg); color:var(--err)}
.tag-warn{background:var(--warn-bg); color:var(--warn)}

.alert{padding:10px 13px; border-radius:8px; font-size:12.5px; margin-bottom:12px; border:1px solid}
.alert-err{background:var(--err-bg); border-color:#F5C6C1; color:#8E271C}
.alert-warn{background:var(--warn-bg); border-color:#F3DFB4; color:#7A4F06}
.alert-ok{background:var(--ok-bg); border-color:#BFE5CF; color:#12603A}
.alert-info{background:#EEF4FD; border-color:#CFE0F7; color:#1B4C8C}
/* ตัวหนาตัวแรกของกล่องข้อความคือหัวเรื่อง จึงขึ้นบรรทัดใหม่ ส่วนตัวหนาอื่นอยู่ในบรรทัดเดียวกัน */
.alert > b:first-child{display:block; margin-bottom:2px}

/* ---------- Steps (คำอธิบายวิธีคำนวณ) ---------- */
.step{border:1px solid var(--line); border-radius:var(--r); margin-bottom:12px; background:var(--surface); overflow:hidden}
.step-h{display:flex; gap:10px; align-items:center; padding:10px 14px; background:var(--brand-050); border-bottom:1px solid var(--brand-100)}
.step-h .n{width:23px;height:23px;border-radius:50%; background:var(--brand); color:#fff; display:grid;place-items:center; font-size:11.5px; font-weight:700; flex:none}
.step-h b{font-size:13.5px; color:var(--brand-700)}
.step-b{padding:12px 14px}
.formula{
  background:#FAFBFD; border:1px solid var(--line); border-left:3px solid var(--accent);
  border-radius:6px; padding:9px 13px; font-family:var(--mono); font-size:12.5px;
  margin:8px 0; overflow-x:auto; line-height:1.75; white-space:pre-wrap;
}
.cite{font-size:11px; color:var(--ink-3); font-style:italic; margin-top:6px}
.cite::before{content:'📖 '}

/* ---------- Plot ---------- */
.plot-wrap{position:relative; background:#fff; border:1px solid var(--line); border-radius:var(--r); overflow:hidden}
#plotCanvas{display:block; width:100%; height:560px; cursor:grab}
#plotCanvas.grabbing{cursor:grabbing}
.plot-tools{
  position:absolute; top:10px; right:10px; display:flex; flex-direction:column; gap:5px;
  background:rgba(255,255,255,.94); border:1px solid var(--line); border-radius:8px; padding:7px; box-shadow:var(--sh-1);
}
.plot-tools .btn{padding:4px 9px; font-size:11.5px}
.plot-legend{
  position:absolute; left:10px; bottom:10px; background:rgba(255,255,255,.94); border:1px solid var(--line);
  border-radius:8px; padding:9px 12px; font-size:11px; box-shadow:var(--sh-1); line-height:1.9;
}
.plot-legend i{display:inline-block; width:22px; margin-right:6px; vertical-align:middle}
.plot-info{
  position:absolute; left:10px; top:10px; background:rgba(255,255,255,.94); border:1px solid var(--line);
  border-radius:8px; padding:8px 12px; font-size:11.5px; box-shadow:var(--sh-1); font-family:var(--mono);
}

/* ---------- Theory ---------- */
.theory{max-width:920px; font-size:14px; line-height:1.85}
.theory h3{font-size:17px; color:var(--brand-700); margin:26px 0 10px; padding-bottom:6px; border-bottom:2px solid var(--brand-100)}
.theory h4{font-size:14.5px; color:var(--ink); margin:18px 0 6px}
.theory p{margin:0 0 11px}
.theory ul,.theory ol{margin:0 0 12px; padding-left:22px}
.theory li{margin-bottom:5px}
.theory .note{background:var(--accent-050); border-left:3px solid var(--accent); padding:11px 14px; border-radius:0 8px 8px 0; margin:14px 0; font-size:13px}
.theory table{width:100%; border-collapse:collapse; font-size:12.5px; margin:12px 0}
.theory th,.theory td{border:1px solid var(--line); padding:6px 9px; text-align:center}
.theory th{background:var(--brand-050); color:var(--brand-700); font-weight:600}
.theory .eq{
  background:#FAFBFD; border:1px solid var(--line); border-left:3px solid var(--brand);
  padding:11px 16px; border-radius:0 8px 8px 0; font-family:var(--mono); font-size:13px; margin:12px 0; overflow-x:auto;
}

/* ---------- Modal / toast ---------- */
.modal-backdrop{position:fixed; inset:0; background:rgba(20,24,32,.5); z-index:200; display:none}
.modal-backdrop.show{display:block}
.modal{
  position:fixed; z-index:201; left:50%; top:50%; transform:translate(-50%,-50%);
  width:min(680px,92vw); max-height:86vh; background:#fff; border-radius:var(--r-lg);
  box-shadow:var(--sh-3); display:none; flex-direction:column; overflow:hidden;
}
.modal.show{display:flex}
.modal-head{display:flex; align-items:center; justify-content:space-between; padding:13px 17px; border-bottom:1px solid var(--line); background:var(--brand-050)}
.modal-head b{color:var(--brand-700); font-size:15px}
.modal-body{padding:17px; overflow-y:auto; font-size:13.5px}
.modal-foot{padding:11px 17px; border-top:1px solid var(--line); display:flex; align-items:center; justify-content:flex-end; gap:8px; background:var(--bg); flex-wrap:wrap}
.modal-foot:empty{display:none}

/* ปุ่มปิดหน้าต่าง — ต้องเห็นชัดและกดง่ายบนมือถือ ของเดิมเป็นปุ่มจาง ๆ มองไม่เห็น */
.modal-x{
  display:inline-flex; align-items:center; gap:6px; flex:none; cursor:pointer;
  border:1.5px solid var(--brand); background:#fff; color:var(--brand);
  border-radius:9px; padding:7px 13px; font:inherit; font-size:13px; font-weight:700;
  min-height:38px; line-height:1; transition:.12s;
}
.modal-x .x{font-size:15px}
.modal-x:hover,.modal-x:active{background:var(--brand); color:#fff}

.toast-wrap{position:fixed; right:18px; bottom:18px; z-index:300; display:flex; flex-direction:column; gap:8px}
.toast{
  background:var(--ink); color:#fff; padding:10px 15px; border-radius:8px; font-size:13px;
  box-shadow:var(--sh-2); animation:slideIn .2s ease; max-width:340px;
}
.toast.ok{background:var(--ok)} .toast.err{background:var(--err)} .toast.warn{background:var(--warn)}
@keyframes slideIn{from{transform:translateX(30px);opacity:0}to{transform:none;opacity:1}}

/* ---------- misc ---------- */
.empty-state{text-align:center; padding:60px 20px; color:var(--ink-3)}
.empty-state .big{font-size:46px; margin-bottom:10px; opacity:.35}
.empty-state h3{font-size:17px; color:var(--ink-2); margin-bottom:6px}
.pill{display:inline-block; font-size:11px; padding:2px 9px; border-radius:20px; background:var(--line-2); color:var(--ink-2); font-weight:600}
.pill-m{background:var(--brand-050); color:var(--brand-700)}
.pill-o{background:var(--accent-050); color:#A85508}
.spacer{flex:1}
.nowrap{white-space:nowrap}
.tar{text-align:right} .tac{text-align:center}
.fmono{font-family:var(--mono)}
.small{font-size:11.5px}
.mt8{margin-top:8px} .mt12{margin-top:12px} .mt16{margin-top:16px} .mb8{margin-bottom:8px} .mb12{margin-bottom:12px}
.flex{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.divider{height:1px;background:var(--line);margin:14px 0}
.report-root{display:none}

/* =========================================================
   วิธีทำอย่างละเอียด + รูปประกอบ
   ========================================================= */
.seg{display:inline-flex;border:1px solid var(--line);border-radius:7px;overflow:hidden}
.seg button{border:0;background:#fff;padding:6px 13px;font:inherit;font-size:12.5px;cursor:pointer;color:var(--ink-2)}
.seg button.on{background:var(--brand);color:#fff;font-weight:600}

.work{border:1px solid var(--line); border-radius:8px; margin:10px 0; overflow:hidden; background:#fff}
.work-h{background:var(--line-2); padding:7px 12px; font-weight:600; font-size:12.5px; color:var(--ink-2)}
.work-b{padding:11px 13px; display:flex; gap:16px; align-items:flex-start; flex-wrap:wrap}
.work-b pre{
  margin:0; flex:1 1 340px; min-width:0; font-family:var(--mono); font-size:12px;
  line-height:1.9; white-space:pre-wrap; word-break:break-word; color:var(--ink); tab-size:2;
}
.work-b > .tbl-wrap{flex:1 1 340px; min-width:0}
/* ตารางกว้าง (DMD · พิกัดฉาก · แบบฟอร์ม 7.5) — ใช้เต็มความกว้าง แล้วเลื่อนแนวนอนในกรอบตัวเอง */
.work-b > .tbl-block{flex:1 1 100%; min-width:0}
.tbl-block .tbl-wrap{overflow-x:auto}
/* ตารางคำนวณเนื้อที่ — เน้นช่องที่ใช้ตรวจสอบ DMD เส้นสุดท้าย */
.dmd-tbl td.mark{background:var(--err-bg); box-shadow:inset 0 0 0 1.5px #E9A9A2; font-weight:600}
.dmd-tbl tr.dmd-chk td{background:var(--ok-bg); color:var(--ok); font-size:11.5px}
.dmd-tbl tr.sum td,
.cc-tbl tr.sum td,
.form-tbl tr.sum td{background:var(--line-2); font-weight:600}

/* ตารางที่ 7.6 — วิธีพิกัดฉาก (คูณลง +  /  คูณขึ้น −) */
.cc-tbl td.down{color:var(--ok)}
.cc-tbl td.up{color:var(--err)}
.cc-tbl thead th:nth-child(2){background:var(--ok-bg); color:var(--ok)}
.cc-tbl thead th:nth-child(3){background:var(--err-bg); color:var(--err)}

/* ตารางที่ 7.5 — แบบฟอร์มสรุปการคำนวณวงรอบ */
.form-tbl{font-size:11.5px}
.form-tbl th,.form-tbl td{padding:4px 6px}
.form-tbl tr.sta-row td{background:var(--brand-050); font-weight:600}
.form-tbl td.corr{color:#00529B; font-style:italic}
/* สมุดสนาม — ช่องกรอกต้องกว้างพอให้เห็นค่าเต็ม (เช่น 28.658 · 210-58-59)
   และตัดลูกศรขึ้น–ลงของช่องตัวเลขออก เพราะเบียดพื้นที่จนตัวเลขโดนบัง */
#abTargetBox input[type=number]{min-width:76px; text-align:right; -moz-appearance:textfield}
#abTargetBox input[type=number]::-webkit-outer-spin-button,
#abTargetBox input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none; margin:0}
#abTargetBox input.fmono{min-width:94px}

/* ตารางสมุดสนาม (รูปแบบเดียวกับตารางที่ 7.2) */
.book-tbl{font-size:11.5px}
.book-tbl th,.book-tbl td{padding:4px 7px}
.book-tbl td.sta{background:var(--brand-050); font-size:13px; vertical-align:middle}
.book-tbl td.hi{background:var(--accent-050)}
.book-tbl tr.face-r td{background:#FAFBFD; color:var(--ink-2)}
.book-tbl tr.face-r:hover td{background:#F3F5F9}

/* ตารางสรุปแอซิมัทไป–กลับ */
.az-tbl td.bk{color:var(--ink-3)}
.az-tbl tbody tr:hover td.bk{color:var(--ink)}

/* ---------- ปรับแก้ด้วยกำลังสองน้อยที่สุด ---------- */
.theory .eq.eqp{white-space:pre-wrap}
.mat-tbl{font-size:11px}
.mat-tbl th,.mat-tbl td{padding:3px 6px}
.mat-tbl thead th{font-family:var(--mono); font-size:10.5px}
.mat-tbl td.zero{color:var(--line); font-weight:400}
.mat-tbl td.hi{background:var(--accent-050); font-weight:600}
.mat-tbl td.r,.mat-tbl td.l{font-family:var(--mono)}
table.tbl tr.row-bad td{background:var(--err-bg)}
table.tbl tr.row-bad td:last-child{font-weight:700; color:var(--err)}
.ell-cell svg{display:block; margin:0 auto}

.tbl-foot{
  font-family:var(--mono); font-size:11.5px; line-height:1.75; padding:9px 11px;
  background:#FAFBFD; border:1px solid var(--line); border-top:0;
  border-radius:0 0 8px 8px; white-space:pre-wrap; overflow-x:auto;
}
.fig{margin:0; flex:0 0 336px; max-width:100%}
.fig.fig-wide{flex:1 1 100%}
.fig svg{border:1px solid var(--line); border-radius:8px; display:block; background:#fff; width:100%; height:auto}
.fig figcaption{font-size:10.5px; color:var(--ink-3); text-align:center; margin-top:5px; line-height:1.45}

/* =========================================================
   โต๊ะเขียนแบบวงรอบ (Drafting Board)
   ========================================================= */
.bd-tools{display:flex; gap:8px; align-items:center; flex-wrap:wrap; padding:9px 12px;
  border-bottom:1px solid var(--line); background:linear-gradient(#fff,#FBFCFE)}
.bd-modes{display:flex; border:1px solid var(--line); border-radius:7px; overflow:hidden}
.bd-modes button{border:0; background:#fff; padding:6px 13px; font:inherit; font-size:12.5px; cursor:pointer; color:var(--ink-2)}
.bd-modes button.on{background:var(--brand); color:#fff; font-weight:600}
.bd-sep{width:1px; height:20px; background:var(--line)}
.bd-snap{display:flex; align-items:center; gap:5px; font-size:12px; color:var(--ink-2); white-space:nowrap}
.bd-snap select{width:auto; padding:4px 6px; font-size:12px}
.bd-zoom{display:flex; align-items:center; gap:4px}
.bd-zoom button{border:1px solid var(--line); background:#fff; border-radius:6px; padding:4px 9px; cursor:pointer; font:inherit; font-size:12px}
.bd-zoom button:hover{background:var(--brand-050)}
.bd-zoom span{font-family:var(--mono); font-size:11.5px; color:var(--ink-3); min-width:46px; text-align:center}
.bd-hint{padding:8px 13px; font-size:12px; background:var(--accent-050);
  border-bottom:1px solid var(--line); color:#7A4F06; line-height:1.5}
.bd-nav{display:inline-block; margin-left:6px; padding-left:8px; border-left:1px solid #E4C79A; color:#946408}

/* โต๊ะคุมมุมมองเอง (มาตราส่วน + จุดกึ่งกลาง) ไม่พึ่งแถบเลื่อนของเบราว์เซอร์
   จึงกดค้างลากเลื่อนได้เสมอ ไม่ว่าจะซูมเข้าหรือออกแค่ไหน */
.bd-shell{
  position:relative; height:640px; overflow:hidden; background:#fff;
  cursor:grab; touch-action:none; user-select:none;
}
.bd-shell.panning{cursor:grabbing}
.bd-svg{position:absolute; left:0; top:0; pointer-events:none}
.bd-grid{stroke:rgba(158,27,50,.10); stroke-width:1}
.bd-grid.b{stroke:rgba(158,27,50,.22)}
.bd-gtx{font-family:'Roboto Mono',monospace; font-size:9.5px; fill:var(--ink-3)}
.bd-gtx.b{fill:var(--ink-2); font-size:10px}
.bd-scalebar{fill:none; stroke:var(--ink-2); stroke-width:1.4}
.bd-info{
  position:absolute; left:10px; top:10px; z-index:4; pointer-events:none;
  background:rgba(255,255,255,.94); border:1px solid var(--line); border-radius:8px;
  padding:7px 11px; font-family:var(--mono); font-size:11px; color:var(--ink-2);
  box-shadow:var(--sh-1); line-height:1.6;
}
.bd-info b{font-family:Sarabun,sans-serif; font-size:10.5px; color:var(--ink-3); font-weight:600}
.bd-info hr{margin:5px 0; border-top:1px solid var(--line-2)}
.bd-edge{stroke:var(--brand); stroke-width:2.2; stroke-linecap:round}
.bd-edge.draft{stroke:var(--ink-3); stroke-width:1.6; stroke-dasharray:7 5}
.bd-arrow{fill:var(--brand)}
.bd-lblbg{fill:#fff; opacity:.92; stroke:var(--line)}
.bd-lbl{font-family:'Roboto Mono',monospace; font-size:11px; fill:var(--brand-900); text-anchor:middle; font-weight:500}
.bd-lbl.draft{fill:var(--ink-3); font-style:italic; font-family:Sarabun,sans-serif}
.bd-lbl2{font-family:'Roboto Mono',monospace; font-size:10px; fill:var(--ink-3); text-anchor:middle}
/* แนวเล็งกลับไปหมุดอ้างอิง R.O. — ที่มาของทิศทางทั้งวงรอบ */
.bd-ro{stroke:#6B4EAE; stroke-width:1.8; stroke-dasharray:9 5; stroke-linecap:round}
.bd-romk{fill:#6B4EAE}
.bd-rolbl{font-family:'Roboto Mono',monospace; font-size:10.5px; fill:#6B4EAE; text-anchor:middle; font-weight:600}
.bd-arc{fill:none; stroke:var(--accent); stroke-width:2}
.bd-arc.draft{stroke:var(--ink-3); stroke-dasharray:4 3; stroke-width:1.4}
.bd-arcbg{fill:#fff; opacity:.9}
.bd-arclbl{font-family:'Roboto Mono',monospace; font-size:10.5px; fill:#A85508; text-anchor:middle; font-weight:500}
.bd-arclbl.draft{fill:var(--ink-3); font-style:italic; font-family:Sarabun,sans-serif; font-size:10px}
.bd-nodes.hide-cards .bd-card{display:none}

/* ขยายโต๊ะเต็มจอ */
.bd-full{position:fixed; inset:0; z-index:150; background:#fff; display:flex; flex-direction:column}
.bd-full .bd-shell{flex:1; height:auto}

/* ชั้นการ์ดต้องไม่รับคลิก มิฉะนั้นจะบังพื้นที่ว่างจนกดค้างเลื่อนโต๊ะไม่ได้
   ให้เฉพาะตัวหมุดกับการ์ดเท่านั้นที่รับคลิก */
.bd-nodes{position:absolute; left:0; top:0; width:100%; height:100%; pointer-events:none}
.bd-pt{position:absolute; width:0; height:0; pointer-events:auto}
.bd-mk{position:absolute; left:-8px; top:-8px; width:16px; height:16px; border-radius:50%;
  background:var(--brand); border:2.5px solid #fff; box-shadow:0 1px 5px rgba(0,0,0,.32); cursor:grab; z-index:3}
.bd-mk.ctrl{background:var(--accent); border-radius:3px}
.bd-no{position:absolute; left:11px; top:-25px; font-size:11px; font-weight:700; color:var(--brand);
  background:#fff; border:1px solid var(--brand-100); border-radius:4px; padding:0 5px; cursor:grab; z-index:3}
.bd-card{position:absolute; left:24px; top:16px; width:198px; background:#fff;
  border:1px solid var(--line); border-radius:9px; box-shadow:var(--sh-2); font-size:12px; z-index:2}
/* วางการ์ดในควอดรันต์ด้านนอกของมุม จะได้ไม่บังส่วนโค้งและป้ายมุม */
.bd-pt.cl .bd-card{left:auto; right:24px}
.bd-pt.ct .bd-card{top:auto; bottom:16px}
.bd-pt.cl .bd-no{left:auto; right:11px}
.bd-pt.ct .bd-no{top:auto; bottom:-25px}
.bd-h{display:flex; gap:3px; align-items:center; padding:5px 6px; background:var(--brand-050);
  border-bottom:1px solid var(--brand-100); border-radius:8px 8px 0 0; cursor:grab}
.bd-nm{flex:1; min-width:0; border:1px solid transparent; background:transparent; font-weight:700;
  font-size:12.5px; padding:2px 4px; border-radius:4px; color:var(--brand-700)}
.bd-nm:hover,.bd-nm:focus{background:#fff; border-color:var(--line)}
.bd-ins,.bd-del{border:0; background:transparent; cursor:pointer; font-size:12.5px; padding:2px 5px; border-radius:4px; line-height:1}
.bd-ins{color:var(--ok)} .bd-del{color:var(--err)}
.bd-ins:hover{background:var(--ok-bg)} .bd-del:hover{background:var(--err-bg)}
.bd-co{display:flex; justify-content:space-between; gap:6px; padding:4px 8px;
  font-family:var(--mono); font-size:10.5px; color:var(--ink-3); border-bottom:1px dashed var(--line-2)}
.bd-row{display:flex; align-items:center; gap:6px; padding:4px 8px}
.bd-row label{font-size:10.5px; color:var(--ink-3); white-space:nowrap; min-width:50px}
.bd-dms{display:flex; gap:3px; flex:1; min-width:0}
.bd-dms input{width:100%; min-width:0; text-align:center; font-family:var(--mono); font-size:11px;
  padding:3px 2px; border:1px solid var(--line); border-radius:4px}
.bd-di{flex:1; min-width:0; text-align:right; font-family:var(--mono); font-size:11px;
  padding:3px 5px; border:1px solid var(--line); border-radius:4px}
.bd-di:disabled{background:var(--line-2); color:var(--ink-3)}

/* =========================================================
   Responsive — แท็บเล็ตและโทรศัพท์
   ========================================================= */
.nav-toggle{display:none}
.sidebar-backdrop{display:none}
.brand{min-width:0}
.brand-text{min-width:0}
.brand-text h1{white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.header-actions{flex:none}
#plotCanvas{touch-action:none}

/* =========================================================
   ตัวช่วยสำหรับผู้ใช้ใหม่ — คู่มือย่อ และป้ายบอกทิศทางในตาราง
   ========================================================= */
.howto{
  background:linear-gradient(#FFF9F0,#FFFDFA); border:1px solid #F0DCC0;
  border-left:4px solid var(--accent); border-radius:10px; margin-bottom:14px; overflow:hidden;
}
.howto>summary{
  cursor:pointer; padding:11px 14px; font-size:13.5px; color:#7A4F06;
  list-style:none; user-select:none; display:flex; align-items:center; gap:8px;
}
.howto>summary::-webkit-details-marker{display:none}
.howto>summary::before{content:'▸'; font-size:13px; transition:.15s}
.howto[open]>summary::before{transform:rotate(90deg)}
.howto>summary:hover{background:#FFF4E4}
.howto-b{padding:4px 14px 14px; font-size:13px; line-height:1.7; color:var(--ink-2)}
.howto-step{display:flex; gap:10px; align-items:flex-start; padding:7px 0; border-top:1px dashed #EEDCC4}
.howto-step .n{
  flex:none; width:22px; height:22px; border-radius:50%; background:var(--accent); color:#fff;
  display:grid; place-items:center; font-size:11.5px; font-weight:700; margin-top:2px;
}
.howto-note{
  margin-top:10px; padding:9px 11px; background:#fff; border:1px solid #F0DCC0;
  border-radius:7px; font-size:12.5px; line-height:1.7;
}

/* ป้ายเล็กใต้หัวตาราง และใต้ชื่อหมุด — บอกว่าตัวเลขในช่องคือของแนวไหน */
.th-sub{
  font-weight:400; font-size:10px; color:var(--ink-3); line-height:1.35;
  margin-top:2px; white-space:normal;
}
table.tbl thead th .th-sub b{color:var(--brand-700)}
.cell-dir{
  font-family:var(--mono); font-size:10px; color:var(--ink-3);
  text-align:center; margin-top:3px; white-space:nowrap; letter-spacing:-.1px;
  overflow:hidden; text-overflow:ellipsis; max-width:100%;
}
/* บนจอแคบ ตารางกลายเป็นการ์ดรายสถานี ป้ายจึงชิดซ้ายให้อ่านต่อจากชื่อหมุดได้เลย */
@media (max-width:760px){
  .cell-dir{text-align:left; font-size:10.5px; white-space:normal; margin-top:2px}
  .th-sub{display:none}
}
/* ช่องมุมที่ได้จากสมุดสนามแล้ว — ย้ำด้วยสีว่าไม่ต้องพิมพ์ซ้ำ */
input.from-book{background:var(--ok-bg); border-color:#BFE5CF}
input.from-book:focus{background:#fff}

/* ---------------------------------------------------------
   ช่องที่ไม่เกี่ยวกับแถว/โหมดนั้น — ปิดไว้กันกรอกผิดช่อง
   ทำให้ดู "ตัน" ชัดเจน ไม่ใช่แค่จาง ๆ จะได้ไม่พยายามคลิก
   และชี้เมาส์ค้างจะบอกเหตุผลว่าทำไมจึงกรอกไม่ได้
   --------------------------------------------------------- */
input.off-cell, select.off-cell, textarea.off-cell,
input:disabled, select:disabled, textarea:disabled,
/* ช่องที่มีสีพื้นเฉพาะของตัวเอง (ไม้กลาง · ระยะจากกึ่งกลาง) ต้องเขียนทับให้ชนะ
   ไม่งั้นจะยังดูเหมือนช่องที่กรอกได้ทั้งที่ปิดไปแล้ว */
table.lvl-input td.isc input.off-cell,
table.lvl-input td.offc input.off-cell,
table.lvl-input input:disabled{
  background:repeating-linear-gradient(135deg,#E8EAEE 0 4px,#DFE2E7 4px 8px) !important;
  color:#9AA3AF; border-color:#D3D8E0; cursor:not-allowed;
  -webkit-text-fill-color:#9AA3AF;
}
input.off-cell::placeholder{color:#B6BDC8}
td:has(> input.off-cell){background:#F5F6F8}

/* ช่องมุมที่ "ปิดเพราะค่ามาจากสมุดสนาม" ไม่ใช่ช่องที่ไม่เกี่ยวข้อง
   จึงคงสีเขียวไว้ให้รู้ว่ามีค่าอยู่จริง เพียงแต่แก้ที่นี่ไม่ได้ */
table.tbl input.from-book:disabled,
input.from-book:disabled{
  background:var(--ok-bg) !important;
  color:#2E6B3E; -webkit-text-fill-color:#2E6B3E;
  border-color:#BFE5CF; cursor:not-allowed;
}

/* =========================================================
   วัดสอบกล้องประมวลผลรวม (Total Station Certification)
   ========================================================= */
/* ---- ด่านรหัสผ่าน ---- */
.cert-gate{display:flex; justify-content:center; padding:40px 16px 80px}
.cert-gate-card{
  width:100%; max-width:440px; background:#fff; border:1px solid var(--line);
  border-radius:14px; padding:28px 24px 24px; text-align:center; box-shadow:0 8px 28px rgba(20,24,31,.08);
}
.cert-lock{font-size:38px; line-height:1; margin-bottom:10px}
.cert-gate-card h2{font-size:17px; margin:0 0 4px; color:var(--brand-900)}
.cert-gate-card p{margin:0 0 16px; font-size:12.5px}
.cert-gate-note{
  text-align:left; background:var(--warn-bg); border:1px solid #F0E0B4; color:#7A6224;
  border-radius:8px; padding:9px 12px; font-size:12px; line-height:1.55; margin-bottom:16px;
}
.cert-gate-card label{display:block; text-align:left; font-size:12px; font-weight:600; margin-bottom:5px}
.cert-gate-card input{
  width:100%; text-align:center; letter-spacing:5px; font-size:18px; font-family:var(--mono);
  padding:11px 12px; border:1.6px solid var(--line); border-radius:9px;
}
.cert-gate-card input:focus{border-color:var(--brand); outline:none}
.cert-gate-card .btn{width:100%; margin-top:14px; justify-content:center; padding:11px}
.cert-gate-msg{min-height:20px; margin-top:9px; font-size:12.5px; color:var(--err); line-height:1.5}
.cert-gate-foot{margin-top:16px; font-size:11px; color:var(--ink-3); line-height:1.55; text-align:left}

/* ---- บทเรียนและภาพประกอบ ---- */
.cert-fig{margin:14px 0 18px; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:#fff}
.cert-fig figcaption{background:var(--line-2); padding:7px 12px; font-size:12.5px; color:var(--ink-2)}
/* จำกัดความกว้างของภาพ ไม่ให้ยืดจนตัวหนังสือในภาพใหญ่เกินเนื้อหารอบข้าง */
.cert-svg{display:block; width:100%; height:auto; max-width:660px; margin:0 auto; background:#fff; padding:8px}
.cert-svg .s-lbl{font:600 11px Sarabun,sans-serif; fill:#9E1B32}
.cert-svg .s-lbl2{font:600 11px Sarabun,sans-serif; fill:#2E6BB8}
.cert-svg .s-lbl3{font:600 11px Sarabun,sans-serif; fill:#0A6B3D}
.cert-svg .s-sm{font:11px Sarabun,sans-serif; fill:#3A4048}
.cert-cap{padding:7px 12px; font-size:12px; color:var(--ink-3); border-top:1px dashed var(--line); line-height:1.55}
.cert-ul,.cert-ol{margin:8px 0 8px 20px; line-height:1.75; font-size:13px}
.cert-ul li,.cert-ol li{margin-bottom:5px}
.cert-grid2{display:grid; grid-template-columns:1fr 1fr; gap:6px 18px; margin:6px 0}
.cert-chk-line{display:flex; gap:8px; font-size:12.5px; line-height:1.5; align-items:flex-start}
.cert-no{
  flex:none; width:19px; height:19px; border-radius:50%; background:var(--brand); color:#fff;
  font-size:11px; display:flex; align-items:center; justify-content:center; margin-top:1px;
}
.cert-crit{
  display:flex; flex-wrap:wrap; gap:8px 22px; background:var(--ok-bg); border:1px solid #BFE5CF;
  border-radius:8px; padding:9px 12px; font-size:12.5px; margin-top:10px;
}
.cert-steps{display:grid; grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:8px}
.cert-steps > div{
  display:flex; gap:9px; align-items:center; background:#fff; border:1px solid var(--line);
  border-radius:9px; padding:9px 11px; font-size:12.5px;
}
.cert-steps span{
  flex:none; width:24px; height:24px; border-radius:50%; background:var(--brand); color:#fff;
  font-weight:700; font-size:12px; display:flex; align-items:center; justify-content:center;
}
/* ---- กล่อง "วิธีวัดสอบ" เหนือช่องกรอกของแต่ละหัวข้อ ---- */
.method-note{
  margin:0 0 10px; padding:9px 13px; font-size:12.5px; line-height:1.6;
  background:#F7F8FA; border-left:3px solid var(--brand); color:var(--ink-2);
}
.method-note b{color:var(--brand-900)}
.card-body.tight > .method-note{margin:0; border-bottom:1px solid var(--line)}
/* ---- กล่องผลทันทีท้ายการ์ดกรอกข้อมูล (วัดสอบกล้อง) ---- */
.live-v{margin:10px 0 0; font-size:12.8px; line-height:1.55}
.card-body.tight > .live-v{margin:0; padding:8px 12px; border-top:1px solid var(--line)}
.live-v .lv-h{font-size:11.5px; color:var(--muted); margin-bottom:4px}
.live-v .lv-row{padding:6px 10px; border-radius:6px; margin-top:4px; border-left:4px solid}
.live-v .lv-row.ok{background:#EAF6EE; border-color:#1E7F4D; color:#14532D}
.live-v .lv-row.no{background:#FDECEC; border-color:#D32F2F; color:#7F1D1D}
.live-v .lv-row.warn{background:#FFF6E5; border-color:#F58220; color:#7A3E00}
.live-v .lv-row.wait{background:#F4F6F9; border-color:#9AA3B2; color:var(--ink-2)}
.live-v .lv-fix{margin-top:4px; font-size:12.3px; color:#5B1515}

/* ---- การ์ดขั้นตอนในแท็บวิธีคำนวณ ---- */
.step-card{border-left:4px solid var(--brand)}
.step-card .work{margin-top:10px}
.step-card .rpt-h2{border:0; margin:14px 0 4px; color:var(--brand-900)}

/* ---- ป้ายบอกว่าช่องนี้ใช้กับมาตรฐานใด : ก = แบบโรงงาน · ข = ตามกฎหมายไทย ---- */
.tag-fac, .tag-law{
  display:inline-flex; align-items:center; justify-content:center; width:17px; height:17px;
  border-radius:50%; font-size:11px; font-weight:700; margin-right:5px; vertical-align:-3px;
}
.tag-fac{background:#E7EEF8; color:#2E6BB8}
.tag-law{background:#FBF1DD; color:#8A6417}
.tag-both{background:#E6F2EA; color:#0A6B3D}

/* ---- เลือกแบบการตรวจการวัดระยะ ก · ข · ค ---- */
.dist-opts{display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:9px; margin:0 0 12px}
.dist-opt{
  display:flex; gap:9px; align-items:flex-start; cursor:pointer;
  border:1.5px solid var(--line); border-radius:10px; padding:10px 12px; background:#fff;
  font-size:13px; line-height:1.5; transition:border-color .15s, background .15s;
}
.dist-opt:hover{border-color:#C9CED6}
.dist-opt input{margin-top:3px; accent-color:var(--brand-700)}
.dist-opt small{display:block; color:var(--ink-3); font-size:11.5px; margin-top:2px}
.dist-opt.on{border-color:var(--brand-700); background:#FFF8F8; box-shadow:0 0 0 2px rgba(158,27,50,.08)}
.dist-tag{
  flex:none; display:inline-flex; align-items:center; justify-content:center;
  width:24px; height:24px; border-radius:50%; font-size:13px; font-weight:700;
}
/* ซ่อนส่วนที่ไม่เกี่ยวกับแบบที่เลือก
   only-f  ใช้เมื่อตรวจแบบโรงงาน (ก, ค) · only-l  ใช้เมื่อตรวจตามกฎหมาย (ข, ค) · only-lo  เฉพาะแบบ ข */
.dist-card[data-dist="factory"] .only-l,
.dist-card[data-dist="factory"] .only-lo,
.dist-card[data-dist="legal"] .only-f,
.dist-card[data-dist="both"] .only-lo{display:none}

/* ---- สเปกการวัดระยะของเครื่อง ±(a มม. + b × 10⁻⁶ × D) ---- */
.spec-row{display:flex; flex-wrap:wrap; align-items:center; gap:6px}
.spec-row input{width:84px}
.spec-row .spec-eq{font-family:'Roboto Mono',monospace; font-size:13px; color:var(--ink-2)}
.spec-show{font-family:'Roboto Mono',monospace; font-size:13px; padding:7px 10px; background:#F6F7F9; border-radius:6px}
.spec-help{margin-top:8px; border:1px solid var(--line); border-radius:8px; background:#FAFBFC}
.spec-help > summary{cursor:pointer; padding:8px 11px; font-size:12.5px; font-weight:600; color:var(--brand-700)}
.spec-help[open] > summary{border-bottom:1px solid var(--line)}
.spec-help-b{padding:10px 12px; font-size:12.5px; line-height:1.7}
.spec-help-b p{margin:0 0 8px}
.spec-help-b .tbl{margin-bottom:8px}

/* ---- การ์ดอธิบายสองมาตรฐานคู่กัน ---- */
.std-2{display:grid; grid-template-columns:repeat(auto-fit,minmax(310px,1fr)); gap:11px; margin:0 0 12px}
.std-c{border:1px solid var(--line); border-radius:10px; padding:11px 13px; background:#fff; font-size:12.5px; line-height:1.65}
.std-fac{border-left:4px solid #2E6BB8}
.std-law{border-left:4px solid #B8892B}
.std-c .std-h{font-size:13.5px; font-weight:700; color:var(--ink); margin-bottom:2px}
.std-fac .std-h b{color:#2E6BB8}
.std-law .std-h b{color:#8A6417}
.std-c .std-q{color:var(--ink-3); font-size:12px; margin-bottom:7px}
.std-c .std-f{
  font-family:'Roboto Mono',monospace; font-size:11.5px; line-height:1.6; padding:6px 9px;
  background:#F6F7F9; border-radius:5px; margin-bottom:7px; white-space:pre-wrap; word-break:break-word;
}
.std-c .std-s{color:var(--ink-2); font-size:12px}

/* ---- ช่องกรอกระยะทดสอบ 4 ระยะ ---- */
.edm-set{border:1px solid var(--line); border-radius:9px; padding:9px 11px; margin-bottom:9px; background:#fff}
.edm-in{display:grid; grid-template-columns:minmax(180px,1fr) 3fr; gap:11px; margin-top:8px; align-items:start}
.edm-in label{display:block; font-size:12px; color:var(--ink-2); margin-bottom:4px}
.edm-in input, .edm-in textarea{width:100%}
.edm-line{display:flex; flex-wrap:wrap; gap:5px 14px; align-items:center; padding:5px 0}
.edm-line + .edm-line{border-top:1px dashed var(--line)}
.edm-line .lb{font-weight:600; color:var(--ink-2); min-width:104px}
.edm-set .edm-name{
  width:100%; border:0; border-bottom:1px dashed var(--line); font-weight:600; font-size:12.5px;
  padding:2px 0 5px; color:var(--brand-900); background:transparent;
}
.edm-set .edm-name:focus{outline:none; border-bottom-color:var(--brand)}
.edm-set textarea{width:100%; font-size:12.5px; line-height:1.6}
.edm-stat{
  margin-top:7px; padding-top:4px; border-top:1px dashed var(--line);
  font-size:12px; color:var(--ink-2);
}
.edm-stat b{color:var(--ink)}

/* ---- แถบเลือกรอบการวัดสอบ (ก่อน / หลังปรับแก้) ---- */
.round-bar{
  display:flex; flex-wrap:wrap; gap:10px 14px; align-items:center;
  background:#fff; border:1px solid var(--line); border-radius:11px;
  padding:10px 12px; margin-bottom:14px;
}
.round-tabs{display:flex; gap:8px; flex-wrap:wrap; flex:1 1 420px}
.round-btn{
  display:flex; flex-direction:column; gap:2px; align-items:flex-start; cursor:pointer;
  border:1.5px solid var(--line); border-radius:9px; background:#FAFBFC;
  padding:8px 14px; min-width:190px; text-align:left; font-family:inherit; color:var(--ink-2);
}
.round-btn:hover{border-color:var(--brand); background:#fff}
.round-btn.active{border-color:var(--brand); background:#fff; box-shadow:0 0 0 3px rgba(158,27,50,.10)}
.round-btn .rb-no{font-size:11.5px; color:var(--ink-3); letter-spacing:.3px}
.round-btn .rb-nm{font-size:14px; font-weight:700; color:var(--ink)}
.round-btn.active .rb-nm{color:var(--brand-900)}
.round-btn .rb-st{font-size:11.5px; font-weight:600}
.round-btn .rb-st.ok{color:var(--ok)}
.round-btn .rb-st.no{color:var(--err)}
.round-btn .rb-st.wait{color:var(--ink-3)}
.round-act{display:flex; gap:7px; flex-wrap:wrap}
.round-now{flex:1 1 100%; font-size:12px; color:var(--ink-3); border-top:1px dashed var(--line); padding-top:8px}
.round-now b{color:var(--brand-900)}
/* ป้ายบอกรอบเหนือตารางผลลัพธ์และหน้าวิธีคำนวณ */
.round-head{
  margin:0 0 12px; padding:9px 13px; font-size:13px;
  background:#F7F8FA; border-left:3px solid var(--brand); color:var(--ink-2);
}
.round-head b{color:var(--brand-900)}

/* ---- บันทึกการปรับแก้ระหว่างสองรอบ ---- */
.adj-items{margin-top:12px; border-top:1px dashed var(--line); padding-top:10px}
.adj-h{font-weight:600; font-size:12.5px; color:var(--ink-2); margin-bottom:6px}
.adj-items .check{display:block; margin:3px 0; font-size:12.5px}
.adj-rec{font-size:12.5px; line-height:1.7; color:var(--ink-2)}
.adj-rec b{color:var(--brand-900)}

/* ---- กล่องอ้างอิงกฎหมาย ---- */
.law-box{
  margin:12px 0; padding:11px 14px; font-size:12.5px; line-height:1.75;
  background:#FBF7EF; border:1px solid #E6D9BE; border-left:4px solid #B8892B; border-radius:8px; color:var(--ink-2);
}
.law-box .law-h{font-weight:700; color:#8A6417; margin-bottom:5px}
.law-box ul{margin:4px 0 0; padding-left:20px}
.law-box li{margin:4px 0}
.law-box b{color:var(--ink)}
.card-body > .law-box:first-child{margin-top:0}

/* ---- ผลถดถอยแยกค่าคงที่กับมาตราส่วน ---- */
.moc-fit{margin-top:10px}
.moc-fit-box{border:1px solid var(--line); border-radius:9px; overflow:hidden; background:#fff}
.moc-fit-box .work-h{padding:7px 12px; background:#F6F7F9; border-bottom:1px solid var(--line);
  font-weight:600; font-size:12.5px; color:var(--ink-2)}
.moc-fit-g{display:grid; grid-template-columns:repeat(auto-fit,minmax(215px,1fr)); gap:1px; background:var(--line)}
.moc-fit-g > div{background:#fff; padding:9px 12px}
.moc-fit-g span{display:block; font-size:11.5px; color:var(--ink-3)}
.moc-fit-g b{display:block; font-size:16px; font-family:'Roboto Mono',monospace; color:var(--brand-900); margin:2px 0 3px}
.moc-fit-g em{display:block; font-size:11.5px; font-style:normal; color:var(--ink-3); line-height:1.55}

/* ---- ตารางเทียบก่อน–หลังปรับแก้ ---- */
.cmp-up{color:var(--ok); font-weight:600}
.cmp-down{color:var(--err); font-weight:600}
tr.cmp-fixed{background:var(--ok-bg)}
tr.cmp-broke{background:var(--err-bg)}

/* ---- ป้ายผลการวัดสอบ ---- */
.cert-badge{display:inline-block; padding:3px 11px; border-radius:20px; font-size:12px; font-weight:600}
.cert-badge.ok{background:var(--ok-bg); color:var(--ok)}
.cert-badge.no{background:var(--err-bg); color:var(--err)}
.cert-badge.wait{background:var(--line-2); color:var(--ink-3)}
.res-card.cert-res.ok{border-color:#BFE5CF}
.res-card.cert-res.no{border-color:#EFC2C2}
.res-card.cert-res .s{font-size:11.5px; line-height:1.5}
@media (max-width:760px){ .cert-grid2{grid-template-columns:1fr} }

/* ช่องที่กรอกได้ แต่โปรแกรมไม่ได้นำค่าไปคำนวณ (จดไว้เป็นบันทึกสนามเท่านั้น)
   ทำให้จางลงเล็กน้อยเพื่อบอกลำดับความสำคัญ แต่ยังพิมพ์ได้ตามปกติ */
input.soft-cell{background:#FAFAFB; color:#6B7280}
input.soft-cell:focus{background:#fff; color:inherit}

/* ช่องตั้งค่าที่โหมดปัจจุบันไม่ได้ใช้ — หรี่ป้ายชื่อลง แล้วบอกเหตุผลไว้ใต้ช่อง */
.field-off > label{color:#9AA3AF}
.hint.lock-why{
  margin-top:5px; padding:5px 8px; border-radius:6px; line-height:1.45;
  background:#FFF8E6; border:1px solid #F0E0B4; color:#7A6224;
}
.hint.lock-why b{color:#5F4B14}

/* =========================================================
   งานระดับ (Levelling)
   ========================================================= */
/* ตารางกรอกสมุดสนามระดับ — ช่องตัวเลขต้องกว้างพอให้เห็นค่า 3 ตำแหน่งทศนิยมครบ
   และตัดปุ่มลูกศรขึ้น–ลงของ input number ออก เพราะกินที่และกดพลาดง่ายบนมือถือ */
table.lvl-input td{padding:4px 5px}
table.lvl-input input{padding:5px 6px; font-size:12.5px; text-align:right; min-width:74px}
table.lvl-input input[data-f="sta"],
table.lvl-input input[data-f="remark"]{text-align:left; min-width:96px}
table.lvl-input input[data-f="remark"]{min-width:150px}
table.lvl-input input[type=number]{-moz-appearance:textfield; appearance:textfield}
table.lvl-input input[type=number]::-webkit-outer-spin-button,
table.lvl-input input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none; margin:0}
table.lvl-input td.isc input{background:var(--accent-050)}

/* ตารางสมุดสนาม 3 สายใย และตารางค่าระดับ */
.lvl-book td.wire{font-size:11px; color:var(--ink-3); text-align:left; white-space:nowrap}
.lvl-book td.sta,.lvl-tbl td.sta{font-weight:700; color:var(--brand-700); background:#FAFBFD}
.lvl-book td.i{font-family:var(--mono); color:var(--ink-3); font-size:11px}
.lvl-book tr.mean td{border-bottom:1px solid var(--ink-3)}
.lvl-book tr.mean td.r{font-weight:700}
.lvl-book td.sm,.lvl-tbl td.sm{font-size:11px; color:var(--ink-3); white-space:normal; min-width:140px}
table.tbl tr.is td{background:#FCFCFD; color:var(--ink-2)}
table.tbl tr.is td.sta{font-weight:400; color:var(--ink-2)}
table.tbl td.corr{color:#00529B; font-style:italic}
.ok-txt{color:var(--ok); font-weight:700}
.err-txt{color:var(--err); font-weight:700}

/* ---- รูปตัดตามขวาง ---- */
.cx-row{border:1px solid var(--line); border-radius:10px; margin:0 12px 12px; overflow:hidden; background:#fff}
.cx-head{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:9px 12px; background:var(--brand-050); border-bottom:1px solid var(--brand-100); font-size:13px;
}
.cx-head b{color:var(--brand-700)}
.cx-sta{font-family:var(--mono); font-size:12.5px; color:var(--ink-2)}
.cx-link{font-size:11.5px; color:var(--ok); background:var(--ok-bg); padding:3px 8px; border-radius:20px}
.cx-man{font-size:11.5px; color:var(--warn); background:var(--warn-bg); padding:3px 8px; border-radius:20px}
.cx-none{font-size:11.5px; color:var(--err); background:var(--err-bg); padding:3px 8px; border-radius:20px}
.cx-body{display:grid; grid-template-columns:300px 1fr; gap:14px; padding:12px}
.cx-form{display:flex; flex-direction:column; gap:9px; min-width:0}
.cx-form textarea{
  font-family:var(--mono); font-size:12.5px; line-height:1.65; resize:vertical;
  white-space:pre; overflow-wrap:normal; overflow-x:auto;
}
/* ตารางจุดรูปตัด — อ่านอย่างเดียว ข้อมูลจริงอยู่ในสมุดสนาม */
.cx-pts{max-height:250px; overflow:auto; border:1px solid var(--line); border-radius:7px}
.cx-pts table{font-size:12px; margin:0}
.cx-pts thead th{position:sticky; top:0; z-index:1; font-size:11px}
.cx-pts td{padding:4px 8px}
/* ช่องระยะจากกึ่งกลางในสมุดสนาม — เน้นให้เห็นว่าเป็นตัวเชื่อมไปยังรูปตัด */
table.lvl-input td.offc input{background:#EDF4FB}
table.tbl th.offc{background:#E3EEF8; color:#1B4F72}
tr.row-flash td{animation:rowFlash 1.6s ease-out}
@keyframes rowFlash{0%{background:var(--accent-050)}100%{background:transparent}}
.cx-fig{min-width:0}
.cx-area{display:flex; gap:14px; flex-wrap:wrap; align-items:center; font-size:12.5px; margin-bottom:6px}
.cx-area .cut{color:var(--brand-700); background:var(--brand-050); padding:4px 10px; border-radius:6px}
.cx-area .fill{color:var(--ok); background:var(--ok-bg); padding:4px 10px; border-radius:6px}
.cx-chk{font-size:11.5px; padding:5px 9px; border-radius:6px; margin-bottom:6px; line-height:1.5}
.cx-chk.ok{color:var(--ok); background:var(--ok-bg)}
.cx-chk.bad{color:var(--warn); background:var(--warn-bg)}
svg.cs-svg{display:block; width:100%; height:auto; max-width:100%;
  border:1px solid var(--line); border-radius:8px; background:#fff}
.cs-tbl td.cut{color:var(--brand-700)}
.cs-tbl td.fill{color:var(--ok)}
/* ตารางสรุปข้อมูลพื้นที่ — รูปแบบรายงานวิเคราะห์ Cut/Fill */
table.cs-sum{max-width:520px}
table.cs-sum thead th{background:var(--accent-050); color:#7A4F06; text-align:left}
table.cs-sum td{padding:6px 10px}
table.cs-sum td.l{text-align:left}
table.cs-sum tr.hi td{background:var(--accent-050)}
table.cs-sum .net-fill{color:var(--err)}
table.cs-sum .net-cut{color:var(--ok)}
@media (max-width:900px){
  .cx-body{grid-template-columns:1fr}
  .cx-row{margin:0 0 12px}
}

/* รูปตัดตามยาว */
.lvl-fig{padding:10px 12px; background:#fff}
.lvl-fig svg,svg.lvl-svg{display:block; width:100%; height:auto; max-width:100%;
  border:1px solid var(--line); border-radius:8px; background:#fff}

/* กล่องข้อสังเกตในหน้าทฤษฎี */
.theory .warn-note{background:var(--warn-bg); border-left-color:var(--warn); color:#7A4F06}
.theory .ref-note{
  background:var(--bg); border:1px solid var(--line); border-radius:8px;
  padding:11px 13px; font-size:11.5px; color:var(--ink-3); line-height:1.7; margin-top:22px;
}
.theory .ref-note b{color:var(--ink-2)}
.theory .mono{font-family:var(--mono); font-size:12px}

/* ---------- ≤ 1024px : เมนูซ้ายเป็นลิ้นชักเลื่อนออก ---------- */
@media (max-width:1024px){
  .nav-toggle{
    display:inline-grid; place-items:center; flex:none;
    width:38px; height:38px; margin-right:2px;
    background:rgba(255,255,255,.14); border:1px solid rgba(255,255,255,.22);
    color:#fff; font-size:19px; line-height:1; border-radius:8px; cursor:pointer;
    -webkit-tap-highlight-color:transparent;
  }
  .nav-toggle:active{background:rgba(255,255,255,.28)}

  .sidebar{
    position:fixed; top:var(--header-h); left:0; bottom:0; z-index:120;
    width:284px; flex:0 0 284px; max-height:none;
    transform:translateX(-101%); transition:transform .22s ease;
    box-shadow:var(--sh-3); overscroll-behavior:contain;
  }
  .sidebar.open{transform:none}

  .sidebar-backdrop{
    position:fixed; left:0; right:0; bottom:0; top:var(--header-h);
    background:rgba(20,24,32,.45); z-index:110;
  }
  .sidebar-backdrop.show{display:block}

  .content{padding:14px 13px 60px}

  /* แผงเอกสารเป็นชั้นเต็มจอ */
  .doc-panel{
    display:none; position:fixed; top:var(--header-h); left:0; right:0; bottom:0;
    width:auto; flex:none; min-width:0; max-height:none; z-index:130; border-left:0;
  }
  .doc-panel.open{display:flex; width:auto; flex:none; min-width:0}
}

/* ---------- ≤ 760px : โทรศัพท์ ---------- */
@media (max-width:760px){
  :root{--header-h:56px}
  body{font-size:13.5px}

  .app-header{padding:0 10px; gap:8px}
  .brand{gap:9px}
  .brand-mark{height:34px; min-width:34px; padding:3px 6px; border-radius:8px}
  .brand-mark img{height:26px}
  .brand-text h1{font-size:13.5px}
  .brand-text p{display:none}
  .header-actions{gap:5px}
  .header-actions .btn{padding:8px 9px}
  .header-actions .lbl{display:none}
  .header-actions .ico{font-size:16px}

  .content{padding:12px 10px 50px}

  .page-head{flex-direction:column; align-items:stretch; gap:10px}
  .page-head h2{font-size:18px}
  .page-actions{gap:6px}
  .page-actions .btn{flex:1 1 calc(50% - 6px); justify-content:center}

  .tabs{flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none}
  .tabs::-webkit-scrollbar{display:none}
  .tab{padding:9px 13px; font-size:12.5px; white-space:nowrap; flex:none}

  .card-head{flex-wrap:wrap; padding:10px 12px}
  .card-body{padding:12px}
  .grid{gap:10px}

  /* ตารางผลลัพธ์ : เลื่อนแนวนอนได้ */
  .tbl-wrap{-webkit-overflow-scrolling:touch}
  table.tbl{font-size:12px}
  table.tbl th,table.tbl td{padding:5px 6px}

  /* ---- ตารางข้อมูลรังวัด : เปลี่ยนเป็นการ์ดรายสถานี ไม่ต้องเลื่อนซ้ายขวา ---- */
  .sta-wrap{overflow:visible}
  #tblStations,#tblStations tbody,#tblStations tfoot{display:block; width:100%}
  #tblStations thead{display:none}
  #tblStations tbody tr{
    display:grid; grid-template-columns:24px repeat(5,1fr); gap:7px 8px;
    padding:11px 12px 13px; border-bottom:1px solid var(--line); align-items:end;
  }
  #tblStations tbody tr:hover{background:transparent}
  #tblStations tbody td{border:0; padding:0; text-align:left; white-space:normal}
  #tblStations tbody td[data-l]::before{
    content:attr(data-l); display:block; font-size:10px; font-weight:600;
    color:var(--ink-3); margin-bottom:3px; letter-spacing:.2px;
  }
  #tblStations tbody td:nth-child(1){grid-row:1; grid-column:5; text-align:right; padding-bottom:2px}
  #tblStations tbody td:nth-child(2){grid-row:1; grid-column:1; font-weight:700; color:var(--brand); padding-bottom:8px}
  #tblStations tbody td:nth-child(3){grid-row:1; grid-column:2/5}
  #tblStations tbody td:nth-child(4){grid-row:3; grid-column:4/7}
  #tblStations tbody td:nth-child(5){grid-row:2; grid-column:1/3}
  #tblStations tbody td:nth-child(6){grid-row:2; grid-column:3/5}
  #tblStations tbody td:nth-child(7){grid-row:2; grid-column:5/7}
  #tblStations tbody td:nth-child(8){grid-row:3; grid-column:1/4}
  #tblStations tbody td:nth-child(9){grid-row:4; grid-column:1/4}
  #tblStations tbody td:nth-child(10){grid-row:4; grid-column:4/7}
  #tblStations tbody td:nth-child(11){grid-row:5; grid-column:1/4}
  #tblStations tbody td:nth-child(12){grid-row:5; grid-column:4/7}
  #tblStations tbody td:nth-child(13){grid-row:1; grid-column:6; text-align:right; padding-bottom:6px}
  #tblStations tbody .cell-btn{width:100%; padding:8px 6px; font-size:12px}
  #tblStations .row-drag{display:none}
  #tblStations .mv{display:inline-block; width:24px; height:26px; margin:0}
  #tblStations .del{font-size:16px; padding:3px 5px; opacity:1}
  #tblStations tbody input,#tblStations tbody select{
    width:100% !important; min-width:0; border:1px solid var(--line); background:#fff;
    padding:8px 9px; border-radius:6px; font-size:14px; text-align:left;
  }
  #tblStations tbody input[type=number]{text-align:right}
  #tblStations tbody .w-dms,#tblStations tbody .w-dms-s{width:100%}
  #tblStations tfoot tr{display:block; padding:10px 12px; background:var(--line-2)}
  #tblStations tfoot td{display:inline-block; border:0; padding:0 10px 0 0; text-align:left; white-space:normal}

  .res-grid{grid-template-columns:1fr}
  .res .v{font-size:18px}

  #plotCanvas{height:390px}
  .plot-legend{font-size:10px; padding:7px 9px; line-height:1.7}
  .plot-tools .btn{padding:6px 10px}

  .work-b{flex-direction:column; padding:9px 10px; gap:10px}
  .work-b pre{flex:1 1 auto; width:100%; font-size:11px; line-height:1.85}
  .fig{flex:1 1 auto; width:100%}
  .bd-shell{height:460px}
  .bd-card{width:172px; font-size:11.5px}
  .bd-tools{gap:6px; padding:8px 10px}
  .bd-hint{font-size:11.5px}
  .seg button{padding:6px 10px; font-size:12px}

  .theory{font-size:13.5px; line-height:1.8}
  .theory .eq,.formula{font-size:11.5px; padding:9px 11px}
  .theory h3{font-size:15.5px}

  .modal{width:96vw; max-height:88vh; border-radius:12px}
  .modal-body{padding:14px}
  .modal-head{padding:10px 12px; gap:10px}
  .modal-head b{font-size:14px; min-width:0}
  .modal-x{min-height:44px; padding:9px 15px; font-size:14px}
  .modal-foot{padding:10px 12px}
  .modal-foot .btn{flex:1 1 100%; justify-content:center; min-height:44px}
  .modal-foot .muted{flex:1 1 100%; text-align:center; margin:0 0 4px !important}
  .toast-wrap{right:10px; left:10px; bottom:10px}
  .toast{max-width:none}

  .report-preview{padding:10px}
}

/* ---------- หน้าพรีวิวรายงานจากลิงก์แชร์ (index.html?view=…) ---------- */
body.view-mode .app-header, body.view-mode .app-body, body.view-mode .sidebar-backdrop{display:none !important}
body.view-mode{background:var(--bg)}
.view-bar{
  position:sticky; top:0; z-index:30; display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between;
  padding:10px 16px; background:var(--surface); border-bottom:2px solid var(--brand); box-shadow:0 2px 8px rgba(0,0,0,.06);
}
.view-brand{display:flex; gap:10px; align-items:center; min-width:0}
.view-brand img{height:34px; width:auto}
.view-brand b{display:block; color:var(--brand-700); font-size:15px}
.view-brand span{display:block; font-size:12px; color:var(--ink-3)}
.view-actions{display:flex; flex-wrap:wrap; gap:6px}
.view-msg{max-width:1240px; margin:24px auto; padding:14px 16px; text-align:center; color:var(--ink-2)}
.view-err{color:var(--err); background:var(--err-bg); border-radius:var(--r)}
body.view-mode .report-root{display:block; max-width:1240px; margin:16px auto 32px; width:auto}
@media (max-width:700px){ body.view-mode .report-root{margin:8px} }
.reg-open{opacity:.55}

/* ---------- ตัวนับผู้ใช้ (เมนูซ้าย) และหน้าสถิติ ---------- */
.visit-box{display:flex; gap:8px; align-items:center; margin:6px 2px 2px; padding:6px 10px; border-radius:8px;
  background:var(--surface); border:1px dashed #F7C9A0; font-size:12px; color:var(--ink-2); line-height:1.35}
.visit-box b{color:var(--brand-700); font-size:14px}
.visit-box small{color:var(--ink-3)}
.vb-ico{font-size:18px}
.st-tiles{display:grid; grid-template-columns:repeat(auto-fit, minmax(160px, 1fr)); gap:10px; margin-bottom:14px}
.st-tile{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:12px 14px}
.st-l{font-size:12px; color:var(--ink-3)}
.st-v{font-size:26px; font-weight:700; color:var(--ink); line-height:1.25; margin-top:2px}
.st-s{font-size:11.5px; color:var(--ink-3)}
.st-seg{display:flex; gap:6px}
.st-chart{position:relative}
.st-chart svg{width:100%; height:auto; display:block}
.st-grid{stroke:var(--line-2); stroke-width:1}
.st-base{stroke:#98A2B0; stroke-width:1}
.st-ax{font-size:11px; fill:var(--ink-3)}
.st-fill{fill:var(--brand)}
.st-bar{cursor:default}
.st-bar.on .st-fill{fill:var(--brand-900)}
.st-tip{position:absolute; pointer-events:none; background:var(--ink); color:#fff; font-size:12px; padding:5px 9px;
  border-radius:6px; white-space:nowrap; box-shadow:0 2px 8px rgba(0,0,0,.18)}
.st-table{margin-top:10px}
.st-table summary{cursor:pointer; color:var(--brand-700); font-size:13px}
.st-2col{display:grid; grid-template-columns:repeat(auto-fit, minmax(320px, 1fr)); gap:14px}
.st-hbars{display:flex; flex-direction:column; gap:7px}
.st-hrow{display:grid; grid-template-columns:minmax(110px, 38%) 1fr 54px; gap:8px; align-items:center; font-size:13px}
.st-hl{color:var(--ink-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.st-ht{background:var(--line-2); border-radius:4px; height:14px}
.st-hb{background:var(--brand); height:14px; border-radius:0 4px 4px 0}
.st-hv{text-align:right; font-weight:600; color:var(--ink)}

/* ---------- วัดสอบกล้องระดับ ---------- */
.lc-yn-row{display:flex; gap:10px; flex-wrap:wrap}
.lc-yn{display:inline-flex; align-items:center; gap:6px; padding:8px 16px; border:1.5px solid var(--line); border-radius:8px;
  cursor:pointer; font-weight:600; background:var(--surface)}
.lc-yn.on.pass{border-color:var(--ok); background:var(--ok-bg); color:var(--ok)}
.lc-yn.on.fail{border-color:var(--err); background:var(--err-bg); color:var(--err)}
.lc-adj{display:flex; flex-wrap:wrap; gap:8px 18px}
.lc-adj label{display:flex; gap:6px; align-items:center; font-size:13px}
.lc-live{color:var(--ink-2)}
/* โหมดกรอกทีละขั้นตอน */
.lc-mode{display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin:0 0 10px}
.lc-chips{display:flex; flex-wrap:wrap; gap:6px; margin:0 0 12px}
.lc-chip{display:inline-flex; align-items:center; gap:6px; padding:5px 10px 5px 5px; border:1px solid var(--line); border-radius:20px;
  background:var(--surface); font:inherit; font-size:12.5px; color:var(--ink-2); cursor:pointer}
.lc-chip .lc-cn{width:22px; height:22px; border-radius:50%; display:grid; place-items:center; background:var(--line-2); font-weight:700; font-size:11.5px}
.lc-chip.ok .lc-cn{background:var(--ok); color:#fff}
.lc-chip.opt{border-style:dashed}
.lc-chip.on{border-color:var(--brand); box-shadow:0 0 0 3px rgba(158,27,50,.10); color:var(--brand-900); font-weight:600}
.lc-chip.on .lc-cn{background:var(--brand); color:#fff}
.lc-step{border:1.5px solid var(--brand-100); border-radius:var(--r); background:var(--surface); margin-bottom:12px; overflow:hidden}
.lc-step-h{display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; padding:10px 14px; background:var(--brand-050); border-bottom:1px solid var(--brand-100)}
.lc-step-h b{font-size:16px; color:var(--brand-900)}
.lc-step-no{font-size:12px; color:var(--ink-3)}
.lc-where{font-size:12.5px; background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:2px 9px; color:var(--ink-2)}
.lc-opt{font-size:11.5px; background:var(--warn-bg); color:var(--warn); border-radius:12px; padding:2px 8px; font-weight:600}
.lc-step-b{padding:10px 14px 4px}
.lc-tools{font-size:13px; color:var(--ink-2); margin-bottom:4px}
.lc-nav{display:flex; justify-content:space-between; gap:10px; margin:6px 0 18px}
.lc-acts{display:flex; flex-wrap:wrap; gap:8px; margin:0 0 12px}
/* วัดสอบกล้องประมวลผลรวม — โหมดทีละขั้นตอนซ่อนการ์ดที่ไม่เกี่ยวกับขั้นปัจจุบัน */
.wz-hide{display:none !important}

/* ---------- ทะเบียนใบรับรอง ---------- */
.reg-actions{flex-wrap:wrap; gap:6px}
.reg-tbl td{white-space:nowrap}
.reg-btns{display:flex; gap:4px; flex-wrap:wrap; min-width:200px; max-width:290px}
.reg-btns .reg-del{color:var(--err)}
.reg-res{display:inline-block; padding:1px 9px; border-radius:10px; font-size:12px; font-weight:600}
.reg-ok{background:var(--ok-bg); color:var(--ok)}
.reg-no{background:var(--err-bg); color:var(--err)}
.reg-wait{background:var(--warn-bg); color:var(--warn)}
.reg-overdue{color:var(--err); font-weight:600}
.reg-long{white-space:pre-wrap !important; min-width:260px; max-width:420px}
.reg-admin-only{display:none}
.reg-is-admin .reg-admin-only{display:inline-flex}
.reg-btns .btn[disabled]{opacity:.35; cursor:not-allowed}
.reg-warn{color:var(--warn); background:var(--warn-bg); padding:6px 10px; border-radius:6px}

/* ---------- ห้องบทเรียน ---------- */
.ls-books{display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:14px}
.ls-book{display:flex; gap:14px; text-align:left; padding:16px; border:1px solid var(--line); border-radius:var(--r-lg);
  background:var(--surface); box-shadow:var(--sh-1); cursor:pointer; font:inherit; color:inherit; transition:.15s}
.ls-book:hover{border-color:var(--brand); box-shadow:var(--sh-2); transform:translateY(-1px)}
/* การ์ดคู่มือที่มีปุ่มแชร์ — ปุ่มแชร์อยู่มุมขวาบน แยกจากปุ่มเปิดเล่ม */
.ls-card{position:relative; display:flex}
.ls-card .ls-book{flex:1; width:100%; padding-right:92px}
.ls-share-btn{position:absolute; top:10px; right:10px}
.ls-book-ico{font-size:34px; line-height:1}
.ls-book-t{display:flex; flex-direction:column; gap:4px; min-width:0}
.ls-book-t b{font-size:16px; color:var(--brand-900)}
.ls-book-t small{color:var(--ink-3)}
.ls-book-c{font-size:12px; color:var(--ink-2)}
.ls-prog{display:block; height:6px; background:var(--line-2); border-radius:4px; overflow:hidden; margin:4px 0 2px}
.ls-prog span{display:block; height:100%; background:var(--ok)}
.ls-crumb{font-size:12px; color:var(--ink-3); margin-bottom:2px}
.ls-wrap{display:grid; grid-template-columns:250px minmax(0,1fr); gap:18px; align-items:start}
.ls-toc{position:sticky; top:calc(var(--header-h) + 12px); background:var(--surface); border:1px solid var(--line); border-radius:var(--r);
  padding:8px; max-height:calc(100vh - var(--header-h) - 30px); overflow:auto}
.ls-toc-h{font-weight:600; font-size:12.5px; color:var(--brand-900); padding:4px 6px 8px; border-bottom:1px solid var(--line-2); margin-bottom:6px}
.ls-toc-h small{display:block; font-weight:400; color:var(--ink-3)}
.ls-toc-i{display:flex; gap:8px; align-items:flex-start; width:100%; text-align:left; border:0; background:none; font:inherit; font-size:12.5px;
  color:var(--ink-2); padding:6px; border-radius:7px; cursor:pointer; line-height:1.4}
.ls-toc-i:hover{background:var(--line-2)}
.ls-toc-i.on{background:var(--brand-050); color:var(--brand-900); font-weight:600}
.ls-toc-n{flex:none; width:22px; height:22px; border-radius:50%; display:grid; place-items:center; background:var(--line-2); font-size:11px; font-weight:700}
.ls-toc-i.on .ls-toc-n{background:var(--brand); color:#fff}
.ls-toc-i.done .ls-toc-n{background:var(--ok); color:#fff}
.ls-lab-dot{font-size:11px}
.ls-toc-sel{display:none; padding:7px 9px; border:1px solid var(--line); border-radius:7px; font:inherit; max-width:62vw}
.ls-main{min-width:0}
.ls-goals{background:var(--accent-050); border:1px solid #F7D6B5; border-radius:var(--r); padding:10px 14px; margin-bottom:14px}
.ls-goals ul{margin:4px 0 0; padding-left:20px}
.ls-body{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:6px 20px 14px; margin-bottom:14px; font-size:14.5px; line-height:1.75}
.ls-sec{padding-top:12px}
.ls-sec + .ls-sec{border-top:1px dashed var(--line); margin-top:8px}
.ls-sec h4{font-size:16px; color:var(--brand-900); margin:0 0 6px}
.ls-sec p{margin:6px 0}
.ls-sec ul,.ls-sec ol{margin:6px 0; padding-left:22px}
.ls-sec .formula{font-size:13px}
.ls-fig{margin:12px 0; text-align:center}
.ls-fig svg,.lab-svg{width:100%; max-width:600px; height:auto; background:#fff; border:1px solid var(--line-2); border-radius:8px; display:block; margin:0 auto}
.lab-svg{margin:10px auto}
.ls-fig figcaption{font-size:12px; color:var(--ink-3); margin-top:5px}
.ls-key{background:#EEF4FD; border-left:3px solid #2563A8; border-radius:6px; padding:8px 12px; margin:10px 0; font-size:13.5px; color:#1B4C8C}
.ls-tbl td{white-space:normal !important; vertical-align:top}
.ls-lab{border-color:var(--accent); box-shadow:0 0 0 3px rgba(245,130,32,.08)}
.ls-lab textarea{width:100%; resize:vertical}
.lab-out{margin-top:12px}
.lab-out .tbl-wrap{margin:10px 0}
.lab-h{font-size:13.5px; color:var(--brand-700); margin:14px 0 6px}
.lab-acts{margin-top:8px}
.ls-links{display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:0 0 14px; font-size:13px}
.ls-mis{background:var(--warn-bg); border:1px solid #F3DFB4; border-radius:var(--r); padding:10px 14px; margin-bottom:14px; color:#7A4F06}
.ls-mis ul{margin:4px 0 0; padding-left:20px}
.ls-quiz{background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:12px 14px; margin-bottom:14px}
.ls-quiz h4{font-size:15px; margin:0 0 8px; color:var(--brand-900)}
.ls-q{border-top:1px solid var(--line-2); padding:8px 0}
.ls-q summary{cursor:pointer; line-height:1.5}
.ls-q > div{margin:8px 0 2px 18px; padding:8px 12px; background:var(--ok-bg); border-radius:6px; color:#12603A}
.ls-done-row{margin:0 0 10px; font-size:13.5px}
.ls-done-row label{display:inline-flex; gap:7px; align-items:center; cursor:pointer}
.ls-nav{display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:14px}
.ls-page h4{display:flex; gap:8px; align-items:baseline; flex-wrap:wrap}
.ls-pno{flex:none; font-size:11.5px; font-weight:700; color:#fff; background:var(--brand); border-radius:12px; padding:2px 9px}
.ls-shot img{display:block; max-width:100%; height:auto; margin:0 auto; border:1px solid var(--line); border-radius:8px; box-shadow:var(--sh-1); cursor:zoom-in}
.ls-how{background:var(--ok-bg); border:1px solid #BFE5CF; border-radius:8px; padding:8px 14px; margin:10px 0; font-size:13.5px}
.ls-how b:first-child{color:#12603A}
.ls-how ol{margin:4px 0 0; padding-left:22px}
.ls-how li{margin:3px 0}
.ls-warn{background:var(--warn-bg); border-left:3px solid var(--warn); border-radius:6px; padding:8px 12px; margin:10px 0; font-size:13.5px; color:#7A4F06}
.ls-btn{display:inline-block; font-size:12px; font-weight:600; background:#2B2F36; color:#E8EBF0; border-radius:4px; padding:0 7px; line-height:20px; white-space:nowrap}
.ls-credit{font-size:11.5px; color:var(--ink-3); border-top:1px solid var(--line); padding-top:10px; line-height:1.6}
@media (max-width:1024px){
  .ls-wrap{grid-template-columns:minmax(0,1fr)}
  .ls-toc{display:none}
  .ls-toc-sel{display:inline-block}
  .ls-body{padding:4px 14px 12px}
}

/* ---------- ป้องกันภาพซ้อนตอนพิมพ์ ---------- */
@media print{
  .sidebar-backdrop,.nav-toggle{display:none !important}
}

/* ---------- โต๊ะเขียนแบบ : ให้เลื่อนหน้าผ่านได้ ----------
   ตัวโต๊ะจับเมาส์/นิ้วไว้ลากและซูมรูปเอง ถ้าสูงเกินจอ จะเลื่อนหน้าต่อไม่ได้
   → สูงเต็มจอพอดี (เลื่อนลงสุดแล้วโต๊ะเต็มจอใต้หัวเว็บ) และเว้นแถบขวาไว้ให้ปัด/หมุนล้อเลื่อนหน้า (กด ⛶ เต็มจอ แล้วแถบหายไป) */
.bd-shell{height:calc(100vh - var(--header-h) - 8px); min-height:260px; margin-right:46px; border-right:1px solid var(--line)}
:has(> .bd-shell){position:relative}
:has(> .bd-shell)::after{
  content:'⇕\A ปัด\A เลื่อน\A หน้า'; white-space:pre; position:absolute; right:0; bottom:0; width:46px;
  height:calc(100vh - var(--header-h) - 8px); min-height:260px;
  display:flex; align-items:center; justify-content:center; text-align:center;
  font-size:11px; line-height:1.5; color:var(--ink-3); pointer-events:none;
  background:repeating-linear-gradient(0deg, var(--line-2) 0 1px, transparent 1px 14px)
}
.card:has(.bd-shell){margin-bottom:0}
.content:has(.tab-panel.active .bd-shell){padding-bottom:0}
.bd-full .bd-shell{height:auto; min-height:0; margin-right:0; border-right:0}
.bd-full::after{display:none}
@media print{ :has(> .bd-shell)::after{display:none} }
/* วัดสอบกล้องประมวลผลรวม — ช่องแนบภาพถ่ายเครื่องมือ 2 รูป */
.cert-photos{display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px; margin-top:8px}
.cert-photo{border:1px solid var(--line); border-radius:10px; padding:10px; background:var(--card, #fff); display:flex; flex-direction:column; gap:6px}
.cert-photo .cp-head{display:flex; justify-content:space-between; align-items:center}
.cert-photo .cp-frame{display:flex; align-items:center; justify-content:center; height:200px; border:2px dashed var(--line); border-radius:8px; cursor:pointer; overflow:hidden; background:var(--bg-soft, #F6F7F9)}
.cert-photo .cp-frame.has{border-style:solid}
.cert-photo .cp-frame.drag{border-color:var(--brand, #9E1B32); background:#FCEEF0}
.cert-photo .cp-frame img{width:100%; height:100%; object-fit:contain}
.cert-photo .cp-empty{text-align:center; color:var(--muted, #737C8C); font-size:14px; line-height:1.6}
.cert-photo .cp-meta{font-size:12px; color:var(--muted, #737C8C)}
/* ประกันสินค้า */
.wt-prods{display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:10px}
.wt-prod{display:flex; flex-direction:column; gap:4px; padding:12px 14px; border:2px solid var(--line); border-radius:12px; cursor:pointer; background:var(--card, #fff)}
.wt-prod input{display:none}
.wt-prod .wt-ico{font-size:26px}
.wt-prod .wt-m{font-size:13px; color:var(--muted, #737C8C)}
.wt-prod.on{border-color:var(--brand, #9E1B32); background:#FCEEF0}
.wt-prod.on .wt-m{color:var(--brand, #9E1B32); font-weight:700}
.wt-badge{display:inline-block; padding:3px 10px; border-radius:999px; font-size:13px; font-weight:700; border:1px solid transparent}
.wt-badge.ok{background:#EAF6EC; color:#0A6B3D; border-color:#7BBF92}
.wt-badge.wait{background:#FFF6E3; color:#7A4F06; border-color:#F3DFB4}
.wt-badge.no{background:#FBECEC; color:#B3261E; border-color:#E39A9A}
.wt-terms{margin:0; padding-left:22px; line-height:1.75}
.wt-terms li{margin-bottom:6px}
.wt-chk{display:flex; gap:8px; align-items:flex-start; margin:6px 0; line-height:1.6; cursor:pointer}
.wt-chk input{margin-top:5px; flex:none}
.req{color:#C0392B}
/* ตรวจสอบเครื่องรับ GNSS RTK */
.gn-h{margin:4px 0 8px; font-size:14px; color:var(--brand-700)}
/* ---- งานวงรอบ : การ์ดเริ่มงานแบบง่าย ---- */
.qs-step{margin:14px 0 6px;font-size:13.5px}
.qs-step:first-child{margin-top:0}
.qs-opts{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:8px}
.qs-opt{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;padding:10px 12px;border:1.5px solid var(--line,#D9DEE6);
  border-radius:10px;background:#fff;cursor:pointer;font:inherit;color:inherit}
.qs-opt b{font-size:14px}
.qs-opt span{font-size:12px;color:var(--muted,#6B7280)}
.qs-opt:hover{border-color:var(--brand,#9E1B32)}
.qs-opt.on{border-color:var(--brand,#9E1B32);background:#FDF2F4;box-shadow:inset 0 0 0 1px var(--brand,#9E1B32)}
.qs-opt.on b::before{content:'✔ ';color:var(--brand,#9E1B32)}
.qs-sum{margin-top:12px;padding:10px 12px;background:#F4F6F9;border-radius:8px;font-size:13px;line-height:1.7}
.adv-cfg{margin:0 0 16px}
.adv-cfg > summary{cursor:pointer;padding:10px 14px;background:#F4F6F9;border:1px solid var(--line,#D9DEE6);border-radius:10px;font-size:13.5px;font-weight:600}
.adv-cfg[open] > summary{margin-bottom:10px}
.adv-cfg.locked > summary{cursor:not-allowed;color:var(--muted,#6B7280);background:#EEF0F3}
.adv-cfg.locked > summary::marker{color:transparent}
.adv-cfg > summary{display:none}
.ui-mode-bar{margin:0 0 14px}
.ui-mode-bar .round-btn{min-width:240px}
/* =========================================================
   ระบบบัญชี — ใบเสนอราคา / ใบเสร็จรับเงิน (A4 แนวตั้ง)
   ========================================================= */
.qd-wrap{overflow:auto; background:#E9ECF1; padding:14px; border-radius:8px}
.qd{width:194mm; margin:0 auto; background:#fff; color:#111; font-family:Sarabun,'TH Sarabun New',sans-serif; font-size:11.2px; line-height:1.35; padding:6mm 5mm; box-shadow:0 2px 10px rgba(0,0,0,.12)}
.qd-head{display:grid; grid-template-columns:44mm 1fr 34mm; align-items:center; gap:4mm; padding-bottom:2mm}
.qd-logo{width:100%; height:auto}
.qd-co{text-align:center; border-bottom:1.5px solid #9AA0A8; padding-bottom:1mm}
.qd-brand{font-size:30px; font-weight:800; letter-spacing:2px; color:#222; line-height:1}
.qd-coname{font-size:14px; font-weight:700; color:#2B4FA0}
.qd-coaddr{font-size:9px; color:#444; line-height:1.45}
.qd-title{font-size:17px; font-weight:700; text-align:center; line-height:1.5}
.qd-tax{font-size:10px; margin:1mm 0 0.5mm}
.qd table{width:100%; border-collapse:collapse; table-layout:fixed}
.qd th,.qd td{border:1px solid #000; padding:1.2mm 1.6mm; vertical-align:middle; word-wrap:break-word}
.qd-info th{text-align:right; font-weight:700; background:#fff}
.qd-info td .c, .qd-info td.c{text-align:center}
.qd-info tr.tall td, .qd-info tr.tall th{height:12mm}
.qd-items{border-top:0}
.qd-items thead th{background:#F8CBAD; font-weight:400; text-align:center; border-bottom:0}
.qd-items thead tr.en th{border-top:0; border-bottom:1px solid #000}
.qd-items tbody td{border-top:0; border-bottom:0; padding:0.7mm 1.6mm; height:5.2mm}
.qd-items tbody tr:last-child td{border-bottom:1px solid #000}
.qd-items td.c{text-align:center} .qd td.r{text-align:right}
.qd-items tr.sec td:nth-child(2){padding:0}
.qd-sec{background:#BDD7EE; text-align:center; font-weight:700; padding:0.7mm}
.qd-items a{color:#1F3FBF; text-decoration:underline; word-break:break-all}
.qd-foot th{text-align:left; font-weight:400; background:#C6E0B4}
.qd-foot td{background:#fff}
.qd-foot tr.hl td[colspan]{background:#C6E0B4}
.qd-foot th .g{color:#3C8F5A} .qd-foot th .rd{color:#C00000}
.qd-foot th.gt, .qd-foot td.gt{font-weight:400; border-top:2.5px double #000}
.qd-foot td{font-size:10.6px}
.qd-signhd{vertical-align:top !important}
.qd-sign{max-height:13mm; max-width:60mm; margin-top:1mm}
.qd-close{font-size:14px; font-weight:700; line-height:2.1; padding:3mm !important}
.qd-note{font-size:10.5px; font-weight:400; line-height:1.4; margin-bottom:2mm}
.qd-signer{line-height:1.55}
.qd-line{letter-spacing:1px; color:#555}
@media print{
  .qd{box-shadow:none; padding:0; width:194mm; margin:0}
  .qd *{-webkit-print-color-adjust:exact; print-color-adjust:exact}
  .qd-items a{color:#1F3FBF}
}
.qd-paid{display:inline-block; border:2.5px solid #0A6B3D; color:#0A6B3D; border-radius:6px; padding:0 10px; font-size:17px; margin-bottom:2mm; transform:rotate(-3deg)}
/* ---- สัญญาเช่าซื้อ (A4 แนวตั้ง 2 หน้า) ---- */
.ct{font-family:Sarabun,'TH Sarabun New',sans-serif; color:#111; font-size:12px; line-height:1.68}
.ct-page{width:176mm; min-height:262mm; margin:0 auto 14px; background:#fff; padding:12mm 14mm 10mm 16mm; box-shadow:0 2px 10px rgba(0,0,0,.12); position:relative; box-sizing:content-box}
.ct-ref{font-size:10px; color:#555; text-align:right}
.ct-title{font-size:17px; font-weight:700; text-align:center; margin:2mm 0 1mm}
.ct-place{text-align:right} .ct-date{text-align:center; margin:1mm 0 2mm}
.ct-p{margin:0 0 1mm; text-align:justify} .ct-p.ind{text-indent:12mm}
.ct-clause{margin:1.5mm 0 0.5mm 12mm}
.ct-item{margin-left:24mm} .ct-qty{float:right}
.ct-acc{margin-left:36mm} .ct-acc ol{margin:0; padding-left:6mm}
.ct-ul{margin:0 0 1mm 24mm; padding-left:4mm}
.ct-fill{display:inline-block; border-bottom:1px dotted #333; text-align:center; padding:0 2mm; line-height:1.35; text-indent:0}
.ct-b{color:#1F5FBF; font-weight:700} .ct-g{color:#2E9E4B; font-weight:700}
.ct-signs{width:100%; border-collapse:collapse; margin-top:6mm; font-size:11px; text-align:center}
.ct-signs td{padding:0 1mm; vertical-align:top}
.ct-signcol{width:92mm; margin:10mm 0 0 auto; line-height:2.4}
.ct-paren{display:block; text-align:center}
.ct-pno{text-align:center; font-size:11px; position:absolute; bottom:4mm; left:0; right:0}
.ct-pno.top{position:static; margin-bottom:2mm}
@media print{
  .ct-page{box-shadow:none; margin:0; padding:0; width:auto; min-height:0; page-break-after:always}
  .ct-page:last-child{page-break-after:auto}
  .ct-pno{position:static; margin-top:4mm}
  .ct *{-webkit-print-color-adjust:exact; print-color-adjust:exact}
}
.st-struct > summary{cursor:pointer; list-style:none}
.st-struct > summary::-webkit-details-marker{display:none}
.st-tree{background:#F4F6F9; border:1px solid var(--line); border-radius:8px; padding:10px 12px; font-family:var(--mono); font-size:12.5px; line-height:1.6; overflow:auto; white-space:pre}
body.view-mode .report-root.acc-view{max-width:none; overflow-x:auto; padding:0 8px}
@media print{ body.view-mode .report-root.acc-view{overflow:visible; padding:0} }
/* ---- ลงนามสัญญาออนไลน์ ---- */
.sg-status{max-width:176mm; margin:12px auto 0; padding:10px 14px; border-radius:8px; background:#EAF6EE; border:1px solid #9BD3AE; font-size:14px}
.sg-panel{max-width:176mm; margin:16px auto 40px; padding:16px 18px; background:#fff; border:2px solid var(--brand, #9E1B32); border-radius:12px; box-shadow:0 2px 10px rgba(0,0,0,.08); font-size:14px}
.sg-panel h3{margin:0 0 4px; color:var(--brand-900, #6B0F21)}
.sg-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:10px; margin:10px 0}
.sg-grid label{display:flex; flex-direction:column; gap:4px; font-weight:600; font-size:13px}
.sg-grid input:not([type=file]){padding:8px 10px; border:1px solid var(--line, #D9DEE6); border-radius:8px; font:inherit; font-size:15px}
.sg-ph img{max-width:100%; max-height:180px; object-fit:contain; border-radius:8px}
.sg-ph img:not([src]), .sg-ph img[src=""]{display:none}
.sg-padwrap{margin:10px 0}
.sg-padh{display:flex; justify-content:space-between; align-items:center; font-weight:600; font-size:13px; margin-bottom:4px}
.sg-padwrap canvas{width:100%; height:180px; border:2px dashed #8A93A3; border-radius:10px; background:#FCFCFD; display:block; touch-action:none}
.sg-panel .check{display:block; margin:8px 0; font-size:13.5px}
.sg-msg{color:#B3261E; min-height:20px; margin:6px 0}
.ct-sigbox{height:13mm; display:flex; align-items:flex-end; justify-content:center}
.ct-sigbox.r{justify-content:flex-start; padding-left:14mm}
.ct-sig{max-height:13mm; max-width:52mm}
.ct-evt{width:100%; border-collapse:collapse; font-size:11.5px; margin-top:3mm}
.ct-evt th,.ct-evt td{border:1px solid #999; padding:1.6mm 2mm; text-align:left; vertical-align:top}
.ct-evt th{width:42mm; background:#F4F6F9}
.ct-evt .ct-sig{max-height:16mm}
.ct-p.sub{text-indent:0; margin-left:12mm; padding-left:9mm; text-indent:-9mm}
.ct-p.sub b{display:inline-block; min-width:8mm; text-indent:0}
.att-up{cursor:pointer}
.ct-pending{background:#FFF4D6; padding:0 2px}
.sg-padbar{display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:8px}
.sg-padst{flex:1 1 160px; font-size:13px; color:#6B7280}
.sg-padst.ok{color:#1E7B3C; font-weight:600}
.sg-clear{background:#fff; color:#B3261E; border:1.5px solid #B3261E; font-weight:600; padding:8px 14px}
.sg-clear:not(:disabled):hover{background:#FDECEA}
.sg-undo{background:#fff; color:#374151; border:1.5px solid #8A93A3; font-weight:600; padding:8px 14px}
.sg-undo:not(:disabled):hover{background:#F4F6F9}
.acc-units-pub .ac-units input.acUnit{width:150px !important}
.acc-units-pub .ac-units th, .acc-units-pub .ac-units td{white-space:normal}
.sg-padbar .btn:disabled{opacity:.45; cursor:not-allowed}
/* ---- รายการเอกสารแบบต้นไม้ (ใบเสนอราคา → สัญญา → ใบเสร็จ) ---- */
.ac-tr.ac-d0 td{border-top:2px solid var(--line, #D9DEE6)}
.ac-tr.ac-d1 td, .ac-tr.ac-d2 td{background:#FAFBFC; font-size:13px}
.ac-tw{display:inline-flex; align-items:center; gap:6px; white-space:nowrap}
.ac-d1 .ac-tw{padding-left:14px}
.ac-d2 .ac-tw{padding-left:38px}
.ac-br{display:inline-block; width:12px; height:12px; border-left:2px solid #A7B0BF; border-bottom:2px solid #A7B0BF; border-bottom-left-radius:3px; margin-top:-8px}
.ac-unitrow .ac-tw{white-space:normal; flex-wrap:wrap}
.ac-units-box{max-width:940px; margin:8px 0 4px 34px; padding:10px; background:#fff; border:1px solid var(--line, #D9DEE6); border-radius:8px}
.ac-units .ac-sub td{background:#F7F9FB}
.ac-units input.acUnit{padding:6px 8px; border:1px solid var(--line, #D9DEE6); border-radius:6px; font-size:14px; background:#fff; max-width:100%}
.ac-units input.acUnit:focus{outline:2px solid var(--brand, #9E1B32); outline-offset:0}
.ac-units-box .row, .acc-units-pub .row{display:flex; align-items:center}
.ac-sep td{background:#F4F6F9; padding-top:10px}
.acc-units-pub{max-width:176mm; margin:16px auto 40px; padding:16px 18px; background:#fff; border:1.5px solid var(--line, #D9DEE6); border-radius:12px; font-size:14px}
.acc-units-pub h3{margin:0 0 4px}

/* ---- เข้าสู่ระบบ · ผู้ใช้ (auth.js) ---- */
.au-form{display:flex; flex-direction:column; gap:10px; font-size:14px}
.au-form label{display:flex; flex-direction:column; gap:4px; font-weight:600; font-size:13px}
.au-form input{padding:9px 11px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:15px}
.au-form input:focus{border-color:var(--brand); outline:none}
.au-msg{color:#B3261E; min-height:18px; font-size:13px}
.au-menu h4{margin:14px 0 8px}
.au-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:8px}
.au-sys{display:flex; flex-direction:column; align-items:flex-start; gap:2px; padding:10px 12px; border:1px solid var(--line); border-radius:10px;
  background:#fff; cursor:pointer; text-align:left; font:inherit}
.au-sys span{font-size:20px} .au-sys b{font-size:13.5px} .au-sys small{font-size:11.5px; color:#6B7280}
.au-sys:hover{border-color:var(--brand); background:#FFF7F8}
.au-sys.au-admin{border-color:var(--brand); grid-column:1/-1}
/* ---- ผู้ดูแลระบบ (admin-module.js) ---- */
.ad-chip{display:inline-block; padding:1px 8px; margin:1px 3px 1px 0; border-radius:999px; background:#EEF2F7; font-size:12px; white-space:nowrap}
.ad-chip.ad-all{background:#FDECEE; color:var(--brand-900); font-weight:600}
.ad-st{display:inline-block; padding:1px 8px; border-radius:6px; font-size:12px; font-weight:600}
.ad-st.on{background:#EAF6EE; color:#1E7B3C} .ad-st.off{background:#EEF0F3; color:#6B7280} .ad-st.warn{background:#FFF4D6; color:#8A5A00}
.ad-edit{border:1.5px solid var(--brand); border-radius:10px; padding:12px 14px; margin-bottom:14px; background:#FFFCFC}
.ad-edit h4{margin:0 0 10px}
.ad-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:10px; align-items:end}
.ad-grid label{display:flex; flex-direction:column; gap:4px; font-size:13px; font-weight:600}
.ad-grid input:not([type=checkbox]), .ad-grid select{padding:8px 10px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:14px}
.ad-grid label.check{flex-direction:row; align-items:center; gap:6px; font-weight:400}
.ad-pw{display:flex; gap:6px} .ad-pw input{flex:1; font-family:'Roboto Mono',monospace}
.ad-mods{display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:8px; margin:6px 0 10px}
.ad-mod{display:flex; gap:8px; align-items:flex-start; padding:8px 10px; border:1px solid var(--line); border-radius:8px; cursor:pointer; background:#fff}
.ad-mod b{display:block; font-size:13.5px} .ad-mod small{display:block; font-size:11.5px; color:#6B7280}
.ad-mod:has(input:checked){border-color:var(--brand); background:#FFF7F8}
.ad-matrix td, .ad-matrix th{text-align:center}
.ad-fail td{background:#FFF4F2}
.ad-legacy{display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin:14px 0 6px; padding:10px 12px; border:1px dashed #C9A227; border-radius:8px; background:#FFFBEA}
/* ---- คู่มือโครงสร้างระบบ (sysdoc-module.js) ---- */
.sd-layers{display:flex; flex-direction:column; gap:4px; max-width:900px}
.sd-l{display:flex; flex-direction:column; padding:9px 14px; border-radius:10px; border:1.5px solid; font-size:13px}
.sd-l b{font-size:14px} .sd-l span{color:#4B5563}
.sd-l1{border-color:#9AA5B5; background:#F6F7F9} .sd-l2{border-color:#B9862E; background:#FFF8EA} .sd-l3{border-color:var(--brand); background:#FFF5F6}
.sd-l4{border-color:#3B7A57; background:#F0F8F3} .sd-l5{border-color:#3563A8; background:#F0F5FC} .sd-l6{border-color:#5B4B8A; background:#F5F3FB}
.sd-2{display:grid; grid-template-columns:1fr 1fr; gap:8px}
.sd-ar{font-size:12px; color:#6B7280; padding-left:16px}
.sd-ol{margin:0; padding-left:20px; line-height:1.9; font-size:13.5px}
.sd-kv{display:grid; gap:4px; margin:10px 0; font-size:13px}
.sd-kv > div{display:grid; grid-template-columns:130px 1fr; gap:8px}
.sd-flowtabs{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px}
@media (max-width:700px){ .sd-2{grid-template-columns:1fr} .sd-kv > div{grid-template-columns:1fr} }
/* ---- ผังงาน (ui/flowchart.js) ---- */
.fc-wrap{overflow:auto; padding:6px 0; text-align:center}
.fc-svg{max-width:none; height:auto; font-family:'Sarabun',sans-serif}
.fc-tx{font-size:13px; fill:#1F2937} .fc-bold{font-weight:700} .fc-small{font-size:11.5px; fill:#4B5563}
.fc-lbl{font-size:12px; font-weight:700; fill:var(--brand-900)} .fc-side{font-size:11.5px; fill:#3563A8; font-family:'Roboto Mono',monospace}
.fc-ico{font-size:14px}
.fc-ln{fill:none; stroke:#4B5563; stroke-width:1.6} .fc-ln2{fill:none; stroke:#3563A8; stroke-width:1.4} .fc-dash{stroke-dasharray:4 3; stroke:#3563A8}
.fc-arr{fill:#4B5563}
.fc-term{fill:#FDECEE; stroke:var(--brand); stroke-width:1.8}
.fc-io{fill:#FFF8EA; stroke:#B9862E; stroke-width:1.6}
.fc-proc{fill:#fff; stroke:#4B5563; stroke-width:1.6}
.fc-if{fill:#FFFBEA; stroke:#C9A227; stroke-width:1.8}
.fc-doc{fill:#F0F8F3; stroke:#3B7A57; stroke-width:1.6}
.fc-api{fill:#F0F5FC; stroke:#3563A8; stroke-width:1.6}
.fc-data{fill:#F5F3FB; stroke:#5B4B8A; stroke-width:1.6}
.fc-page{fill:#F6F7F9; stroke:#6B7280; stroke-width:1.6}
.fc-join{fill:#fff; stroke:#4B5563; stroke-width:1.6}
.fc-goto{fill:#FFF4F2; stroke:#B3261E; stroke-width:1.6}
.fc-legend{display:flex; flex-wrap:wrap; gap:4px 14px; font-size:12px; color:#4B5563; margin-bottom:6px}
.fc-li{display:inline-flex; align-items:center; gap:4px}
@media print{ .fc-wrap{overflow:visible} .fc-svg{max-width:100%} .sd-flowtabs{display:none} }.sd-sys td{white-space:normal; vertical-align:top} .sd-sys td:nth-child(3){min-width:240px; max-width:340px} .sd-sys td:nth-child(4), .sd-sys td:nth-child(5){min-width:150px; max-width:220px}
/* ---- ปิดรหัสเดิมแล้ว (auth.js เพิ่ม body.legacy-off) : ซ่อนช่องรหัสเปิดโปรแกรมในหน้าด่าน เหลือปุ่มเข้าสู่ระบบ ---- */
body.legacy-off .cert-gate-card label, body.legacy-off .cert-gate-card input[type=password],
body.legacy-off .cert-gate-card .btn-orange:not([data-auth-login]), body.legacy-off .cert-gate-card .cert-gate-note,
body.legacy-off .cert-gate-card .cert-gate-foot, body.legacy-off #wtAdmin .field, body.legacy-off #wtPinGo{display:none}
body.legacy-off .cert-gate-card [data-auth-login]{background:var(--brand); color:#fff; border-color:var(--brand)}
/* ---- การเข้าใช้รายระบบ (app.js ตั้ง .module-host[data-access]) : account = ซ่อนช่องรหัสเปิดโปรแกรม · public = ซ่อนปุ่มล็อก ---- */
.module-host[data-access=account] .cert-gate-card label, .module-host[data-access=account] .cert-gate-card input[type=password],
.module-host[data-access=account] .cert-gate-card .btn-orange:not([data-auth-login]), .module-host[data-access=account] .cert-gate-card .cert-gate-note,
.module-host[data-access=account] .cert-gate-card .cert-gate-foot, .module-host[data-access=account] #wtAdmin .field, .module-host[data-access=account] #wtPinGo{display:none}
.module-host[data-access=account] .cert-gate-card [data-auth-login]{background:var(--brand); color:#fff; border-color:var(--brand)}
.module-host[data-access=public] #btnLock, .module-host[data-access=public] #lcLock, .module-host[data-access=public] #gnLock, .module-host[data-access=public] #lsLock{display:none}
.ad-acc td, .ad-acc th{vertical-align:middle}
.ad-acc .seg{display:inline-flex; flex-wrap:wrap; gap:4px}
.ad-acc .seg label{display:inline-flex; align-items:center; gap:4px; padding:4px 8px; border:1px solid var(--line,#E5E7EB); border-radius:8px; font-size:12.5px; cursor:pointer; white-space:nowrap}
.ad-acc .seg label.on{background:var(--brand-50,#FFF4EC); border-color:var(--brand); font-weight:600}
.au-link{display:inline-block; margin-top:6px; font-size:12.5px; color:var(--brand-900)}
.ad-key{display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:10px; align-items:end; margin:10px 0}
.ad-key label{display:flex; flex-direction:column; gap:4px; font-size:13px; font-weight:600}
.ad-key input{padding:8px 10px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:14px}/* ---- สถานะเอกสาร · ประวัติย้อนหลัง (accounting-ledger.js) ---- */
.ac-st{display:inline-block; margin-top:3px; padding:1px 8px; border-radius:999px; font-size:11.5px; font-weight:700; white-space:nowrap}
.ac-st.st-draft{background:#FFF4D6; color:#8A5A00} .ac-st.st-ok{background:#EAF6EE; color:#1E7B3C} .ac-st.st-cancel{background:#EEF0F3; color:#6B7280}
.ac-cancelled td{opacity:.62} .ac-cancelled .ac-cx{color:#B3261E; opacity:1}
.ac-approve{background:#1E7B3C; color:#fff; border:0; font-weight:700}
.ac-removed td{opacity:.6} .ac-removed small{color:#B3261E}
.ac-stamp{border:3px solid #B3261E; color:#B3261E; font-weight:800; font-size:18px; text-align:center; padding:6px 10px; margin:0 auto 6mm; max-width:180mm; transform:rotate(-1deg)}
.lg-filter{display:flex; flex-wrap:wrap; gap:8px; align-items:flex-end; margin-bottom:12px}
.lg-filter label{display:flex; flex-direction:column; gap:3px; font-size:12px; font-weight:600}
.lg-filter input, .lg-filter select{padding:6px 8px; border:1px solid var(--line); border-radius:6px; font:inherit; font-size:13px}
.lg-filter label:nth-child(3){flex:1 1 220px}
.lg-tbl td{vertical-align:top; white-space:normal}
.lg-diff div{margin:1px 0} .lg-diff b{color:#4B5563; font-weight:600} .lg-diff s{color:#B3261E} .lg-diff span{color:#1E7B3C}
.lg-why{color:var(--brand-900); margin-bottom:2px}
.lg-hist .tbl td{white-space:normal}.site-banner{padding:7px 18px; background:#EAF2FD; color:#1F3B66; font-size:13px; border-bottom:1px solid #BCD3F2}
.site-banner.danger{background:#FDECEA; color:#8A1C14; border-color:#F2B8B5}
/* ---- ประวัติเวอร์ชัน (sysdoc → changelog.js) ---- */
.cl-ver{border:1px solid var(--line); border-radius:10px; padding:10px 14px; margin-bottom:10px; background:#fff}
.cl-ver.cur{border-color:var(--brand); box-shadow:0 0 0 2px #FDECEE}
.cl-h{font-size:14.5px} .cl-tag{display:inline-block; font-family:'Roboto Mono',monospace; background:var(--brand); color:#fff; border-radius:6px; padding:1px 8px; font-size:12px}
.cl-sys{margin:6px 0}
.cl-sec{margin:6px 0; font-size:13px} .cl-sec ul{margin:2px 0 0; padding-left:20px} .cl-sec li{margin:1px 0}
.cl-sec.good b{color:#1E7B3C} .cl-sec.bad b{color:#B3261E} .cl-sec.warn b{color:#8A5A00}
.cl-files{font-size:12px; margin-top:4px}/* ต้นไม้เอกสารบัญชี : ปุ่มจัดการเรียงแนวนอน 2–3 แถว ไม่ให้แถวสูงเกิน */
.ac-tr td.reg-btns{display:table-cell; min-width:430px; max-width:none; white-space:normal}
.ac-tr td.reg-btns .btn{margin:2px 1px}
.sd-sys td, .sd-sys td *{white-space:normal !important; overflow-wrap:anywhere}
.sd-sys td:nth-child(7){min-width:120px} .sd-sys td:nth-child(7) .muted{white-space:nowrap !important}
.site-banner.warn{background:#FFF8E1; color:#6B4E00; border-color:#F2D58A}
/* ---- รายจ่าย · หน้ารอตรวจ (expense-module.js) ---- */
.ex-form{border:1.5px solid var(--brand)}
.ex-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:10px; align-items:end}
.ex-grid label{display:flex; flex-direction:column; gap:4px; font-size:12.5px; font-weight:600}
.ex-grid label a{font-weight:400; font-size:12px}
.ex-grid label.wide{grid-column:1/-1}
.ex-grid label.check{flex-direction:row; align-items:center; gap:6px; font-weight:400}
.ex-grid input:not([type=checkbox]), .ex-grid select{padding:7px 9px; border:1px solid var(--line); border-radius:7px; font:inherit; font-size:14px}
.ex-tbl td{white-space:normal}
.ex-count{display:inline-block; min-width:20px; padding:0 6px; border-radius:999px; background:#B3261E; color:#fff; font-size:11.5px; font-weight:700}
.py-total{margin:10px 0; font-size:15px; text-align:right}
.rv-item{display:grid; grid-template-columns:minmax(320px,1fr) minmax(280px,1fr); gap:14px; padding:12px; border:1px solid var(--line); border-radius:10px; margin-bottom:12px; background:#fff}
.rv-head{font-size:14px; margin-bottom:6px} .rv-head input{margin-right:6px; transform:scale(1.2)}
.rv-kv{width:100%; border-collapse:collapse; font-size:13px} .rv-kv th{width:100px; text-align:left; color:#6B7280; font-weight:600; padding:2px 6px 2px 0; vertical-align:top} .rv-kv td{padding:2px 0}
.rv-miss{margin-top:6px; padding:6px 9px; background:#FFF4D6; color:#6B4E00; border-radius:6px; font-size:12.5px}
.rv-file{border:1px dashed #C7CDD6; border-radius:8px; padding:6px; min-height:160px; background:#FAFBFC}
.rv-file img{max-width:100%; max-height:420px; display:block; margin:0 auto; border-radius:6px}
.rv-file iframe{width:100%; height:420px; border:0; background:#fff}
.rv-fname{font-size:12px; margin-top:4px} .rv-nofile{color:#B3261E; text-align:center; padding:50px 0; font-size:13px}
@media (max-width:900px){ .rv-item{grid-template-columns:1fr} }/* ---- หน้าแนบท้ายใบเสนอราคา : ขอบเขตงาน · เงื่อนไข ---- */
.qd-p2{page-break-before:always; break-before:page; margin-top:10mm}
.qd-p2h{display:flex; gap:10px; align-items:center; border-bottom:2px solid #9E1B32; padding-bottom:3mm; margin-bottom:4mm; font-size:12.5px}
.qd-p2h .qd-logo{height:14mm}
.qd-p2sum{background:#F7F3F4; border-radius:2mm; padding:3mm 4mm; font-size:12.5px; line-height:1.7}
.qd-p2 h3{font-size:15px; margin:5mm 0 2mm; color:#5E0F1E}
.qd-ol{margin:0; padding-left:7mm; font-size:13px; line-height:1.75}
.qd-p2sign{display:flex; justify-content:space-around; margin-top:12mm; text-align:center; font-size:12.5px; line-height:1.6}
@media print{ .qd-p2{margin-top:0} }.qd-p2h .qd-logo{height:12mm; width:auto; max-width:45mm}
/* ---- ล็อตนำเข้า (imports-module.js) ---- */
.im-kv{display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:8px 14px; font-size:13px}
.im-kv b{display:block; color:#6B7280; font-weight:600; font-size:12px}
.im-check{display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:8px}
.im-check > div{display:flex; align-items:center; gap:8px; padding:8px 10px; border:1px solid var(--line); border-radius:8px; font-size:13px}
.im-check > div.ok{background:#F2FAF4; border-color:#B9E1C6} .im-check > div.miss{background:#FFF8E6; border-color:#F2D58A}
.im-check > div b{flex:1} .im-check small{color:#6B7280}
/* ขั้นตอนนำเข้าก่อนขาย (imports-module procHTML) */
.im-proc{list-style:none; margin:0; padding:0; display:grid; gap:8px}
.im-proc > li{border:1px solid var(--line); border-radius:10px; padding:10px 12px; font-size:13px}
.im-proc > li.done{background:#F2FAF4; border-color:#B9E1C6} .im-proc > li.cur{background:#FFF8E6; border-color:#F2D58A} .im-proc > li.todo{opacity:.75}
.im-proc-h{margin-bottom:6px} .im-proc-b{display:grid; gap:6px}
.im-bill{border-top:1px dashed var(--line); padding-top:6px} .im-pays{margin:4px 0 0 18px; padding:0; color:#4B5563}
.im-need{color:#B3261E; font-size:12.5px}
/* 🔗 ER diagram (er-module.js · หน้าผู้ดูแลระบบ) */
.er-wrap{overflow-x:auto; border:1px solid var(--line); border-radius:10px; background:#FBFCFE; padding:6px}
.er-svg{display:block; min-width:1182px; width:100%; height:auto; font-family:inherit}
.er-t{font-size:13.5px; font-weight:700} .er-s{font-size:10px; fill:#64748B} .er-f{font-size:11.5px; fill:#334155}
.er-pk{font-weight:700; fill:#0F172A} .er-fk{fill:#1D4ED8} .er-card{font-size:12px; font-weight:700; fill:#0F172A}
.er-legend{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; font-size:12.5px}
.er-legend span{border:1px solid var(--line); border-radius:999px; padding:2px 10px; background:#fff}
.er-help{font-size:13.5px; line-height:1.6} .er-help h4{margin:12px 0 4px}
.er-stats{display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:8px; margin:10px 0}
.er-stats div{border:1px solid var(--line); border-radius:8px; padding:8px; text-align:center} .er-stats b{display:block; font-size:20px} .er-stats small{color:#6B7280}
/* แท็บ 📦 นำเข้า (expense-module importsHTML) : PI → ขั้นตอน → บิล → การจ่าย */
.ac-tr.ac-lot td{background:#FFF7EC} .ac-tr.ac-step td{background:#F3F5F9; font-size:13px}
.im-add{display:grid; grid-template-columns:220px 1fr auto; gap:8px; align-items:start; margin-bottom:10px}
.im-add select, .im-add textarea{padding:7px 9px; border:1px solid var(--line); border-radius:7px; font:inherit; font-size:14px}
.im-steps{display:flex; gap:2px; margin-bottom:3px} .im-steps i{width:12px; height:6px; border-radius:3px; background:#E3E7ED} .im-steps i.done{background:#7FB98F} .im-steps i.cur{background:var(--brand)}
.im-stagebar{display:flex; flex-wrap:wrap; gap:4px}
.im-pos{color:#1E7B3C} .im-neg{color:#B3261E}
@media (max-width:700px){ .im-add{grid-template-columns:1fr} }
/* ---- ระบบบัญชี : ตารางเอกสารพอดีจอ · เมนู ⋯ · แถบแก้ไข · หน้าต่างดูเอกสาร ---- */
.ac-docs-wrap{width:100%}
table.ac-docs{width:100%}
table.ac-docs td{white-space:normal}
table.ac-docs td.fmono, table.ac-docs .reg-res{white-space:nowrap}
table.ac-docs td:nth-child(3){min-width:240px}
table.ac-docs td.ac-acts{white-space:nowrap; text-align:right; width:1%}
.ac-acts > .btn{margin-left:3px}
.ac-more{position:relative; display:inline-block; margin-left:3px}
.ac-chan{color:#1F6FB2}
/* กรรมการของนิติบุคคล · ผู้ลงนาม/พยานในสัญญา */
.ac-dirs{margin-top:10px; padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:#FAFBFD}
.ac-dirs-h{display:flex; align-items:center; gap:8px; flex-wrap:wrap}
table.ac-dirt{width:100%; margin-top:6px} table.ac-dirt td{white-space:normal}
.ac-dirform{margin-top:8px; padding:10px; border:1px dashed #C7CDD6; border-radius:8px; background:#fff}
.ct-signers{display:grid; grid-template-columns:repeat(3,minmax(0,1fr)) auto; gap:8px; align-items:center; margin:6px 0 10px; padding:8px; border:1px dashed #C7CDD6; border-radius:8px}
.sg-wit{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:10px 0}
.sg-wit canvas{width:100%; height:110px; border:1px dashed #9CA3AF; border-radius:8px; background:#fff; touch-action:none; margin-top:6px}
.sg-wit label{display:block; font-weight:600; font-size:13.5px}
.sg-wit input{display:block; width:100%; margin-top:4px; padding:9px 11px; border:1px solid var(--line); border-radius:8px; font:inherit; font-size:15px; box-sizing:border-box}
.sg-who{margin:8px 0; display:flex; flex-direction:column; gap:4px}
@media (max-width:640px){ .sg-wit, .ct-signers{grid-template-columns:1fr} }
/* ตารางลูกค้าพอดีจอ : ข้อความตัดบรรทัดได้ · ปุ่มจัดการเรียงลงล่าง */
table.ac-cust{width:100%}
table.ac-cust td{white-space:normal}
table.ac-cust td.reg-btns{display:table-cell; min-width:0; max-width:none; width:1%; white-space:nowrap}
table.ac-cust td.reg-btns .btn{display:flex; width:100%; justify-content:center; margin:2px 0}
.ac-cust-lock{padding:8px 11px; border:1px solid var(--line); border-radius:8px; background:#F7F8FA; font-size:14px}
.ac-cust-lock .hint{margin-top:3px}
.ac-date{color:#6B7280; font-family:'Sarabun',sans-serif}
.ac-menu{position:fixed; z-index:150; min-width:240px; background:#fff; border:1px solid var(--line); border-radius:10px;
  box-shadow:0 10px 28px rgba(20,24,32,.18); padding:6px; display:flex; flex-direction:column; text-align:left}
.ac-menu[hidden]{display:none}
.ac-menu button{background:none; border:0; text-align:left; padding:7px 10px; border-radius:7px; font:inherit; font-size:13.5px; cursor:pointer; color:inherit}
.ac-menu button:hover{background:var(--brand-050)}
.ac-menu button.reg-del{color:#B3261E}
.ac-mh{font-size:11.5px; color:#6B7280; padding:6px 10px 2px; font-weight:600}
/* 📦 นำเข้า (expense-module) : หน้าลอย ดู/แก้ไข — ต่ำกว่าเมนู ⋯ (150) และหน้าต่าง App.modal (200) */
.ex-float{position:fixed; inset:0; z-index:120; background:rgba(20,24,32,.45); display:flex; align-items:flex-start; justify-content:center; padding:4vh 16px; overflow:auto}
.ex-float-card{position:relative; width:min(980px,100%); max-height:92vh; overflow:auto; background:var(--bg-card,#fff); border-radius:14px; box-shadow:0 18px 50px rgba(20,24,32,.3); padding:16px 18px}
.ex-float-card > .card{margin:0; border:0; box-shadow:none}
.ex-float-x{position:absolute; top:10px; right:12px; z-index:2; border:0; background:#F3F4F6; border-radius:8px; width:32px; height:32px; font-size:16px; cursor:pointer}
.ex-vh h3{margin:0 40px 10px 0; font-size:18px}
table.ex-kv{width:100%; margin-bottom:6px} table.ex-kv td, table.ex-kv th{white-space:normal} table.ex-kv th{width:32%; color:#4B5563; font-weight:600}
/* ล็อตนำเข้า → สินค้าในล็อต : ช่องรุ่น (เลือก + ชื่อ) ซ้อนบน-ล่างในช่องเดียว ไม่ล้นไปทับช่องจำนวน */
table.im-items{width:100%} table.im-items td{white-space:normal; vertical-align:top}
table.im-items td.im-model{width:55%; min-width:240px}
table.im-items td.im-model select, table.im-items td.im-model input{display:block; width:100%; max-width:none; box-sizing:border-box}
table.im-items td.im-model input{margin-top:4px; text-align:left}
table.im-items input{border:1px solid var(--line,#D9DEE6); border-radius:6px; padding:6px 8px; background:#fff; font:inherit}
/* ตารางในหน้าลอย : ตัดบรรทัดได้ ไม่ต้องเลื่อนซ้ายขวา */
.ex-float .tbl-wrap{overflow-x:visible} .ex-float .tbl{width:100%} .ex-float .tbl td, .ex-float .tbl th{white-space:normal}
.ex-float .py-fx{white-space:normal; align-items:flex-start} .ex-float .py-fx label{display:flex; align-items:center; gap:6px; flex-wrap:nowrap; white-space:nowrap}
.ex-float .py-fx input{width:130px; border:1px solid var(--line,#D9DEE6); border-radius:6px; padding:6px 8px; background:#fff; text-align:right}
.ex-float .py-fx small{max-width:230px; line-height:1.35}
/* แถบแท็บรายจ่าย : ลิงก์ไประบบล็อตนำเข้า · สต๊อก (ชิดขวา) */
#exTabs .ex-tab-link{margin-left:auto; color:var(--brand-900,#7A1020); font-weight:600}
.bk-day{display:inline-flex; align-items:center; gap:2px; padding:2px 4px 2px 8px; margin:2px; border:1px solid var(--line); border-radius:8px; background:#FAFBFC}
@media (max-width:640px){ .ex-float{padding:0} .ex-float-card{max-height:100vh; height:100vh; border-radius:0; padding:12px} }
.ac-editbar{display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:10px 14px; margin-bottom:12px; background:var(--brand-050); border:1px solid var(--line); border-radius:10px}
.ac-editbar b{font-size:15px; color:var(--brand-700)}
.ac-editbar .muted{font-size:12.5px}
.modal.modal-doc{width:min(1000px,96vw); max-height:94vh}
.modal.modal-doc .modal-body{padding:10px; background:#E9ECF1}
.ac-preview{padding:0}
/* ---- 🤖 เลขา Claude (admin-module.js) ---- */
.ad-steps{margin:4px 0 8px; padding-left:22px; font-size:13.5px; line-height:1.9}
.ad-steps code, .ad-pre{background:#F4F5F7; border-radius:5px; padding:1px 6px; font-size:12.5px}
.ad-pre{display:block; padding:10px 12px; white-space:pre-wrap; line-height:1.7; border:1px solid var(--line)}
/* ---- จ่ายบิลต่างประเทศ (expense-module.js) ---- */
.py-fx{display:flex; flex-direction:column; gap:3px; font-size:12.5px; white-space:nowrap}
.py-fx input{width:110px; padding:4px 6px; border:1px solid var(--line); border-radius:6px; font:inherit}
/* ---- สต๊อก (imports-module.js) ---- */
.sk-st{display:inline-block; padding:1px 8px; border-radius:999px; font-size:12px; font-weight:600; white-space:nowrap}
.sk-incoming{background:#EEF2FF; color:#3730A3} .sk-instock{background:#E8F6EC; color:#1E7B3C} .sk-reserved{background:#FFF4D6; color:#7A5400}
.sk-cut{background:#F1F2F4; color:#4B5563} .sk-sold{background:#F1F2F4; color:#4B5563}
.sk-model{display:grid; grid-template-columns:repeat(auto-fill,minmax(230px,1fr)); gap:8px; margin-bottom:12px}
.sk-model > div{border:1px solid var(--line); border-radius:10px; padding:10px 12px; background:#fff; font-size:13px}
.sk-model b{display:block; font-size:14px; margin-bottom:4px} .sk-model .n{font-size:22px; font-weight:700; color:#1E7B3C}
/* ---- ห้องบทเรียน : อ่านภาษาอังกฤษประกอบภาษาไทย (ปุ่ม 🔤 · lessons-module.js) ---- */
.ls-body:not(.bi) .ls-en{display:none}
.ls-body.bi .ls-en{display:block; margin:6px 0 12px; padding:8px 12px; border-left:3px solid #1F6FB2; background:#F3F7FC; border-radius:0 8px 8px 0;
  font-family:'Segoe UI',Arial,sans-serif; font-size:14px; line-height:1.6; color:#24364B}
.ls-en-h{display:block; font-size:11px; font-weight:700; letter-spacing:.08em; color:#1F6FB2; text-transform:uppercase; margin-bottom:2px}
.ls-body.bi .ls-pair{display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; align-items:start}
.ls-body.bi .ls-pair > .ls-en{margin:0}
@media (max-width:900px){ .ls-body.bi .ls-pair{grid-template-columns:1fr} }
.ls-terms{margin:12px 0; padding:10px 12px; border:1px dashed #9DB6D3; border-radius:10px; background:#FAFCFF}
.ls-terms td[lang=en]{font-family:'Segoe UI',Arial,sans-serif}

/* ---------- 🏦 บัญชีธนาคาร · เทียบรายการ (bank-module.js) ---------- */
.bk-accs{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px;margin:0 0 12px}
.bk-acc{display:flex;flex-direction:column;gap:3px;text-align:left;border:1px solid var(--line);border-radius:10px;background:#fff;padding:10px 12px;cursor:pointer;font:inherit}
.bk-acc.on{border-color:var(--brand);box-shadow:0 0 0 2px rgba(159,29,53,.15)} .bk-acc .mono{font-size:17px;font-weight:700} .bk-acc small{font-size:12px}
.bk-filter{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px} .bk-filter select,.bk-filter input{border:1px solid var(--line);border-radius:7px;padding:6px 9px;font:inherit;font-size:13px;background:#fff} .bk-filter select{width:auto;flex:0 0 auto} .bk-filter input{flex:1;min-width:200px;width:auto}
.bk-sum{display:flex;flex-wrap:wrap;gap:18px;font-size:13.5px;margin:6px 0 10px}
.bk-tbl td{vertical-align:top} .bk-tbl tr.bk-open td{background:#FFFBEB} .bk-last{min-width:220px;max-width:340px}
.bk-ex{display:flex;flex-direction:column;align-items:flex-start;gap:1px;text-align:left;border:1px solid #BFE5CF;background:#F0FBF4;border-radius:8px;padding:5px 8px;cursor:pointer;font:inherit;font-size:12.5px;width:100%}
.bk-ex.wait{border-color:#F5D38A;background:#FFF8E6} .bk-ex small{color:var(--ink-2)} .bk-ex span{white-space:normal;line-height:1.35}
.bk-seg{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px} .bk-seg label{border:1px solid var(--line);border-radius:7px;padding:6px 10px;cursor:pointer;font-size:13px} .bk-seg label.on{border-color:var(--brand);background:#FDF2F4;font-weight:600} .bk-seg input{display:none}
.bk-dlg label,#bkBody label:not(.check){display:flex;flex-direction:column;gap:4px;font-size:13px;margin:6px 0}
.bk-dlg label input,.bk-dlg label select,#bkBody label input:not([type=checkbox]),#bkBody label select,#bkBody textarea{border:1px solid var(--line);border-radius:7px;padding:7px 9px;font:inherit;font-size:13px;background:#fff;width:100%;box-sizing:border-box}
#bkBody textarea{font-family:'Roboto Mono',Consolas,monospace;font-size:12px}
@media print{.bk-filter,.page-actions,#bkTabs,.bk-accs{display:none!important}}
/* รายจ่าย : ส่วนของบิลรวม · ไฟล์ใช้ร่วม (20261027h) */
/* ใบสำคัญรับเงิน (พิมพ์ · 20261027i) */
.rcvp{width:186mm; margin:0 auto; font-size:14px; color:#111; background:#fff; font-family:'Sarabun','TH Sarabun New',sans-serif}
.rcvp-head{display:flex; justify-content:space-between; align-items:flex-start; border-bottom:2px solid #111; padding-bottom:6px}
.rcvp-co{font-size:17px; font-weight:700} .rcvp-addr{font-size:12px} .rcvp-title{font-size:20px; font-weight:700; text-align:right} .rcvp-title small{font-size:12px; font-weight:400}
.rcvp-meta{margin:8px 0 4px auto; border-collapse:collapse} .rcvp-meta th,.rcvp-meta td{padding:2px 8px; text-align:left} .rcvp-meta th{font-weight:600}
.rcvp-p{line-height:1.8; margin:8px 0}
.rcvp-tbl{width:100%; border-collapse:collapse; margin:6px 0} .rcvp-tbl th,.rcvp-tbl td{border:1px solid #333; padding:5px 7px} .rcvp-tbl th{background:#f1f1f1}
.rcvp-tbl .c{text-align:center} .rcvp-tbl .r{text-align:right} .rcvp-sum td{font-weight:700}
.rcvp-sign{display:grid; grid-template-columns:1fr 1fr; gap:20px; margin-top:34px; text-align:center; line-height:2}
.rcvp-note{margin-top:22px; font-size:12px; color:#444}
/* ---- 📜 งานสารบรรณ (saraban-module.js · 20261030a) ---- */
.sb-q{min-width:240px; height:32px; padding:0 10px; border:1px solid #D9DEE6; border-radius:8px; font:inherit}
.sb-urg{display:inline-block; margin-right:6px; padding:0 7px; border-radius:6px; background:#FDECEC; color:#B3261E; font-size:12px; font-weight:700}
tr.sb-unread td{background:#FFF8E6} tr.sb-unread td b{color:#9E1B32}
.sb-cnew,.sb-send{margin:12px 0; padding:10px 12px; border:1px dashed #C9CFD8; border-radius:10px; background:#FAFBFC}
.sb-files{margin:0; padding-left:18px} .sb-files li{margin:4px 0}
.sb-preview{overflow-x:auto; background:#EEF0F3; padding:14px; border-radius:10px}
.sb-preview .sbl{margin:0 auto; box-shadow:0 1px 8px rgba(0,0,0,.12); padding:15mm 20mm 15mm 30mm; width:210mm; box-sizing:border-box; min-height:297mm}
/* หนังสือบนหัวบริษัท (A4 · ตัวอย่างบนจอ + พิมพ์จาก #reportRoot) */
.sbl{position:relative; background:#fff; color:#111; font-family:'Sarabun','TH Sarabun New',sans-serif; font-size:15px; line-height:1.65}
.sbl-urg{position:absolute; top:8mm; left:30mm; padding:2px 12px; border:2px solid #B3261E; color:#B3261E; font-weight:700; font-size:17px}
.sbl-draft::after{content:'ร่าง'; position:absolute; top:40%; left:50%; transform:translate(-50%,-50%) rotate(-24deg); font-size:110px; font-weight:700; color:rgba(179,38,30,.12); pointer-events:none}
.sbl-head{display:flex; gap:12px; align-items:center; border-bottom:1.4px solid #9E1B32; padding-bottom:5px; margin-bottom:14px}
.sbl-logo{height:13mm; width:auto; flex:none}
.sbl-brand{display:flex; flex-direction:column; line-height:1.35} .sbl-brand b{font-size:15px; color:#9E1B32} .sbl-brand span{font-size:10.5px; color:#333}
.sbl-row{display:flex; justify-content:space-between} .sbl-date{text-align:center; margin:6px 0 12px}
.sbl-meta{border-collapse:collapse; margin-bottom:8px} .sbl-meta th{text-align:left; vertical-align:top; font-weight:600; padding:1px 14px 1px 0; white-space:nowrap} .sbl-meta td{padding:1px 0}
.sbl-body p{text-indent:2.5cm; margin:0 0 8px; text-align:justify}
.sbl-sign{margin:22px 0 0 45%; text-align:center} .sbl-sigimg{height:16mm; display:flex; align-items:flex-end; justify-content:center} .sbl-sigimg img{max-height:16mm; max-width:55mm}
.sbl-dept{margin-top:24px; font-size:13.5px}
/* กระดาษเปล่าหัวบริษัท (เอกสารแนบ) : 1 แผ่น = 1 หน้า A4 */
.sbl-attach{margin:-6px 0 0 auto; width:fit-content; max-width:70%; padding:4px 10px; border:1px solid #9E1B32; border-radius:4px; font-size:12.5px; line-height:1.5; text-align:right}
.sbl-blank{page-break-after:always; break-after:page} .sbl-blank:last-child{page-break-after:auto; break-after:auto}
/* เอกสารแนบ : หน้าแยกต่อท้ายหนังสือ */
.sbl-annex{page-break-before:always; break-before:page} .sb-preview .sbl + .sbl{margin-top:14px}
.sbl-annex-h{text-align:center; font-weight:700; font-size:18px; margin:4px 0 2px} .sbl-annex-t{text-align:center; font-weight:600; margin-bottom:12px}
.sbl-annex-b p{margin:0 0 8px; text-align:left}
/* ✍️ ตัวแก้ไขแบบ Word (เนื้อหาหนังสือ · เอกสารแนบ) */
.ex-grid > div.wide{grid-column:1/-1; min-width:0}
.sb-rte-lbl{font-size:13px; font-weight:600; margin:6px 0 4px}
.sb-rte{border:1px solid var(--border, #ccc); border-radius:8px; background:#fff; overflow:hidden}
.sb-rte-bar{display:flex; flex-wrap:wrap; gap:3px; align-items:center; padding:5px 6px; background:#F6F3F4; border-bottom:1px solid var(--border, #ddd); position:sticky; top:0; z-index:2}
.sb-rte-bar select{height:28px; padding:0 4px; font-size:12.5px; width:auto; min-width:0}
.sb-rb{height:28px; min-width:28px; padding:0 7px; border:1px solid transparent; border-radius:5px; background:transparent; font-size:12.5px; cursor:pointer; color:#222; display:inline-flex; align-items:center; gap:3px; position:relative}
.sb-rb:hover{background:#fff; border-color:#ccc}
.sb-rcol input[type=color]{width:18px; height:18px; padding:0; border:0; background:none; cursor:pointer}
.sb-rsep{width:1px; height:20px; background:#ccc; margin:0 3px}
.sb-rte-ed{min-height:220px; max-height:70vh; overflow:auto; padding:12px 16px; font-family:'Sarabun','TH Sarabun New',sans-serif; font-size:15px; line-height:1.65; color:#111; outline:none}
.sb-rte-ed img{cursor:pointer} .sb-rte-ed img.sb-imgsel{outline:3px solid #2F6FED; outline-offset:1px}
.sb-rte-ed td, .sb-rte-ed th{min-width:30px}
.sbl-rich p{margin:0 0 8px} .sbl-rich h2{font-size:20px; margin:6px 0} .sbl-rich h3{font-size:17px; margin:6px 0} .sbl-rich ul, .sbl-rich ol{margin:0 0 8px; padding-left:28px}
.sbl-rich table{margin:4px 0 8px} .sbl-rich img{max-width:100%; height:auto} .sbl-rich blockquote{margin:0 0 0 40px}
.sbl-body.sbl-rich p{text-indent:0; text-align:left}
/* 📄 หน้า A4 : เส้นขึ้นหน้าใหม่ในตัวอย่าง · แถบจำนวนหน้า · ช่องพิมพ์กว้างเท่าพื้นที่พิมพ์จริง (160 มม.) */
.sbl-sign, .sbl-rich tr, .sbl-rich img{break-inside:avoid; page-break-inside:avoid}
.sbl-pgbrk{position:absolute; left:0; right:0; height:0; border-top:2px dashed #2F6FED; z-index:3; pointer-events:none}
.sbl-pgbrk span{position:absolute; right:6px; top:-11px; background:#2F6FED; color:#fff; font-size:11px; line-height:1; padding:4px 8px; border-radius:10px; font-family:system-ui,sans-serif}
.sb-pginfo{margin:0 0 8px; padding:8px 10px; border:1px solid var(--border, #ddd); border-radius:8px; background:#F7F9FF; font-size:13px; line-height:1.6}
.sb-pginfo:empty{display:none}
.sb-pgchip{display:inline-block; padding:1px 8px; border-radius:10px; background:#E6EDFF; color:#1E3A8A; font-size:12px; margin:0 2px} .sb-pgchip.more{background:#FFF1D6; color:#8A4B00}
.sb-pgnote{margin-top:4px; color:#333} .sb-pgwarn{margin-top:4px; color:#9A3412; background:#FFF4E5; border-radius:6px; padding:4px 8px}
.sb-rte{background:#EDEDED} .sb-rte-ed{width:calc(160mm + 32px); max-width:100%; margin:10px auto; box-sizing:border-box; background:#fff; box-shadow:0 1px 4px rgba(0,0,0,.12)}
.sb-annex-f{border:1px dashed var(--border, #ccc); border-radius:8px; padding:8px 10px; margin-top:8px}
@media print{ .report-root .sbl{width:auto; min-height:0; padding:0; box-shadow:none} .sbl *{-webkit-print-color-adjust:exact; print-color-adjust:exact} }
/* ใบรับรองกล้อง : ลายเซ็นผู้วัดสอบ/ผู้รับรอง (20261029a) */
.cert-sigs{display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px; margin-top:8px}
.cert-sig{border:1px solid var(--line,#D9DEE6); border-radius:10px; padding:10px; background:#fff; display:flex; flex-direction:column; gap:6px}
.cert-sig .cs-frame{display:flex; align-items:center; justify-content:center; height:80px; border:1px dashed #C9CFD8; border-radius:8px; cursor:pointer; background:#FAFBFC}
.cert-sig .cs-frame img{max-height:70px; max-width:95%; object-fit:contain}
/* ใบรับรองกล้อง : เลือกแบบ มีรูป / ไม่มีรูป (20261028a) */
.page-actions select.cert-photo-mode{width:auto; flex:0 0 auto; height:32px; padding:0 8px; border:1px solid #D9DEE6; border-radius:8px; background:#fff; color:#1f2937; font:inherit; font-size:13px}
/* ใบสำคัญรับเงิน : ช่องกรอกในตารางรายการ · ฟอร์มรายจ่าย : แถบคำอธิบายเต็มความกว้าง */
table.tbl.rcv-lines input{width:100%; min-width:60px; border:1px solid #D9DEE6; border-radius:6px; padding:5px 8px; background:#fff; font:inherit}
.ex-full{grid-column:1/-1} details.ex-full summary{cursor:pointer}
.ex-part{color:#5B3FA6} .ex-share{display:inline-block; padding:1px 8px; border-radius:10px; font-size:12px; background:#E8F0FE; color:#1A4FB4}
.bk-sugb,#bkGo,#bkUn{color:var(--ink,#1f2937)!important;background:#fff!important;border:1px solid var(--line,#D9DEE6)!important;margin:2px 4px 2px 0} #bkUn{color:#B42318!important}

/* ===== ✅ ภาษี · ปิดเดือน · ส่งนักบัญชี (tax-module.js · 20261111d) ===== */
.tx-progress { display:flex; align-items:center; gap:10px; margin:4px 0 10px; }
.tx-bar { flex:1; height:10px; background:var(--line-2); border-radius:6px; overflow:hidden; }
.tx-bar i { display:block; height:100%; background:var(--ok); }
.tx-next { font-size:14.5px; }
.tx-list { list-style:none; margin:0; padding:0; counter-reset:tx; }
.tx-item { display:flex; gap:10px; padding:10px 8px; border-bottom:1px solid var(--line-2); }
.tx-item.tx-cur { background:var(--brand-050); border-radius:8px; }
.tx-mark { flex:0 0 28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; border:2px solid var(--line); }
.tx-ok .tx-mark { background:var(--ok); color:#fff; border-color:var(--ok); }
.tx-todo .tx-mark { color:var(--brand-700); border-color:var(--brand-700); }
.tx-na { opacity:.55; }
.tx-warn .tx-mark { background:var(--warn-bg); color:var(--warn); border-color:var(--warn); }
.tx-txt { flex:1; min-width:0; }
.tx-how { font-size:12.5px; color:var(--brand-900); margin-top:3px; }
.tx-due { color:var(--warn); }
.tx-flow { border:1px solid var(--line); border-radius:10px; padding:10px; margin-top:10px; }
.tx-flow-h { margin-bottom:6px; }
.tx-steps { display:flex; flex-wrap:wrap; align-items:center; gap:4px; }
.tx-step { font-size:12.5px; padding:3px 8px; border-radius:12px; border:1px solid var(--line); background:#fff; }
.tx-step.tx-ok { background:var(--ok-bg); border-color:var(--ok); color:var(--ok); }
.tx-step.tx-cur { background:var(--brand-050); border-color:var(--brand-700); color:var(--brand-900); font-weight:700; }
.tx-arrow { color:#9aa3b2; font-size:12px; }
.tx-doc { font-size:13.5px; color:#000; }
.tx-doc h2 { font-size:20px; }
.tx-doc-r { text-align:right; font-size:12px; }
.tx-doc-t { width:100%; border-collapse:collapse; margin:8px 0; }
.tx-doc-t td, .tx-doc-t th { border:1px solid #000; padding:6px 8px; vertical-align:top; }
.tx-doc-g th { background:#eee; }
.tx-doc-t .r { text-align:right; } .tx-doc-t .c { text-align:center; }
.tx-doc-sign { margin-top:24px; text-align:center; line-height:1.9; }
.tx-doc-sign2 { margin-top:30px; display:flex; justify-content:space-between; gap:20px; text-align:center; line-height:1.9; }
.tx-doc-sign2 > div { flex:1; }

/* ===== 🖊 เอกสารภายใน · ลงนามออนไลน์ (esign-module.js · 20261112a) ===== */
.es-doc { font-size:14px; color:#000; background:#fff; padding:6px 4px; line-height:1.7; }
.es-head { text-align:center; margin-bottom:6px; }
.es-title { text-align:center; font-size:19px; margin:8px 0 4px; }
.es-meta { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; margin-bottom:8px; font-size:13.5px; }
.es-body table { width:100%; border-collapse:collapse; }
.es-body td, .es-body th { border:1px solid #888; padding:3px 6px; }
.es-sigs { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:18px 24px; margin-top:22px; text-align:center; break-inside:avoid; }
.es-sig { break-inside:avoid; font-size:13.5px; }
.es-sig img { display:block; margin:0 auto -6px; max-width:200px; max-height:70px; }
.es-sig-wait { height:56px; display:flex; align-items:flex-end; justify-content:center; color:#9aa3b2; font-size:12px; }
.es-at { font-size:11px; color:#555; }
.es-cert { margin-top:18px; padding:8px 10px; border:1px dashed #999; font-size:11.5px; color:#333; line-height:1.55; word-break:break-all; break-inside:avoid; }
.es-pad { display:block; width:100%; height:180px; border:2px dashed var(--line); border-radius:10px; background:#fff; margin:6px 0; }
.es-pad-s { height:120px; }
.es-consent { display:flex; gap:8px; align-items:flex-start; padding:8px 10px; background:var(--brand-050); border-radius:8px; font-size:13px; margin:8px 0; }
.es-consent input { margin-top:4px; flex:0 0 auto; }
.es-wit { border-top:1px solid var(--line-2); padding-top:6px; margin-top:6px; }
.es-lines { max-height:340px; overflow:auto; }
.es-q { margin:4px 0 6px; } .es-q input { width:100%; max-width:420px; }
.es-srow { border-bottom:1px dashed var(--line-2); padding-bottom:6px; margin-bottom:6px; }
.bk-es { margin-top:4px; font-size:12px; }
.bk-tbl tr.bk-flash td { background:#FEF3C7 !important; transition:background .4s; }

/* ===== 📋 ใบส่งมอบงานรายงวด (svc-module.js · 20261112c) ===== */
.sw-doc { background:#fff; padding:6px; }
.sw-note { border:1px solid #999; border-radius:6px; padding:8px 10px; min-height:60px; line-height:1.6; margin-bottom:8px; }
.sw-doc .ct-sig { max-width:180px; max-height:60px; display:block; margin:0 auto -6px; }