/* v0.16.2 layout polish (loaded last). */

.choice-caret{font-size:18px}

/* Catalog field picker: one option per row (a global rule made the labels inline). */
#main .catalog-scope .scope-panel label{display:flex;justify-content:flex-start;width:100%;text-align:left;white-space:nowrap}
#main .catalog-tools .catalog-scope .scope-panel input[type=checkbox]{flex:0 0 16px;width:16px;min-width:16px;max-width:16px}

/* Bulk supplier for "Hạng mục & sản phẩm". */
.bulk-supplier-btn{display:inline-flex;align-items:center;gap:6px}
.bulk-supplier-btn .solid-icon{width:15px;height:15px;flex-basis:15px}
.bulk-supplier-list{max-height:min(420px,50vh);overflow:auto;margin:10px 0 0;border:1px solid #eaecf0;border-radius:8px}
.bulk-supplier-group{padding:8px 12px;background:#f8fafc;border-bottom:1px solid #eaecf0;font-weight:700;color:#344054}
#dialog .bulk-supplier-list{display:block}
#dialog .bulk-supplier-list .bulk-supplier-row{display:grid;grid-template-columns:24px minmax(0,1.6fr) minmax(0,1fr) minmax(0,.8fr);align-items:center;justify-content:stretch;gap:10px;width:100%;margin:0;padding:8px 12px;border-bottom:1px solid #f2f4f7;text-align:left;cursor:pointer}
.bulk-supplier-row:last-child{border-bottom:0}
.bulk-supplier-row.disabled{color:#98a2b3;cursor:not-allowed}
.bulk-supplier-row input{width:16px;height:16px;margin:0}
.bulk-supplier-row .money{text-align:right;font-variant-numeric:tabular-nums}
.bulk-supplier-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-top:10px}

/* "Hạng mục & sản phẩm" header pins under the top bar while its products scroll; it unpins when the section ends. */
#quote-form .fold-head[data-fold=products]{position:sticky;top:64px;z-index:7}
#quote-form .fold-card:not(.collapsed)>.fold-head[data-fold=products]{box-shadow:0 6px 14px #10182824}

/* Dialog footer: no shadow above the buttons, same colour as the content. */
#dialog .dialog-actions,#dialog .preview-actions{box-shadow:none}

/* Progress: note beside the status (dialog) / to the right of the dates (editor). */
.progress-dialog-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
.progress-dialog-grid .progress-note-field{grid-column:2/4}
.progress-note-field{display:flex;flex-direction:column}
.progress-note-field textarea{flex:1;min-height:0;resize:vertical}
.progress-note-field .hint{margin-top:4px}
.progress-grid .progress-note-field{grid-column:3/5;grid-row:1/3;margin:0}
@media(max-width:1100px){.progress-grid .progress-note-field{grid-column:1/-1;grid-row:auto}}
@media(max-width:640px){.progress-dialog-grid{grid-template-columns:minmax(0,1fr)}.progress-dialog-grid .progress-note-field{grid-column:auto}}

/* Quote view: title + "Sửa / tạo phiên bản tiếp" stay at the top while scrolling. */
.page-head.quote-view-head{position:sticky;top:64px;z-index:9;margin:-20px -20px 16px;padding:12px 20px;border-bottom:1px solid #e4e7ec;background:#f3f5f8f2;backdrop-filter:blur(6px)}

/* Small, even spacing (progress panel, issues box, products fold). */
.progress-panel>p:last-child,.progress-panel>.hint:last-child{margin-bottom:0}
.progress-panel .progress-panel-head{margin-bottom:10px}
#main .errors{padding:12px 20px}
#main .errors ul{margin:8px 0 0;padding-left:20px}
#fold-products>p.muted{margin:0 0 12px}
.group-body .group-empty{margin:12px 0 0}
.group-body .add-line-btn{margin-top:12px}
/* "Thêm sản phẩm" in the group header: light button, blue on hover. */
#quote-form .group-head .head-add-line{display:inline-flex;align-items:center;gap:6px;height:32px;margin:0 0 0 4px;padding:0 12px;border:1px solid #d0d5dd;border-radius:6px;background:#f2f4f7;color:#1d2433;font-size:14px;font-weight:600;white-space:nowrap;box-shadow:none}
#quote-form .group-head .head-add-line .solid-icon{width:15px;height:15px;flex-basis:15px}
#quote-form .group-head .head-add-line:hover,#quote-form .group-head .head-add-line:focus-visible{border-color:var(--brand);background:var(--brand);color:#fff}
#quote-form .group-body .group-empty{margin:12px 0 0}

/* Auto-growing text: one row when empty, grows with the content. */
#quote-form textarea.auto-grow{min-height:0;height:auto;field-sizing:content;resize:vertical;overflow:hidden;line-height:1.5}

/* Customer smart search: columns Họ và tên · SĐT · Địa chỉ · Email, add button at the bottom. */
.suggest-cols{display:grid;grid-template-columns:1.3fr .9fr 1.5fr 1.3fr;gap:10px;align-items:baseline;width:100%;text-align:left}
.suggest-cols>*{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.suggest-cols>span{color:#475467;font-size:13px}
.suggest-cols-head{padding:4px 10px 6px;border-bottom:1px solid #eaecf0;margin-bottom:4px}
.suggest-cols-head>span{color:#667085;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em}
.suggest-footer{display:flex;align-items:center;gap:8px;width:100%;margin:6px 0 0;padding:9px 10px;border:0;border-top:1px solid #eaecf0;border-radius:0 0 6px 6px;background:none;color:var(--brand);font-weight:600;text-align:left}
.suggest-footer:hover{background:var(--brand-soft)}
.suggest-footer .solid-icon{width:14px;height:14px;flex-basis:14px}

/* Product line: description, dimensions, quantity, price, unit, supplier/brand and image on one row. */
.line-editor .line-grid{display:flex;flex-wrap:wrap;align-items:flex-start;gap:10px 12px}
.line-grid>label,.line-grid>.image-field{margin:0;min-width:0}
.line-grid>label:has(textarea){flex:3 1 220px}
.line-grid>label:has([name^="dimension-"]){flex:0 1 84px}
.line-grid>label:has([name^="quantity-"]){flex:0 1 88px}
.line-grid>label:has([name^="price-"]){flex:0 1 124px}
.line-grid>label:has([name^="unit-"]){flex:0 1 116px}
.line-grid>label:has([name^="supplier-"]),.line-grid>label:has([name^="brand-"]){flex:1 1 160px;max-width:240px;grid-column:auto}
.line-grid>.image-field{flex:1 1 200px;max-width:280px}
.line-editor .row.line-head{margin-bottom:10px!important}

/* Quote line image: once chosen, the image takes the place of "Chọn ảnh"; × stays at the top right. */
.line-image-field{position:relative}
.line-image-field.has-image .file-btn,.line-image-field.has-image .file-status,.line-image-field.has-image>label{display:none}
.line-image-field.has-image .image-choice{position:absolute;top:0;right:0;padding:0;border:0}
.line-grid>.line-image-field.has-image{flex:0 0 auto;max-width:280px;padding-right:22px}
.line-image-field.has-image [data-image]{margin-top:2px}
.line-image-field .line-image-thumb{display:block;width:auto;max-width:100%;height:auto;max-height:110px;margin:0;border:1px solid #e4e7ec;border-radius:6px;object-fit:contain;cursor:pointer}
.line-image-field .line-image-thumb:hover,.line-image-field .line-image-thumb:focus-visible{border-color:var(--brand);outline:2px solid color-mix(in srgb,var(--brand) 25%,transparent)}

/* Crop step: free 4-direction frame with handles. */
#media-dialog .crop-panel{display:flex;flex-direction:column;gap:8px}
#media-dialog .crop-tools{display:flex;align-items:end;flex-wrap:wrap;gap:10px 14px}
#media-dialog .crop-tools h3{margin:0 auto 6px 0}
#media-dialog .crop-tools label{display:flex;flex-direction:column;gap:4px;margin:0;min-width:200px}
#media-dialog .crop-tools select{margin:0}
#media-dialog .crop-panel .hint{margin:0}
#media-dialog #crop-canvas{margin:4px auto;border-radius:4px;cursor:crosshair;touch-action:none}
#media-dialog .crop-actions{display:flex;justify-content:flex-end;gap:10px}
