/* Quotation templates: the drawn page (public/qdesign-core.js, also on /q) and the designer (public/qdesign.js). */
.qd-page { position: relative; box-sizing: border-box; overflow: hidden; color-scheme: light; text-align: start; -webkit-print-color-adjust: exact; print-color-adjust: exact; flex: none; }
.qd-page *, .qd-page *::before, .qd-page *::after { box-sizing: border-box; }
/* The app's own table, list and heading styles stay out of the page. */
.qd-page table, .qd-page th, .qd-page td, .qd-page ul, .qd-page li { text-transform: none; letter-spacing: inherit; font-size: inherit; color: inherit; background: none; margin: 0; border: 0; box-shadow: none; position: static; white-space: normal; }
.qd-page th, .qd-page td { line-height: inherit; height: auto; vertical-align: top; }
.qd-page table { min-width: 0; width: 100%; border-collapse: collapse; }
.qd-tbl td:empty::after, .qd-tbl th:empty::after { content: "\00a0"; }
.qd-el { position: absolute; display: flex; flex-direction: column; overflow: visible; min-width: 0; }
.qd-el > .qd-in { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.qd-text > .qd-in { white-space: normal; }
.qd-image img { display: block; width: 100%; height: 100%; border-radius: inherit; user-select: none; -webkit-user-drag: none; }
.qd-image { overflow: hidden; }
.qd-ul { list-style: none; padding: 0; }
.qd-ul li { display: flex; gap: 8px; align-items: baseline; }
.qd-ul li:last-child { margin-bottom: 0 !important; }
.qd-mk { flex: none; min-width: 1em; font-weight: 700; }
.qd-tbl { width: 100%; border-collapse: collapse; }
.qd-tbl th, .qd-tbl td { text-align: start; vertical-align: top; font-weight: inherit; }
.qd-tbl th { font-weight: 700; }
.qd-items .qd-n { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.qd-items .qd-c-no { width: 1%; text-align: center; }
.qd-items .qd-off { font-size: .8em; opacity: .7; }
.qd-tot { display: grid; }
.qd-tr { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; }
.qd-tr .qd-n { font-variant-numeric: tabular-nums; white-space: nowrap; }
.qd-chip { display: inline-block; padding: 0 6px; border-radius: var(--radius-sm); background: #e8f0ff; color: #1d4ed8; border: 1px dashed #93b4f5; font-size: .85em; font-weight: 600; font-style: normal; text-transform: none; letter-spacing: 0; line-height: 1.5; }

/* Thumbnails and the library */
.qd-thumb { position: relative; overflow: hidden; border-radius: var(--radius-sm); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line, #ddd); background: #fff; pointer-events: none; }
.qd-lib { display: grid; gap: 14px; margin-bottom: 16px; }
.qd-lib-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; }
.qd-lib-head h2 { margin: 0 0 4px; }
.qd-lib-head p { margin: 0; max-width: 62ch; }
.qd-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.qd-card { display: grid; gap: 8px; align-content: start; }
.qd-card.def .qd-thumb { box-shadow: 0 0 0 2px var(--green, #0e6a5a); }
.qd-card-pic { padding: 8px; display: grid; place-items: center; background: var(--bg, #f6f6f4); border-radius: var(--radius); min-height: 140px; }
.qd-card-pic:hover { filter: none; background: var(--accent-soft, #ececea); }
.qd-blank span { font-size: var(--text-4xl); color: var(--muted, #666); }
.qd-card-in { display: grid; gap: 6px; }
.qd-card-in b { overflow-wrap: anywhere; }
.qd-card-in .tag { justify-self: start; font-size: var(--text-xs); }
.qd-card-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.qd-card-btns button { padding: 5px 10px; font-size: var(--text-base); }
.qd-gallery { display: grid; gap: 12px; }

/* The quotation form's extra lines and a quotation's template menu (public/crm.js) */
.cq-more { grid-template-columns: 1fr 1fr 1fr auto !important; align-items: end; }
.q-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.q-tpl { display: inline-flex; gap: 6px; align-items: center; font-size: var(--text-base); }
.q-tpl select { max-width: 200px; }
@media (max-width: 560px) { .cq-more { grid-template-columns: 1fr 1fr !important; } }

/* Dialogs */
body.qd-open { overflow: hidden; }
.qd-modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: stretch; justify-content: center; padding: 16px; }
.qd-modal[hidden] { display: none; }
.qd-box { background: var(--surface, #fff); color: var(--ink, #111); border-radius: var(--radius-lg, 14px); box-shadow: var(--shadow-lg); width: min(1100px, 100%); display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden; }
.qd-galbox { padding: 0 18px 18px; overflow: auto; gap: 10px; }
.qd-galbox > p { margin: 0; }
.qd-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line, #ddd); background: var(--surface, #fff); position: sticky; top: 0; z-index: 2; }
.qd-galbox .qd-bar { margin: 0 -18px; }
.qd-bar h2 { margin: 0; font-size: var(--text-lg); }
.qd-bar-r { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-inline-start: auto; }
.qd-prevbox { width: min(980px, 100%); }
.qd-prev-scroll { overflow: auto; padding: 18px; background: var(--bg, #f3f3f1); flex: 1; min-height: 0; }
.qd-fit { position: relative; width: 100%; max-width: 794px; margin: 0 auto; }
.qd-fit > .qd-page { box-shadow: 0 2px 14px rgba(0,0,0,.14); }

/* The editor */
.qde { padding: 0; }
.qde-in { background: var(--surface, #fff); color: var(--ink, #111); width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.qde-top { gap: 8px 12px; }
.qde-name input { font: inherit; font-weight: 600; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink); width: min(260px, 60vw); }
.qde-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.qde-tools button { min-width: 34px; padding: 5px 9px; }
.qde-tools #qdeZoom { min-width: 44px; text-align: center; font-size: var(--text-base); }
.qde-chk { font-size: var(--text-base); display: inline-flex; gap: 6px; align-items: center; }
.qde-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px minmax(0, 1fr) 300px; }
.qde-add, .qde-props { overflow: auto; padding: 12px; border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.qde-props { border-inline-end: 0; border-inline-start: 1px solid var(--line); }
.qde-add h3, .qde-props h3 { margin: 4px 0 0; font-size: var(--text-md); }
.qde-addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qde-addgrid button { display: grid; gap: 2px; justify-items: center; padding: 8px 4px; font-size: var(--text-xs); line-height: 1.2; text-align: center; }
.qde-addgrid button span { font-size: var(--text-lg); }
.qde-layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.qde-layers button { width: 100%; text-align: start; display: grid; padding: 5px 8px; font-size: var(--text-sm); background: transparent; border-color: transparent; }
.qde-layers button small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qde-layers button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--line); }
.qde-layers button.off { opacity: .5; }
.qde-stage { overflow: auto; background: var(--bg, #ededeb); padding: 16px; position: relative; touch-action: pan-x pan-y; }
.qde-canvas { position: relative; margin: 0 auto; }
.qde-canvas .qd-page { position: absolute; left: 0; top: 0; box-shadow: 0 2px 16px rgba(0,0,0,.16); }
.qde-canvas .qd-el { cursor: move; touch-action: none; }
.qde-canvas .qd-el:hover { outline: 1px dashed rgba(29, 78, 216, .6); outline-offset: 0; }
.qde-canvas .qd-hidden { opacity: .25; }
.qde-canvas .qd-empty { background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 8px, #e5e7eb 8px, #e5e7eb 16px); border: 1px dashed #9ca3af; align-items: center; justify-content: center; color: #4b5563; font: 600 13px/1.2 system-ui, sans-serif; text-align: center; }
.qde-margin { position: absolute; border: 1px dashed rgba(29, 78, 216, .18); pointer-events: none; }
.qde-sel { position: absolute; outline: 2px solid #1d4ed8; pointer-events: none; z-index: 5; }
.qde-sel.locked { outline-style: dashed; outline-color: #9ca3af; }
.qde-h { position: absolute; width: calc(12px * var(--z, 1)); height: calc(12px * var(--z, 1)); background: #fff; border: calc(2px * var(--z, 1)) solid #1d4ed8; border-radius: var(--radius-sm); pointer-events: auto; touch-action: none; transform: translate(-50%, -50%); }
.qde-h-nw { left: 0; top: 0; cursor: nwse-resize; } .qde-h-n { left: 50%; top: 0; cursor: ns-resize; } .qde-h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.qde-h-e { left: 100%; top: 50%; cursor: ew-resize; } .qde-h-se { left: 100%; top: 100%; cursor: nwse-resize; } .qde-h-s { left: 50%; top: 100%; cursor: ns-resize; }
.qde-h-sw { left: 0; top: 100%; cursor: nesw-resize; } .qde-h-w { left: 0; top: 50%; cursor: ew-resize; }
.qde-g-wrap { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.qde-g { position: absolute; background: #e11d48; }
.qde-g-v { top: 0; bottom: 0; width: 1px; } .qde-g-h { left: 0; right: 0; height: 1px; }
.qde-props fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 10px; margin: 0; display: grid; gap: 8px; min-width: 0; }
.qde-props legend { font-size: var(--text-sm); font-weight: 600; color: var(--muted); padding: 0 4px; }
.qde-props label { display: grid; gap: 3px; font-size: var(--text-base); min-width: 0; }
.qde-props label.inline { display: inline-flex; align-items: center; gap: 6px; }
.qde-props input:not([type=checkbox]):not([type=color]), .qde-props select, .qde-props textarea { font: inherit; font-size: var(--text-base); padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink); min-width: 0; width: 100%; }
.qde-props textarea { resize: vertical; }
.qde-props p { margin: 0; font-size: var(--text-sm); }
.qde-props-head { display: flex; justify-content: space-between; align-items: center; }
.qde-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.qde-row.qde-wrap, .qde-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.qde-acts button, .qde-wrap button { padding: 5px 9px; font-size: var(--text-sm); }
.qde-color { display: grid; gap: 4px; font-size: var(--text-base); }
.qde-color-in { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qde-color input[type=color] { width: 40px; height: 30px; padding: 0 2px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; }
.qde-color .chip, .qde-align .chip { padding: 4px 10px; font-size: var(--text-xs); }
.qde-align { display: flex; flex-wrap: wrap; gap: 4px; }
.qde-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.qde-sw { width: 26px; height: 26px; border-radius: 50%; padding: 0; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.qde-col { display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: center; }
.qde-grid-wrap { overflow: auto; max-height: 260px; }
.qde-grid { border-collapse: collapse; min-width: 0; width: auto; }
.qde-grid td { border: 0; }
.qde-grid td { padding: 2px; }
.qde-props .qde-grid input { width: 110px; min-width: 110px; }
.qde-field select { font-size: var(--text-base); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 1000px) {
  .qde-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(260px, 1fr) minmax(0, 40%); }
  .qde-add { border: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .qde-add h3, .qde-layers { display: none; }
  .qde-addgrid { display: flex; overflow-x: auto; }
  .qde-addgrid button { flex: none; min-width: 72px; }
  .qde-props { border: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .qd-modal { padding: 0; }
  .qd-box { border-radius: 0; }
  .qde-tools .qde-chk { display: none; }
  .qd-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Printing a preview: only the page. */
@media print {
  body.qd-printing > *:not(#qdPrev) { display: none !important; }
  body.qd-printing #qdPrev { position: static; padding: 0; background: none; display: block; }
  body.qd-printing #qdPrev .qd-box { box-shadow: none; border-radius: 0; max-height: none; overflow: visible; width: auto; display: block; }
  body.qd-printing #qdPrev .qd-bar { display: none; }
  body.qd-printing #qdPrev .qd-prev-scroll { padding: 0; overflow: visible; background: none; }
  body.qd-printing #qdPrev .qd-fit { height: auto !important; max-width: none; margin: 0; }
  body.qd-printing #qdPrev .qd-page { box-shadow: none; transform: none !important; }
  body.qd-printing { overflow: visible; }
}
