.qe-print { color:#1c3142; }
.qe-print-head { display:flex; align-items:center; justify-content:space-between; gap:15px; flex-wrap:wrap; }
.qe-print-head h1{margin:0}
.qe-print-live{background:#e9f8f4;color:#177e62;padding:8px 12px;border-radius:10px;font-size:12px;font-weight:700}
.qe-live-dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#17a47d;margin-inline-end:5px}

.qe-print-grid{
  display:grid;
  grid-template-columns:minmax(380px,1.15fr) minmax(360px,1fr);
  gap:17px;
  align-items:stretch;
  min-height:calc(100vh - 240px);
}
.qe-print-right{min-width:0; display:flex; flex-direction:column; gap:17px;}
.qe-preview-panel{flex:1 1 auto}
.qe-settings-panel{flex:0 0 auto}
.qe-print-panel{background:#fff;border:1px solid #dce9ee;border-radius:16px;box-shadow:0 7px 25px rgba(30,57,77,.035);padding:16px}
.qe-print-panel-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}
.qe-print-panel-head h2{font-size:16px;margin:0;font-weight:800}
.qe-print-panel-head span{color:#667a87;font-size:12px}

.qe-btn{border:0;border-radius:10px;padding:10px 13px;font-family:inherit;font-size:12px;font-weight:800;cursor:pointer;transition:background .2s, opacity .2s}
.qe-btn:disabled{opacity:.48;cursor:not-allowed}
.qe-btn-primary{color:white;background:#047caa}.qe-btn-primary:hover:not(:disabled){background:#066487}
.qe-btn-secondary{color:#32647b;border:1px solid #d1e4eb;background:#f4fafd}.qe-btn-secondary:hover:not(:disabled){background:#e5f4fa}
.qe-btn-sm{padding:8px 11px;font-size:11px;border-radius:9px}

.qe-print input[type=search],.qe-print input[type=number],.qe-print input[type=date],.qe-print select{
  border:1px solid #d6e3eb;border-radius:11px;min-height:42px;background:#fff;padding:8px 12px;color:#20374c;font:inherit;font-size:12px
}
.qe-search-row{display:grid;grid-template-columns:minmax(0,1fr) 94px;gap:10px;align-items:stretch;margin-top:12px;width:100%;direction:rtl}
.qe-search-row input{min-width:0;width:100%;grid-column:1;grid-row:1}
.qe-search-row .qe-btn{height:100%;min-width:94px;grid-column:2;grid-row:1;white-space:nowrap}
.qe-printer-row{display:flex;gap:8px}
.qe-printer-row select{flex:1;min-width:0}

.qe-date-filters{display:flex;flex-direction:column;gap:9px}
.qe-date-mode,.qe-date-inputs{display:flex;align-items:center;gap:7px;flex-wrap:wrap}
.qe-date-mode button[aria-pressed="true"]{background:#dbf2fa;border-color:#65afce;color:#005d85}
.qe-date-inputs[hidden]{display:none}
.qe-date-inputs label{display:flex;align-items:center;gap:5px;font-size:12px;font-weight:700}

.qe-print-list{display:flex;flex-direction:column;overflow:hidden;height:100%;min-height:calc(100vh - 240px)}
.qe-barcode-items{flex:1;min-height:0;overflow:auto;margin-top:12px;display:flex;flex-direction:column;gap:12px;scrollbar-gutter:stable}
.qe-list-pagination{display:flex;justify-content:center;align-items:center;gap:10px;padding-top:12px;border-top:1px solid #ecf2f6;margin-top:12px}
.qe-empty,.qe-list-foot{padding:13px 4px;font-size:12px;color:#70838e}

.qe-group-card{border:1px solid #dfeaf0;border-radius:16px;background:#fff;box-shadow:0 3px 15px rgba(31,58,76,.03);overflow:hidden}
.qe-group-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 14px 12px;cursor:pointer}
.qe-group-head:hover{background:#fafcfd}
.qe-group-head[aria-expanded="true"]{background:#fbfdfe}
.qe-group-summary{display:flex;flex-direction:column;gap:5px;min-width:0;flex:1;text-align:right}
.qe-group-patient{font-size:16px;font-weight:800;color:#15364b;line-height:1.4}
.qe-group-meta{font-size:13px;color:#5c7381;line-height:1.5}
.qe-group-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-start}
.qe-group-count{display:inline-flex;align-items:center;justify-content:center;min-width:76px;padding:6px 10px;border-radius:999px;background:#eaf6fb;color:#2f7fa1;font-size:11px;font-weight:800}
.qe-group-toggle{min-width:92px}
.qe-group-body{padding:0 14px 14px;display:flex;flex-direction:column;gap:10px}
.qe-group-body[hidden]{display:none}

.qe-barcode-item{display:grid;grid-template-columns:minmax(88px,102px) minmax(0,1fr);gap:12px;align-items:center;width:100%;border:1px solid #dce9ef;border-radius:14px;background:#fff;padding:12px;cursor:pointer}
.qe-barcode-item:hover,.qe-barcode-item[aria-pressed="true"]{background:#ebf7fc;border-color:#80bfd8}
.qe-barcode-main{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;width:100%}
.qe-item-label{display:flex;flex-direction:column;gap:6px;min-width:0;text-align:right}
.qe-item-barcode{font-family:Consolas,monospace;font-size:22px;font-weight:800;direction:ltr;text-align:right;unicode-bidi:isolate;color:#19374b;line-height:1.25}
.qe-item-patient,.qe-item-meta{font-size:13px;color:#587080;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.qe-item-status{color:#197e61;font-size:12px;white-space:nowrap;font-weight:700}
.qe-item-pending{color:#a46b18;font-size:12px;white-space:nowrap;font-weight:700}
.qe-item-print{min-width:88px}

.qe-preview-paper{display:flex;align-items:center;justify-content:center;min-height:260px;padding:18px;background:#eaf1f5;border-radius:12px;overflow:auto;direction:ltr}
.qe-preview-paper canvas{display:block;max-width:100%;height:auto;box-shadow:0 3px 12px #243e5726;background:white;image-rendering:pixelated}
.qe-print-note{font-size:11px;margin-top:11px;line-height:1.8;color:#627985}.qe-print-note.error{color:#b02239}.qe-print-note.warn{color:#93600c}.qe-print-note.ok{color:#147c60}
.qe-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.qe-form-row{display:flex;flex-direction:column;gap:7px;margin:13px 0}.qe-form-row label{font-size:12px;font-weight:800}
.qe-custom-dimensions{display:flex;gap:12px}.qe-custom-dimensions[hidden]{display:none}.qe-custom-dimensions label{flex:1;display:flex;flex-direction:column;gap:5px;font-size:12px}.qe-custom-dimensions input{width:100%}
.qe-options-row{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px}.qe-check,.qe-dpi{font-size:12px;display:flex;align-items:center;gap:6px;cursor:pointer}.qe-tag{background:#e7f8f0;border-radius:50px;padding:5px 9px;color:#1a7a59!important}

@media(max-width:1100px){
  .qe-print-grid{grid-template-columns:minmax(0,1fr); min-height:auto}
  .qe-print-list{min-height:600px}
}
@media(max-width:700px){
  .qe-group-head,.qe-barcode-item{grid-template-columns:minmax(0,1fr); display:flex; flex-direction:column; align-items:stretch}
  .qe-search-row{display:grid;grid-template-columns:minmax(0,1fr) 86px;align-items:stretch;gap:8px}
  .qe-search-row .qe-btn{min-width:86px}
  .qe-group-actions,.qe-barcode-main{width:100%}
  .qe-printer-row,.qe-custom-dimensions,.qe-date-mode,.qe-date-inputs,.qe-actions{flex-wrap:wrap}
  .qe-preview-paper{min-height:180px}
}

/* V1.10: Group cards line up with the search/refresh row; keep search geometry unchanged. */
.qe-print-list .qe-barcode-items {
  scrollbar-gutter:auto; /* remove the reserved blank strip beside the cards */
  scrollbar-width:thin;
  width:100%;
  min-width:0;
  padding:0;
}
.qe-print-list .qe-group-card {
  box-sizing:border-box;
  width:100%;
  min-width:0;
  flex-shrink:0;
}
/* Closed by default: only one compact header row is shown until explicitly opened. */
.qe-print-list .qe-group-body[hidden] {display:none;}

/* V1.11: one viewport, no horizontal page scrollbar at 1366x768 or 1920x1080.
   Only the received-barcode list has a vertical scrollbar. */
.main-wrap:has(#qe-barcode-print){min-width:0;max-width:100%;overflow-x:clip;}
.main-wrap:has(#qe-barcode-print) .workspace{min-width:0;overflow-x:clip;}
.qe-print{min-width:0;max-width:100%;}
.qe-print-grid{
  min-width:0;
  height:calc(100dvh - 200px);
  min-height:460px;
  max-width:100%;
  grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);
  align-items:stretch;
}
.qe-print-grid > *, .qe-print-panel, .qe-print-right{min-width:0;max-width:100%;}
.qe-print-list{height:100%;min-height:0;overflow:hidden;}
.qe-print-list .qe-barcode-items{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;}
.qe-print-right{height:100%;min-height:0;overflow:hidden;}
.qe-preview-panel{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;}
.qe-preview-panel .qe-preview-paper{flex:1;min-height:125px;overflow:hidden;}
.qe-preview-panel .qe-preview-paper canvas{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;}
.qe-settings-panel{flex:0 0 auto;}
.qe-printer-row,.qe-actions,.qe-search-row,.qe-date-filters{min-width:0;max-width:100%;}
.qe-item-barcode{font-size:clamp(14px,1.25vw,22px);overflow-wrap:anywhere;}
.qe-group-head{min-width:0;}
@media (min-width:1101px) and (max-height:850px){
  .main-wrap:has(#qe-barcode-print) .workspace{padding:12px 20px;}
  .qe-print-head{margin-bottom:12px;}
  .qe-print-head .crumb{margin-bottom:2px;}
  .qe-print-head h1{font-size:21px;}
  .qe-print-grid{height:calc(100dvh - 155px);min-height:435px;gap:12px;}
  .qe-print-right{gap:10px;}
  .qe-print-panel{padding:12px;}
  .qe-print-panel-head{margin-bottom:8px;}
  .qe-preview-paper{padding:10px;}
  .qe-form-row{margin:7px 0;gap:4px;}
  .qe-print-note{margin-top:5px;font-size:10px;}
  .qe-actions{margin-top:6px;}
  .qe-print .qe-btn{padding-top:7px;padding-bottom:7px;}
  .qe-print input[type=search],.qe-print select{min-height:36px;}
}
@media(max-width:1100px){
  .qe-print-grid{height:auto;min-height:0;grid-template-columns:minmax(0,1fr);}
  .qe-print-list{height:65dvh;min-height:420px;}
  .qe-print-right{height:auto;overflow:visible;}
}
@media(max-width:700px){
  .qe-print-list{height:60dvh;min-height:370px;}
  .qe-group-patient{overflow-wrap:anywhere;}
}

/* V1.12: FIXED VIEWPORT desktop layout. The outer page must never scroll. */
@media (min-width:1101px) {
  html:has(#qe-barcode-print),body:has(#qe-barcode-print) {
    height:100%;width:100%;max-width:100%;overflow:hidden!important;
  }
  body:has(#qe-barcode-print) .shell {
    height:100dvh;min-height:0;max-height:100dvh;overflow:hidden;
  }
  body:has(#qe-barcode-print) .sidebar {
    height:100dvh;min-height:0;max-height:100dvh;
    overflow-y:auto;overflow-x:hidden;
  }
  body:has(#qe-barcode-print) .main-wrap {
    height:100dvh;min-height:0;max-height:100dvh;
    overflow:hidden;display:flex;flex-direction:column;
  }
  body:has(#qe-barcode-print) .topbar {
    flex:0 0 68px;height:68px;min-height:68px;
  }
  body:has(#qe-barcode-print) .workspace {
    flex:1 1 auto;min-height:0;min-width:0;
    overflow:hidden!important;display:flex;flex-direction:column;
    padding:12px 18px 14px;
  }
  body:has(#qe-barcode-print) .qe-print {
    display:flex;flex-direction:column;flex:1 1 auto;
    min-height:0;min-width:0;max-height:100%;
  }
  body:has(#qe-barcode-print) .qe-print-head {
    flex:0 0 auto;margin-bottom:12px;
  }
  body:has(#qe-barcode-print) .qe-print-grid {
    display:grid;flex:1 1 auto;
    height:auto!important;min-height:0!important;max-height:100%;
    grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);
    gap:12px;overflow:hidden;
  }
  body:has(#qe-barcode-print) .qe-print-list,
  body:has(#qe-barcode-print) .qe-print-right {
    min-height:0!important;height:100%;max-height:100%;overflow:hidden;
  }
  body:has(#qe-barcode-print) .qe-print-list .qe-barcode-items {
    flex:1 1 0;min-height:0!important;overflow-y:auto;overflow-x:hidden;
    overscroll-behavior:contain;
  }
  body:has(#qe-barcode-print) .qe-preview-panel {
    min-height:0;overflow:hidden;
  }
  body:has(#qe-barcode-print) .qe-preview-panel .qe-preview-paper {
    flex:1 1 0;min-height:85px;max-height:100%;
  }
  body:has(#qe-barcode-print) .qe-settings-panel {flex:0 0 auto;}
}
@media (min-width:1101px) and (max-height:800px) {
  body:has(#qe-barcode-print) .qe-print-panel {padding:10px 12px;}
  body:has(#qe-barcode-print) .qe-print-grid {gap:10px;}
  body:has(#qe-barcode-print) .qe-print-right {gap:9px;}
  body:has(#qe-barcode-print) .qe-print-panel-head {margin-bottom:6px;}
  body:has(#qe-barcode-print) .qe-form-row {margin:5px 0;gap:3px;}
  body:has(#qe-barcode-print) .qe-preview-paper {padding:8px;}
  body:has(#qe-barcode-print) .qe-print-head {margin-bottom:8px;}
  body:has(#qe-barcode-print) .qe-print-head h1 {font-size:20px;}
  body:has(#qe-barcode-print) .qe-print-note {margin-top:3px;line-height:1.5;}
  body:has(#qe-barcode-print) .qe-actions {margin-top:5px;}
}
