:root {
  --bg: #e2eafb; --surface: #fbfcff; --ink: #1b2550; --muted: #55608c; --line: #c8d4f0;
  --side: #cbdcfc; --side-ink: #1e3a8a;
  --accent: #4338ca; --accent-2: #2b8fe8; --accent-soft: #d6dfff; --accent-ink: #fff;
  --ok: #3f7a55; --ok-soft: #dcebdf; --warn: #a8690a; --warn-soft: #fbe7b8; --bad: #b3261e;
  --blue: #7c3aed; --blue-soft: #efe8fe; --amber: #f0b429;
  --shadow: 0 1px 0 #fff inset, 0 6px 18px rgba(50, 70, 150, .10);
  --display: "IBM Plex Sans Thai", "Leelawadee UI", sans-serif;
  --body: "Sarabun", "Leelawadee UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.6; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.3; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.grow { flex: 1 1 auto; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

/* ค่าฐานของช่องกรอกทุกช่อง (ทับได้ด้วยคลาส) */
:where(input, select, textarea, button) { font: inherit; color: inherit; }
:where(input, select, textarea) { width: 100%; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
:where(input, select, textarea):disabled { background: var(--bg); color: var(--ink); opacity: 1; }
:where(input, select, textarea, button, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 2px; }
button { padding: 8px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; white-space: nowrap; font-family: var(--display); font-weight: 600; font-size: .95rem; box-shadow: var(--shadow); }
button:hover { border-color: var(--accent-2); }
button.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--accent-ink); text-shadow: 0 1px 1px rgba(30, 30, 110, .35); }
button.primary:hover { filter: brightness(.96); }
button:disabled { opacity: .6; cursor: default; }
a { color: var(--accent); }

.card { background: var(--surface); border: 2px solid #fff; border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
.login { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.msg { min-height: 1.6em; font-size: .95rem; color: var(--ok); }
.msg.bad { color: var(--bad); }

/* ── โครงหน้า: เมนูซ้าย + เนื้อหา ── */
#app { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
#app.navhide { grid-template-columns: minmax(0, 1fr); }
#app.navhide .side { display: none; }
.side { position: sticky; top: 12px; height: calc(100vh - 24px); margin: 12px 0 12px 12px; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; background: linear-gradient(180deg, #cbdcfc, #c8c2f5); border-radius: 26px; color: var(--side-ink); box-shadow: 0 6px 18px rgba(60, 80, 160, .15); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 16px; text-decoration: none; color: var(--side-ink); }
.brand .logo { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 18px; object-fit: cover; border: 2px solid #fff; display: grid; place-items: center; background: #fff; color: #fff; font-family: var(--display); font-weight: 700; font-size: 1.2rem; box-shadow: 0 4px 10px rgba(79, 70, 229, .28); }
.brand b { display: block; font-family: var(--display); font-size: 1rem; line-height: 1.25; }
.brand small { display: block; font-size: .8rem; color: #5a6a9a; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav .item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 16px; font-family: var(--display); font-weight: 600; font-size: .98rem; white-space: nowrap; color: var(--side-ink); text-decoration: none; }
.nav .item svg { flex: 0 0 auto; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav a.item:hover { background: rgba(255, 255, 255, .45); }
.nav .item.on { background: var(--surface); box-shadow: 0 4px 12px rgba(60, 80, 160, .18); }
.nav .item.soon { color: #6f7fb0; cursor: default; }
.nav .item.soon em { margin-left: auto; font-style: normal; font-family: var(--body); font-weight: 400; font-size: .72rem; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, .55); white-space: nowrap; }
.navhead { padding: 12px 12px 4px; font-family: var(--display); font-weight: 700; font-size: .75rem; letter-spacing: .05em; color: #6f7fb0; }
.sidefoot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .6); display: flex; flex-direction: column; gap: 8px; }
.sidefoot #who { font-size: .85rem; color: #46558a; padding: 0 6px; overflow-wrap: anywhere; }
.sidefoot button { width: 100%; }
.scrim { display: none; }

.main { min-width: 0; padding: 12px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.top { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--surface); border: 2px solid #fff; border-radius: 22px; box-shadow: var(--shadow); }
.top .burger { padding: 6px 10px; border: 0; background: none; box-shadow: none; font-size: 1.3rem; line-height: 1; }
.top b { display: block; font-family: var(--display); font-size: 1.05rem; line-height: 1.3; }
.top small { display: block; font-size: .82rem; color: var(--muted); }
.page { display: flex; flex-direction: column; gap: 16px; }

/* ── หน้าหลัก: การ์ดเลือกงาน ── */
#app.home, #app.home.navhide { grid-template-columns: minmax(0, 1fr); }
#app.home .side, #app.home .burger, #app.home .scrim { display: none !important; }
#app.home .main { max-width: 1280px; width: 100%; margin: 0 auto; }
.hello { padding: 6px 4px 0; }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.app { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 24px 20px 0; text-align: center; text-decoration: none; color: var(--ink); white-space: normal; font-family: var(--body); font-weight: 400; cursor: pointer; transition: transform .12s; }
a.app:hover, button.app:hover { transform: translateY(-2px); border-color: #fff; box-shadow: 0 1px 0 #fff inset, 0 10px 24px rgba(50, 70, 150, .16); }
.app b { font-family: var(--display); font-size: 1.1rem; margin-top: 12px; }
.app small { font-size: .85rem; color: var(--muted); min-height: 1.6em; }
.app .go { align-self: stretch; margin-top: 14px; padding: 12px 0; border-top: 1px solid var(--line); font-family: var(--display); font-weight: 600; font-size: .95rem; color: var(--accent); }
.appico { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; color: #fff; box-shadow: 0 6px 14px rgba(50, 70, 150, .22); }
.appico svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.appico.c1 { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.appico.c2 { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.appico.c3 { background: linear-gradient(135deg, #aab4d4, #7a86ad); }
.appico.c4 { background: linear-gradient(135deg, #f7cf5a, #e9a11a); }
.app.soon { cursor: default; opacity: .7; }
.app.soon .go { color: var(--muted); }

.hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; background: linear-gradient(120deg, #e3edff, var(--surface) 60%); }
.hero .txt { flex: 1 1 320px; min-width: 0; }
.tag { display: inline-block; padding: 2px 12px; border-radius: 999px; background: var(--accent-soft); color: #1e40af; font-family: var(--display); font-weight: 700; font-size: .78rem; letter-spacing: .04em; margin-bottom: 6px; }
.hero .filters { display: flex; flex-direction: column; gap: 8px; flex: 0 1 340px; }
.hero .filters .row { display: flex; gap: 8px; align-items: center; }
.hero .filters label { margin: 0; white-space: nowrap; }
.hero .filters :where(input, select) { border-radius: 999px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 16px 18px; border-left: 4px solid var(--c); }
.stat span { display: block; font-size: .9rem; color: var(--muted); }
.stat b { display: block; font-family: var(--display); font-size: 1.7rem; line-height: 1.4; color: var(--c); font-variant-numeric: tabular-nums; }
.stat small { display: block; font-size: .8rem; color: var(--muted); }
.stat.s1 { --c: var(--ok); } .stat.s2 { --c: var(--accent); } .stat.s3 { --c: #b8851f; } .stat.s4 { --c: var(--blue); background: linear-gradient(120deg, var(--surface), var(--blue-soft)); }

.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar label { margin: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 1rem; }
.check input { width: auto; accent-color: var(--accent); }
.cardhead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cardhead h3 { color: #1e40af; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--display); font-size: .88rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .6); }
td a { font-weight: 600; text-decoration: none; }
#ovTable td:nth-child(3) { min-width: 240px; }
td a:hover { text-decoration: underline; }
.num { text-align: right; white-space: nowrap; }
.mono { white-space: nowrap; }
td.warn { color: var(--warn); font-weight: 600; }
td.ok { color: var(--ok); }
td.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.pill { display: inline-block; padding: 1px 12px; border-radius: 999px; font-family: var(--display); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: #2c5c3e; }
.pill.warn { background: var(--warn-soft); color: #7a4b00; }

/* ── ตารางกรอกเงินได้รายเดือน ── */
.cardhead label { margin: 0; white-space: nowrap; }
select.auto { width: auto; border-radius: 999px; }
.paygrid th, .paygrid td { padding: 6px 6px; vertical-align: middle; }
.paygrid th:not(:nth-child(2)), .paygrid td:not(:nth-child(2)) { text-align: right; white-space: nowrap; }
.paygrid .stick { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 200px; white-space: nowrap; }
.paygrid .carry { background: rgba(227, 236, 245, .55); }
.paygrid .tot { font-weight: 600; }
.paygrid tfoot td { font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; }
.paygrid input.cell { width: 104px; padding: 5px 8px; border-radius: 8px; text-align: right; font-variant-numeric: tabular-nums; }
.paygrid input.cell.dirty { background: var(--warn-soft); }
.paygrid input.cell.bad { border-color: var(--bad); background: #fde4e1; }
.hint { font-size: .88rem; margin-top: 8px; }

/* ── หน้านำเข้า ── */
#impTable td, #batTable td { vertical-align: middle; }
#impTable td.check input { width: 18px; height: 18px; }
#impTable select { min-width: 220px; padding: 5px 10px; border-radius: 10px; }
#impTable tr.dim td { color: var(--muted); }
#impTable td:last-child { min-width: 260px; font-size: .9rem; }
#impTable td:last-child .muted { font-size: .85rem; }
.hero .filters input[type=file] { padding: 6px 10px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.grid .wide { grid-column: span 2; }
.grid .full { grid-column: 1 / -1; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
dialog { border: 2px solid #fff; border-radius: 24px; padding: 22px; width: min(680px, calc(100vw - 32px)); color: var(--ink); background: var(--surface); box-shadow: 0 20px 50px rgba(30, 40, 90, .3); }
dialog::backdrop { background: rgba(23, 37, 84, .45); }

@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) {
  #app, #app.navhide { grid-template-columns: minmax(0, 1fr); }
  .side, #app.navhide .side { display: none; position: fixed; z-index: 20; top: 0; left: 0; height: 100vh; width: 264px; margin: 0; border-radius: 0 26px 26px 0; }
  #app.navshow .side { display: flex; }
  #app.navshow .scrim { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(23, 37, 84, .4); }
  .main { padding: 10px 16px 24px; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .grid .wide { grid-column: auto; }
  .stats { gap: 10px; }
  .stat b { font-size: 1.35rem; }
}

/* ── 50 ทวิ · ภ.ง.ด.1ก ── */
.docopts { display: flex; gap: 14px 28px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.docopts input[type=date] { width: auto; border-radius: 999px; }
.warnlist { margin: 0 0 12px; padding: 10px 14px 10px 32px; border-radius: 16px; background: var(--warn-soft); color: #7a4b00; font-size: .95rem; }
.warnlist:empty { display: none; }
#docTable tfoot td { font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--accent-soft); }
tr.rowlink button { padding: 4px 14px; white-space: nowrap; }

/* ── แท็บในหน้านำเข้า + ตารางไฟล์รายเดือน ── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs button { font-family: var(--display); font-weight: 600; }
.tabs button.on { background: var(--surface); border-color: var(--accent); color: var(--accent); box-shadow: 0 4px 12px rgba(60, 80, 160, .14); }
input.auto { width: auto; }
#imTable td { vertical-align: middle; }
#imTable td.check input { width: 18px; height: 18px; }
#imTable tr.dim td { color: var(--muted); }
#imTable td:last-child { min-width: 300px; font-size: .9rem; }
#imTable td:last-child .muted { font-size: .85rem; }
#imTable td:last-child .bad { color: var(--bad); }

/* วิธีใช้ไฟล์ยื่นออนไลน์ */
.rdhelp { margin-top: 12px; }
.rdhelp summary { cursor: pointer; font-weight: 600; }
.rdhelp ol { margin: 8px 0; padding-left: 22px; line-height: 1.7; }

/* รูปลายเซ็น/ตราประทับในข้อมูลบริษัท */
.imgslot .imgbox { height: 110px; border: 1px dashed #c9ced6; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin: 4px 0 8px; background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 0 0 / 16px 16px; }
.imgslot .imgbox img { max-width: 92%; max-height: 96px; }
.imgslot input[type=file] { max-width: 220px; }

/* โลโก้ */
.loginlogo { display: block; width: 210px; height: 210px; margin: 0 auto 4px; border-radius: 28px; }
.login h1 { text-align: center; color: #1e3a8a; }
.hello { display: flex; align-items: center; gap: 16px; }
.hello img { width: 92px; height: 92px; border-radius: 26px; border: 3px solid #fff; box-shadow: var(--shadow); }
h2 { color: #1e3a8a; }

/* หน้าบริษัท: สรุปรายเดือน + รายคนของเดือน */
.pmstats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; }
.linkbtn { padding: 2px 4px; border: 0; background: none; box-shadow: none; color: var(--accent); text-decoration: underline; font-weight: 600; font-size: 1rem; }
.linkbtn:hover { color: var(--blue); }
#pmTable td, #pmTable th { padding: 9px 10px; }
#pmTable .carryrow td { background: rgba(227, 236, 245, .55); }
.paygrid .sumcol { background: var(--accent-soft); font-weight: 600; }
#payMonthBox .cardhead, #payYearBox .cardhead { margin-bottom: 8px; }
@media (max-width: 720px) { .pmstats { grid-template-columns: 1fr; } }

/* การ์ดลายเซ็นและตราประทับ: 2 ช่องเท่ากัน */
.cardhead .sub { font-size: .88rem; margin-top: 2px; }
.imgpair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
#fsCard .imgpair { margin-top: 16px; }
.imgpair .imgslot b { display: block; font-family: var(--display); margin-bottom: 6px; }
.imgpair .imgslot .imgbox { height: 180px; border-radius: 16px; margin: 0 0 10px; }
.imgpair .imgslot .imgbox img { max-width: 88%; max-height: 156px; }
@media (max-width: 720px) { .imgpair { grid-template-columns: 1fr; } }
.imgpair .imgslot input[type=file] { max-width: none; width: auto; flex: 1 1 320px; }
.imgpair .imgslot .actions { flex-wrap: wrap; }

/* สถานะตรวจ (หน้ายื่นรายเดือน + สรุปรายเดือนหน้าบริษัท) */
.checkrow { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
#pmTable td:last-child, #pmTable th:last-child { text-align: left; }

/* หน้าล็อกอิน: ช่องใส่รหัส 6 หลัก */
#loginCodeBox { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid rgba(60, 80, 160, .15); }
#loginCodeBox[hidden] { display: none; }
#loginCode { font-size: 1.4rem; letter-spacing: .35em; text-align: center; }
#loginCodeBox p { margin: 0; text-align: center; }

/* หน้าตั้งค่าสำนักงาน */
.btnlink { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1px solid rgba(60, 80, 160, .2); color: var(--accent); font-weight: 600; text-decoration: none; }
#setTable tr.off td { color: #8b93a7; }

/* หน้ารวม: แถบ 12 เดือนต่อบริษัท */
.mstrip { display: inline-flex; gap: 3px; vertical-align: middle; }
.mdot { display: inline-block; width: 13px; height: 13px; border-radius: 4px; background: #e3e8f3; border: 1px solid #cdd5e6; vertical-align: middle; }
.mdot.data { background: #f6c453; border-color: #d89c1d; }
.mdot.ok { background: #4fae78; border-color: #2f8a57; }
.legend .mdot { margin: 0 4px 0 10px; }
.legend .mdot:first-child { margin-left: 0; }
.loginlead { text-align: center; margin: 0; }

/* รายรับ */
.nav > div { display: flex; flex-direction: column; gap: inherit; }
.nav > div[hidden] { display: none; }
.pill.bad { background: #fde2e2; color: #9b1c1c; }
.pill.off { background: #e8ebf3; color: #5b6478; }
tr.void td { color: var(--muted); }
tr.void td:nth-child(2) { text-decoration: line-through; }
td.acts { white-space: nowrap; text-align: right; }
td.acts button { margin-left: 6px; }
.linetable td { padding: 4px 6px; vertical-align: middle; }
.linetable input, .linetable select { width: 100%; min-width: 0; }
.linetable td.num input { text-align: right; }
.linetable th:nth-child(2) { width: 46%; }
.linefoot { display: flex; align-items: center; gap: 12px; }
#vIncWht .hero .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; flex: 0 1 520px; }
table.sumfoot tfoot td, #whTable tfoot td { font-weight: 600; border-top: 2px solid var(--line); padding-top: 10px; }
/* หน้าต่างค่าบริการประจำ: กว้างพอให้ช่องเดือนเริ่ม/หยุดอ่านออกเต็มคำ */
#feeDlg { width: min(940px, calc(100vw - 32px)); }
#fdTable { table-layout: fixed; width: 100%; min-width: 760px; }
#fdTable th:nth-child(1) { width: 36px; }
#fdTable th:nth-child(2) { width: auto; }
#fdTable th:nth-child(3) { width: 130px; }
#fdTable th:nth-child(4), #fdTable th:nth-child(5) { width: 160px; }
#fdTable th:nth-child(6) { width: 70px; }
#fdTable th { white-space: nowrap; }
.total { font-family: var(--display); font-weight: 700; color: #1e3a8a; margin: 0; }
.feelist { margin: 0; padding: 0; list-style: none; }
.feelist li.ended { color: var(--muted); }
.cardhead .row { display: flex; align-items: center; gap: 8px; }
.cardhead .row label { margin: 0; white-space: nowrap; }
.cardhead .row select { width: auto; border-radius: 999px; }
td.zero { color: var(--muted); }
/* ใบแจ้งหนี้ครั้งเดียว: มีช่อง จำนวน · หน่วย · ราคาต่อหน่วย */
#invDlg { width: min(940px, calc(100vw - 32px)); }
#ivTable { table-layout: fixed; width: 100%; min-width: 760px; }
#ivTable th:nth-child(1) { width: 36px; }
#ivTable th:nth-child(2) { width: auto; }
#ivTable th:nth-child(3) { width: 80px; }
#ivTable th:nth-child(4) { width: 100px; }
#ivTable th:nth-child(5), #ivTable th:nth-child(6) { width: 130px; }
#ivTable th:nth-child(7) { width: 70px; }
#ivTable th { white-space: nowrap; }
#ivTable td.lt { text-align: right; font-variant-numeric: tabular-nums; }
button.mini { padding: 2px 10px; font-size: .82rem; margin-left: 6px; }
.pill.sent { margin-left: 6px; }
.small { font-size: .82rem; }
/* ปุ่ม ⋯ ในแถว + เมนูคำสั่ง */
button.more { padding: 6px 12px; font-size: 1.15rem; line-height: 1; letter-spacing: 1px; }
.rowmenu { position: fixed; z-index: 50; min-width: 190px; padding: 6px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 34px rgba(30, 40, 90, .22); }
.rowmenu button { border: 0; box-shadow: none; background: transparent; border-radius: 10px; padding: 9px 14px; text-align: left; font-weight: 500; }
.rowmenu button:hover, .rowmenu button:focus-visible { background: var(--bg); outline: none; }
.rowmenu button.danger { color: #b3261e; }
td.acts .muted { margin-right: 4px; }
/* ตารางใบแจ้งหนี้ / ใบเสร็จ: เลขที่ วันที่ ยอดเงิน ไม่ตัดบรรทัด · ชื่อบริษัทกับรายการรับความกว้างที่เหลือ */
#incTable th, #rcTable th { white-space: nowrap; }
#incTable td:nth-child(2), #incTable td:nth-child(3), #incTable td:nth-child(6), #incTable td:nth-child(7),
#rcTable td:nth-child(2), #rcTable td:nth-child(3), #rcTable td:nth-child(5), #rcTable td:nth-child(6), #rcTable td:nth-child(7), #rcTable td:nth-child(8) { white-space: nowrap; }
#incTable td:nth-child(4), #incTable td:nth-child(5), #rcTable td:nth-child(4) { min-width: 150px; }
#incTable td, #rcTable td { vertical-align: middle; }
#incTable td:nth-child(8) .pill { display: inline-block; margin: 2px 6px 2px 0; }
#incTable td.acts, #rcTable td.acts { width: 1%; }
/* จอแคบ ตารางเลื่อนข้างได้ แต่คอลัมน์ปุ่มเกาะขอบขวาไว้เสมอ */
#incTable td:nth-child(4), #incTable td:nth-child(5), #rcTable td:nth-child(4) { min-width: 120px; }
#incTable td.acts, #rcTable td.acts, #incTable tbody tr:hover td.acts, #rcTable tbody tr:hover td.acts { position: sticky; right: 0; background: var(--surface); }
#incTable td.acts, #rcTable td.acts { box-shadow: -10px 0 10px -10px rgba(30, 40, 90, .18); }
/* หน้าแรก: ระบบที่กำลังจะมี (ยังเข้าไม่ได้) */
.soonhead { margin: 26px 4px 12px; font-family: var(--display); font-size: 1rem; color: var(--muted); }
.app.soon { border-style: dashed; border-color: var(--line); box-shadow: none; }
.app.soon .go { display: flex; align-items: center; justify-content: center; gap: 6px; }
.app.soon .lock svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
/* เครื่องมือ: รวมลิงก์ */
.appico.c5 { background: linear-gradient(135deg, #5fd4c4, #1f9e8f); }
a.btnlink.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--accent-ink); text-shadow: 0 1px 1px rgba(30, 30, 110, .35); font-family: var(--display); font-size: .95rem; box-shadow: var(--shadow); white-space: nowrap; }
#tlTable td { vertical-align: middle; }
#tlTable td:nth-child(3) a { font-weight: 600; }
#tlTable td.acts { width: 1%; white-space: nowrap; }
#tlTable td.acts .btnlink { margin-right: 6px; }
#tlTable th:first-child, #tlTable td:first-child { width: 48px; }
#tlTable td:nth-child(2) { width: 160px; }
#bkTable { max-width: 560px; }
#bkTable th:first-child, #bkTable td:first-child { width: 48px; }
#bkTable th:last-child { text-align: right; }

/* ตั้งค่า › ตั้งค่าเอกสาร (spec §8.17): ฟอร์มซ้าย · ตัวอย่าง PDF ขวา */
.dswrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.dsblock { margin-bottom: 20px; }
.dsblock > b { display: block; font-family: var(--display); margin-bottom: 6px; }
.dsblock .dsgap { margin-top: 10px; }
.dsblock .checkrow { margin-bottom: 0; gap: 8px 18px; }
.dsform .imgslot .imgbox { height: 130px; border-radius: 16px; padding: 0 12px; text-align: center; }
.dsform .imgslot .imgbox img { max-height: 110px; }
.dsform .imgslot input[type=file] { max-width: none; flex: 1 1 240px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.swatch { width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatch.on { box-shadow: 0 0 0 3px var(--accent); }
.swatch:disabled { cursor: default; opacity: .75; }
.swatch.on:disabled { opacity: 1; }
#dsColor { width: 56px; height: 36px; padding: 2px; border-radius: 10px; }
.dsprev { position: sticky; top: 16px; }
.dsprev .actions { margin-bottom: 10px; }
#dsFrame { width: 100%; aspect-ratio: 210 / 297; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
@media (max-width: 980px) { .dswrap { grid-template-columns: 1fr; } .dsprev { position: static; } }
@media (max-width: 720px) { .grid.two { grid-template-columns: 1fr; } }

/* ตัวเลขในตารางสรุปที่กดแล้วไปเมนูของแบบนั้น (spec §7.32) */
.numlink { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.numlink:hover { color: var(--blue); }
