#order-editor{width:min(1450px,97vw);max-width:97vw;max-height:94vh;padding:20px;border:1px solid #dbe2ea;border-radius:12px;color:#293543}#order-picker{width:min(1100px,95vw);max-height:90vh;border:1px solid #dbe2ea;border-radius:12px;padding:20px}#order-editor::backdrop,#order-picker::backdrop{background:#152131a6}.editor-pricebar{display:flex;align-items:end;gap:9px;flex-wrap:wrap;margin:14px 0}.editor-pricebar>strong{align-self:center}.editor-pricebar label{max-width:120px}.editor-pricebar button[aria-pressed=true]{background:#0d6efd;color:white;border-color:#0d6efd}.editor-fields{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:16px 0}.editor-fields label,.editor-pricebar label{display:flex;flex-direction:column;gap:5px;font-size:12px}.editor-fields input[type=checkbox]{width:20px;height:20px}.editor-fields textarea{min-height:38px}.editor-lines{overflow:auto;margin:16px 0}.editor-table{width:100%;border-collapse:collapse;min-width:1120px}.editor-table th,.editor-table td{padding:9px;border-bottom:1px solid #e2e8ef;vertical-align:middle;text-align:left}.editor-table th{background:#f4f7fb;font-size:12px}.editor-table input{width:90px;min-width:70px}.editor-table select{max-width:170px;min-width:90px}.editor-table small,.editor-picker-row small{display:block;color:#798390;margin-top:5px}.editor-table td[data-label="Товар"]{min-width:230px}.editor-actions{display:flex;flex-wrap:wrap;gap:8px;position:sticky;bottom:-20px;background:white;padding:12px 0;border-top:1px solid #e2e8ef}.editor-actions button:first-child{background:#0d6efd;color:white}.editor-picker-filters{display:flex;gap:10px;margin:15px 0}.editor-picker-filters input{flex:1}.editor-picker-filters select{max-width:35%}.editor-picker-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid #e2e8ef}.editor-picker-row>div{flex:1}.editor-picker-row input{width:90px}.order-print-sheet{display:none}
@media(max-width:800px){#order-editor,#order-picker{padding:12px;max-width:100vw;width:100vw;max-height:98vh}.editor-fields{grid-template-columns:repeat(2,minmax(0,1fr))}.editor-lines .editor-table{min-width:0}.editor-lines .editor-table thead{display:none}.editor-lines .editor-table tr{display:block;border:1px solid #dce3eb;border-radius:8px;padding:8px;margin:10px 0}.editor-lines .editor-table td{display:flex;justify-content:space-between;gap:8px;border:0;padding:5px;min-width:0}.editor-lines .editor-table td:before{content:attr(data-label);font-size:12px;color:#667789}.editor-lines .editor-table td[data-label="Товар"]{display:block}.editor-lines .editor-table td[data-label="Товар"]:before{display:none}.editor-table input,.editor-table select{width:55%;max-width:none}.editor-actions{bottom:-12px}.editor-picker-row{flex-wrap:wrap}.editor-picker-row>div{flex-basis:100%}.editor-picker-filters{flex-direction:column}.editor-picker-filters select{max-width:100%}}@media(max-width:420px){.editor-fields{grid-template-columns:1fr}.editor-pricebar{gap:6px}.editor-pricebar button{padding:8px}}
@media print{@page{size:A4 portrait;margin:12mm}body.printing-order>*,body.printing-order dialog{display:none!important}body.printing-order>#order-print-sheet{display:block!important;position:static;color:#000;background:#fff;font:11pt Arial,sans-serif;width:100%;padding:0}#order-print-sheet h1{font-size:17pt;font-weight:bold;margin:0 0 12mm}#order-print-sheet table{border-collapse:collapse;width:100%;display:table!important}#order-print-sheet thead{display:table-header-group!important}#order-print-sheet tbody{display:table-row-group!important}#order-print-sheet tr{display:table-row!important;break-inside:avoid}#order-print-sheet th,#order-print-sheet td{display:table-cell!important;border:1px solid #000;padding:5px;font-size:10pt;background:white;color:black}#order-print-sheet td:before{display:none!important}#order-print-sheet td:nth-child(2){width:50%;text-align:left}#order-print-sheet td{text-align:right}#order-print-sheet .print-total{text-align:right;font-weight:bold;margin:8mm 0}#order-print-sheet p{font-size:11pt}}

#order-print-preview{width:min(850px,96vw);max-height:94vh;padding:22px;border:1px solid #dbe2ea;border-radius:10px;background:#f1f3f5}#order-print-preview::backdrop{background:#152131a6}.order-print-paper{background:white;padding:35px;margin-top:18px;color:black;font:11pt Arial,sans-serif}.order-print-paper h1{font-size:14pt;margin:0 0 35px}.order-print-paper table{width:100%;border-collapse:collapse}.order-print-paper th,.order-print-paper td{padding:5px;border:1px solid black;font-size:9pt}.order-print-paper td:nth-child(2){width:45%}.order-print-paper .print-total{text-align:right;font-weight:bold;margin:24px 0}@media(max-width:600px){.order-print-paper{padding:12px;overflow:auto}.order-print-paper table{min-width:570px}}@media print{dialog::backdrop{display:none!important}#order-print-sheet h1{font-size:14pt}}

#order-editor .editor-fields>label,#order-editor .editor-pricebar>label{margin:0;min-width:0}#order-editor .editor-fields input:not([type=checkbox]),#order-editor .editor-fields select,#order-editor .editor-fields textarea{width:100%;min-width:0}#order-editor .editor-pricebar button[aria-pressed=false]{background:#fff;color:#0d6efd;border:1px solid #a9c9f6}#order-editor .editor-pricebar button[aria-pressed=true]{background:#0d6efd;color:#fff;box-shadow:0 0 0 2px #b6d4fe}#order-editor .editor-pricebar{align-items:center}#order-editor .editor-pricebar input{height:38px}

#order-print-preview .order-print-paper table,#order-print-sheet table{table-layout:fixed;min-width:0;width:100%}#order-print-preview .order-print-paper th,#order-print-preview .order-print-paper td,#order-print-sheet th,#order-print-sheet td{position:static!important;min-width:0!important;max-width:none!important;white-space:normal;overflow-wrap:anywhere;background:#fff!important;text-align:right}#order-print-preview .order-print-paper th:first-child,#order-print-preview .order-print-paper td:first-child,#order-print-sheet th:first-child,#order-print-sheet td:first-child{width:5%;text-align:center}#order-print-preview .order-print-paper th:nth-child(2),#order-print-preview .order-print-paper td:nth-child(2),#order-print-sheet th:nth-child(2),#order-print-sheet td:nth-child(2){width:45%;text-align:left}#order-print-preview .order-print-paper th:nth-child(3),#order-print-sheet th:nth-child(3){width:10%}#order-print-preview .order-print-paper th:nth-child(4),#order-print-sheet th:nth-child(4){width:8%}#order-print-preview .order-print-paper th:nth-child(7),#order-print-sheet th:nth-child(7){width:14%}#order-print-preview .order-print-paper th:nth-child(8),#order-print-sheet th:nth-child(8){width:18%}.order-print-paper p{color:#000}.order-print-paper{min-width:0}#order-print-preview{overflow:auto}

#order-editor .editor-comment,#order-editor .editor-extra{grid-column:1/-1}#order-editor .editor-comment textarea{min-height:64px;resize:vertical}#order-editor .editor-extra>summary{cursor:pointer;list-style:none;display:flex;align-items:center;gap:8px;font-size:13px;color:#43556b;padding:8px 0}#order-editor .editor-extra>summary::-webkit-details-marker{display:none}#order-editor .editor-extra>summary:before{content:"+";display:inline-grid;place-items:center;width:22px;height:22px;border:1px solid #cbd5e1;border-radius:4px;font-size:18px}#order-editor .editor-extra[open]>summary:before{content:"−"}#order-editor .editor-extra-fields{margin:8px 0 0}#order-editor .editor-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:10px}#order-editor .editor-toolbar .editor-pricebar{margin:0 0 0 10px;gap:8px}#order-editor .editor-pricebar>label{flex-direction:row;align-items:center;max-width:none;white-space:nowrap;gap:8px}#order-editor .editor-pricebar input{width:90px;min-width:0}@media(max-width:800px){#order-editor .editor-toolbar .editor-pricebar{margin:0;flex-basis:100%}}

#order-editor{width:98vw;max-width:98vw;height:97vh;max-height:97vh}#order-print-preview{width:94vw;max-width:94vw;height:93vh;max-height:93vh}#order-print-preview .print-plain th:nth-child(8){width:32%}#order-print-preview .print-plain h1{margin-bottom:12px}#order-print-preview .print-buyer{margin:0 0 30px}

#order-editor .editor-pricebar button[data-price-id]:disabled{opacity:1;cursor:default;pointer-events:none}

#orders-table .order-select-cell{width:38px;min-width:38px;text-align:center}#orders-table .order-select-cell input{width:18px;height:18px;cursor:pointer}#print-orders{margin-right:8px}#print-orders:disabled{opacity:.5;cursor:default}

@media(max-width:767px){#orders-table td.order-select-cell{grid-column:1;padding:4px 0;border:0;text-align:left}#orders-table td:nth-child(2){grid-column:2;text-align:right}#orders-table td:nth-child(4){grid-column:auto}#orders-table td:nth-child(7){grid-column:1/-1}}

/* Keep scrolling table cells below the fixed action panel. */
#order-editor .editor-lines{position:relative;isolation:isolate;z-index:0}
#order-editor .editor-actions{z-index:5;background:#fff;box-shadow:0 -4px 12px #17212f0d}
#order-editor>.dialog-header{z-index:6}

#order-editor .editor-actions-left,#order-editor .editor-actions-right{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0}#order-editor .editor-actions-right{margin-left:auto;justify-content:flex-end}

/* Phone order editor: full-screen sheet and compact editable item cards. */
@media(max-width:767px){
 #order-editor,#order-picker{box-sizing:border-box;width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;padding:10px;padding-bottom:max(12px,env(safe-area-inset-bottom));border:0;border-radius:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}
 #order-editor>.dialog-header,#order-picker>.dialog-header{position:sticky;top:-10px;display:flex;align-items:center;gap:8px;margin:0 -10px;padding:8px 10px;background:white;z-index:30}
 #order-editor>.dialog-header h2,#order-picker>.dialog-header h2{flex:1;min-width:0;font-size:16px;line-height:1.25;margin:0;overflow-wrap:anywhere}
 #order-editor>.dialog-header button{flex:0 0 40px;width:40px;height:40px;min-height:40px;padding:4px}
 #order-picker>.dialog-header button{width:auto;max-width:115px;font-size:12px;line-height:1.2}
 #order-editor form,#order-editor .order-documents-panel{min-width:0}
 #order-editor .order-document-tabs{gap:6px;margin:8px 0}
 #order-editor .order-document-tabs button{flex:1;min-width:0;font-size:12px;min-height:40px;padding:7px}
 #order-editor .editor-fields{grid-template-columns:80px minmax(0,1fr);gap:8px;margin:10px 0}
 #order-editor .editor-fields>label{font-size:11px;gap:3px}
 #order-editor .editor-fields>label:has(#edit-buyer),#order-editor .editor-fields>label:has(#edit-org){grid-column:1/-1}
 #order-editor .editor-fields input:not([type=checkbox]),#order-editor .editor-fields select,#order-editor .editor-fields textarea{box-sizing:border-box;max-width:100%;width:100%;min-height:40px;padding:7px 8px;font-size:16px!important;margin:0}
 #order-editor .editor-fields input[type=checkbox]{width:22px;height:22px;min-height:22px;margin:8px 0}
 #order-editor .editor-extra-fields{grid-template-columns:repeat(2,minmax(0,1fr));margin:6px 0}
 #order-editor .editor-extra-fields>label:has(#edit-contract){grid-column:1/-1}
 #order-editor .editor-extra>summary{padding:6px 0;font-size:12px}
 #order-editor .editor-comment textarea{min-height:48px;height:48px}
 #order-editor .editor-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:10px 0}
 #order-editor .editor-toolbar>button{width:100%;min-width:0;min-height:40px;padding:7px;font-size:12px;line-height:1.2}
 #order-editor .editor-toolbar>button:first-child{grid-column:1/-1}
 #order-editor .editor-toolbar .editor-pricebar{grid-column:1/-1;display:grid;grid-template-columns:auto repeat(3,minmax(0,1fr));gap:5px;width:100%;margin:2px 0 0}
 #order-editor .editor-pricebar>strong{font-size:11px}
 #order-editor .editor-pricebar button{padding:6px 4px;min-width:0;min-height:40px;font-size:12px;white-space:normal;line-height:1.2}
 #order-editor .editor-pricebar>label{grid-column:1/-1;display:flex;flex-direction:row;justify-content:flex-end;font-size:12px;margin:0}
 #order-editor .editor-pricebar input{width:85px;height:40px;font-size:16px!important}
 #order-editor .editor-lines{overflow:visible;margin:8px 0}
 #order-editor .editor-table,#order-editor .editor-table tbody{display:block;width:100%;min-width:0}
 #order-editor .editor-table thead{display:none}
 #order-editor .editor-table tbody tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px 8px;padding:9px;margin:0 0 8px;background:#fff;border:1px solid #dce3eb;border-radius:8px}
 #order-editor .editor-table td{position:static!important;display:flex;flex-direction:column;justify-content:flex-start;gap:3px;min-width:0!important;max-width:none!important;padding:0;border:0;background:transparent!important;font-size:13px;overflow-wrap:anywhere}
 #order-editor .editor-table td:before{display:block;font-size:10px;line-height:1.2;color:#64748b;margin:0;content:attr(data-label)}
 #order-editor .editor-table td[data-label="Товар"]{grid-column:1/-1;display:block;font-size:14px;line-height:1.3}
 #order-editor .editor-table td[data-label="Товар"]:before{display:none}
 #order-editor .editor-table small{font-size:10px;margin-top:2px}
 #order-editor .editor-table td[data-label="Склад резерва"]{grid-column:1/-1}
 #order-editor .editor-table td[data-label="Кол-во"]{grid-column:1;grid-row:3}
 #order-editor .editor-table td[data-label="Ед."]{grid-column:2;grid-row:3;justify-content:center}
 #order-editor .editor-table td[data-label="Цена"]{grid-column:3;grid-row:3}
 #order-editor .editor-table td[data-label="Скидка, %"]{grid-column:1;grid-row:4}
 #order-editor .editor-table td[data-label="НДС"]{grid-column:2;grid-row:4}
 #order-editor .editor-table td[data-label="Резерв"]{grid-column:3;grid-row:4}
 #order-editor .editor-table td[data-label="Сумма"]{grid-column:1/3;grid-row:5;flex-direction:row;align-items:center;gap:6px;font-size:15px;font-weight:600}
 #order-editor .editor-table td:has(>.editor-remove-icon){grid-column:3;grid-row:5}
 #order-editor .editor-table td:has(>.editor-remove-icon):before{display:none}
 #order-editor .editor-table input,#order-editor .editor-table select{box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:40px;margin:0;padding:7px 6px;font-size:16px!important}
 #order-editor .editor-table td:last-child button{width:100%;min-height:40px;padding:7px 4px;background:#fff1f1;border-color:#ffdbdb;color:#b02a37;font-size:12px}
 #order-editor #edit-total{margin:10px 0;font-size:18px;text-align:right}
 #order-editor #edit-status:empty{display:none}
 #order-editor .editor-actions{position:static;display:flex;flex-direction:column;gap:6px;padding:10px 0 0;margin:8px 0 0;box-shadow:none}
 #order-editor .editor-actions-left{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
 #order-editor .editor-actions-right{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;width:100%;margin:0}
 #order-editor .editor-actions button{width:100%;min-width:0;min-height:44px;padding:7px 5px;font-size:12px;line-height:1.2;white-space:normal}
 #order-picker .editor-picker-filters{gap:6px;margin:8px 0}
 #order-picker .editor-picker-filters input,#order-picker .editor-picker-filters select{width:100%;min-width:0;max-width:100%;box-sizing:border-box}
 #order-picker .editor-picker-row{gap:6px;padding:9px 0;font-size:13px}
 #order-picker .editor-picker-row input{width:85px;font-size:16px!important}
}

/* Compact phone order header: labels beside their fields. */
@media(max-width:767px){
 #order-editor .order-document-tabs{margin:5px 0;gap:5px}
 #order-editor .order-document-tabs button{min-height:34px;padding:5px 7px;font-size:12px}
 #order-editor #edit-form>.editor-fields{grid-template-columns:1fr;gap:5px;margin:6px 0}
 #order-editor #edit-form>.editor-fields>label{display:grid;grid-template-columns:80px minmax(0,1fr);align-items:center;gap:6px;font-size:11px;grid-column:1/-1}
 #order-editor #edit-form>.editor-fields>label:has(#edit-posted){display:flex;flex-direction:row;gap:8px;min-height:26px}
 #order-editor .editor-fields input[type=checkbox]{margin:0;width:20px;height:20px;min-height:20px}
 #order-editor .editor-fields input:not([type=checkbox]),#order-editor .editor-fields select{min-height:36px;height:36px;padding:5px 7px}
 #order-editor .editor-fields .search-select{width:100%;min-width:0}
 #order-editor .editor-fields .search-select:after{top:8px}
 #order-editor .editor-extra>summary{padding:4px 0;font-size:11px;gap:6px}
 #order-editor .editor-extra>summary:before{width:18px;height:18px;font-size:16px}
 #order-editor #edit-form>.editor-fields>.editor-comment{display:flex;align-items:stretch;gap:3px}
 #order-editor .editor-comment textarea{height:38px;min-height:38px;padding:5px 7px}
}

#order-editor .editor-pricebar>.editor-price-select{display:none}
@media(max-width:767px){
 #order-editor .editor-toolbar .editor-pricebar{display:grid;grid-template-columns:minmax(0,1fr) 100px;gap:8px;align-items:end;margin:0}
 #order-editor .editor-pricebar>strong,#order-editor .editor-pricebar>button[data-price-id]{display:none}
 #order-editor .editor-pricebar>label,#order-editor .editor-pricebar>.editor-price-select{display:flex;grid-column:auto;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:3px;margin:0;min-width:0;font-size:11px}
 #order-editor .editor-pricebar input,#order-editor .editor-pricebar select{box-sizing:border-box;width:100%;max-width:100%;min-width:0;height:36px;min-height:36px;padding:5px 7px;font-size:16px!important}
}

#order-editor .editor-status-row{display:contents}
@media(max-width:767px){
 #order-editor .editor-status-row{grid-column:1/-1;display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:4px 12px}
 #order-editor .editor-status-row>label{display:flex;flex-direction:row;align-items:center;gap:6px;margin:0;font-size:11px}
 #order-editor .editor-status-row>.editor-extra{display:contents}
 #order-editor .editor-status-row>.editor-extra>summary{grid-column:2;grid-row:1;padding:4px 0;font-size:11px}
 #order-editor .editor-status-row>.editor-extra>.editor-extra-fields{grid-column:1/-1;margin:4px 0}
 #order-editor .editor-status-row>.editor-extra:not([open])>.editor-extra-fields{display:none}
}

/* Unified mobile order appearance. */
@media(max-width:767px){
 #order-editor{background:#f4f6f9;color:#243247;padding:8px;padding-bottom:max(12px,env(safe-area-inset-bottom))}
 #order-editor>.dialog-header{top:-8px;margin:0 -8px;padding:8px 10px;border-bottom:1px solid #e1e7ef;box-shadow:0 2px 6px #24324706}
 #order-editor>.dialog-header h2{font-size:15px;line-height:1.35;font-weight:650;letter-spacing:-.2px}
 #order-editor>.dialog-header button{border-radius:10px;background:#f0f3f7;color:#526175}
 #order-editor .order-document-tabs{display:flex;padding:3px;margin:8px 0;background:#e6ecf3;border-radius:10px;gap:3px}
 #order-editor .order-document-tabs button{border:0;border-radius:7px;background:transparent;color:#59697c;min-height:34px;font-size:12px;font-weight:500}
 #order-editor .order-document-tabs button[aria-selected=true]{background:#fff;color:#0d6efd;box-shadow:0 1px 4px #24324718}
 #order-editor #edit-form>.editor-fields{padding:10px;margin:0 0 8px;gap:6px;background:#fff;border:1px solid #e1e7ef;border-radius:12px}
 #order-editor #edit-form>.editor-fields>label{grid-template-columns:76px minmax(0,1fr);color:#68788b;font-size:11px}
 #order-editor .editor-status-row{padding:0 0 7px;margin-bottom:1px;border-bottom:1px solid #edf0f5;gap:5px 9px}
 #order-editor .editor-status-row>label{color:#526175;font-weight:500}
 #order-editor .editor-status-row>label:has(:checked){color:#198754}
 #order-editor .editor-status-row>.editor-extra>summary{justify-self:end;color:#526175;gap:5px}
 #order-editor .editor-extra>summary:before{border:0;background:#edf3fa;color:#0d6efd;border-radius:4px}
 #order-editor .editor-extra-fields{padding:8px;background:#f7f9fc;border-radius:8px}
 #order-editor input:not([type=checkbox]),#order-editor select,#order-editor textarea{border-color:#dce3ed;border-radius:7px;color:#243247;box-shadow:none}
 #order-editor input:focus,#order-editor select:focus,#order-editor textarea:focus{border-color:#78abf8;outline:2px solid #0d6efd20;outline-offset:0}
 #order-editor input:disabled,#order-editor select:disabled{background:#f0f3f7;color:#8a96a6}
 #order-editor .editor-comment{margin-top:2px!important}
 #order-editor .editor-toolbar{padding:9px;margin:0 0 8px;background:#fff;border:1px solid #e1e7ef;border-radius:12px;gap:6px}
 #order-editor .editor-toolbar>button{border-radius:7px;font-weight:500}
 #order-editor .editor-toolbar>button:first-child{background:#0d6efd;border-color:#0d6efd;color:#fff;min-height:38px}
 #order-editor .editor-toolbar>button:not(:first-child){background:#f1f6ff;border-color:#dce9fc;color:#356399;min-height:36px;font-size:11px}
 #order-editor .editor-toolbar .editor-pricebar{padding-top:7px;margin-top:1px;border-top:1px solid #edf0f5;grid-template-columns:minmax(0,1fr) 90px}
 #order-editor .editor-pricebar>label{color:#68788b}
 #order-editor .editor-table tbody tr{padding:10px;gap:7px 8px;border-color:#e1e7ef;border-radius:12px;margin-bottom:7px;box-shadow:0 1px 2px #24324703}
 #order-editor .editor-table td[data-label="Товар"]{padding-bottom:6px;border-bottom:1px solid #edf0f5;font-weight:600}
 #order-editor .editor-table td[data-label="Товар"] strong{font-weight:650}
 #order-editor .editor-table td[data-label="Сумма"]{color:#243247}
 #order-editor .editor-table td[data-label="Сумма"]:before{font-weight:400;font-size:11px}
 #order-editor .editor-table td:last-child button{background:#fff7f7;border:1px solid #f6dddd;border-radius:7px}
 #order-editor #edit-total{padding:11px 12px;margin:9px 0;background:#eaf2ff;border:1px solid #dce8fc;border-radius:10px;color:#164c9b;font-size:18px;font-weight:700}
 #order-editor .editor-actions{padding:9px;margin:0;background:white;border:1px solid #e1e7ef;border-radius:12px;gap:6px}
 #order-editor .editor-actions button{border-radius:7px;font-weight:500}
 #order-editor .editor-actions-left button{background:#fff;color:#0d6efd;border:1px solid #cddff9}
 #order-editor .editor-actions-left #edit-save{background:#0d6efd;color:white;border-color:#0d6efd}
 #order-editor .editor-actions-right button{background:#f5f7fa;color:#526175;border:1px solid #e1e7ef;min-height:38px;font-size:11px}
 #order-editor #edit-status:not(:empty){padding:8px 10px;border-radius:8px;font-size:12px;line-height:1.4;margin:7px 0}
}

#order-editor .editor-mobile-caption{display:none}
@media(max-width:767px){
 #order-editor .editor-desktop-caption{display:none}
 #order-editor .editor-mobile-caption{display:inline}
 #order-editor .editor-status-row{grid-template-columns:auto minmax(0,1fr);min-height:32px;padding-bottom:5px;gap:6px}
 #order-editor .editor-status-row>.editor-extra>summary{justify-self:end;display:inline-flex;align-items:center;min-height:32px;padding:3px 0 3px 8px;font-size:12px;font-weight:400;line-height:1.2;white-space:nowrap;gap:5px}
 #order-editor .editor-status-row>.editor-extra>summary:before{display:none}
 #order-editor .editor-status-row>.editor-extra>summary:after{content:'⌄';font-size:15px;line-height:1}
 #order-editor .editor-status-row>.editor-extra[open]>summary:after{content:'⌃'}
 #order-editor .editor-toolbar>button:not(:first-child){height:36px;min-height:36px;padding:5px 7px;font-size:12px;font-weight:400;line-height:1.2;white-space:nowrap;background:#fff;border:1px solid #dce3ed;color:#526175;box-shadow:none}
}

/* One chevron for native controls, searchable lists and disclosure. */
#order-editor{--editor-chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='m6 9 6 6 6-6' stroke='%23596778' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
#order-editor select,#order-editor input:is([type=date],[type=datetime-local]){
 appearance:none;-webkit-appearance:none;background-image:var(--editor-chevron);background-repeat:no-repeat;background-position:right 10px center;background-size:16px 16px;padding-right:34px!important
}
#order-editor input:is([type=date],[type=datetime-local])::-webkit-calendar-picker-indicator{opacity:0;cursor:pointer}
#order-editor .search-select>input{padding-right:34px!important;text-overflow:ellipsis}
#order-editor .editor-fields .search-select:after{content:'';position:absolute;right:10px;top:50%;width:16px;height:16px;transform:translateY(-50%);background:var(--editor-chevron) center/16px 16px no-repeat;pointer-events:none}
#order-editor .editor-fields .search-select:has([aria-expanded="true"]):after{transform:translateY(-50%) rotate(180deg)}
#order-editor .editor-status-row>.editor-extra>summary:before{display:none}
#order-editor .editor-status-row>.editor-extra>summary:after{content:'';display:inline-block;flex:0 0 16px;width:16px;height:16px;background:var(--editor-chevron) center/16px 16px no-repeat;transform:none}
#order-editor .editor-status-row>.editor-extra[open]>summary:after{content:'';transform:rotate(180deg)}
/* Compact desktop order header; phone layout remains independently responsive. */
@media(min-width:768px){
 #order-editor{padding:12px 18px}
 #order-editor>.dialog-header{display:flex;align-items:center;justify-content:space-between;gap:12px;top:-12px;padding:0 0 8px;min-height:36px}
 #order-editor>.dialog-header h2{margin:0;font-size:18px;line-height:1.3}
 #order-editor>.dialog-header button{min-height:32px;height:32px;width:32px;padding:4px}
 #order-editor .order-document-tabs{margin:7px 0;gap:6px}
 #order-editor .order-document-tabs button{min-height:32px;padding:5px 12px;font-size:13px}
 #order-editor #edit-form>.editor-fields{grid-template-columns:minmax(250px,.85fr) minmax(280px,1fr) minmax(320px,1.2fr);gap:7px 14px;margin:6px 0 10px}
 #order-editor .editor-status-row{grid-column:1/-1;display:grid;grid-template-columns:auto 1fr;align-items:center;gap:6px 20px;min-height:28px}
 #order-editor .editor-status-row>label{display:flex;flex-direction:row;align-items:center;gap:8px;margin:0;font-size:12px}
 #order-editor .editor-status-row input[type=checkbox]{margin:0;width:18px;height:18px}
 #order-editor .editor-status-row>.editor-extra{display:contents}
 #order-editor .editor-status-row>.editor-extra>summary{grid-column:2;grid-row:1;justify-self:start;padding:3px 0;font-size:12px}
 #order-editor .editor-status-row>.editor-extra>.editor-extra-fields{grid-column:1/-1;margin:0 0 4px;padding:8px;background:#f6f8fb;border-radius:6px;gap:7px 12px}
 #order-editor .editor-status-row>.editor-extra:not([open])>.editor-extra-fields{display:none}
 #order-editor #edit-form>.editor-fields>label{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:8px;font-size:12px}
 #order-editor .editor-fields input:not([type=checkbox]),#order-editor .editor-fields select{box-sizing:border-box;height:34px;min-height:34px;padding:5px 9px;margin:0;font-size:13px}
 #order-editor .editor-fields .search-select{min-width:0;width:100%}
 #order-editor #edit-form>.editor-fields>.editor-comment{grid-column:1/-1;grid-template-columns:auto minmax(0,1fr)}
 #order-editor .editor-comment textarea{box-sizing:border-box;height:38px;min-height:38px;padding:6px 9px;font-size:13px;margin:0;resize:vertical}
 #order-editor .editor-toolbar{gap:7px;margin:0}
 #order-editor .editor-toolbar button{min-height:34px;padding:6px 10px;font-size:13px}
 #order-editor .editor-toolbar .editor-pricebar{gap:6px;margin-left:8px}
 #order-editor .editor-pricebar input{height:34px;min-height:34px;width:75px;padding:5px 8px}
 #order-editor .editor-lines{margin:10px 0}
}
@media(min-width:768px) and (max-width:1100px){
 #order-editor #edit-form>.editor-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
 #order-editor #edit-form>.editor-fields>label:has(#edit-org){grid-column:1/-1}
 #order-editor .editor-extra-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* Keep tabs, posting and disclosure on one header line. */
#order-editor .editor-topline{display:grid;grid-template-columns:auto auto minmax(0,1fr);align-items:center;gap:8px 20px;margin:8px 0;}
#order-editor .editor-topline .order-document-tabs{margin:0;}
#order-editor .editor-topline .editor-status-row,#order-editor .editor-topline .editor-extra{display:contents;}
#order-editor .editor-topline .editor-status-row>label{grid-column:2;grid-row:1;display:flex;align-items:center;gap:8px;margin:0;white-space:nowrap;font-size:12px;}
#order-editor .editor-topline #edit-posted{width:18px;height:18px;min-height:18px;margin:0;}
#order-editor .editor-topline .editor-extra>summary{grid-column:3;grid-row:1;justify-self:start;display:inline-flex;align-items:center;gap:6px;padding:5px 0;min-height:32px;font-size:12px;white-space:nowrap;}
#order-editor .editor-topline .editor-extra>.editor-extra-fields{grid-column:1/-1;grid-row:2;margin:0;padding:10px;background:#f6f8fb;border-radius:8px;}
#order-editor .editor-topline .editor-extra:not([open])>.editor-extra-fields{display:none;}
#order-editor .editor-toolbar{align-items:center;}
#order-editor .editor-toolbar .editor-pricebar{align-items:center;}
#order-editor .editor-pricebar>label:has(#edit-discount){margin:0;align-self:center;}
#order-editor .editor-pricebar #edit-discount{margin:0;display:block;box-sizing:border-box;}
@media(min-width:768px){#order-editor .editor-pricebar>label:has(#edit-discount){display:flex;flex-direction:row;align-items:center;gap:8px;}#order-editor .editor-pricebar #edit-discount{height:34px;min-height:34px;padding:5px 8px;}}
@media(max-width:767px){
 #order-editor .editor-topline{gap:5px 8px;grid-template-columns:minmax(0,1fr) auto auto;}
 #order-editor .editor-topline .order-document-tabs{padding:2px;gap:2px;}
 #order-editor .editor-topline .order-document-tabs button{min-height:34px;padding:5px;font-size:11px;line-height:1.2;}
 #order-editor .editor-topline .editor-status-row>label{font-size:11px;gap:4px;}
 #order-editor .editor-topline .editor-extra>summary{font-size:11px;gap:3px;}
 #order-editor .editor-topline .editor-extra>.editor-extra-fields{padding:8px;}
 #order-editor .editor-pricebar>label:has(#edit-discount){align-self:stretch;}
 #order-editor .editor-pricebar #edit-discount{height:36px;min-height:36px;}
}

/* The order picker uses the catalogue itself, including its responsive layout. */
.order-catalog-banner{grid-column:1/-1;display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:10px 16px;background:#eef5ff;border-bottom:1px solid #cbdcf4;position:sticky;top:0;z-index:40}
.order-catalog-banner button{margin-left:auto;white-space:nowrap;flex:none;width:auto;height:auto;padding:8px 14px}
.order-catalog-banner .detail{font-size:12px;flex:1;min-width:0;overflow-wrap:anywhere}
.order-catalog-picking .app-main,.order-catalog-picking .category-sidebar{grid-row:3}
.order-catalog-picking #cart-open{display:none!important}
@media(max-width:767px){.order-catalog-banner{grid-row:2;padding:8px 10px;gap:6px}.order-catalog-banner strong{font-size:14px}.order-catalog-banner button{min-height:40px;font-size:13px}.order-catalog-banner .detail:empty{display:none}.order-catalog-banner .detail:not(:empty){flex-basis:100%;order:3}.order-catalog-picking .category-sidebar{grid-row:3}.order-catalog-picking .app-main{grid-row:4}}

.order-catalog-added{position:relative;flex:none}.order-catalog-added>summary{cursor:pointer;white-space:nowrap;padding:8px 12px;border:1px solid #b7cdef;border-radius:6px;background:white;color:#0d6efd;list-style:none}.order-catalog-added>summary::-webkit-details-marker{display:none}.order-catalog-added-list{position:absolute;right:0;top:calc(100% + 6px);width:560px;max-width:calc(100vw - 24px);max-height:min(55vh,480px);overflow:auto;background:white;border:1px solid #dbe3ed;border-radius:8px;padding:8px 12px;box-shadow:0 8px 28px #17212f26;color:#293543;z-index:45}.order-catalog-added-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:16px;padding:10px 0;border-bottom:1px solid #e9edf3;font-size:13px}.order-catalog-added-row small{display:block;color:#798390;margin-top:3px}.order-catalog-added-row>div:first-child{overflow-wrap:anywhere;min-width:0}.order-catalog-added-values{display:flex;flex-direction:column;gap:4px;text-align:right;white-space:nowrap}.order-catalog-added-total{display:block;text-align:right;padding:12px 0 4px;font-size:14px}
@media(max-width:767px){.order-catalog-added{position:static}.order-catalog-added>summary{font-size:13px;min-height:40px;box-sizing:border-box}.order-catalog-added-list{left:10px;right:10px;top:100%;width:auto;max-width:none}.order-catalog-banner>strong{flex-basis:100%}.order-catalog-added-row{gap:8px}}

.order-catalog-quantity{display:flex;align-items:center;justify-content:flex-end;gap:6px}
.order-catalog-quantity input{width:88px;min-width:0;box-sizing:border-box;padding:6px 8px;font:inherit}
.order-catalog-banner .order-catalog-added-values button{margin:0;padding:4px 8px;font-size:12px;min-height:30px}
.order-catalog-banner .order-catalog-remove{color:#b42318;background:#fff;border:1px solid #edc5c1;align-self:flex-end}
.order-catalog-remove-confirm{display:flex;flex-direction:column;gap:5px;white-space:normal}

.order-exchange-badge{font-size:13px;padding:6px 10px;border-radius:6px;max-width:100%;overflow-wrap:anywhere}
.order-exchange-badge.is-pending{background:#fff4d6;color:#795400}
.order-exchange-badge.is-error{background:#fff0f0;color:#a32121}
.order-exchange-badge.is-done{background:#e6f5eb;color:#19703b}
.order-exchange-actions{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0}
#order-editor .dialog-header{flex-wrap:wrap}

/* Emphasize the primary order columns; keep codes secondary. */
#order-editor .editor-table th:is([data-label="Товар"],[data-label="Кол-во"],[data-label="Ед."],[data-label="Цена"],[data-label="Сумма"]),
#order-editor .editor-table td[data-label="Товар"] strong,
#order-editor .editor-table td:is([data-label="Кол-во"],[data-label="Ед."],[data-label="Цена"],[data-label="Сумма"]),
#order-editor .editor-table td:is([data-label="Кол-во"],[data-label="Цена"]) input,
#order-editor .editor-table td:is([data-label="Кол-во"],[data-label="Ед."],[data-label="Цена"],[data-label="Сумма"])::before{font-weight:700}
#order-editor .editor-table td[data-label="Товар"] small{font-weight:400}
#order-editor .editor-table button.editor-remove-icon{display:inline-flex;align-items:center;justify-content:center;width:34px;min-width:34px;height:34px;min-height:34px;padding:7px;color:#7b8797;background:transparent;border:1px solid transparent;border-radius:6px}
#order-editor .editor-table button.editor-remove-icon:hover{color:#c12c35;background:#fff1f2;border-color:#f3cbd0}
#order-editor .editor-table button.editor-remove-icon:focus-visible{outline:2px solid #0d6efd;outline-offset:2px}
#order-editor .editor-remove-icon svg{display:block;flex:none;pointer-events:none}
@media(max-width:767px){#order-editor .editor-table button.editor-remove-icon{width:40px;height:40px;min-height:40px}}

@media(max-width:767px){#order-editor .editor-table td[data-label="Отгружено"]{grid-column:1;grid-row:6}#order-editor .editor-table td[data-label="Осталось отгрузить"]{grid-column:2/4;grid-row:6}}

#order-editor .editor-line-meta{display:flex;flex-direction:column;align-items:flex-start;gap:3px}
#order-editor .editor-line-meta small{margin:0;white-space:nowrap;font-weight:400}
#order-editor .order-line-icons{display:inline-flex;gap:6px;align-items:center}
#order-editor .order-line-icons .order-completion-icon{display:inline-flex;width:22px;height:22px;position:relative;flex:none}
#order-editor .order-line-icons:empty{display:none}
#order-editor .order-line-icons svg{width:22px;height:22px}
#order-editor .order-line-icons .is-not-shipped{color:#8693a3}
#order-editor .order-line-icons .is-returned{color:#b76820}

#order-editor .dialog-header #order-error-button {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  padding: 5px 10px;
  border: 1px solid #efb6ba;
  border-radius: 6px;
  background: #fff1f2;
  color: #a32121;
  font-weight: 600;
}
#order-error-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  box-sizing: border-box;
  overflow: auto;
  padding: 20px;
  color: #212529;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  box-shadow: 0 12px 48px #17212f33;
}
#order-error-dialog h2 { margin: 0 0 10px; font-size: 20px; color: #a32121; }
#order-error-dialog p { margin: 0 0 18px; color: #25303c; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
#order-error-dialog button { min-height: 40px; height: auto; padding: 8px 12px; }
#order-error-dialog .order-error-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
#order-error-dialog .order-error-dismiss { display: block; margin-left: auto; }
#order-editor .order-error-motion {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  display: grid;
  place-items: center;
  background: #fff1f2;
  color: #a32121;
  border-radius: 6px;
  font-weight: 600;
}

@media (min-width:801px){
 #order-editor .editor-table :is(th,td)[data-label="Код товара"]{width:1%;white-space:nowrap}
 #order-editor .editor-table tbody td{vertical-align:middle}
}
@media (max-width:800px){
 #order-editor .editor-lines .editor-table td[data-label="Код товара"]{display:block;grid-column:1/-1;grid-row:auto;order:1}
 #order-editor.order-workspace .editor-lines .editor-table td[data-label="Код товара"]{order:1;grid-column:1/-1}
 #order-editor .editor-lines .editor-table td[data-label="Код товара"]::before{display:none}
}
