/* WorkLine 1.11.14 — Списания (выравнивание заголовков и кнопок), Заказы (убран дубль заголовка, кнопки по центру, перенос товаров между подразделениями) */

/* ================================================================
   10.1) Списания: «Шаблоны» и «История списаний» на одном уровне с кнопками
   ================================================================ */
#writeoffs .wo-collapsible-head {
  display: flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  gap: 6px !important;
  margin-bottom: 0 !important;
}
#writeoffs .wo-collapsible-head .collapsible-card-toggle {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 32px;
  line-height: 1.2 !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
}
#writeoffs .wo-collapsible-head .collapsible-card-toggle > span:first-child {
  flex: 0 1 auto !important;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}
#writeoffs .wo-collapsible-head .collapsible-card-chevron {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-left: 2px;
  flex: 0 0 auto;
}
#writeoffs .wo-collapsible-head .orders-small-btn {
  margin: 0 !important;
  align-self: center !important;
  height: 32px;
  min-height: 32px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px;
  padding: 0 9px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  white-space: nowrap;
  flex: 0 0 auto;
}

#writeoffs .wo-history-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  margin: 0 0 8px 0 !important;
  padding: 0 !important;
  min-height: 32px;
}
#writeoffs .wo-history-head > .wo-history-title {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#writeoffs .wo-history-head > .wo-history-title .wl-icon {
  flex: 0 0 auto;
  margin: 0 !important;
}
#writeoffs .wo-history-head .wo-history-actions {
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  gap: 5px !important;
  margin: 0 !important;
  flex: 0 0 auto !important;
}
#writeoffs .wo-history-head .wo-history-actions .orders-small-btn {
  margin: 0 !important;
  height: 32px;
  min-height: 32px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 4px;
  padding: 0 9px !important;
  font-size: 12px !important;
  line-height: 1 !important;
  white-space: nowrap;
  flex: 0 0 auto;
}
#writeoffs .wo-history-head .wo-history-actions .orders-small-btn .wl-icon {
  flex: 0 0 auto;
  margin: 0 !important;
}
#writeoffs .wo-history-head .wo-history-clear-btn {
  color: #ef4444;
  border-color: rgba(239, 68, 68, .45);
}

@media (max-width: 560px) {
  #writeoffs .wo-history-head .wo-hb {
    display: none !important;
  }
  #writeoffs .wo-history-head .wo-history-actions .orders-small-btn {
    width: 34px;
    min-width: 34px;
    padding: 0 !important;
    gap: 0;
  }
  #writeoffs .wo-history-head > .wo-history-title {
    font-size: 13.5px;
  }
}
@media (max-width: 440px) {
  #writeoffs .wo-collapsible-head {
    gap: 4px !important;
  }
  #writeoffs .wo-collapsible-head .orders-small-btn {
    height: 30px;
    min-height: 30px;
    padding: 0 7px !important;
    font-size: 11px !important;
  }
  #writeoffs .wo-collapsible-head .collapsible-card-toggle {
    min-height: 30px;
  }
}
@media (max-width: 390px) {
  #writeoffs .wo-collapsible-head .wo-bw {
    display: none !important;
  }
  #writeoffs .wo-collapsible-head .orders-small-btn {
    width: 34px;
    min-width: 34px;
    padding: 0 !important;
  }
}

/* ================================================================
   11.2 & 11.3) Заказы: без дублирующего заголовка, верхние кнопки по центру
   ================================================================ */
#orders .orders-head {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
#orders .orders-head-actions {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin: 0 auto;
}
#orders .orders-head-actions .orders-small-btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ================================================================
   11.1) Перенос / копирование товаров между подразделениями
   ================================================================ */
/* Кнопка переноса внутри редактирования одной позиции */
.orders-item-edit-actions .orders-item-move-btn {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-color: rgba(var(--primary-rgb), .38);
  color: var(--primary);
  background: rgba(var(--primary-rgb), .08);
}

/* Модалка переноса */
#orders-transfer-overlay.ot-overlay {
  z-index: 9590;
}
#orders-transfer-overlay .ot-box {
  width: min(94vw, 520px);
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: rgb(var(--card-rgb, 255, 255, 255));
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .34);
}
html[data-theme="dark"] #orders-transfer-overlay .ot-box {
  background: rgb(var(--card-rgb, 24, 27, 34));
  border-color: rgba(255, 255, 255, .14);
}
#orders-transfer-overlay .ot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px !important;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
#orders-transfer-overlay .ot-head-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
#orders-transfer-overlay .ot-head-ico {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(var(--primary-rgb), .14);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
}
#orders-transfer-overlay .ot-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}
#orders-transfer-overlay .ot-close {
  position: static !important;
  top: auto !important;
  right: auto !important;
  transform: none !important;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
}

#orders-transfer-overlay .ot-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Откуда ⇄ Куда */
.ot-route {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}
.ot-loc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ot-loc-field > span {
  font-size: 11.5px;
  font-weight: 700;
  opacity: .68;
  padding-left: 2px;
}
.ot-select {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  box-sizing: border-box;
  outline: none;
}
.ot-select:focus {
  border-color: var(--primary);
}
.ot-swap-btn {
  width: 40px;
  height: 42px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color .15s ease, transform .12s ease;
}
.ot-swap-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.ot-swap-btn:active {
  transform: scale(.93);
}

/* Переместить / Скопировать */
.ot-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(128, 128, 128, .12);
}
html[data-theme="dark"] .ot-seg {
  background: rgba(255, 255, 255, .07);
}
.ot-seg-btn {
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  opacity: .76;
  font: inherit;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, opacity .15s ease;
}
.ot-seg-btn.on {
  background: var(--primary);
  color: #fff;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
}
html[data-theme="dark"] .ot-seg-btn.on {
  color: var(--on-primary, #111318);
}
.ot-hint {
  font-size: 12.5px;
  line-height: 1.35;
  opacity: .74;
  margin-top: -6px;
}

/* Вкладки объёма: Весь каталог | По категориям | По товарам */
.ot-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.ot-tab {
  min-height: 36px;
  padding: 4px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  opacity: .72;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.ot-tab.on {
  background: rgba(var(--primary-rgb), .16);
  color: var(--primary);
  opacity: 1;
}

.ot-scope-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Режим «Весь каталог» */
.ot-all-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ot-all-stat {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ot-all-num {
  min-width: 48px;
  height: 48px;
  padding: 0 10px;
  border-radius: 14px;
  background: rgba(var(--primary-rgb), .14);
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.ot-all-desc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ot-all-desc b {
  font-size: 14.5px;
  font-weight: 800;
}
.ot-all-desc span {
  font-size: 12.5px;
  opacity: .7;
}
.ot-dup-note {
  font-size: 12.5px;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, .12);
  color: var(--text);
}
.ot-dup-note.ok {
  background: rgba(16, 185, 129, .12);
}

/* Списки категорий и товаров */
.ot-search-wrap {
  width: 100%;
}
.ot-search {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
  outline: none;
}
.ot-search:focus {
  border-color: var(--primary);
}
.ot-list-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.ot-list-meta {
  font-size: 12.5px;
  opacity: .78;
  font-variant-numeric: tabular-nums;
}
.ot-link-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  padding: 4px 6px;
  cursor: pointer;
}
.ot-check-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 290px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.ot-item-cat-hdr {
  font-size: 11.5px;
  font-weight: 800;
  opacity: .62;
  padding: 6px 4px 2px;
}
.ot-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color .14s ease, background .14s ease;
}
.ot-check-row.is-checked {
  border-color: rgba(var(--primary-rgb), .55);
  background: rgba(var(--primary-rgb), .08);
}
.ot-check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex: 0 0 auto;
  margin: 0;
}
.ot-check-name {
  flex: 1 1 0;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ot-check-count {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 700;
  opacity: .68;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ot-item-info {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ot-item-info .ot-check-name {
  flex: 0 0 auto;
  white-space: nowrap;
}
.ot-item-meta {
  font-size: 11.5px;
  opacity: .66;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ot-empty-state {
  padding: 24px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ot-empty-state.compact {
  padding: 18px 12px;
}
.ot-empty-ico {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(var(--primary-rgb), .12);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ot-empty-state b {
  font-size: 15px;
  font-weight: 800;
}
.ot-empty-state p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  opacity: .72;
  max-width: 320px;
}

/* Футер модалки */
#orders-transfer-overlay .ot-foot {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
}
#orders-transfer-overlay .ot-foot-note {
  font-size: 12px;
  text-align: center;
  opacity: .72;
  min-height: 16px;
  font-variant-numeric: tabular-nums;
}
#orders-transfer-overlay .ot-foot-actions {
  display: grid;
  grid-template-columns: 0.85fr 1.55fr;
  gap: 8px;
}
#orders-transfer-overlay .ot-foot-actions .btn-main {
  margin: 0;
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
}
#orders-transfer-overlay .ot-foot-actions .btn-main:disabled {
  opacity: .48;
  cursor: not-allowed;
}
