/* Keep this tool's layout isolated from the shared admin dialogs. */
html:has(dialog.inventory-image-modal[open]),
body:has(dialog.inventory-image-modal[open]){overflow:hidden;overscroll-behavior:none}
dialog.inventory-image-modal{width:min(1100px,calc(100vw - 48px));max-width:1100px;height:min(900px,calc(100vh - 48px));height:min(900px,calc(100dvh - 48px));max-height:calc(100vh - 48px);max-height:calc(100dvh - 48px);margin:auto;padding:0;overflow:hidden;border:1px solid #d7e5e1;border-radius:20px;background:#f5f9f7;color:#213d39;box-shadow:0 24px 90px #133f3833}
.inventory-image-modal #modal-content,.inventory-image-modal #modal-form{height:100%;min-height:0;min-width:0}
.inventory-image-modal #modal-form{display:flex;flex-direction:column;overflow:hidden}
.inventory-image-modal .modal-head{flex:0 0 auto;gap:12px;padding:12px 20px;background:#fff;border-bottom:1px solid #dfeae6}
.inventory-image-modal .modal-head h2{min-width:0;font-size:18px;line-height:1.45;overflow-wrap:anywhere;color:#1c3c35}
.inventory-image-modal .modal-head .x{display:flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;height:44px;padding:0;border-radius:12px;color:#526f66;font-size:26px}
.inventory-image-modal .modal-head .x:hover{background:#eef5f2}
.inventory-image-modal .modal-body{flex:1 1 auto;min-height:0;min-width:0;padding:0;overflow:hidden}
.inventory-image-modal .modal-foot{display:none}
.inventory-image-modal .modal-error{flex:0 0 auto;margin:0;padding:12px 20px;border:0;border-top:1px solid #efd2c9;border-radius:0;font-size:14px;line-height:1.5;overflow-wrap:anywhere}
.inventory-image-modal [hidden]{display:none!important}

#inventory-image-tool{display:flex;flex-direction:column;height:100%;min-height:0;min-width:0;color:#29453e}
#inventory-image-tool *{box-sizing:border-box}
#inventory-image-tool .image-toolbar{flex:0 0 auto;display:grid;gap:12px;padding:14px 20px;background:#fff;border-bottom:1px solid #dfeae6}
#inventory-image-tool .image-context{min-width:0;color:#61796f;font-size:13px;line-height:1.55;overflow-wrap:anywhere}
#inventory-image-tool .image-context strong{color:#26483c;font-weight:650}
#inventory-image-tool .image-context small{font-size:12px;color:#6e837b}
#inventory-image-tool .image-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px;padding:4px;background:#edf5f1;border:1px solid #e1ebe6;border-radius:13px}
#inventory-image-tool .image-tabs button{min-width:0;min-height:44px;padding:10px 14px;border:0;border-radius:9px;background:transparent;color:#59746a;font-size:15px;font-weight:600;line-height:1.4;white-space:normal}
#inventory-image-tool .image-tabs button[aria-pressed="true"]{background:#fff;color:#087864;box-shadow:0 2px 7px #204d3a12}
#inventory-image-tool .image-tabs button:hover{color:#087864}
/* The workspace is the only document scroller inside this dialog. */
#inventory-image-tool .image-workspace{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable;padding:20px;background:#f1f7f4}
#inventory-image-tool .image-preview-panel,#inventory-image-tool .image-settings-panel{min-width:0;width:100%;margin:0 auto}
#inventory-image-tool .image-primary-controls,#inventory-image-tool .image-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;align-items:start;margin-bottom:14px;padding:16px;background:#fff;border:1px solid #dfe9e4;border-radius:14px}
#inventory-image-tool .image-field{display:flex;flex-direction:column;gap:7px;min-width:0;margin:0;font-size:13px;font-weight:550;line-height:1.45;color:#536c61}
/* Override global textarea min-height:190px and small mobile input fonts. */
#inventory-image-tool .image-field input,#inventory-image-tool .image-field textarea,#inventory-image-tool .image-field select{display:block;width:100%;min-width:0;min-height:44px;max-width:100%;padding:10px 11px;border:1px solid #cdded5;border-radius:9px;font:400 16px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;background:#fff;color:#244034}
#inventory-image-tool .image-field textarea{min-height:72px;resize:vertical}
#inventory-image-tool .image-field input[type="file"]{padding:7px;overflow:hidden;font-size:16px;line-height:1.7}
#inventory-image-tool .image-field input[type="file"]::file-selector-button{min-height:32px;margin-right:8px;padding:4px 9px;border:0;border-radius:6px;background:#eaf4ef;color:#23674e;font:inherit}
#inventory-image-tool .image-field input:focus,#inventory-image-tool .image-field textarea:focus,#inventory-image-tool .image-field select:focus{border-color:#3c9c7a;outline:2px solid #cdeade;outline-offset:1px}
#inventory-image-tool .image-field input:disabled,#inventory-image-tool .image-field select:disabled{opacity:.6}
#inventory-image-tool .hint{margin:0;color:#71847a;font-size:12px;font-weight:400;line-height:1.6;overflow-wrap:anywhere}
#inventory-image-tool .btn{min-width:0;min-height:44px;padding:10px 13px;border:1px solid #d2e1d8;border-radius:10px;background:#fff;color:#355c4b;font-size:14px;font-weight:600;line-height:1.45;white-space:normal;text-align:center;overflow-wrap:anywhere;touch-action:manipulation}
#inventory-image-tool .btn:hover{background:#f2f8f4;border-color:#a7c7b6}
#inventory-image-tool .btn.primary{background:#087f68;border-color:#087f68;color:#fff}
#inventory-image-tool .btn.primary:hover{background:#076e59;border-color:#076e59}
#inventory-image-tool .btn:disabled,#inventory-image-tool .btn[aria-disabled="true"]{opacity:.45;cursor:not-allowed}
#inventory-image-tool .btn[aria-disabled="true"]{pointer-events:none}
#inventory-image-tool button:focus-visible,#inventory-image-tool a:focus-visible,.inventory-image-modal .x:focus-visible{outline:3px solid #99ceba;outline-offset:2px}
#inventory-image-tool .image-notice{padding:12px 14px;margin:0 0 14px;border:1px solid #d8e9df;border-radius:11px;background:#eaf5ee;color:#536f60;font-size:13px;line-height:1.65;overflow-wrap:anywhere}
#inventory-image-tool .image-notice:empty{display:none}
#inventory-image-tool .image-result-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin:0 0 14px}
#inventory-image-tool .image-result-actions>.btn{flex:1 1 140px}
#inventory-image-tool .image-preview{min-width:0;max-width:100%;padding:14px;border:1px solid #d8e4dc;border-radius:14px;background:#e7eeea;text-align:center;overflow:visible}
#inventory-image-tool .image-preview img{display:block;width:auto;max-width:100%;height:auto;margin:auto;background:#fff;border-radius:3px;box-shadow:0 3px 14px #23463214}
#inventory-image-tool .image-preview-empty,#inventory-image-tool .image-empty{display:grid;place-items:center;min-height:240px;padding:28px 20px;color:#75887e;font-size:14px;line-height:1.7;text-align:center;overflow-wrap:anywhere}

#inventory-image-tool .image-section{min-width:0;margin:0 0 14px;border:1px solid #dce8e0;border-radius:14px;background:#fff;overflow:hidden}
#inventory-image-tool .image-section:last-child{margin-bottom:0}
#inventory-image-tool .image-section>summary{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:54px;padding:15px 16px;list-style:none;color:#294f3e;font-size:15px;font-weight:650;line-height:1.5;cursor:pointer;overflow-wrap:anywhere}
#inventory-image-tool .image-section>summary::-webkit-details-marker,#inventory-image-tool .image-product-details>summary::-webkit-details-marker{display:none}
#inventory-image-tool .image-section>summary::after{content:"⌄";flex:0 0 auto;align-self:center;color:#7d9b89;font-size:20px;line-height:1}
#inventory-image-tool .image-section[open]>summary{margin-bottom:0;border-bottom:1px solid #edf2ee}
#inventory-image-tool .image-section[open]>summary::after{transform:rotate(180deg)}
#inventory-image-tool .image-section-body{display:grid;gap:14px;min-width:0;padding:16px}
#inventory-image-tool .image-color-tools{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) 44px;gap:10px;align-items:end;min-width:0;margin:0}
#inventory-image-tool .image-color-tools .image-field{min-width:0}
#inventory-image-tool .image-color-tools>.btn{min-width:86px}
#inventory-image-tool .image-color-swatch{display:block;justify-self:center;width:44px;height:44px;border:1px solid #c5d8cb;border-radius:10px}
#inventory-image-tool .image-batch{display:flex;flex-wrap:wrap;gap:8px;min-width:0;margin:0}
#inventory-image-tool .image-batch>.btn{flex:1 1 150px}
#inventory-image-tool .image-products{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;min-width:0;max-height:none;overflow:visible;padding:0}
#inventory-image-tool .image-product-setting{display:flex;flex-direction:column;gap:10px;min-width:0;padding:12px;border:1px solid #dbe6de;border-top:6px solid var(--module-color,#FBE3D5);border-radius:12px;background:#fff}
#inventory-image-tool .image-product-label{display:flex;align-items:center;gap:9px;min-width:0;min-height:44px;margin:0;color:#2f4f3d;font-size:15px;line-height:1.5;cursor:pointer}
#inventory-image-tool .image-product-label>input[type="checkbox"]{flex:0 0 20px;width:20px;height:20px;margin:0;accent-color:#087f68}
#inventory-image-tool .image-product-label>strong{flex:1 1 auto;min-width:0;font-weight:650;overflow-wrap:anywhere}
#inventory-image-tool .image-product-label>span{flex:0 0 auto;margin-left:auto;color:#7a8b7d;font-size:12px;white-space:nowrap}
#inventory-image-tool .image-product-details{min-width:0;border-top:1px solid #edf2ed}
#inventory-image-tool .image-product-details>summary{display:flex;align-items:center;min-height:44px;margin:0;padding:10px 0;list-style:none;font-size:13px;line-height:1.5;color:#497b5d;font-weight:550;cursor:pointer}
#inventory-image-tool .image-product-details>summary::after{content:"＋";margin-left:auto;padding-left:8px;color:#89a28b}
#inventory-image-tool .image-product-details[open]>summary{margin-bottom:6px}
#inventory-image-tool .image-product-details[open]>summary::after{content:"−"}
#inventory-image-tool .image-product-details>.image-field{margin-bottom:12px}
#inventory-image-tool .image-product-details>.image-field:last-child{margin-bottom:0}
#inventory-image-tool .image-adjacency{min-width:0}
#inventory-image-tool .image-group{display:flex;flex-wrap:wrap;align-items:center;gap:9px;min-width:0;padding:12px 0;border-bottom:1px solid #e8eee8}
#inventory-image-tool .image-group:first-child{padding-top:0}
#inventory-image-tool .image-group:last-child{padding-bottom:0;border-bottom:0}
#inventory-image-tool .image-group>strong{flex-basis:100%;font-size:14px;color:#34543d}
#inventory-image-tool .image-group-item{display:grid;grid-template-columns:minmax(0,1fr) 44px 44px;align-items:center;gap:6px;max-width:100%;min-width:0;padding:6px 8px 6px 12px;border:1px solid #dce8da;border-radius:10px;background:#f2f7ee;color:#3c5a39}
#inventory-image-tool .image-group-item>span{min-width:0;font-size:14px;line-height:1.5;overflow-wrap:anywhere}
#inventory-image-tool .image-group-item .btn{width:44px;min-height:44px;padding:8px;font-size:18px;font-weight:500}
/* A fixed flex row, outside the workspace scroll, keeps both actions reachable. */
#inventory-image-tool .image-export-actions{position:relative;z-index:2;flex:0 0 auto;display:flex;gap:10px;margin:0;padding:12px 20px;background:#fff;border-top:1px solid #d9e6de;box-shadow:0 -3px 12px #24453205}
#inventory-image-tool .image-export-actions>.btn{flex:1 1 0;min-width:0;min-height:48px}
#inventory-image-tool .image-export-actions>.btn.primary{flex-grow:1.25}

@media(max-width:900px){
  #inventory-image-tool .image-products{grid-template-columns:repeat(2,minmax(0,1fr))}
  #inventory-image-tool .image-color-tools{grid-template-columns:minmax(0,1fr) auto}
  #inventory-image-tool .image-color-swatch{align-self:end}
}
@media(max-width:650px){
  dialog.inventory-image-modal{inset:0;width:100vw;max-width:100vw;height:100vh;height:100dvh;max-height:100vh;max-height:100dvh;margin:0;border:0;border-radius:0}
  .inventory-image-modal .modal-head{padding:8px 12px;padding-top:max(8px,env(safe-area-inset-top,0px))}
  .inventory-image-modal .modal-head h2{font-size:16px}
  .inventory-image-modal .modal-error{padding:10px 14px;font-size:13px}
  #inventory-image-tool .image-toolbar{gap:9px;padding:10px 14px 12px}
  #inventory-image-tool .image-context{font-size:12px}
  #inventory-image-tool .image-tabs button{font-size:14px}
  #inventory-image-tool .image-workspace{padding:14px;scrollbar-gutter:auto}
  #inventory-image-tool .image-primary-controls,#inventory-image-tool .image-controls{gap:12px;padding:13px;border-radius:12px}
  #inventory-image-tool .image-section{margin-bottom:12px;border-radius:12px}
  #inventory-image-tool .image-section>summary{min-height:52px;padding:13px 14px;font-size:14px}
  #inventory-image-tool .image-section-body{padding:14px;gap:12px}
  #inventory-image-tool .image-products{grid-template-columns:minmax(0,1fr);gap:10px}
  #inventory-image-tool .image-product-setting{padding:11px 12px}
  #inventory-image-tool .image-batch{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  #inventory-image-tool .image-batch>.btn:last-child:nth-child(odd){grid-column:1/-1}
  #inventory-image-tool .image-group{display:grid;grid-template-columns:minmax(0,1fr);gap:9px}
  #inventory-image-tool .image-group-item{width:100%}
  #inventory-image-tool .image-preview{padding:9px;border-radius:12px}
  #inventory-image-tool .image-preview-empty,#inventory-image-tool .image-empty{min-height:220px;padding:24px 15px}
  #inventory-image-tool .image-result-actions{gap:8px}
  #inventory-image-tool .image-result-actions>.btn{flex-basis:110px}
  #inventory-image-tool .image-export-actions{gap:9px;padding:10px 14px;padding-bottom:calc(10px + env(safe-area-inset-bottom,0px))}
  #inventory-image-tool .image-export-actions>.btn{padding:11px 10px;font-size:14px}
}
@media(max-width:360px){
  #inventory-image-tool .image-workspace{padding:10px}
  #inventory-image-tool .image-toolbar{padding-right:10px;padding-left:10px}
  #inventory-image-tool .image-primary-controls,#inventory-image-tool .image-controls{padding:11px;gap:9px}
  #inventory-image-tool .image-section-body{padding:11px}
  #inventory-image-tool .image-color-tools{gap:8px}
  #inventory-image-tool .image-color-tools>.btn{min-width:76px;padding-right:9px;padding-left:9px}
  #inventory-image-tool .image-export-actions{padding-right:10px;padding-left:10px}
}
#inventory-image-tool .image-export-actions{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.25fr)}
#inventory-image-tool .image-export-status{grid-column:1/-1;margin:0;font-size:12px;line-height:1.5;color:#61796f;overflow-wrap:anywhere}
#inventory-image-tool .image-export-status[data-error="true"]{color:#a43f30}
#inventory-image-tool .image-font-status{font-size:12px;color:#6c7f75;line-height:1.6;margin:0 0 14px}
#inventory-image-tool .image-save-help{flex-basis:100%;font-size:12px;color:#61796f;line-height:1.6;margin:0}
#inventory-image-tool .image-selection-count{flex-basis:100%;grid-column:1/-1;font-size:12px;line-height:1.6;color:#61796f}
@media(max-width:650px){
  #inventory-image-tool .image-primary-controls{grid-template-columns:minmax(0,1fr)}
  #inventory-image-tool .image-primary-controls>.image-field:last-child{display:grid;grid-template-columns:minmax(0,1fr) 90px;align-items:center}
  #inventory-image-tool .image-primary-controls>.image-field:last-child>.hint{grid-column:1/-1}
}
