#order-editor.order-workspace{width:calc(100vw - 32px);max-width:1800px;height:calc(100dvh - 32px);max-height:none;padding:0 18px 0;border-radius:10px;overflow:auto;background:#fff;color:#28323d}
#order-editor.order-workspace>.dialog-header{position:sticky;top:0;z-index:12;display:flex;align-items:center;gap:14px;margin:0;padding:12px 0;background:#fff;border-bottom:1px solid #e5eaf1}
#order-editor.order-workspace .dialog-header h2{font-size:20px;margin:0;white-space:normal}
#order-editor.order-workspace .dialog-header>button{width:32px;min-height:32px;padding:4px;background:#f5f6f8;color:#64748b;border:0;margin:0}
.workspace-state{font-size:12px;background:#eef2f6;border-radius:14px;padding:4px 10px;color:#566477}
.workspace-posting{margin-left:auto;display:flex;gap:12px;align-items:center;font-size:13px;white-space:nowrap}.workspace-posting .is-posted{color:#16844b;font-weight:600}
#order-editor.order-workspace #edit-post-toggle{padding:6px 10px;min-height:32px;background:white;border:1px solid #d8e0e9;color:#405269;font-size:12px}
#order-editor.order-workspace .workspace-primary{display:grid;grid-template-columns:1.4fr 1fr 1fr 1fr;gap:14px;margin:12px 0 8px;padding:0}
#order-editor.order-workspace .workspace-primary>label{display:flex;flex-direction:column;align-items:stretch;gap:4px;min-width:0;margin:0;font-size:12px;color:#64748b}
#order-editor.order-workspace .workspace-primary input,#order-editor.order-workspace .workspace-primary select{height:36px;min-height:36px;margin:0;padding:6px 10px;font-size:14px!important;width:100%;box-sizing:border-box}
#order-editor.order-workspace .search-select{width:100%;min-width:0}
#order-editor.order-workspace .search-select input{background-image:none!important;padding-right:30px}
#order-editor.order-workspace .workspace-comment{position:relative;display:flex;align-items:center;gap:12px;margin:0 0 8px;font-size:12px;color:#64748b}
#order-editor.order-workspace .workspace-comment textarea{flex:1;min-width:0;height:34px;min-height:34px;max-height:160px;resize:vertical;padding:7px 35px 7px 10px;font-size:13px;line-height:18px;margin:0;box-sizing:border-box;border:1px solid #d6dee8;border-radius:5px}
#order-editor.order-workspace .workspace-comment.expanded textarea{height:90px}
#order-editor.order-workspace .workspace-comment button{position:absolute;right:5px;top:4px;padding:0;width:26px;min-height:26px;border:0;background:white;color:#64748b}
.workspace-nav{display:flex;align-items:center;gap:15px;border-bottom:1px solid #dfe6ee;position:relative;min-height:44px}
#order-editor.order-workspace .order-document-tabs{display:flex;gap:15px;margin:0;padding:0;border:0;width:auto}
#order-editor.order-workspace .order-document-tabs button{padding:10px 2px;border:0;border-bottom:3px solid transparent;border-radius:0;background:none;color:#526174;font-size:14px;min-height:42px;white-space:nowrap;flex:none}
#order-editor.order-workspace .order-document-tabs button[aria-selected=true]{color:#0d6efd;border-bottom-color:#0d6efd;background:none;font-weight:600}
#order-editor.order-workspace .workspace-extra{position:static;width:auto;margin:0;padding:0;border:0;background:none}
#order-editor.order-workspace .workspace-extra>summary{font-size:14px;padding:10px 0;margin:0;background:none;border:0;color:#526174;list-style:none;cursor:pointer}
#order-editor.order-workspace .workspace-extra>summary:before,#order-editor.order-workspace .workspace-extra>summary:after{display:none}
#order-editor.order-workspace .workspace-extra .editor-extra-fields{position:absolute;z-index:20;left:0;right:0;top:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));padding:16px;margin:0;gap:12px;background:white;border:1px solid #dbe3ed;border-radius:6px;box-shadow:0 8px 24px #1f293722;max-height:50vh;overflow:auto}
#order-editor.order-workspace .workspace-extra:not([open]) .editor-extra-fields{display:none}
.workspace-payment{margin-left:auto;display:flex;align-items:center;gap:12px;font-size:13px;font-weight:600}
#order-editor.order-workspace .workspace-payment button{padding:6px 10px;min-height:32px;border:1px solid #0d6efd;background:#fff;color:#0d6efd;font-size:13px}
#order-editor.order-workspace .editor-toolbar{display:flex;gap:10px;align-items:center;margin:0;padding:10px 0;background:white;border:0;border-radius:0}
#order-editor.order-workspace .editor-toolbar>button,#order-editor.order-workspace .workspace-reserve>summary{padding:6px 12px;min-height:34px;font-size:13px;border:1px solid #cbd5e1;border-radius:5px;background:white;color:#526174;box-sizing:border-box}
.workspace-reserve{position:relative}.workspace-reserve>summary{cursor:pointer;list-style:none}.workspace-reserve>summary:after{content:'⌄';margin-left:8px}.workspace-reserve-menu{position:absolute;left:0;top:100%;z-index:15;min-width:260px;padding:6px;background:white;border:1px solid #dbe3ed;box-shadow:0 5px 15px #0002;border-radius:5px}
#order-editor.order-workspace .workspace-reserve-menu button{display:block;width:100%;text-align:left;background:white;color:#405269;border:0;font-size:13px;padding:8px}
#order-editor.order-workspace .editor-pricebar{margin:0 0 0 auto;padding:0;display:flex;align-items:center;gap:12px;flex-wrap:nowrap}
#order-editor.order-workspace .editor-pricebar>strong,#order-editor.order-workspace .editor-pricebar>button{display:none}
#order-editor.order-workspace .editor-pricebar label{display:flex;align-items:center;gap:8px;margin:0;font-size:13px;white-space:nowrap}
#order-editor.order-workspace .editor-price-select{display:flex}
#order-editor.order-workspace .editor-pricebar input,#order-editor.order-workspace .editor-pricebar select{height:34px;min-height:34px;padding:5px 8px;margin:0;font-size:13px;box-sizing:border-box}
#order-editor.order-workspace #edit-price-select{width:170px}#order-editor.order-workspace #edit-discount{width:75px}
#order-editor.order-workspace #edit-form{margin:0;display:flex;flex-direction:column;min-height:calc(100% - 220px)}
#order-editor.order-workspace #edit-form[hidden]{display:none}
#order-editor.order-workspace .workspace-footer{position:sticky;bottom:0;z-index:10;margin-top:auto;background:#fff;border-top:1px solid #dfe6ee;padding:8px 0 0}
#order-editor.order-workspace #edit-total{margin:0;padding:0 0 8px;font-size:16px;gap:10px 18px;align-items:center}
#order-editor.order-workspace #edit-total-input{font-size:17px;height:36px;width:170px}
.workspace-due{margin-left:auto;font-size:17px;white-space:nowrap}
#order-editor.order-workspace #edit-status:empty{display:none}#order-editor.order-workspace #edit-status{margin:0;padding:5px 0;font-size:12px}
#order-editor.order-workspace .editor-actions{position:static;margin:0;padding:9px 0;display:flex;justify-content:space-between;gap:10px;border-top:1px solid #e4e9f0}
#order-editor.order-workspace .editor-actions button{min-height:36px;padding:7px 12px;font-size:13px;background:#fff;border:1px solid #cbd5e1;color:#43536a}
#order-editor.order-workspace .editor-actions #edit-save{background:#0d6efd;color:#fff;border-color:#0d6efd}
#order-editor.order-workspace .editor-lines{margin:0;padding:0}#order-editor.order-workspace .order-payments{margin:8px 0;padding:12px;border:1px solid #e1e7ef;border-radius:6px}
@media(max-width:800px){
 #order-editor.order-workspace{width:100vw;max-width:100vw;height:100dvh;padding:0 10px;border-radius:0}
 #order-editor.order-workspace>.dialog-header{flex-wrap:wrap;gap:6px;padding:8px 0}
 #order-editor.order-workspace .dialog-header h2{font-size:16px;flex:1}
 .workspace-state{font-size:10px}.workspace-posting{order:4;width:100%;justify-content:space-between}.workspace-posting~button{order:3}
 #order-editor.order-workspace .workspace-primary{grid-template-columns:1fr 1fr;gap:8px;margin:8px 0}
 #order-editor.order-workspace .workspace-primary input{font-size:16px!important}
 #order-editor.order-workspace .workspace-comment{gap:6px}
 .workspace-nav{flex-wrap:wrap;gap:4px 12px;padding-bottom:6px}
 #order-editor.order-workspace .order-document-tabs{gap:12px}
 #order-editor.order-workspace .order-document-tabs button,#order-editor.order-workspace .workspace-extra>summary{font-size:12px;min-height:34px;padding:7px 0}
 .workspace-payment{width:100%;justify-content:space-between}
 #order-editor.order-workspace .workspace-extra .editor-extra-fields{grid-template-columns:1fr 1fr;padding:10px}
 #order-editor.order-workspace .editor-toolbar{flex-wrap:wrap;gap:6px;padding:8px 0}
 #order-editor.order-workspace .editor-pricebar{width:100%;justify-content:space-between;gap:8px}
 #order-editor.order-workspace #edit-price-select{width:140px}
 #order-editor.order-workspace .workspace-footer{padding-top:6px}
 #order-editor.order-workspace #edit-total{gap:6px;font-size:14px}
 #order-editor.order-workspace #edit-total-input{width:135px;font-size:16px}
 #order-editor.order-workspace #edit-total .editor-align-linear{font-size:11px;order:3;flex-basis:100%}
 .workspace-due{font-size:13px}
 #order-editor.order-workspace .editor-actions{flex-wrap:wrap;gap:6px;padding:6px 0}
 #order-editor.order-workspace .editor-actions-left,#order-editor.order-workspace .editor-actions-right{display:flex;flex-wrap:wrap;gap:6px}
 #order-editor.order-workspace .editor-actions button{font-size:12px;padding:6px 8px}
}

#order-editor.order-workspace #edit-post-toggle{width:auto!important;max-width:none!important;flex:none!important}
#order-editor.order-workspace .workspace-comment:not(.expanded) textarea{display:none}
#order-editor.order-workspace .workspace-comment.expanded .workspace-comment-preview{display:none}
#order-editor.order-workspace .workspace-comment .workspace-comment-preview{position:static;flex:1;width:0;min-width:0;height:34px;min-height:34px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;padding:7px 35px 7px 10px;border:1px solid #d6dee8;border-radius:5px;background:white;font-size:13px;color:#28323d}
@media(max-width:800px){
 #order-editor.order-workspace .workspace-primary>label{grid-column:auto!important;grid-row:auto!important;width:auto!important}
 #order-editor.order-workspace .workspace-primary input{padding:5px 6px;font-size:14px!important}
 #order-editor.order-workspace .workspace-footer{background:white!important;padding:5px 0 0!important}
 #order-editor.order-workspace #edit-total{display:flex!important;flex-wrap:wrap!important;align-items:center!important;padding:4px 0!important;margin:0!important;min-height:0!important;background:white!important;border:0!important;border-radius:0!important;gap:5px!important}
 #order-editor.order-workspace #edit-total>label{margin:0!important;padding:0!important;min-height:0!important;display:flex!important;align-items:center!important;gap:5px!important}
 #order-editor.order-workspace #edit-total .editor-align-linear{flex-basis:100%!important;width:100%!important;justify-content:flex-start!important;font-size:10px!important;min-height:22px!important}
 #order-editor.order-workspace #edit-align-linear{width:16px!important;height:16px!important;margin:0!important;min-height:16px!important;flex:none!important}
 #order-editor.order-workspace #edit-total-input{width:112px!important;height:30px!important;min-height:30px!important;padding:4px!important;margin:0!important;font-size:15px!important}
 #order-editor.order-workspace .workspace-due{font-size:12px!important}
 #order-editor.order-workspace .editor-actions{display:flex!important;gap:5px!important;padding:5px 0!important}
 #order-editor.order-workspace .editor-actions-left,#order-editor.order-workspace .editor-actions-right{display:flex!important;flex-direction:row!important;flex-wrap:wrap!important;width:100%!important;gap:5px!important;margin:0!important}
 #order-editor.order-workspace .editor-actions button{width:auto!important;flex:1!important;min-height:30px!important;height:30px!important;padding:4px 6px!important;font-size:11px!important;margin:0!important}
}

/* All workspace sections participate in one exclusive tab selection. */
#order-editor.order-workspace [role="tabpanel"][hidden]{display:none!important}
#order-editor.order-workspace .workspace-requisites-panel{padding:12px 0;margin:0}
#order-editor.order-workspace .workspace-requisites-panel .editor-extra-fields{position:static;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:0;padding:0;border:0;box-shadow:none;max-height:none}
@media(max-width:800px){#order-editor.order-workspace .workspace-requisites-panel .editor-extra-fields{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}}

#order-editor.order-workspace[open]{display:flex;flex-direction:column}
#order-editor.order-workspace>*{flex-shrink:0}
#order-editor.order-workspace #edit-form{min-height:0}
#order-editor.order-workspace>.workspace-footer{margin-top:auto}

#order-editor.order-workspace #edit-markup{width:75px}
@media(max-width:767px){
 #order-editor.order-workspace .editor-pricebar{flex-wrap:wrap;justify-content:flex-start}
 #order-editor.order-workspace .editor-price-select{flex-basis:100%}
 #order-editor.order-workspace .editor-pricebar label{flex-shrink:0}
}

#order-editor.order-workspace>.dialog-header{padding-right:48px}
#order-editor.order-workspace>.dialog-header>.editor-close{position:absolute;right:0;top:12px;flex:none;margin:0}
@media(max-width:767px){#order-editor.order-workspace>.dialog-header>.editor-close{top:8px}}

#order-editor.order-workspace #edit-total{display:flex;align-items:center;gap:20px}
.workspace-totals-left{display:flex;flex-direction:column;align-items:flex-start;gap:8px;flex-shrink:0}
#order-editor.order-workspace #edit-total .workspace-comment{flex:1;min-width:180px;margin:0;text-align:left;font-weight:400}
#order-editor.order-workspace .workspace-details-toggle{display:inline-flex;align-items:center;gap:7px;margin:0;font-size:13px;white-space:nowrap}
.workspace-details-toggle input{width:16px;height:16px;margin:0}
#order-editor.hide-order-details .editor-table :is(th,td):is([data-label="Склад резерва"],[data-label="Резерв"],[data-label="Скидка / наценка, %"],[data-label="Скидка, %"],[data-label="НДС"]),
#order-editor.hide-order-details .editor-line-summary{display:none!important}
#order-editor .editor-table :is(th,td)[data-label="№"]{width:1%;min-width:0;max-width:none;padding-left:7px;padding-right:7px;white-space:nowrap;font-weight:400;color:#64748b}
#order-editor .editor-table td[data-label="Сумма"] input{font-weight:700;width:130px;max-width:100%}
#order-editor #edit-status:empty{display:none}
@media(max-width:767px){
 #order-editor .editor-table td[data-label="№"]{grid-column:1/-1;grid-row:auto;width:auto;display:block}
 #order-editor.order-workspace #edit-total .workspace-comment{flex-basis:100%;order:2}
}

/* Keep data columns together; the action cell absorbs the spare width. */
@media(min-width:801px){
 #order-editor.order-workspace .editor-table{table-layout:auto;width:100%}
 #order-editor.order-workspace .editor-table :is(th,td){width:1%;min-width:0;max-width:none;padding-left:7px;padding-right:7px;white-space:nowrap}
 #order-editor.order-workspace .editor-table :is(th,td)[data-label="Товар"]{width:430px;min-width:300px;max-width:460px;white-space:normal}
 #order-editor.order-workspace .editor-table :is(th,td)[data-label="Ед."]{padding-left:2px;padding-right:14px}
 #order-editor.order-workspace .editor-table th:last-child,
 #order-editor.order-workspace .editor-table td:has(>.editor-remove-icon){width:100%;text-align:right}
 #order-editor.order-workspace .editor-table input{width:85px;min-width:0}
 #order-editor.order-workspace .editor-table td[data-label="Сумма"] input{width:130px}
}
#order-editor .order-stock-hint{position:fixed;z-index:100;max-width:280px;padding:9px 12px;border:1px solid #cbdcf3;border-radius:7px;background:#f1f7ff;color:#243247;box-shadow:0 3px 12px #182a4020;font-size:13px;pointer-events:none}
#order-editor .order-stock-hint small{display:block;margin-top:3px;color:#64748b;font-size:11px}

@media(min-width:801px){
 #order-editor.order-workspace #edit-total{align-items:flex-start;padding-top:8px}
 #order-editor .workspace-totals-left{gap:8px}
 #order-editor .workspace-totals-left>label{display:flex;align-items:center;gap:8px;margin:0;padding:0;min-height:36px}
 #order-editor .workspace-totals-left>.editor-align-linear{min-height:24px;font-size:13px;font-weight:400}
 #order-editor .workspace-totals-left>.editor-align-linear input{margin:0}
 #order-editor.order-workspace #edit-total .workspace-comment{min-height:36px;align-items:center;margin:0;padding:0}
 #order-editor.order-workspace #edit-total .workspace-due{display:flex;align-items:center;min-height:36px;margin-top:0;padding:0}
}

@media(min-width:801px){
 #order-editor.order-workspace .editor-toolbar{position:sticky;top:var(--order-header-height,60px);z-index:6}
 #order-editor.order-workspace .editor-lines{overflow:visible}
 #order-editor.order-workspace .editor-table thead th{position:sticky;top:calc(var(--order-header-height,60px) + var(--document-toolbar-height,0px));z-index:3;background:#f4f7fb;box-shadow:0 1px 0 #dfe6ee}
}

@media(min-width:801px){
 #order-editor.order-workspace #edit-total-input{margin:0;box-sizing:border-box;height:34px;min-height:34px}
 #order-editor.order-workspace .workspace-totals-left>label:first-child{min-height:34px}
 #order-editor.order-workspace #edit-total .workspace-comment{min-height:34px}
}

#order-editor.order-workspace>.dialog-header>#edit-status{margin:0;padding:6px 10px;font-size:12px;line-height:1.4;max-width:420px;border-radius:6px;background:#eef5ff;color:#526174}
#order-editor.order-workspace>.dialog-header>#edit-status.checkout-error{background:#fff0f0;color:#a32121}
#order-editor.order-workspace>.dialog-header>#edit-status:empty{display:none}

#order-editor.order-workspace .workspace-save-notice{flex:1 1 260px;min-width:0;margin:0;padding:7px 12px;align-self:center;border-radius:7px;background:#eef5ff;color:#526174;font-size:12px;line-height:1.4;overflow-wrap:anywhere}
#order-editor.order-workspace .workspace-save-notice[hidden]{display:none}
@media(max-width:800px){#order-editor.order-workspace .workspace-save-notice{flex-basis:auto;width:100%;box-sizing:border-box}}

#order-editor.hide-order-shipments .editor-table :is(th,td):is([data-label="Отгружено"],[data-label="Осталось отгрузить"]){display:none!important}

/* Fit short orders to their contents; long orders retain scrolling. */
#order-editor.order-workspace{height:fit-content;max-height:calc(100dvh - 32px);margin:auto;box-sizing:border-box}
#order-editor.order-workspace #edit-form{min-height:0}
#order-editor.order-workspace .workspace-footer{margin-top:8px}
#order-editor.order-workspace .editor-actions #edit-save{background:#fff;color:#0d6efd;border-color:#cbd5e1}
#order-editor.order-workspace .editor-actions #edit-save-post{background:#0d6efd;color:#fff;border-color:#0d6efd}
@media(max-width:800px){#order-editor.order-workspace{max-height:100dvh}}

#order-editor.order-workspace .editor-actions .document-delete-button{background:#dc3545;color:#fff;border-color:#dc3545}
#order-editor.order-workspace .editor-actions .document-delete-button:hover{background:#bb2d3b;border-color:#b02a37}

@media(min-width:801px){
 #order-editor.order-workspace #edit-total{
  display:grid;grid-template-columns:max-content minmax(0,1fr);
  grid-template-areas:"totals due" "comment comment";gap:5px 24px
 }
 #order-editor.order-workspace .workspace-totals-left{grid-area:totals;gap:2px}
 #order-editor.order-workspace #edit-total .workspace-due{grid-area:due;justify-self:start;margin-left:0}
 #order-editor.order-workspace #edit-total .workspace-comment{grid-area:comment;min-width:0;width:100%}
 #order-editor.order-workspace .editor-table td :is(input,select):enabled:not(:hover):not(:focus):not(:invalid){
  border-color:transparent;background-color:transparent;box-shadow:none
 }
}
