/* =========================================================================
   โปรแกรมคำนวณใบเสนอราคา TOSTEM — บริษัท วินดอร์ กลาส ดีไซน์ จำกัด
   ภาษาการออกแบบฝั่งพื้นที่ทำงาน อ้างอิงจาก windoor-quotation-mockup.html
     พื้นหลังสว่าง · การ์ดขาวขอบบางเงาเบามุมโค้ง · เลขขั้นตอนวงกลมสีน้ำเงิน
     ตัวเลขที่ผู้ใช้แก้ = เด่น / ตัวเลขที่ระบบคำนวณ = เบาลง
   ฝั่งขวา (พรีวิวใบเสนอราคา) คงรูปแบบเดิม ใช้สไตล์ที่แปลงจากฟอร์ม Excel
   ========================================================================= */

:root {
  /* ---- ชุดสีตาม mockup ---- */
  --navy:        #10233f;
  --navy-2:      #16304f;
  --blue:        #2563eb;
  --blue-dark:   #1d4ed8;
  --blue-soft:   #eaf1ff;
  --bg:          #eef1f6;
  --card:        #ffffff;
  --border:      #e3e7ee;
  --text:        #1b2433;
  --text-mute:   #6b7686;
  --green:       #178a4c;
  --green-dark:  #12703c;
  --red:         #d93025;
  --red-dark:    #b8241b;
  --amber:       #f6a824;
  --amber-ink:   #4a2c00;
  --amber-lbl:   #7a4900;
  --warn:        #8a5a00;
  --warn-soft:   #fdeecb;
  --bad:         #d93025;
  --bad-soft:    #fdecea;

  /* ---- ชื่อโทเคนเดิม ให้ส่วนที่เหลือของโปรแกรมใช้ต่อได้ ---- */
  --ground:      var(--bg);
  --surface:     var(--card);
  --surface-2:   #f6f8fb;
  --surface-3:   #eef1f6;
  --line:        var(--border);
  --line-2:      #d5dbe6;
  --ink:         var(--text);
  --ink-2:       #4a5566;
  --ink-3:       var(--text-mute);
  --accent:      var(--blue);
  --accent-ink:  #ffffff;
  --accent-soft: var(--blue-soft);
  --paper:       #ffffff;
  --paper-ink:   #000000;

  --shadow: 0 1px 2px rgba(16,35,63,.06), 0 1px 12px rgba(16,35,63,.05);
  --shadow-1: var(--shadow);
  --shadow-2: 0 4px 24px rgba(16,35,63,.12), 0 1px 4px rgba(16,35,63,.08);
  --radius: 12px;
  --appbar-h: 58px;

  --font-ui: 'Noto Sans Thai', 'Sarabun', 'Inter', 'Leelawadee UI', Tahoma, sans-serif;
  --font-num: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
  --font-data: var(--font-num);
  --font-paper: 'Sarabun', 'Noto Sans Thai', 'Leelawadee UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- แถบบนสุด ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  height: var(--appbar-h); padding: 0 20px;
  background: var(--navy); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.appbar .spacer, .preview-bar .spacer { flex: 1; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, #2f6fed, #1d4ed8);
  display: grid; place-items: center;
  font-family: 'Inter', sans-serif; font-weight: 800; font-size: 18px; color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text .b1 { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.brand-text .b2 { font-family: 'Inter', sans-serif; font-weight: 600; font-size: 9px; letter-spacing: 2px; color: #9fb3d6; }
.brand-divider { width: 1px; height: 26px; background: rgba(255,255,255,.18); margin: 0 5px; }
.app-title { font-weight: 600; font-size: 15.5px; color: #f3f6fc; }

.topbar-btn {
  font-family: inherit; font-size: 13px; font-weight: 500;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: #e8edf6; padding: 8px 14px; border-radius: 9px; cursor: pointer;
  white-space: nowrap; transition: background .15s ease;
}
.topbar-btn:hover { background: rgba(255,255,255,.14); }
.topbar-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.topbar-btn.primary:hover { background: var(--blue-dark); }

/* ---------- ปุ่มทั่วไป ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-weight: 600; font-size: 13.5px;
  border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  background: var(--card); color: var(--text);
  transition: background .15s ease;
  white-space: nowrap;
}
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: #f5f7fa; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border: 1px solid var(--border); }
.btn.sm:hover { background: #f5f7fa; }
.btn.icon { padding: 3px 9px; font-size: 13px; border: 1px solid var(--border); background: #fff; color: var(--text-mute); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--bad-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.mt10 { margin-top: 10px; }

/* ---------- โครงหน้า 2 คอลัมน์ ---------- */
.workspace {
  --split-left: 40%;              /* ความกว้างคอลัมน์ซ้าย — ลากเส้นแบ่งแล้ว JS เขียนทับเป็น px */
  --split-w: 6px;                 /* ความหนาเส้นแบ่ง */
  display: grid;
  grid-template-columns: minmax(0, var(--split-left)) var(--split-w) minmax(0, 1fr);
  height: calc(100vh - var(--appbar-h));
  overflow: hidden;
}
.pane { min-width: 0; min-height: 0; }
.pane-left {
  overflow-y: auto; overflow-x: hidden;
  padding: 22px 20px 70px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.pane-right {
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: #e6eaf1;
}

/* ---------- เส้นแบ่งคอลัมน์แบบลากได้ ---------- */
.splitter {
  position: relative;
  cursor: col-resize;
  background: var(--border);
  border: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;                     /* กันการ scroll แย่งเวลาลากบนจอสัมผัส */
  transition: background .14s ease;
}
.splitter::before {                       /* พื้นที่จับกว้างกว่าตัวเส้นจริง จับง่ายขึ้น */
  content: ''; position: absolute; top: 0; bottom: 0; left: -5px; right: -5px;
}
.splitter .grip {
  width: 2px; height: 34px; border-radius: 2px;
  background: #fff; opacity: .55; pointer-events: none;
  box-shadow: 3px 0 0 rgba(255,255,255,.55), -3px 0 0 rgba(255,255,255,.55);
}
.splitter:hover, .splitter:focus-visible { background: var(--blue); outline: none; }
.splitter:hover .grip, .splitter:focus-visible .grip { opacity: .9; }
body.is-splitting { cursor: col-resize; user-select: none; }
body.is-splitting .splitter { background: var(--blue); }
body.is-splitting .splitter .grip { opacity: .9; }
body.is-splitting iframe { pointer-events: none; }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .pane-left { overflow: visible; }
  .pane-right { height: 90vh; position: sticky; top: var(--appbar-h); border-left: 0; border-top: 1px solid var(--border); }
  .splitter { display: none; }
}

/* ---------- การ์ดขั้นตอน ---------- */
.step-card {
  flex: none;                     /* ไม่ให้การ์ดถูกบีบเมื่อคอลัมน์ยาวเกินจอ */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.step-head {
  width: 100%; display: flex; align-items: center; gap: 11px;
  font-family: inherit; text-align: left; cursor: pointer;
  padding: 18px 22px; border: 0; background: none; color: var(--text);
}
.step-card.open .step-head { padding-bottom: 4px; }
.step-head:hover .step-title { color: var(--blue-dark); }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--blue); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-num); font-weight: 700; font-size: 13px;
}
.step-title { font-size: 15.5px; font-weight: 700; color: var(--text); }
.step-head .sum {
  margin-left: auto; font-size: 12.5px; color: var(--text-mute); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%;
}
.step-head .caret { flex: none; color: #aab3c0; font-size: 13px; transition: transform .15s ease; }
.step-card:not(.open) .step-head .caret { transform: rotate(180deg); }
.step-body { padding: 16px 22px 22px; }
.step-card:not(.open) .step-body { display: none; }

/* ---------- ฟิลด์ ---------- */
.field-row { display: flex; gap: 14px; margin-bottom: 16px; }
.field-row.last { margin-bottom: 0; }
.field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--text-mute); font-weight: 600; }
.field.inline { flex: none; width: 150px; }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; width: 100%;
  padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--text); font-weight: 500;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
input[type=number] { font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
input[readonly] { background: #f6f8fb; color: var(--text-mute); font-weight: 500; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 14px; }
.check-row + .field-row { margin-top: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.check input { width: auto; accent-color: var(--blue); }
.hint { font-size: 12px; color: var(--text-mute); line-height: 1.6; }
.hint.self-center { align-self: center; flex: 1; }
/* ป้ายสถานะตัวช่วย AI ในขั้นที่ 2 — จุดนำหน้าบอกว่าต่อ server กลางได้หรือไม่ */
.hint.ai-on, .hint.ai-off { display: inline-flex; align-items: center; gap: 7px; }
.hint.ai-on::before, .hint.ai-off::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; flex: none;
}
.hint.ai-on { color: var(--green); }
.hint.ai-on::before { background: var(--green); }
.hint.ai-off::before { background: var(--text-mute); opacity: .5; }
.src-note { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.action-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.action-row.between { justify-content: space-between; }

/* ---------- ยุบ / กางรายละเอียด ---------- */
.disclose { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.disclose > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--blue);
  padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff;
}
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary::before { content: '▸'; font-size: 11px; }
.disclose[open] > summary::before { content: '▾'; }
.disclose > summary:hover { background: #f5f7fa; }
.disclose-body { padding-top: 16px; }

/* ---------- แท็บย่อย ---------- */
.tabs { display: flex; gap: 6px; background: #f1f3f7; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tab {
  flex: 1; font-family: inherit; text-align: center; padding: 9px 10px;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--text-mute); background: none;
}
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,35,63,.12); }
.paste-area { min-height: 130px; border-radius: 10px; resize: vertical; font-weight: 400; line-height: 1.7; }

.dropzone {
  border: 2px dashed #c7cee0; border-radius: 10px; background: #fafbfd;
  padding: 26px 16px; text-align: center; color: var(--text-mute); font-size: 13.5px;
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--blue); background: var(--blue-soft); }
.dropzone .cloud { font-size: 26px; margin-bottom: 6px; opacity: .55; line-height: 1; }
.dropzone .dz-sub { font-size: 11.5px; margin-top: 12px; line-height: 1.6; }
#pdfInfo:not(:empty) { margin-top: 10px; }

/* ---------- ตาราง ---------- */
.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.items, table.comps {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.items thead th, table.comps thead th {
  background: #f6f8fb; color: var(--text-mute);
  text-align: left; font-weight: 600; font-size: 11.5px;
  padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.items tbody td, table.comps tbody td, table.comps td {
  padding: 9px 10px; border-bottom: 1px solid #f0f2f6; color: var(--text); vertical-align: middle;
}
table.comps { min-width: 560px; }
table.comps input, table.comps select { padding: 7px 9px; font-size: 13px; }
table.comps td.num {
  text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums;
  white-space: nowrap; color: var(--text-mute);       /* ราคาที่ระบบดึงให้ — น้ำหนักเบากว่าช่องที่กรอกเอง */
}
table.brieftable { min-width: 720px; }
table.brieftable td.tt { font-size: 12.5px; color: var(--text-mute); white-space: nowrap; }
tr.noterow td { border-bottom: 1px solid var(--border); padding-top: 0; }
/* รายการที่ประกอบจากหลายบาน — บรรทัดแรกคือรายการรวม ตามด้วยบานย่อย */
tr.grouphead td { background: #f6f8fb; }
tr.partrow td { background: #fbfcfe; border-bottom-color: #eef1f6; }
tr.partrow td.sub { text-align: center; color: var(--text-mute); }
.rownote {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; color: var(--warn);
  background: var(--warn-soft); border-radius: 6px; padding: 3px 8px; margin-right: 8px;
}
.rawline { font-size: 11.5px; color: var(--text-mute); font-family: var(--font-num); }
.comp-price { font-weight: 600; }
.comp-price.err { color: var(--red); font-weight: 600; font-size: 11.5px; }
.sizehint { font-size: 10.5px; color: var(--text-mute); font-family: var(--font-num); font-weight: 400; }

/* ---------- ④ ตารางรายการสินค้า ---------- */
table.items { table-layout: fixed; }        /* ล็อกความกว้างคอลัมน์ ไม่ให้แถวรายละเอียดดันตาราง */
table.items tr.row > td { cursor: pointer; }
table.items td.code { overflow: hidden; text-overflow: ellipsis; }
table.items td.code div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.items tr.row:hover > td { background: #f8fafd; }
table.items tr.row.on > td { background: var(--blue-soft); border-bottom-color: #cfe0ff; }
table.items td.no { font-family: var(--font-num); color: var(--text-mute); width: 26px; font-weight: 500; }

/* ---- ที่จับสำหรับลากสลับลำดับ ---- */
table.items td.grip { padding-left: 4px; padding-right: 0; }
.drag-handle {
  display: inline-block; cursor: grab; color: #c2c9d4; font-size: 14px; line-height: 1;
  padding: 2px 3px; border-radius: 4px; user-select: none;
}
.drag-handle:hover { color: var(--blue); background: var(--blue-soft); }
.drag-handle:active { cursor: grabbing; }
table.items tr.row.dragging > td { opacity: .4; }
table.items tr.row.drop-above > td { box-shadow: inset 0 2px 0 0 var(--blue); }
table.items tr.row.drop-below > td { box-shadow: inset 0 -2px 0 0 var(--blue); }
table.items td.code b { font-weight: 700; }
table.items td.code div { font-size: 11.5px; color: var(--text-mute); }
table.items td.dim { font-family: var(--font-num); color: var(--text-mute); font-size: 12px; white-space: nowrap; }
table.items td.n { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-mute); }
table.items td.n.strong { color: var(--text); font-weight: 700; font-size: 13.5px; }
table.items td.caret { width: 18px; color: #aab3c0; text-align: center; }
table.items tr.warn td.code::after { content: ' ⚠'; color: var(--red); }
table.items tr.detail > td { padding: 0 0 14px; border-bottom: 1px solid var(--border); background: none; }

.detailbox {
  background: #f8fafd; border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.sect-title {
  font-size: 11.5px; font-weight: 700; color: var(--text-mute);
  letter-spacing: .04em; margin: 0 0 10px;
  display: flex; align-items: center; gap: 9px;
}
.sect-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.cost-total {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 10px;
  padding-top: 10px; margin-top: 12px; border-top: 1px solid var(--border);
}
.cost-total .label { font-size: 13px; font-weight: 600; color: var(--text-mute); }
.cost-total .value { font-size: 18px; font-weight: 800; color: var(--blue); font-family: var(--font-num); }

/* แถบตัวเลขที่ระบบคำนวณให้ — น้ำหนักภาพเบากว่าค่าที่ผู้ใช้กรอก */
.calc-strip {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  font-size: 12px; color: var(--text-mute);
  background: #f6f8fb; border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 13px; margin-bottom: 16px;
}
.calc-strip b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); }
.chip {
  background: #fff; border: 1px solid var(--border); border-radius: 7px;
  padding: 4px 9px; font-size: 11.5px; color: var(--text-mute);
}
.chip b { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.chip.hi { background: var(--blue-soft); border-color: #cfe0ff; color: var(--blue-dark); }
.chip.hi b { color: var(--blue-dark); font-weight: 700; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ---------- ⑤ การ์ดสรุปราคา ---------- */
.summary-cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.sum-card {
  border-radius: 10px; padding: 14px 12px; text-align: center;
  background: #f6f8fb; border: 1px solid var(--border);
}
.sum-card .lbl { font-size: 11.5px; color: var(--text-mute); font-weight: 600; margin-bottom: 6px; }
.sum-card .val {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: 16.5px; font-weight: 800; color: var(--text);
}
.sum-card.total { background: var(--amber); border-color: var(--amber); }
.sum-card.total .lbl { color: var(--amber-lbl); }
.sum-card.total .val { color: var(--amber-ink); font-size: 18px; }

/* ---------- ⑥ ปุ่มส่งออก ---------- */
.export-row { display: flex; gap: 12px; }
.export-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px; border-radius: 11px; border: none; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 14px; color: #fff;
}
.export-btn .ic {
  width: 24px; height: 24px; border-radius: 6px; background: rgba(255,255,255,.22);
  display: grid; place-items: center; font-size: 10px; font-weight: 800; font-family: var(--font-num);
}
.export-excel { background: var(--green); }
.export-excel:hover { background: var(--green-dark); }
.export-pdf { background: var(--red); }
.export-pdf:hover { background: var(--red-dark); }

/* ---------- ฝั่งขวา : พรีวิว (คงรูปแบบเดิม) ---------- */
.preview-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--border);
}
.preview-bar .pv-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.preview-bar .pv-meta { font-size: 12px; color: var(--text-mute); }
.preview-bar .pv-zoom { font-size: 12px; color: var(--text); font-weight: 600; font-family: var(--font-num); min-width: 82px; text-align: center; }
.preview-scroll { flex: 1; overflow: auto; padding: 18px 0 44px; }
#paperWrap { zoom: var(--pv-zoom, 1); }

/* ---------- กระดาษ A4 ที่เรนเดอร์จากฟอร์ม Excel ต้นฉบับ ---------- */
.qt-page {
  position: relative; overflow: hidden; padding: 0 !important;
  background: #fff; color: #000;
  margin: 0 auto 16px; box-shadow: var(--shadow-2);
}
.qt-page:last-child { margin-bottom: 0; }
.qt-page img { display: block; }

/* ---------- กระดาษ A4 (ตัวเดิม สำรองไว้) ---------- */
.page {
  width: 210mm; min-height: 297mm; padding: 12mm 12mm 14mm;
  margin: 0 auto 16px; background: var(--paper); color: var(--paper-ink);
  box-shadow: var(--shadow-2);
  font-family: var(--font-paper);
  font-size: 10.5px; line-height: 1.42; position: relative;
}
.page:last-child { margin-bottom: 0; }
.qt-head { display: flex; gap: 14px; align-items: flex-start; }
.qt-head .brandcol { width: 47%; }
.qt-head .brandcol img.logo { width: 50mm; display: block; }
.qt-head .brandcol .addr { margin-top: 5px; font-size: 10px; line-height: 1.45; }
.qt-head .metacol { flex: 1; font-size: 11px; }
.qt-head .metacol .row { display: flex; gap: 6px; margin-bottom: 2px; }
.qt-head .metacol .row .k { width: 28mm; }
.qt-head .metacol .row .v { flex: 1; font-weight: 600; border-bottom: 1px dotted #999; min-height: 15px; }
.qt-contact { margin-top: 6px; font-size: 10px; }
.intro { margin: 9px 0 7px; text-indent: 8mm; font-size: 11px; }
table.qt { width: 100%; border-collapse: collapse; font-size: 9.6px; table-layout: fixed; }
table.qt th, table.qt td { border: 0.7px solid #333; padding: 2.6px 3px; vertical-align: middle; }
table.qt th { background: #eaeeec; font-weight: 600; text-align: center; font-size: 9.4px; }
table.qt td.c { text-align: center; }
table.qt td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.qt td.desc { font-size: 9.4px; line-height: 1.36; }
table.qt tr.tot td { font-weight: 600; background: #f4f6f5; }
table.qt tr.grand td { font-weight: 700; background: #e4eae8; }
.bahttext { border: 0.7px solid #333; border-top: 0; padding: 4px 6px; font-weight: 600; font-size: 10px; }
.pagenote { margin-top: 6px; font-size: 9.6px; }
.terms h3 { font-size: 11.5px; margin: 0 0 4px; color: #1e4b4a; }
.terms ol, .terms ul { margin: 0 0 8px; padding-left: 5mm; }
.terms li { margin-bottom: 1.5px; font-size: 9.6px; line-height: 1.4; }
.terms p { margin: 0 0 5px; font-size: 9.6px; }
.terms .block { margin-bottom: 9px; }
table.pay { width: 100%; border-collapse: collapse; font-size: 9.8px; margin-bottom: 8px; }
table.pay td { border: 0.7px solid #444; padding: 3px 5px; }
table.pay td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.plan { width: 100%; border-collapse: collapse; font-size: 9.6px; }
table.plan th, table.plan td { border: 0.7px solid #444; padding: 2.5px 4px; }
table.plan th { background: #eef1f0; }
.sign { display: flex; gap: 20px; margin-top: 9mm; }
.sign > div { flex: 1; text-align: center; font-size: 10px; }
.sign .line { border-bottom: 1px dotted #333; height: 15mm; position: relative; }
.sign .line img { position: absolute; bottom: 1mm; left: 50%; transform: translateX(-50%); height: 13mm; }
.brandstrip { margin-top: 5mm; }
.brandstrip img { width: 100%; }
.pagefoot { position: absolute; bottom: 6mm; right: 12mm; font-size: 9px; color: #666; }

/* ---------- พิมพ์ ---------- */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff; height: auto; overflow: visible; }
  .appbar, .pane-left, .preview-bar, .noprint, .toast { display: none !important; }
  .workspace { display: block; height: auto; overflow: visible; }
  .pane-right { display: block; border: 0; background: #fff; height: auto; }
  .preview-scroll { overflow: visible; padding: 0; }
  #paperWrap { zoom: 1 !important; }
  .page, .qt-page {
    width: 210mm; min-height: 297mm; margin: 0; box-shadow: none;
    background: #fff; color: #000;
    page-break-after: always; break-after: page;
  }
  .page:last-child, .qt-page:last-child { page-break-after: auto; break-after: auto; }
}

/* ---------- อื่นๆ ---------- */
.empty { text-align: center; padding: 30px 18px; color: var(--text-mute); font-size: 13px; }
.empty.sm { padding: 16px 12px; font-size: 12.5px; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 9px;
  box-shadow: var(--shadow-2); z-index: 200; font-size: 13.5px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.toast.show { opacity: 1; }
.alert {
  background: var(--warn-soft); border: 1px solid #f0d59a; color: var(--warn);
  padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 12px;
}
.badge {
  display: inline-block; min-width: 20px; text-align: center;
  background: var(--blue-soft); color: var(--blue-dark); border-radius: 999px;
  font-family: var(--font-num); font-size: 11.5px; font-weight: 700; padding: 1px 7px;
}
