/* =========================================================
   SKLADAPLAN — КОМПАКТНАЯ ГЛАВНАЯ
   Подключать ПОСЛЕ style.css и tasks.css.
   ========================================================= */

/* ---------- 1. KPI-строка ---------- */
#spDashboardHeader .sp-dash-kpis {
  gap: 8px !important;
  margin-bottom: 10px !important;
}
#spDashboardHeader .sp-dash-kpi {
  padding: 10px 12px !important;
  border-radius: 12px !important;
}
#spDashboardHeader .sp-dash-kpi-icon {
  width: 26px !important; height: 26px !important;
  font-size: 13px !important; margin-bottom: 4px !important;
  border-radius: 7px !important;
}
#spDashboardHeader .sp-dash-kpi-label { font-size: 10px !important; margin-bottom: 2px !important; }
#spDashboardHeader .sp-dash-kpi-value { font-size: 20px !important; }

/* ---------- 2. «Что требует внимания» / «Мои задачи» ---------- */
#spDashboardHeader .sp-dash-cols { gap: 10px !important; margin-bottom: 10px !important; }
#spDashboardHeader .sp-dash-block {
  padding: 12px 14px !important;
  margin-bottom: 10px !important;
  border-radius: 12px !important;
}
#spDashboardHeader .sp-dash-block-head { margin-bottom: 8px !important; font-size: 13px !important; }
#spDashboardHeader .sp-dash-attention-item { padding: 7px 9px !important; margin-bottom: 4px !important; }
#spDashboardHeader .sp-dash-task-item { padding: 6px 4px !important; }

/* ---------- 3. Виджет «Смена» ---------- */
#spShiftWidget {
  padding: 10px 14px !important;
  margin-bottom: 10px !important;
  border-radius: 12px !important;
}
#spShiftWidget .sp-sh-head { margin-bottom: 6px !important; }
#spShiftWidget .sp-sh-counter { font-size: 16px !important; }
#spShiftWidget .sp-sh-btn { padding: 8px 14px !important; font-size: 12px !important; }

/* ---------- 4. НОВАЯ ЗАЯВКА — скрыта на Главной ---------- */
body.sp-compact-dash .sp-request-card {
  display: none !important;
}

/* ---------- 5. На всякий случай — если остался старый quick-strip ---------- */
#spCompactQuickStrip {
  display: none !important;
}

/* ---------- 6. Большие карточки калькуляторов скрываем ---------- */
body.sp-compact-dash #content > .sp-grid:has(#calcBoxesQty),
body.sp-compact-dash #content > .sp-grid:has(#calcQuickInput) {
  display: none !important;
}

/* ---------- 7. Компактнее «Состояние склада» ---------- */
body.sp-compact-dash .sp-dashboard-kpi-grid { gap: 8px !important; margin-bottom: 8px !important; }
body.sp-compact-dash .sp-dashboard-kpi-grid > .sp-card { padding: 12px !important; }
body.sp-compact-dash .sp-dashboard-columns { gap: 10px !important; }

/* ---------- 8. Логи с табами ---------- */
#spCompactLogs {
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  padding: 0;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
#spCompactLogs .sp-cl-nav {
  display: flex; gap: 4px; padding: 6px 6px 0;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  overflow-x: auto; scrollbar-width: none;
}
#spCompactLogs .sp-cl-nav::-webkit-scrollbar { display: none; }
#spCompactLogs .sp-cl-tab {
  flex: 0 0 auto; border: 0; background: transparent;
  color: #64748b; font-family: inherit; font-size: 12px;
  font-weight: 600; padding: 9px 14px;
  border-radius: 9px 9px 0 0; cursor: pointer; white-space: nowrap;
}
#spCompactLogs .sp-cl-tab.is-active {
  background: #fff; color: #0f172a;
  box-shadow: -1px 0 0 #e2e8f0 inset, 1px 0 0 #e2e8f0 inset, 0 -1px 0 #e2e8f0 inset;
}
#spCompactLogs .sp-cl-body { padding: 12px 16px; }
#spCompactLogs .sp-cl-panel { display: none; }
#spCompactLogs .sp-cl-panel.is-active { display: block; }

/* Оригинальный блок «Последние события» (переехал в табы) — скрываем */
body.sp-compact-dash #spDashboardHeader .sp-dash-block:has(#spDashEvents) {
  display: none !important;
}

/* ---------- 9. Скрыть «Рабочие процессы», «Задачи», «Инструменты» ---------- */
body.sp-compact-dash #content .sp-dashboard-block {
  display: none !important;
}

/* =========================================================
   10. ПРИВЕТСТВЕННЫЙ БЛОК (рисует dashboard.js)
   ========================================================= */

#spDashboardHeader .sp-greet {
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  box-shadow: var(--shadow-card, 0 2px 6px rgba(15,23,42,.04));
  padding: 16px 20px;
  margin-bottom: 12px;
}

#spDashboardHeader .sp-greet-hello {
  font-size: 19px;
  font-weight: 700;
  color: #111;
  letter-spacing: -.01em;
  margin-bottom: 6px;
  line-height: 1.25;
}

#spDashboardHeader .sp-greet-hello b {
  color: #111;
  font-weight: 800;
}

#spDashboardHeader .sp-greet-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

#spDashboardHeader .sp-greet-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

#spDashboardHeader .sp-greet-stat b {
  color: #111;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#spDashboardHeader .sp-greet-muted {
  color: #94a3b8;
}

#spDashboardHeader .sp-greet-warn {
  color: #b42318;
  font-weight: 600;
}

#spDashboardHeader .sp-greet-warn b {
  color: #b42318;
}

@media (max-width: 700px) {
  #spDashboardHeader .sp-greet {
    padding: 14px 16px;
  }
  #spDashboardHeader .sp-greet-hello {
    font-size: 16px;
  }
  #spDashboardHeader .sp-greet-sub {
    font-size: 12px;
    gap: 5px 14px;
  }
}

/* =========================================================
   11. ПЛАВАЮЩИЙ КАЛЬКУЛЯТОР (кнопка + панель)
   ========================================================= */

#spCalcFab {
  position: fixed;
  right: 20px;
  bottom: 86px;
  z-index: 940;

  width: 54px;
  height: 54px;

  border: 0;
  border-radius: 50%;

  background: #111;
  color: #fff;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  transition: transform .15s ease, background .15s ease;

  font-family: inherit;
}
#spCalcFab:hover {
  background: #333;
  transform: translateY(-2px);
}
#spCalcFab:active {
  transform: translateY(0);
}

#spCalcPanel {
  position: fixed;
  right: 20px;
  bottom: 154px;
  z-index: 945;

  width: min(340px, calc(100vw - 40px));

  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .18);

  padding: 16px;

  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .15s ease, transform .15s ease;

  font-family: inherit;
  font-size: 13px;
}
#spCalcPanel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#spCalcPanel .sp-cp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 14px;
  color: #111;
}
#spCalcPanel .sp-cp-close {
  border: 0;
  background: transparent;
  color: #888;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
#spCalcPanel .sp-cp-close:hover {
  background: #f4f4f5;
  color: #111;
}

#spCalcPanel .sp-cp-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#spCalcPanel .sp-cp-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
#spCalcPanel .sp-cp-row {
  display: flex;
  gap: 6px;
}
#spCalcPanel input {
  flex: 1;
  min-width: 0;
  height: 38px;
  box-sizing: border-box;
  border: 1px solid #ddd;
  border-radius: 9px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
#spCalcPanel input:focus {
  border-color: #999;
}
#spCalcPanel .sp-cp-result {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #111;
}

@media (max-width: 700px) {
  #spCalcFab {
    right: 14px;
    bottom: 78px;
  }
  #spCalcPanel {
    right: 14px;
    bottom: 142px;
    width: calc(100vw - 28px);
  }
}

/* =========================================================
   ИКОНКИ В ПРИВЕТСТВЕННОМ БЛОКЕ
   Перебиваем глобальный .icon { width:100%; height:100% }
   из style.css — иначе SVG растягиваются на весь блок.
   ========================================================= */

#spDashboardHeader .sp-greet-stat {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  white-space: nowrap;
}

#spDashboardHeader .sp-greet-stat svg.icon,
#spDashboardHeader .sp-greet-stat .icon {
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  flex: 0 0 14px !important;
  display: inline-block !important;
  stroke-width: 1.9 !important;
  color: #64748b !important;
  vertical-align: middle !important;
}

#spDashboardHeader .sp-greet-warn svg.icon,
#spDashboardHeader .sp-greet-warn .icon {
  color: #b42318 !important;
}

#spDashboardHeader .sp-greet-muted svg.icon,
#spDashboardHeader .sp-greet-muted .icon {
  color: #94a3b8 !important;
}

/* =========================================================
   БАЗА — АПГРЕЙД
   ========================================================= */

/* 1. Убираем верхнюю карточку с дублирующей навигацией —
      в сайдбаре эти разделы и так есть. */
#content > .sp-card:has(> div > [data-page="dashboard"]) {
  display: none !important;
}

/* 2. Иконки-кнопки в колонке «Действия» */
.sp-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sp-row-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  flex-shrink: 0;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.sp-row-icon-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.sp-row-icon-btn:active {
  transform: scale(.96);
}

.sp-row-icon-btn .icon {
  width: 15px;
  height: 15px;
  stroke-width: 1.9;
  pointer-events: none;
}

/* Переопределяем внешний вид кнопок «История» и «Этикетка»,
   которые создают модули box-history.js и labels.js */
.sp-history-btn,
.sp-label-btn {
  width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  margin-left: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  background: #fff !important;
  color: #475569 !important;
  cursor: pointer;
  flex-shrink: 0;
}

.sp-history-btn:hover,
.sp-label-btn:hover {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

.sp-history-btn .icon,
.sp-label-btn .icon {
  width: 15px !important;
  height: 15px !important;
  stroke-width: 1.9;
}

/* 3. Кнопки-действия над таблицей — «Направление» и «Статус»
      переводим во второстепенный стиль, чтобы тёмная primary
      кнопка «В подбор» была единственным акцентом. */
#setDirectionFromBaseBtn,
#setStatusFromBaseBtn {
  background: #f1f5f9 !important;
  color: #334155 !important;
  border: 1px solid #e2e8f0 !important;
}

#setDirectionFromBaseBtn:hover:not(:disabled),
#setStatusFromBaseBtn:hover:not(:disabled) {
  background: #e2e8f0 !important;
}

#setDirectionFromBaseBtn:disabled,
#setStatusFromBaseBtn:disabled {
  background: #f8fafc !important;
  color: #94a3b8 !important;
  border-color: #eef1f4 !important;
}

/* Кнопка «В подбор» остаётся success (тёмная), но в disabled
   виде тоже не должна быть цветной. */
#markPickBtn:disabled {
  background: #f8fafc !important;
  color: #94a3b8 !important;
  border: 1px solid #eef1f4 !important;
  opacity: 1 !important;
}

#deleteSelectedBtn:disabled {
  background: #f8fafc !important;
  color: #94a3b8 !important;
  border: 1px solid #eef1f4 !important;
  opacity: 1 !important;
}

/* 4. SVG-иконки в quickToolsBar */
.quick-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quick-tool-btn .icon {
  width: 14px;
  height: 14px;
  stroke-width: 1.9;
  flex-shrink: 0;
  color: #64748b;
}

.quick-tool-btn:hover .icon {
  color: #0f172a;
}

/* =========================================================
   БАЗА — КНОПКИ ДЕЙСТВИЙ НАД ТАБЛИЦЕЙ
   Все четыре в одном стиле, акцент только у «В подбор».
   ========================================================= */

/* Общая база — единый вид для всех четырёх */
#markPickBtn,
#setDirectionFromBaseBtn,
#setStatusFromBaseBtn,
#deleteSelectedBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  min-height: 40px;
  padding: 0 14px;

  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  color: #334155;

  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;

  transition:
    background .12s ease,
    border-color .12s ease,
    color .12s ease;
}

/* Иконка ровно по центру строки, не «висит» сверху */
#markPickBtn .icon,
#setDirectionFromBaseBtn .icon,
#setStatusFromBaseBtn .icon,
#deleteSelectedBtn .icon {
  display: block;
  width: 15px;
  height: 15px;
  stroke-width: 1.9;
  flex-shrink: 0;
  margin: 0;
  vertical-align: middle;
}

/* Наведение — общий мягкий серый */
#markPickBtn:hover:not(:disabled),
#setDirectionFromBaseBtn:hover:not(:disabled),
#setStatusFromBaseBtn:hover:not(:disabled),
#deleteSelectedBtn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Активная кнопка «В подбор» — единственный тёмный акцент */
#markPickBtn:not(:disabled) {
  background: #18794e;
  border-color: #18794e;
  color: #ffffff;
}

#markPickBtn:hover:not(:disabled) {
  background: #146a43;
  border-color: #146a43;
  color: #ffffff;
}

/* «Удалить» — красный текст на белом, не кричит */
#deleteSelectedBtn:not(:disabled) {
  color: #b42318;
  border-color: #fecaca;
}

#deleteSelectedBtn:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b42318;
}

/* Disabled — все четыре одинаково бледные, ничего не «светится» */
#markPickBtn:disabled,
#setDirectionFromBaseBtn:disabled,
#setStatusFromBaseBtn:disabled,
#deleteSelectedBtn:disabled {
  background: #f8fafc !important;
  border-color: #eef1f4 !important;
  color: #94a3b8 !important;
  opacity: 1 !important;
  cursor: not-allowed;
}

/* =========================================================
   СБОРКА — КНОПКИ +/− КОЛИЧЕСТВА
   ========================================================= */

.assembly-qty-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background .12s ease, border-color .12s ease;
}

.assembly-qty-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.assembly-qty-btn:active {
  transform: scale(.96);
}

/* =========================================================
   СБОРКА — БЕЙДЖ НАПРАВЛЕНИЯ ГРУППЫ (шк)
   ========================================================= */

.assembly-group-direction-btn {
  padding: 2px 10px !important;
  border-radius: 999px !important;
  border: 1px solid #e2e8f0 !important;
  background: #f8fafc !important;
  color: #475569 !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s ease, border-color .12s ease;
}

.assembly-group-direction-btn:hover {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}