/* ============================================================
   เอกสารใบเสนอราคา A4 — ตามต้นแบบ
   ============================================================ */
:root{ --qo:#f97316; --qo-d:#ea580c; --qink:#1e293b; --qmut:#64748b; --qline:#e2e8f0; }

.qwrap{background:#eef2f7;padding:22px;border-radius:14px;overflow-x:auto}
.qdoc{width:210mm;min-height:297mm;background:#fff;margin:0 auto;padding:13mm 13mm 0;
  box-shadow:0 4px 24px rgba(15,23,42,.16);font-size:10.5pt;line-height:1.55;color:var(--qink);
  display:flex;flex-direction:column}
.qdoc *{box-sizing:border-box}

/* ---------- หัวเอกสาร ---------- */
.qtop{display:flex;justify-content:space-between;align-items:flex-start;gap:10mm}
.qlogo{min-height:1px}
.qlogo img{max-height:17mm;max-width:62mm;object-fit:contain}
.qlogo .nm{font-size:15pt;font-weight:700;letter-spacing:.5px}
.qtitle{text-align:right;flex:none}
.qtitle h1{font-size:19pt;font-weight:700;line-height:1.1;margin:0}
.qtitle .en{font-size:9pt;color:var(--qmut);letter-spacing:3px;font-weight:600;margin-bottom:3mm}
.qno{display:inline-block;background:var(--qo);color:#fff;font-weight:700;font-size:10pt;
  padding:1.4mm 5mm;border-radius:100px;letter-spacing:.3px}
.qdate{color:var(--qo-d);font-size:9pt;margin-top:1.8mm}

.qco{margin-top:4mm}
.qco b{font-size:11.5pt;font-weight:700;display:block;margin-bottom:1mm}
.qco p{margin:0;font-size:9pt;color:#475569;line-height:1.55}
.qrule{border:0;border-top:.6mm solid var(--qo);margin:4mm 0 5mm}

/* ---------- ลูกค้า / โครงการ ---------- */
.qparties{display:flex;gap:8mm;margin-bottom:5mm}
.qparty{flex:1;min-width:0}
.qparty h4{font-size:9pt;font-weight:700;color:var(--qo);letter-spacing:.4px;margin:0 0 1.5mm}
.qparty p{margin:0;font-size:9.5pt;line-height:1.55;word-wrap:break-word;color:#334155}
.qparty .nm{font-weight:700;color:var(--qink)}
.qparty .dash{color:#cbd5e1}

/* ---------- ตารางรายการ ---------- */
.qitems{width:100%;margin-bottom:4mm}
.qitems thead th{background:var(--qink);color:#fff;padding:2.6mm 3mm;font-size:9pt;font-weight:600;text-align:left;border:0}
.qitems thead th.c{text-align:center}
.qitems thead th.r{text-align:right}
.qitems tbody td{padding:3mm;border-bottom:.3mm solid var(--qline);vertical-align:top;font-size:9.5pt}
.qitems tbody td.c{text-align:center}
.qitems tbody td.r{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap;font-weight:600}
.qitems .nm{font-weight:700;font-size:10pt;display:block;margin-bottom:1.5mm}
.qspec{list-style:none;margin:0;padding:0}
.qspec li{position:relative;padding-left:4mm;font-size:9pt;color:#475569;line-height:1.6;margin-bottom:.5mm}
.qspec li::before{content:"";position:absolute;left:0;top:1.7mm;width:1.4mm;height:1.4mm;border-radius:50%;background:var(--qo)}
.qwar{margin-top:2.5mm;padding-top:2.5mm;border-top:.3mm dashed #cbd5e1}
.qwar h5{margin:0 0 1.2mm;font-size:9.5pt;font-weight:700;color:var(--qink)}
.qwar ul{list-style:none;margin:0;padding:0}
.qwar li{position:relative;padding-left:4.5mm;font-size:9pt;color:#475569;line-height:1.6;margin-bottom:.4mm}
.qwar li::before{content:"✓";position:absolute;left:0;top:0;color:#16a34a;font-weight:700}
.qgrp td{background:#f8fafc;font-weight:700;font-size:9pt;color:var(--qmut)}

/* ---------- ยอดรวม ---------- */
.qsum{margin-left:auto;width:82mm;margin-bottom:5mm}
.qsum .r{display:flex;justify-content:space-between;gap:4mm;padding:1.8mm 3mm;font-size:9.5pt;border-bottom:.3mm solid var(--qline)}
.qsum .r b{font-variant-numeric:tabular-nums;font-weight:700}
.qsum .r.g{background:#f1f5f9;border-bottom:0}
.qsum .r.net{background:var(--qo);color:#fff;border-radius:2mm;border:0;margin-top:2mm;padding:3mm;font-size:11.5pt;font-weight:700}
.qsum .r.net b{font-size:12.5pt}
.qsum .r.disc b{color:#dc2626}

.qdash{border:0;border-top:.3mm dashed #cbd5e1;margin:0 0 5mm}

/* ---------- หมายเหตุ + งวดชำระ ---------- */
.qbot{display:flex;gap:8mm;margin-bottom:6mm}
.qbot>div{flex:1;min-width:0}
.qbot h4{font-size:9.5pt;font-weight:700;color:var(--qo);margin:0 0 2mm}
.qnotes p{margin:0 0 1.5mm;font-size:9.5pt;line-height:1.6;white-space:pre-wrap;color:#334155}
.qnotes .small{font-size:8.5pt;color:var(--qmut)}
.qpay{width:100%;font-size:9pt}
.qpay th{background:var(--qink);color:#fff;padding:2mm 2.5mm;text-align:left;font-weight:600;font-size:8.5pt}
.qpay th.r{text-align:right}
.qpay td{padding:2mm 2.5mm;border-bottom:.3mm solid var(--qline);white-space:nowrap}
.qpay td:first-child{width:26mm}
.qpay td.r{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.qpay tr.i1 td{background:#fff7ed}
.qpay tr.i1 td.tot,.qpay tr.i2 td.tot{color:var(--qo-d);font-weight:700}
.qpay tr.sum td{background:var(--qink);color:#fff;font-weight:700;border:0}
.qpay tr.sum td.tot{color:var(--qo)}
.qpaynote{margin-top:2mm;font-size:9pt;color:#475569;white-space:pre-wrap;line-height:1.55}

/* ---------- ลายเซ็น ---------- */
.qsign{display:flex;gap:14mm;margin-top:auto;padding-top:8mm}
.qsign div{flex:1;text-align:center;font-size:9.5pt}
.qsign .ln{border-top:.3mm solid #94a3b8;margin-bottom:2mm}
.qsign .cap{color:var(--qmut);font-size:8.5pt;margin-top:1mm}

/* ---------- แถบท้าย ---------- */
.qfoot{background:var(--qo);color:#fff;margin:6mm -13mm 0;padding:3mm 13mm;
  display:flex;justify-content:space-between;align-items:center;gap:6mm;font-size:8.5pt;flex-wrap:wrap}
.qfoot .l{display:flex;align-items:center;gap:4mm;flex-wrap:wrap}
.qfoot .l span{display:inline-flex;align-items:center;gap:1.5mm}
.qfoot svg{width:3.4mm;height:3.4mm;flex:none}
.qfoot .tag{font-weight:700;letter-spacing:.8px}

/* ---------- บังคับ A4 ตอนทำ PDF ---------- */
.qdoc.force-a4{width:210mm!important;min-width:210mm!important;padding:13mm 13mm 0!important;
  font-size:10.5pt!important;border:0!important;border-radius:0!important;box-shadow:none!important}
.qdoc.force-a4 .qtop,.qdoc.force-a4 .qparties,.qdoc.force-a4 .qbot,.qdoc.force-a4 .qsign{flex-direction:row!important}
.qdoc.force-a4 .qtitle{text-align:right!important}
.qdoc.force-a4 .qsum{width:82mm!important;margin-left:auto!important}
.qdoc.force-a4 .qitems{min-width:0!important}
.qdoc.force-a4 .qtbl-wrap{overflow:visible!important;margin:0!important;padding:0!important}
.qdoc.force-a4 .qfoot{margin:6mm -13mm 0!important}

/* ---------- พิมพ์ ---------- */
@media print{
  @page{size:A4;margin:0}
  html,body{background:#fff!important}
  .qwrap{background:#fff;padding:0;border-radius:0;overflow:visible}
  .qdoc{width:210mm!important;min-width:0!important;min-height:auto;box-shadow:none;margin:0;
    padding:12mm 13mm 0!important;font-size:10.5pt!important;border:0!important;border-radius:0!important}
  .qdoc .qtop,.qdoc .qparties,.qdoc .qbot,.qdoc .qsign{flex-direction:row!important}
  .qdoc .qtitle{text-align:right!important}
  .qdoc .qsum{width:82mm!important;margin-left:auto!important}
  .qtbl-wrap{overflow:visible!important;margin:0!important;padding:0!important}
  .qitems{min-width:0!important}
  .qitems tr,.qbot,.qsign,.qsum,.qfoot{page-break-inside:avoid}
  .qfoot{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .qsum .r.net,.qitems thead th,.qpay th,.qpay tr.sum td{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}

/* ---------- มือถือ ---------- */
@media (max-width:900px){
  .qwrap{padding:0;background:transparent}
  .qdoc{width:100%;min-width:0;padding:16px 16px 0;box-shadow:none;border:1px solid var(--qline);
    border-radius:14px;font-size:13px;min-height:0}
  .qtop,.qparties,.qbot,.qsign{flex-direction:column;gap:14px}
  .qtitle{text-align:left}
  .qsum{width:100%}
  .qlogo img{max-height:46px;max-width:170px}
  .qtbl-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:0 -16px 4mm;padding:0 16px}
  .qitems{min-width:520px}
  .qfoot{margin:16px -16px 0;padding:12px 16px;border-radius:0 0 13px 13px;font-size:12px}
  .qsign{padding-top:20px}
}
