/* R6.16.87 — order/product master unification, adaptive dialogs and data-entry closure */
body:has(dialog[open]){overflow:hidden!important}
.quick-entity-dialog{max-height:92vh!important;overflow:hidden!important}
.quick-entity-dialog>form{max-height:92vh;overflow:hidden;display:grid;grid-template-rows:auto minmax(0,1fr) auto auto}
.quick-entity-dialog .quick-form-grid{min-height:0;overflow:auto}
.r61687-entry-tools .r61687-tool-note{margin-right:auto;color:var(--fp-muted);font-size:11px;align-self:center;line-height:1.45}
.r61687-entry-tools .r61686-tool-row{align-items:center;gap:8px;flex-wrap:wrap}

/* Product picker: large enough for categories without clipping the product list. */
.r61650-order-entry .product-picker-sheet.r61686-product-picker.classic-picker-open{inset:2.5vh max(16px,calc((100vw - 1420px)/2))!important;border-radius:18px!important;max-height:95vh!important;overflow:hidden!important}
.r61650-order-entry .product-picker-sheet.r61686-product-picker .product-picker-toolbar{grid-template-columns:minmax(360px,1fr) minmax(190px,.35fr) minmax(130px,.2fr)!important}
.r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-picker{position:relative;z-index:12}
.r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-tree{left:auto!important;right:0!important;width:min(760px,calc(100vw - 56px))!important;max-height:min(68vh,650px)!important;padding:12px!important;border-radius:14px!important;overflow:auto!important;z-index:60!important}
.r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-tree section div{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:4px 8px!important;padding-left:8px!important}
.r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-tree section div button{white-space:normal;line-height:1.35;min-height:36px;text-align:left}

/* Order quick-create uses the same semantics as the master form, only fewer fields are visible. */
.quick-entity-dialog.r61687-product-quick{width:min(980px,96vw)!important;max-width:980px!important;max-height:94vh!important;overflow:hidden!important;padding:0!important}
.r61687-product-quick>form{max-height:94vh;display:grid!important;grid-template-rows:auto minmax(0,1fr) auto auto!important;overflow:hidden!important}
.r61687-product-quick>form>header{padding:15px 18px!important;flex:0 0 auto}
.r61687-product-quick .r61687-dialog-head-actions{display:flex;align-items:center;gap:8px}
.r61687-product-quick .r61687-quick-product-grid{overflow:auto!important;min-height:0;padding:16px 18px 18px!important;grid-template-columns:repeat(2,minmax(0,1fr));align-content:start}
.r61687-product-quick .r61669-quick-extra{border:1px solid var(--fp-border);border-radius:13px;background:var(--fp-surface-2);overflow:visible}
.r61687-product-quick .r61669-quick-extra>summary{padding:11px 13px;font-weight:800;cursor:pointer}
.r61687-product-quick .r61669-quick-extra .quick-form-grid{padding:12px;border-top:1px solid var(--fp-border)}
.r61687-product-quick .r61687-inline-unit{display:grid;grid-template-columns:minmax(0,1fr) 86px;gap:7px}
.r61687-product-quick .r61687-image-upload .image-uploader{margin-top:2px}
.r61687-product-quick .r61687-image-upload .upload-preview{grid-template-columns:repeat(6,minmax(96px,1fr));max-height:none}
.r61687-product-quick .r61687-image-upload .upload-preview-item{min-width:0}
.r61687-product-quick footer{flex:0 0 auto}

/* One master form, two density levels. Values and selected images remain in the same DOM. */
.r61687-product-entry-header{align-items:flex-start!important}
.r61687-entry-switch{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-top:10px}
.r61687-entry-switch small{color:var(--fp-muted);margin-left:3px;line-height:1.45}
.r61687-product-entry.r61687-entry-quick .r61687-full-only{display:none!important}
.r61687-product-entry.r61687-entry-quick details.pm-details{display:none!important}
.r61687-product-entry.r61687-entry-quick .pm-pack-sheet{display:block!important}
.r61687-product-entry.r61687-entry-quick .pm-product-sheet-body{min-height:0}
.r61687-product-entry.r61687-entry-quick .pm-basic-grid{align-content:start}
.r61687-product-entry .pm-basic-field>small{display:block;margin-top:5px;color:var(--fp-muted);font-size:11px;line-height:1.4}

/* High-information selectors need a desktop-size work area, not a narrow phone-like modal. */
.r64-modal-overlay{padding:14px!important}
.r64-modal{width:min(1480px,98vw)!important;height:min(900px,96vh)!important;max-width:none!important}
.r6156-part-picker-modal .r64-modal{width:min(1580px,98vw)!important;height:min(940px,96vh)!important}
.r6156-part-picker-modal .r69-picker-layout{grid-template-columns:260px minmax(560px,1fr) minmax(330px,390px)!important}
.r6156-part-picker-modal .r69-picker-layout.categories-collapsed{grid-template-columns:0 minmax(620px,1fr) minmax(330px,390px)!important}
.r6156-part-picker-modal .r69-picker-layout.detail-collapsed{grid-template-columns:260px 1fr 0!important}
.r6156-part-picker-modal .r69-picker-layout.categories-collapsed.detail-collapsed{grid-template-columns:0 1fr 0!important}

/* Supplier/collaboration create is a focused form; do not stretch five fields across the entire monitor. */
form.form-page-card:has(select[name="collaborationType"]){max-width:1120px!important;margin-inline:auto!important;padding:18px!important}
form.form-page-card:has(select[name="collaborationType"]) .form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px}
form.form-page-card:has(select[name="collaborationType"]) textarea{min-height:86px}
form.form-page-card:has(select[name="collaborationType"]) .form-sticky-actions{margin-top:14px!important;padding-top:12px!important}
form.form-page-card:has(select[name="collaborationType"]) .field.span-2{grid-column:1/-1}

/* Theme-safe overrides. */
.r61650-order-entry .r613-category-tree,.r64-modal,.r6156-part-picker-modal .r64-modal{background:var(--fp-surface)!important;color:var(--fp-text)!important;border-color:var(--fp-border)!important}
.r61650-order-entry .r613-category-tree button,.r6156-part-picker-modal button{color:inherit}
body:has(form.form-page-card select[name="collaborationType"]) main,body:has(form.form-page-card select[name="collaborationType"]) .main-content{min-width:0}

@media(max-width:1100px){
 .r61650-order-entry .product-picker-sheet.r61686-product-picker.classic-picker-open{inset:10px!important}
 .r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-tree section div{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .r61687-product-quick .r61687-image-upload .upload-preview{grid-template-columns:repeat(3,minmax(96px,1fr))}
 .r6156-part-picker-modal .r69-picker-layout{grid-template-columns:220px minmax(0,1fr)!important}
 .r6156-part-picker-modal .r69-picker-detail{display:none!important}
 .r6156-part-picker-modal .r69-picker-layout.categories-collapsed{grid-template-columns:0 minmax(0,1fr)!important}
}
@media(max-width:760px){
 .quick-entity-dialog.r61687-product-quick{width:100vw!important;max-width:none!important;max-height:100vh!important;border-radius:0!important}
 .r61687-product-quick>form{max-height:100vh}
 .r61687-product-quick .r61687-quick-product-grid{grid-template-columns:1fr;padding:12px!important}
 .r61687-product-quick .r61687-quick-product-grid>.span2{grid-column:auto!important}
 .r61650-order-entry .product-picker-sheet.r61686-product-picker .product-picker-toolbar{grid-template-columns:1fr!important}
 .r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-tree{position:fixed!important;left:12px!important;right:12px!important;top:120px!important;width:auto!important;max-height:65vh!important}
 .r61650-order-entry .product-picker-sheet.r61686-product-picker .r613-category-tree section div{grid-template-columns:1fr!important}
 form.form-page-card:has(select[name="collaborationType"]) .form-grid{grid-template-columns:1fr!important}
 form.form-page-card:has(select[name="collaborationType"]) .field.span-2{grid-column:auto}
}
