:root{font-family:Arial,Helvetica,sans-serif;color:#222;background:#e6e6e6;font-size:13px}*{box-sizing:border-box}body{margin:0;background:#e6e6e6}.topbar{min-height:48px;display:flex;align-items:center;gap:18px;padding:0 18px;background:linear-gradient(#fff3a9,#f3d45f);border-bottom:1px solid #a99b54}.topbar__title{font-weight:700;font-size:18px}.topbar__subtitle{color:#555}.topbar__user{margin-left:auto}.layout{display:grid;grid-template-columns:190px 1fr;min-height:calc(100vh - 48px)}.sidebar{background:#d8d8d8;border-right:1px solid #aaa;padding:8px}.sidebar__item{display:block;padding:8px 10px;color:#222;text-decoration:none;border:1px solid transparent}.sidebar__item:hover{background:#efefef;border-color:#aaa}.content{padding:12px;min-width:0}.auth-content{padding:50px 12px}.auth-window{max-width:560px;margin:auto}.breadcrumbs{margin-bottom:8px;color:#555}.window{background:#fff;border:1px solid #999}.window.narrow{max-width:620px}.window__head{padding:7px 10px;background:linear-gradient(#f9efae,#e8cf5e);border-bottom:1px solid #a99b54}.toolbar,.filters,.bulk-toolbar,.pagination{display:flex;gap:6px;align-items:center;padding:8px;border-bottom:1px solid #bbb;background:#ededed;flex-wrap:wrap}.pagination{border-top:1px solid #bbb;border-bottom:0;justify-content:flex-end}.btn{display:inline-block;padding:5px 10px;border:1px solid #888;background:linear-gradient(#fff,#dedede);color:#222;text-decoration:none;cursor:pointer;border-radius:0}.btn:hover{background:#fff}.btn-primary{background:linear-gradient(#fff5a8,#ebcf58);border-color:#9b8434}input,select{min-height:28px;border:1px solid #999;border-radius:0;padding:4px 6px;background:#fff}.filters input{min-width:220px}.form-grid{display:grid;grid-template-columns:150px 1fr;gap:8px 12px;align-items:center;padding:18px}.table-wrap{overflow:auto}.products-wrap{max-height:calc(100vh - 240px)}.grid{width:100%;border-collapse:collapse;background:#fff}.grid th,.grid td{border:1px solid #b9b9b9;padding:5px 6px;vertical-align:middle}.grid thead th{position:sticky;top:0;z-index:2;background:#dcdcdc;font-weight:600;white-space:nowrap}.grid tbody tr:hover{background:#fff9d9}.num{text-align:right;white-space:nowrap}.center{text-align:center}.empty{text-align:center;padding:20px!important;color:#666}.photo-cell{width:58px;text-align:center}.photo-cell img{width:46px;height:46px;object-fit:contain;display:block;margin:auto}.products-grid{min-width:1850px}.cell-input{width:80px;min-width:80px;text-align:right}.decision-cell{min-width:190px;white-space:nowrap}.sale-cell{min-width:105px}.sale-state{display:block;font-size:11px}.grid tr.row-saved td{background:#e8f6df}.grid tr.row-error td{background:#ffe1e1}.modal{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:20;padding:40px}.modal__dialog{max-width:900px;margin:auto;background:#fff;border:1px solid #777}.modal__body{padding:10px;max-height:70vh;overflow:auto}.modal__close{float:right;border:0;background:transparent;font-size:20px;cursor:pointer}.inline-form{display:inline}.link-button{border:0;background:transparent;text-decoration:underline;cursor:pointer}.error-text{color:#a40000}.stock-input{width:90px}.selected-count{min-width:90px}@media(max-width:900px){.layout{grid-template-columns:1fr}.sidebar{display:flex;flex-wrap:wrap;border-right:0;border-bottom:1px solid #aaa}}

/* Stage 5: заказы, номенклатура и отчёт продаж */
.tabs{display:flex;gap:0;border-bottom:1px solid #999;background:#e4e4e4;overflow:auto}.tab{padding:7px 12px;border-right:1px solid #aaa;color:#222;text-decoration:none;white-space:nowrap}.tab:hover{background:#f4f4f4}.tab.is-active{background:#fff7b8;font-weight:700;border-bottom:2px solid #9b8434}.tab-count{display:inline-block;min-width:20px;padding:1px 5px;margin-left:4px;text-align:center;background:#d0d0d0;border:1px solid #aaa}.orders-grid{min-width:1200px}.orders-wrap{max-height:calc(100vh - 245px)}.badge{display:inline-block;padding:2px 5px;border:1px solid #999;background:#eee;white-space:nowrap}.badge.ok{background:#e4f2dd;border-color:#7c9e6d}.badge.warn{background:#fff2c3;border-color:#b69b43}.badge.bad{background:#ffe0e0;border-color:#b56b6b;color:#8a0000}.order-info-grid{display:grid;grid-template-columns:repeat(2,minmax(200px,1fr));gap:8px;padding:8px;margin-bottom:10px;background:#eee;border:1px solid #bbb}.order-info-grid .wide{grid-column:1/-1}.order-modal__dialog{max-width:1050px}.hint-line{padding:7px 9px;background:#fffbe0;border-bottom:1px solid #bbb;color:#555}.nomenclature-grid{min-width:1700px}.nomenclature-wrap{max-height:calc(100vh - 220px)}.commission-select{min-width:245px}.metric-grid{display:grid;grid-template-columns:repeat(6,minmax(150px,1fr));gap:1px;background:#aaa;border-bottom:1px solid #aaa}.metric{padding:10px;background:#fff}.metric span{display:block;color:#666;margin-bottom:5px}.metric strong{font-size:17px}.report-charts{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:8px;background:#e7e7e7;border-bottom:1px solid #aaa}.chart-box{background:#fff;border:1px solid #aaa;padding:8px;min-width:0}.chart-title{font-weight:700;margin-bottom:5px}.chart-box canvas{display:block;width:100%;background:#fff}.report-grid{min-width:1450px}.report-wrap{max-height:calc(100vh - 430px)}.negative{color:#a00000;font-weight:700}.filters label{display:flex;align-items:center;gap:4px;white-space:nowrap}.grid small{color:#666}.nomenclature-page .cell-input{width:105px}.nomenclature-page .commission-rate{width:80px}
@media(max-width:1200px){.metric-grid{grid-template-columns:repeat(3,1fr)}.report-charts{grid-template-columns:1fr}}

.nomenclature-bulk-toolbar .js-bulk-commission-category{min-width:280px}.nomenclature-bulk-toolbar .js-bulk-commission-rate{width:90px}.nomenclature-selected-count{min-width:90px}.nomenclature-grid th:first-child,.nomenclature-grid td:first-child{width:34px;min-width:34px}

.error-line { color: #8a1f11; background: #fff0ec; border-color: #d7a39a; }

/* Stage 7: складские документы */
.compact-form{border-bottom:1px solid #aaa}.document-header{border-bottom:1px solid #aaa}.document-add-item{background:#f6f6f6;border-bottom:1px solid #aaa}.document-add-item select{min-width:420px}.grid tfoot th{background:#e8e8e8}.hint-line{color:#555}.kaspi-search-results{padding:10px;display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:7px;border-bottom:1px solid #aaa;max-height:380px;overflow:auto}.kaspi-result{display:flex;gap:8px;align-items:center;text-align:left;border:1px solid #aaa;background:#fff;padding:7px;cursor:pointer}.kaspi-result:hover,.kaspi-result.selected{background:#fff4b8;border-color:#9b8434}.kaspi-result img{width:56px;height:56px;object-fit:contain}.kaspi-result span{display:flex;flex-direction:column}.kaspi-result small{color:#666;margin-top:4px}.badge.bad{background:#f8cccc;border-color:#b55}.negative{color:#a40000;font-weight:700}
