#commercial-quote-dialog, #stock-item-detail-dialog { width:min(1400px,calc(100vw - 32px)); max-width:calc(100vw - 32px); max-height:calc(100dvh - 32px); padding:0; overflow:auto; }
#commercial-quote-dialog .dialog-card, #stock-item-detail-dialog .dialog-card { width:100%; max-width:none; min-width:0; box-sizing:border-box; }
#commercial-quote-dialog .dialog-card > header, #stock-item-detail-dialog .dialog-card > header { position:sticky; top:0; z-index:3; background:#fff; }
#commercial-quote-dialog .commercial-editor-footer { position:sticky; bottom:0; z-index:3; background:#fff; display:flex; flex-wrap:wrap; gap:12px; }
#commercial-quote-dialog .commercial-editor-footer > span { flex:1; min-width:180px; }
#commercial-quote-dialog :is(input,select,textarea), #stock-history :is(input,select) { min-width:0; width:100%; box-sizing:border-box; }
#commercial-quote-dialog [hidden] { display:none !important; }
#commercial-quote-dialog .dialog-card { height:calc(100dvh - 32px); max-height:900px; min-height:0; display:flex; flex-direction:column; overflow:hidden; }
#commercial-quote-dialog .dialog-card > header, #commercial-quote-dialog .commercial-editor-footer { flex:0 0 auto; position:static; }
.sales-editor-body { flex:1 1 auto; min-height:0; overflow:auto; scroll-padding:12px; }
#commercial-quote-dialog textarea { min-height:72px; }
#stock-history { padding:20px; border-bottom:1px solid #d4dfdc; }
#stock-history-filter { display:flex; flex-wrap:wrap; align-items:end; gap:12px; }
#stock-history-filter label { flex:1 1 130px; display:grid; gap:6px; }
#stock-history-filter [hidden] { display:none; }
.history-balances { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin:18px 0; }
.history-balances > div { display:grid; gap:8px; padding:14px; background:#eef7f5; }
.history-table { overflow-x:auto; }
.history-table table { width:100%; border-collapse:collapse; }
.history-table :is(td,th) { padding:12px 8px; text-align:left; border-bottom:1px solid #d4dfdc; overflow-wrap:anywhere; }
.history-pages { display:flex; gap:12px; align-items:center; justify-content:space-between; margin-top:16px; }
@media(max-width:700px) {
  #commercial-quote-dialog, #stock-item-detail-dialog { width:calc(100vw - 12px); max-width:calc(100vw - 12px); max-height:calc(100dvh - 12px); }
  #commercial-quote-dialog .dialog-card { height:calc(100dvh - 12px); }
  #commercial-quote-dialog .field-grid { grid-template-columns:1fr; }
  #commercial-quote-dialog .commercial-editor-footer button { width:100%; }
  .history-balances { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #stock-history { padding:12px; }
  .history-table table { min-width:580px; }
}

.commercial-live-totals{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px 24px;padding:12px 20px;border-top:1px solid var(--line);background:#e8f6f3;font-variant-numeric:tabular-nums;flex-shrink:0}
.commercial-live-totals strong{margin-left:8px}.commercial-line-total{grid-column:1/-1;text-align:right;font-weight:700;padding:8px;border-top:1px solid var(--line)}
@media(max-width:600px){.commercial-live-totals{padding:8px 12px;gap:4px 12px;font-size:12px}}

#automation-project-dialog{width:min(1100px,calc(100vw - 32px));max-width:calc(100vw - 32px);padding:0;overflow:hidden;max-height:calc(100dvh - 32px)}
#automation-project-form{width:100%;max-width:none;max-height:calc(100dvh - 32px);display:flex;flex-direction:column;overflow:hidden;padding:0}
#automation-project-form>header,#automation-project-form>footer{padding:18px;flex-shrink:0;background:white}
.project-create-body{padding:18px;overflow:auto;min-height:0}.automation-plan-preview{padding:14px;background:#e8f6f3;margin-bottom:14px}.automation-plan-preview ol{columns:2;padding-left:20px}.automation-plan-preview li{break-inside:avoid;margin:5px 0}
#automation-save-template-dialog{width:min(760px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;padding:0}#automation-save-template-dialog .dialog-card{width:100%;max-width:none}
#automation-plan-controls{padding-bottom:18px}#automation-template-save-preview{max-height:30dvh;overflow:auto}
@media(max-width:600px){.automation-plan-preview ol{columns:1}#automation-project-form>header,#automation-project-form>footer,.project-create-body{padding:12px}}
#automation-project-form,#automation-project-form *{box-sizing:border-box;min-width:0}
#automation-project-form :is(input:not([type=radio]),select,textarea){width:100%;max-width:100%}
#automation-project-form>header>div{min-width:0}#automation-project-form .project-create-body{width:100%;min-height:0}
#automation-project-form .automation-template-options input[type=radio]{width:1px;height:1px;margin:0;overflow:hidden;clip-path:inset(50%)}
#automation-project-dialog{margin:auto;height:auto}
#automation-project-form{min-height:0;height:auto}
#automation-project-form>header{position:static;top:auto;margin:0}
#automation-project-form .automation-template-options label>span{float:none;width:100%}
#automation-project-form .automation-template-options label:focus-within>span{outline:2px solid var(--blue-dark);outline-offset:2px}

#automation-project-form>header{display:grid;grid-template-columns:minmax(0,1fr) 44px;gap:12px;align-items:start}
#automation-project-form>header>.icon-button{position:static;margin:0}
