/* รอบ 34: ใบเสนอราคา (/quotes + Components/QuoteEditor.razor + Components/QuotePrint.razor) และแถบ "ขายตามใบเสนอราคา" ในหน้าขาย (.posq-*)
   - โครง .fit ของ fit.css + ชิปช่วงเวลา/ตัวกรองของ expenses.css (.exp-periods, .exp-chip, .exp-toast) + ช่องเลือกสาขา .pl-branch
   - สีสถานะมาจากตัวแปร --qs (ตั้งด้วยคลาส .st-<status>) ใช้ตัวแปรธีม จึงใช้กับโหมดมืดได้ (override ท้ายไฟล์)
   - เอกสารพิมพ์ใช้กระดาษ .dbt-paper ของ credit.css (ขาวเสมอ) + ส่วนเสริม .qt-* ที่นี่
   - พิมพ์: html[data-print="quote"] → พิมพ์เฉพาะ .quote-print บนกระดาษ A4 (ผูกด้วย :has() จึงไม่กระทบการพิมพ์หน้าอื่น) */

@media screen {
  /* ---------- สีสถานะ ---------- */
  .st-draft { --qs: var(--muted); }
  .st-sent { --qs: #2F6FB3; }
  .st-accepted { --qs: var(--ok); }
  .st-converted { --qs: #7C3AED; }
  .st-rejected { --qs: var(--danger); }
  .st-cancelled { --qs: #8A817A; }
  .st-expired { --qs: #B7791F; }

  .qt-st {
    display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; white-space: nowrap;
    font-size: .78rem; font-weight: 700; color: var(--qs); background: color-mix(in srgb, var(--qs) 13%, transparent);
  }
  .qt-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--qs); }
  .qt-st.st-cancelled { text-decoration: line-through; text-decoration-thickness: 1.5px; }
  .qt-expired {
    display: inline-flex; align-items: center; padding: 0 8px; border-radius: 999px; white-space: nowrap;
    background: var(--danger-soft); color: var(--danger); font-size: .72rem; font-weight: 700;
  }
  .qt-dot { flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--qs, var(--muted)); }
  .qt-tag-custom {
    display: inline-flex; align-items: center; padding: 0 8px; border-radius: 999px; white-space: nowrap;
    background: var(--chip); color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .01em;
  }
  .qt-hint { margin: 0; font-size: .8rem; color: var(--muted); }
  .qt-hint.warn { padding: 8px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn-text, #7a5300); font-weight: 600; }

  /* ---------- หัว + แถบช่วงเวลา ---------- */
  .qt-tools { gap: 8px; }
  .qt-search { width: 250px; }
  .qt-add-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; }
  .qt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
  .qt-bar-note { margin-left: auto; font-size: .8rem; }

  /* ---------- ตัวเลขสรุป ---------- */
  .qt-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .qt-stats .fit-stat small { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qt-stat-open { background: var(--brand); color: var(--brand-ink); }
  .qt-stat-open.fit-stat.hl strong { color: var(--brand-ink); }
  .qt-stat-open > span, .qt-stat-open > small { color: var(--brand-ink); opacity: .85; }
  .qt-stat-acc { box-shadow: var(--shadow), inset 3px 0 0 var(--ok); }
  .qt-stat-conv { box-shadow: var(--shadow), inset 3px 0 0 #7C3AED; }

  /* ---------- รายการ ---------- */
  .panel.qt-main { padding: 12px 14px 6px; }
  .qt-chip { --cat: var(--qs, var(--ink)); }
  .qt-chip.on { border-color: var(--qs, var(--ink)); background: color-mix(in srgb, var(--qs, var(--ink)) 12%, var(--surface)); }
  .qt-scroll.table-wrap { border: 0; border-radius: 0; background: transparent; }
  .qt-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .qt-table th { padding: 9px 12px; white-space: nowrap; }
  .qt-table tr:last-child td { border-bottom: 0; }
  .qt-row { cursor: pointer; }
  .qt-row:hover td { background: var(--brand-tint); }
  .qt-row.open td { background: var(--brand-soft); }
  .qt-c-no { white-space: nowrap; }
  .qt-c-no strong { font-weight: 700; font-size: .9rem; }
  .qt-c-date { white-space: nowrap; color: var(--muted); font-size: .86rem; }
  .qt-c-cust { max-width: 340px; }
  .qt-cust-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qt-c-cust small { display: block; font-size: .78rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qt-br-inline { display: none !important; }
  .qt-c-branch { white-space: nowrap; font-size: .88rem; }
  .qt-c-items { color: var(--muted); width: 70px; }
  .qt-c-total { white-space: nowrap; }
  .qt-c-total strong { font-weight: 700; }
  .qt-c-valid { white-space: nowrap; font-size: .86rem; }
  .qt-c-valid .qt-expired { margin-left: 6px; }
  .qt-valid-label { display: none; }
  .qt-c-status { white-space: nowrap; }
  .qt-c-act { width: 52px; padding-left: 0 !important; text-align: center; }
  .qt-row.st-cancelled td, .qt-row.st-rejected .qt-c-total { color: var(--muted); }
  .qt-row.st-cancelled .qt-c-total strong { text-decoration: line-through; }
  .qt-ico-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 10px;
    background: var(--chip); color: var(--ink); font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer;
  }
  .qt-ico-btn:hover:not(:disabled) { background: var(--line); }
  .qt-ico-btn:disabled { opacity: .35; cursor: default; }
  .qt-ico-btn.conv { color: var(--brand-strong, var(--brand)); background: var(--brand-tint); }
  .qt-ico-btn.conv:hover { background: var(--brand-soft); }
  .qt-ico-btn.danger { color: var(--danger); }
  .qt-ico-btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
  .qt-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; border: 0; margin: auto 0; }
  .qt-empty p, .qt-ed-empty p { margin: 0; }
  .qt-empty-ico { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 20px; background: var(--brand-soft); color: var(--brand-strong, var(--brand)); }
  .qt-mbar { display: none; }

  /* ---------- ลิ้นชักรายละเอียด ---------- */
  .drw-sub .qt-st, .drw-sub .qt-expired { margin-right: 2px; }
  .qt-d-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
  .qt-d-hero > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; border-radius: 16px; }
  .qt-d-hero span { color: var(--muted); font-size: .8rem; }
  .qt-d-hero-main { background: var(--brand-tint); border-left: 5px solid var(--brand); }
  .qt-d-hero-main strong { font-size: 1.7rem; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
  .qt-d-hero-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
  .qt-d-valid { background: var(--chip); }
  .qt-d-valid strong { font-size: 1.15rem; font-weight: 700; }
  .qt-d-valid small { font-size: .78rem; color: var(--muted); }
  .qt-d-valid.bad { background: var(--danger-soft); }
  .qt-d-valid.bad strong, .qt-d-valid.bad small { color: var(--danger); }
  .qt-d-sale {
    display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; text-decoration: none; font-weight: 700;
    color: #7C3AED; background: color-mix(in srgb, #7C3AED 11%, var(--surface));
  }
  .qt-d-sale:hover { background: color-mix(in srgb, #7C3AED 17%, var(--surface)); }
  .qt-st-btns { display: flex; flex-wrap: wrap; gap: 8px; }
  .qt-st-btn {
    display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 14px; border: 1.5px solid color-mix(in srgb, var(--qs, var(--line)) 45%, var(--line));
    border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer;
  }
  .qt-st-btn:hover:not(:disabled) { border-color: var(--qs, var(--muted)); background: color-mix(in srgb, var(--qs, var(--muted)) 9%, var(--surface)); }
  .qt-st-btn:disabled { opacity: .5; cursor: default; }
  .qt-st-btn.st-accepted { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
  .qt-st-btn.cancel { border-color: transparent; background: none; color: var(--danger); margin-left: auto; }
  .qt-st-btn.cancel:hover:not(:disabled) { background: var(--danger-soft); border-color: transparent; }
  .void-box.qt-confirm { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); border-radius: 14px; background: var(--danger-soft); }
  .qt-confirm p { margin: 0; font-weight: 600; color: var(--danger); }
  .qt-confirm .actions { margin: 0; }
  .qt-d-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
  .qt-d-lines li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
  .qt-d-lines li:first-child { border-top: 0; }
  .qt-d-line-main { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.35; }
  .qt-d-line-main strong { font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
  .qt-d-line-main small { font-size: .78rem; }
  .qt-d-line-amt { flex: none; font-weight: 700; font-size: .92rem; }
  .qt-d-sums { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
  .qt-sum-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .9rem; }
  .qt-sum-row.disc { color: var(--danger); }
  .qt-sum-row.small { font-size: .78rem; color: var(--muted); }
  .qt-sum-row.total { margin-top: 4px; padding: 8px 12px; border-radius: 12px; background: var(--chip); font-weight: 800; font-size: 1rem; }
  .qt-sum-row.total strong { font-size: 1.2rem; }
  .qt-d-text > div { flex-direction: column; gap: 2px; }
  .qt-d-text dd { text-align: left; }
  .drw-foot .qt-foot-conv { display: inline-flex; align-items: center; gap: 6px; }

  /* ---------- ตัวอย่างพิมพ์ ---------- */
  .qt-docview { display: flex; flex-direction: column; }
  .qt-doc-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
  .qt-doc-actions .btn { display: inline-flex; align-items: center; gap: 7px; }

  /* ---------- ฟอร์มสร้าง/แก้ไข ---------- */
  .qt-ed-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .qt-back { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; }
  .qt-back:hover { background: var(--chip); }
  .qt-ed-tools { gap: 10px; }
  .qt-ed-total { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.2; padding: 0 6px; }
  .qt-ed-total small { color: var(--muted); font-size: .76rem; }
  .qt-ed-total strong { font-size: 1.3rem; font-weight: 800; color: var(--brand-strong, var(--brand)); font-variant-numeric: tabular-nums; }
  .qt-ed-tools .btn { min-height: 42px; }
  .qt-ed-save { min-width: 130px; }
  .panel.qt-ed-main { padding: 12px 14px 8px; gap: 10px; }
  .qt-ed-add { position: relative; display: flex; gap: 8px; flex: none; }
  .qt-psearch { flex: 1 1 auto; width: auto; }
  .qt-custom-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 42px; white-space: nowrap; }
  .qt-presults {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: min(360px, 60vh); overflow-y: auto; overscroll-behavior: contain;
    padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg);
  }
  .qt-presults-empty { margin: 0; padding: 14px; text-align: center; color: var(--muted); font-size: .9rem; }
  .qt-pr { display: flex; align-items: center; gap: 10px 14px; padding: 8px 10px; border-radius: 10px; flex-wrap: wrap; }
  .qt-pr + .qt-pr { border-top: 1px solid var(--line); }
  .qt-pr:hover { background: var(--brand-tint); }
  .qt-pr-name { display: flex; flex-direction: column; flex: 1 1 200px; min-width: 0; line-height: 1.3; }
  .qt-pr-name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qt-pr-name small { font-size: .74rem; }
  .qt-pr-units { display: flex; flex-wrap: wrap; gap: 6px; }
  .qt-pr-unit {
    display: inline-flex; align-items: baseline; gap: 6px; min-height: 34px; padding: 5px 12px; border: 1.5px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: .84rem; cursor: pointer; white-space: nowrap;
  }
  .qt-pr-unit b { color: var(--brand-strong, var(--brand)); font-weight: 700; }
  .qt-pr-unit:hover { border-color: var(--brand); background: var(--brand-tint); }
  /* รอบ 104: ProductLinePicker — สินค้าที่กดหน่วยไม่ได้ (ItemDisabled เช่น ใบโอนที่ไม่มีของเหลือ) */
  .qt-pr.is-off { opacity: .6; }
  .qt-pr-unit:disabled { cursor: not-allowed; }
  .qt-pr-unit:disabled:hover { border-color: var(--line); background: var(--surface); }
  .qt-ed-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; flex: 1 1 auto; border: 0; color: var(--muted); }
  .qt-ed-empty .qt-empty-ico { width: 56px; height: 56px; border-radius: 18px; }
  .qt-lines-wrap.table-wrap { border: 0; border-radius: 0; background: transparent; }
  .qt-lines th { padding: 8px 6px; font-size: .8rem; white-space: nowrap; }
  .qt-lines td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
  .qt-lines tr:last-child td { border-bottom: 0; }
  .qt-lines .qt-l-no { width: 30px; text-align: center; color: var(--muted); padding-top: 14px; font-size: .84rem; }
  .qt-lines .qt-l-desc { min-width: 180px; }
  .qt-lines .qt-l-unit { width: 78px; }
  .qt-lines .qt-l-qty { width: 74px; }
  .qt-lines .qt-l-price { width: 112px; }
  .qt-lines .qt-l-disc { width: 96px; }
  .qt-lines .qt-l-amt { width: 112px; padding-top: 14px; white-space: nowrap; font-size: .92rem; }
  .qt-lines .qt-l-act { width: 72px; }
  .qt-in {
    width: 100%; min-width: 0; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem;
  }
  .qt-in:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
  .qt-in.num { text-align: right; font-variant-numeric: tabular-nums; }
  .qt-l-desc small { display: inline-flex; margin-top: 4px; }
  .qt-list-price { font-size: .74rem; color: var(--warn-text, #7a5300); }
  .qt-unit-fixed { display: inline-flex; align-items: center; min-height: 38px; padding: 0 4px; font-size: .9rem; color: var(--muted); }
  .qt-line.custom td:first-child { box-shadow: inset 3px 0 0 var(--line); }
  /* เลื่อนขึ้น/ลง ซ้อนกันแนวตั้ง + ปุ่มลบ (ประหยัดความกว้างของตาราง) */
  .qt-l-btns { display: inline-grid; grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 2px 4px; }
  .qt-l-btns .qt-ico-btn { width: 28px; height: 18px; border-radius: 6px; }
  .qt-l-btns .qt-ico-btn svg { width: 14px; height: 14px; }
  .qt-l-btns .qt-ico-btn:nth-child(1) { grid-column: 1; grid-row: 1; }
  .qt-l-btns .qt-ico-btn:nth-child(2) { grid-column: 1; grid-row: 2; }
  .qt-l-btns .qt-ico-btn.danger { grid-column: 2; grid-row: 1 / span 2; width: 32px; height: 38px; border-radius: 9px; }
  .qt-l-btns .qt-ico-btn.danger svg { width: 16px; height: 16px; }
  .panel.qt-ed-side { padding: 6px 6px 6px 14px; }
  .qt-ed-side-scroll { display: flex; flex-direction: column; gap: 0; padding-top: 8px !important; padding-bottom: 8px !important; }
  .qt-ed-sec { display: flex; flex-direction: column; gap: 10px; padding: 12px 2px 14px; }
  .qt-ed-sec + .qt-ed-sec { border-top: 1px dashed var(--line); }
  .qt-ed-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .qt-ed-sec-head h2 { margin: 0; font-size: 1rem; }
  .qt-ed-sec-head .link { font-weight: 600; text-decoration: none; font-size: .86rem; }
  .qt-ed-sec-head .link:hover { text-decoration: underline; }
  .qt-ed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; align-items: start; }
  .qt-ed-sec textarea { resize: vertical; }
  .qt-cust-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--brand-tint); border: 1px solid var(--brand-soft); }
  .qt-cust-ava { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
  .qt-cust-chip-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.3; }
  .qt-cust-chip-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qt-cust-chip-text small { font-size: .74rem; }
  .qt-valid-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .qt-valid-chips .chip { cursor: pointer; font: inherit; font-size: .84rem; padding: 4px 12px; }
  .qt-ed-sums { gap: 5px; }
  .qt-bill-disc { cursor: default; }
  .qt-bill-disc .qt-in { width: 150px; min-height: 36px; }
  .qt-ed-mbar { display: none; }
  .qt-ed .qt-hint { margin-top: 2px; }

  /* ---------- แถบใบเสนอราคาในหน้าขาย ---------- */
  .posq-banner {
    display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; padding: 9px 10px 9px 12px; border-radius: 14px;
    background: color-mix(in srgb, #7C3AED 9%, var(--surface)); border: 1px solid color-mix(in srgb, #7C3AED 28%, var(--line));
  }
  .posq-head { display: flex; align-items: center; gap: 8px; color: #6D28D9; }
  .posq-head svg { flex: none; }
  .posq-title { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .posq-x {
    flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 999px;
    background: color-mix(in srgb, #7C3AED 14%, transparent); color: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer;
  }
  .posq-x:hover { background: color-mix(in srgb, #7C3AED 24%, transparent); }
  .posq-sub { color: var(--muted); font-size: .78rem; }
  .posq-warn, .posq-info { margin: 0; padding: 5px 9px; border-radius: 9px; font-size: .78rem; line-height: 1.4; }
  .posq-warn { background: var(--warn-soft); color: var(--warn-text, #7a5300); }
  .posq-info { background: var(--chip); color: var(--muted); }
  .posq-alert { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
}

/* ---------- จอคอม ---------- */
@media screen and (min-width: 1025px) {
  .qt-fit .fit-body > .qt-main { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  .qt-ed-split { grid-template-columns: minmax(0, 1fr) 360px; }
  .qt-ed-main { overflow: visible !important; }
  .qt-ed-main > .qt-lines-wrap { overflow: auto; }
  .qt-ed-side-scroll { margin-right: 0 !important; padding-right: 10px !important; }
}
@media screen and (min-width: 1025px) and (max-width: 1360px) {
  .qt-search { width: 200px; }
  .qt-c-cust { max-width: 220px; }
  .qt-table td, .qt-table th { padding-left: 8px; padding-right: 8px; }
  .qt-c-items { display: none; }
  .qt-ed-split { grid-template-columns: minmax(0, 1fr) 320px; }
  .qt-lines .qt-l-no { display: none; }
  .qt-lines th, .qt-lines td { padding-left: 4px; padding-right: 4px; }
  .qt-lines .qt-l-desc { min-width: 150px; }
  .qt-lines .qt-l-unit { width: 64px; }
  .qt-lines .qt-l-qty { width: 64px; }
  .qt-lines .qt-l-price { width: 98px; }
  .qt-lines .qt-l-disc { width: 82px; }
  .qt-lines .qt-l-amt { width: 102px; font-size: .86rem; }
  .qt-lines .qt-l-act { width: 68px; }
  .qt-in { padding-left: 8px; padding-right: 8px; }
}
@media screen and (min-width: 1500px) {
  .qt-c-cust { max-width: 460px; }
}
@media screen and (min-width: 1700px) {
  .qt-ed-split { grid-template-columns: minmax(0, 1fr) 440px; }
  .qt-lines .qt-l-desc { min-width: 260px; }
}
@media screen and (min-width: 761px) and (max-width: 1024px) {
  .qt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- มือถือ ---------- */
@media screen and (max-width: 760px) {
  .qt-tools { flex-wrap: wrap; }
  .qt-tools .qt-branch { flex: 1 1 100%; }
  .qt-branch select { max-width: none; flex: 1 1 auto; }
  .qt-tools .qt-add-btn { display: none; }
  .qt-search { width: auto; }
  .qt-bar { gap: 8px; }
  .qt-periods { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; padding-bottom: 2px; }
  .qt-periods::-webkit-scrollbar { display: none; }
  .qt-periods .chip { flex: none; }
  .qt-bar-note { display: none; }
  .qt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qt-stats .fit-stat { padding: 10px 12px; }

  .panel.qt-main { padding: 0; background: none; border: 0; box-shadow: none; }
  .qt-chips { margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none; }
  .qt-chips::-webkit-scrollbar { display: none; }
  .qt-table thead { display: none; }
  .qt-table, .qt-table tbody { display: block; width: 100%; }
  .qt-table tr.qt-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "cust cust total" "no date status" "valid valid act";
    align-items: center; gap: 4px 10px; margin-bottom: 8px; padding: 11px 14px;
    border: 1px solid var(--line); border-left: 4px solid var(--qs, var(--line)); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  }
  .qt-table tr.qt-row td { display: block; padding: 0 !important; border: 0; background: none !important; max-width: none; width: auto; min-width: 0; }
  .qt-table .qt-c-cust { grid-area: cust; }
  .qt-table .qt-c-total { grid-area: total; font-size: 1.04rem; text-align: right; }
  .qt-table .qt-c-no { grid-area: no; font-size: .8rem; }
  .qt-table .qt-c-no strong { font-size: .8rem; font-weight: 600; color: var(--muted); }
  .qt-table .qt-c-date { grid-area: date; font-size: .78rem; }
  .qt-table .qt-c-status { grid-area: status; justify-self: end; }
  .qt-table .qt-c-valid { grid-area: valid; font-size: .78rem; color: var(--muted); white-space: normal; }
  .qt-table .qt-c-act { grid-area: act; width: auto; }
  .qt-table .qt-c-act:empty { display: none; }
  .qt-table .qt-c-items, .qt-table .qt-c-branch { display: none !important; }
  .qt-br-inline { display: block !important; }
  .qt-valid-label { display: inline; margin-right: 4px; }
  .qt-mbar {
    display: block; position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15;
    margin: 0 -16px; padding: 8px 16px; background: linear-gradient(to top, var(--bg) 70%, transparent);
  }
  .qt-mbar .btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; font-size: 1rem; box-shadow: var(--shadow-lg); }
  .qt-toast { bottom: calc(146px + env(safe-area-inset-bottom)); }

  .qt-d-hero { grid-template-columns: minmax(0, 1fr); }
  .qt-d-hero-main strong { font-size: 1.5rem; }
  .qt-st-btn.cancel { margin-left: 0; }
  .drw-foot .qt-foot-btn { flex: 1 1 0; padding-left: 6px; padding-right: 6px; font-size: .86rem; min-width: 0; }
  .drw-foot .qt-foot-conv { flex: 1 1 100%; order: -1; justify-content: center; }
  .qt-doc-actions .btn { flex: 1 1 0; justify-content: center; }

  /* ฟอร์ม */
  .qt-ed-tools { display: none; }
  .qt-ed-head .context { display: block; }
  .panel.qt-ed-main { padding: 0; background: none; border: 0; box-shadow: none; }
  .qt-ed-add { flex-wrap: wrap; }
  .qt-psearch { flex: 1 1 100%; }
  .qt-custom-btn { flex: 1 1 100%; justify-content: center; }
  .qt-presults { top: 50px; }
  .qt-pr-units { width: 100%; }
  .qt-ed-empty { padding: 26px 12px; }
  .qt-lines thead { display: none; }
  .qt-lines, .qt-lines tbody { display: block; width: 100%; }
  .qt-lines tr.qt-line {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 8px; margin-bottom: 10px; padding: 10px 12px 12px;
    border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  }
  .qt-lines tr.qt-line.custom { border-left: 4px solid var(--muted); }
  .qt-lines tr.qt-line td { display: block; width: auto !important; min-width: 0 !important; padding: 0 !important; border: 0; }
  .qt-lines .qt-l-no { display: none !important; }
  .qt-lines .qt-l-desc { grid-column: 1 / -1; }
  .qt-lines .qt-l-unit { grid-column: 1 / 2; grid-row: 2; }
  .qt-lines .qt-l-qty { grid-column: 2 / 3; grid-row: 2; }
  .qt-lines .qt-l-price { grid-column: 3 / 4; grid-row: 2; }
  .qt-lines .qt-l-disc { grid-column: 1 / 2; grid-row: 3; }
  .qt-lines .qt-l-amt { grid-column: 2 / 3; grid-row: 3; align-self: end; text-align: right; padding-bottom: 8px !important; }
  .qt-lines .qt-l-act { grid-column: 3 / 4; grid-row: 3; align-self: end; text-align: right; }
  .qt-l-btns { display: inline-flex; gap: 4px; }
  .qt-l-btns .qt-ico-btn, .qt-l-btns .qt-ico-btn.danger { width: 32px; height: 32px; border-radius: 9px; }
  .qt-lines td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: .72rem; }
  .qt-lines .qt-l-unit .qt-unit-fixed { min-height: 0; padding: 18px 0 0; }
  .qt-in { font-size: 16px; }
  .qt-ed-grid { grid-template-columns: minmax(0, 1fr); }
  .panel.qt-ed-side { padding: 4px 14px; }
  .qt-ed-mbar {
    display: flex; align-items: center; gap: 12px; position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15;
    margin: 0 -16px; padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0,0,0,.08);
  }
  .qt-ed-mbar .qt-ed-total { align-items: flex-start; flex: 1 1 auto; padding: 0; }
  .qt-ed-mbar .btn { min-height: 48px; min-width: 140px; }
}

/* ---------- โหมดมืด ---------- */
@media screen {
  html[data-theme="dark"] .st-sent { --qs: #8CC4F2; }
  html[data-theme="dark"] .st-converted { --qs: #B79CFB; }
  html[data-theme="dark"] .st-cancelled { --qs: #8F877F; }
  html[data-theme="dark"] .st-expired { --qs: #F0B44C; }
  html[data-theme="dark"] .qt-stat-open { background: color-mix(in srgb, var(--brand) 70%, #1F1D1B); }
  html[data-theme="dark"] .qt-stat-conv { box-shadow: var(--shadow), inset 3px 0 0 #B79CFB; }
  html[data-theme="dark"] .qt-d-sale { color: #C4B5FD; background: color-mix(in srgb, #7C3AED 22%, var(--surface)); }
  html[data-theme="dark"] .qt-toast { background: #ECE7E1; color: #1F1D1B; }
  html[data-theme="dark"] .posq-banner { background: color-mix(in srgb, #7C3AED 16%, var(--surface)); border-color: color-mix(in srgb, #7C3AED 40%, var(--line)); }
  html[data-theme="dark"] .posq-head { color: #C4B5FD; }
  html[data-theme="dark"] .qt-ed-mbar { box-shadow: 0 -6px 18px rgba(0,0,0,.4); }
}

/* ---------- ส่วนเสริมของกระดาษใบเสนอราคา (บนจอและตอนพิมพ์) ---------- */
.qt-plines .qt-pdesc { overflow-wrap: anywhere; }
.qt-plines .qt-punit { color: #333; }
.qt-sum-small { font-size: .86em; color: #555; }
.qt-pterms { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid #BBB; border-radius: 8px; break-inside: avoid; }
.qt-pterms p { margin: 0; font-size: .95em; color: #222; }

/* =========================== พิมพ์ (A4) =========================== */
@page qt-a4 { size: A4; margin: 12mm; }
@media print {
  html[data-print="quote"]:has(.quote-print), html[data-print="quote"]:has(.quote-print) body {
    margin: 0 !important; padding: 0 !important; height: auto !important; overflow: visible !important;
    background: #fff !important; color: #111 !important; page: qt-a4;
  }
  html[data-print="quote"]:has(.quote-print) body *:not(:has(.quote-print)):not(.quote-print):not(.quote-print *) { display: none !important; }
  html[data-print="quote"]:has(.quote-print) body *:has(.quote-print) {
    display: block !important; position: static !important; inset: auto !important;
    margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
    width: auto !important; max-width: none !important; min-width: 0 !important;
    height: auto !important; min-height: 0 !important; max-height: none !important;
    overflow: visible !important; background: none !important; box-shadow: none !important; transform: none !important;
    animation: none !important; zoom: 1 !important;
  }
  html[data-print="quote"] .quote-print, html[data-print="quote"] .quote-print * { visibility: visible !important; }
  html[data-print="quote"] .quote-print { display: block !important; position: static !important; }
  html[data-print="quote"] .qt-paper {
    max-width: none !important; margin: 0 !important; padding: 0 !important; box-shadow: none !important; border-radius: 0 !important;
    font-size: 10.5pt; gap: 4.5mm;
  }
}
