/**
 * ВЕРСТАК — Стили складского учёта («СТОК» мастера)
 * Тема: #0b0c0e, акцент: #e3a868, карточки: #141519
 */

/* Модальное окно и бэкдроп */
.stock-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 12, 14, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: stockFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.stock-modal-backdrop.hidden {
  display: none !important;
}

@keyframes stockFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.stock-modal-dialog {
  background: #141519;
  border: 1px solid #282a32;
  border-radius: 16px;
  width: 100%;
  max-width: 1040px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(227,168,104, 0.1);
  overflow: hidden;
  box-sizing: border-box;
}

/* Шапка модалки */
.stock-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #202228;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #101115;
}

.stock-badge-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #e3a868;
  background: rgba(227,168,104, 0.1);
  border: 1px solid rgba(227,168,104, 0.25);
  padding: 3px 10px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 6px;
}

.stock-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.stock-sub {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #8e949e;
  line-height: 1.4;
}

.stock-close-btn {
  background: #1d1f26;
  border: 1px solid #2a2d36;
  color: #8e949e;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.stock-close-btn:hover {
  background: #252832;
  color: #fff;
  border-color: #3b3f4c;
}

/* Сводная статистика склада */
.stock-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 24px;
  background: #0f1013;
  border-bottom: 1px solid #202228;
}

.stock-stat-card {
  background: #18191f;
  border: 1px solid #262933;
  padding: 12px 14px;
  border-radius: 10px;
}

.stock-stat-val {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  font-feature-settings: "tnum";
}

.stock-stat-lbl {
  font-size: 12px;
  color: #7d838f;
  margin-top: 2px;
}

/* Тулбар управления */
.stock-toolbar {
  padding: 14px 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #202228;
  background: #141519;
}

.stock-search-wrap {
  position: relative;
  flex: 1;
  max-width: 440px;
}

.stock-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.stock-search-input {
  width: 100%;
  background: #0d0e11;
  border: 1px solid #282b35;
  color: #fff;
  padding: 9px 12px 9px 36px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.stock-search-input:focus {
  border-color: #e3a868;
}

.stock-action-buttons {
  display: flex;
  gap: 8px;
}

.stock-btn-action {
  background: #1d1f26;
  border: 1px solid #2e323d;
  color: #e4e7ec;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.stock-btn-action:hover {
  background: #252933;
  border-color: #3e4453;
  color: #fff;
}

.stock-btn-invoice {
  background: #e3a868;
  border-color: #e3a868;
  color: #0b0c0e;
  font-weight: 700;
}

.stock-btn-invoice:hover {
  background: #d8fa3c;
  border-color: #d8fa3c;
  color: #0b0c0e;
}

/* Зона Drag & Drop */
.stock-dropzone-wrap {
  padding: 16px 24px;
  background: #0f1014;
  border-bottom: 1px solid #202228;
  animation: stockSlideDown 0.2s ease;
}

@keyframes stockSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stock-dropzone {
  position: relative;
  border: 2px dashed #333846;
  background: rgba(20, 21, 25, 0.6);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.stock-dropzone.drag-active {
  border-color: #e3a868;
  background: rgba(227,168,104, 0.05);
}

.stock-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.stock-drop-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.stock-drop-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.stock-drop-sub {
  margin: 4px 0 12px 0;
  font-size: 12px;
  color: #8e949e;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

.stock-drop-manual-wrap {
  margin-top: 8px;
  position: relative;
  z-index: 10;
}

.stock-btn-text-paste {
  background: transparent;
  border: none;
  color: #e3a868;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.stock-manual-text-area {
  margin-top: 10px;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.stock-raw-textarea {
  width: 100%;
  background: #0d0e11;
  border: 1px solid #282b35;
  border-radius: 8px;
  color: #fff;
  padding: 10px 12px;
  font-family: monospace;
  font-size: 12px;
  box-sizing: border-box;
  resize: vertical;
}

.stock-btn-parse-text {
  margin-top: 8px;
  background: #e3a868;
  color: #0b0c0e;
  border: none;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
}

/* Окно сверки позиций (Draft Review) */
.stock-draft-review-wrap {
  padding: 16px 24px;
  background: #171920;
  border-bottom: 1px solid #2b2f3d;
  border-left: 4px solid #e3a868;
}

.stock-draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stock-draft-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.stock-draft-count {
  font-size: 12px;
  font-weight: 700;
  background: rgba(227,168,104, 0.15);
  color: #e3a868;
  padding: 2px 8px;
  border-radius: 6px;
}

.stock-draft-table-scroll {
  max-height: 220px;
  overflow-y: auto;
}

.draft-input-qty, .draft-input-price {
  background: #0c0d10;
  border: 1px solid #333744;
  color: #fff;
  padding: 4px 6px;
  border-radius: 4px;
  width: 80px;
  font-size: 13px;
  font-weight: 600;
}

.btn-remove-draft {
  background: transparent;
  border: none;
  color: #777;
  cursor: pointer;
  font-size: 14px;
}

.btn-remove-draft:hover {
  color: #ff4d4f;
}

.stock-draft-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #242732;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stock-draft-totals {
  font-size: 13px;
  color: #ccc;
}

.stock-draft-totals strong {
  color: #e3a868;
}

.stock-draft-actions {
  display: flex;
  gap: 8px;
}

.stock-btn-cancel-draft {
  background: #20222a;
  border: 1px solid #323644;
  color: #9ba1a6;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.stock-btn-apply-draft {
  background: #e3a868;
  border: none;
  color: #0b0c0e;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

/* Табы категорий */
.stock-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  background: #101115;
  border-bottom: 1px solid #202228;
  overflow-x: auto;
}

.stock-tab {
  background: transparent;
  border: 1px solid transparent;
  color: #8e949e;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.stock-tab:hover {
  color: #fff;
  background: #181920;
}

.stock-tab.active {
  background: #1e2029;
  border-color: #333745;
  color: #e3a868;
}

/* Основная таблица склада */
.stock-table-wrap {
  flex: 1;
  overflow-y: auto;
  max-height: calc(90vh - 320px);
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.stock-table th {
  position: sticky;
  top: 0;
  background: #121317;
  color: #7d838f;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid #22252e;
  z-index: 2;
}

.stock-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #1a1b22;
  color: #e4e7ec;
  vertical-align: middle;
}

.stock-row:hover {
  background: #17181e;
}

.stock-code-cell code {
  font-family: monospace;
  font-weight: 700;
  color: #e3a868;
  background: rgba(227,168,104, 0.08);
  padding: 3px 6px;
  border-radius: 4px;
}

.stock-item-name {
  font-weight: 700;
  color: #fff;
  font-size: 13px;
}

.stock-item-desc {
  font-size: 11px;
  color: #7b818d;
  margin-top: 2px;
}

.stock-cat-pill {
  font-size: 11px;
  background: #1c1e26;
  border: 1px solid #2b2f3a;
  color: #9ba1a6;
  padding: 2px 8px;
  border-radius: 6px;
}

.stock-qty-cell {
  font-feature-settings: "tnum";
}

.stock-qty-num {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.stock-qty-num.qty-zero {
  color: #ff4d4f;
}

.stock-qty-unit {
  font-size: 11px;
  color: #777;
  margin-left: 2px;
}

.stock-price-cell {
  font-weight: 600;
  color: #ccc;
  font-feature-settings: "tnum";
}

.stock-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
}

.status-ok {
  background: rgba(39, 174, 96, 0.12);
  color: #2ecc71;
  border: 1px solid rgba(39, 174, 96, 0.25);
}

.status-low {
  background: rgba(243, 156, 18, 0.12);
  color: #f39c12;
  border: 1px solid rgba(243, 156, 18, 0.25);
}

.status-out {
  background: rgba(231, 76, 60, 0.12);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.25);
}

/* Кнопки +/- */
.stock-qty-ctrls {
  display: inline-flex;
  gap: 4px;
}

.btn-qty-minus, .btn-qty-plus {
  background: #1f212a;
  border: 1px solid #2e323f;
  color: #e4e7ec;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.btn-qty-minus:hover {
  background: #2b2e3a;
  color: #ff4d4f;
  border-color: #444a5a;
}

.btn-qty-plus:hover {
  background: #2b2e3a;
  color: #e3a868;
  border-color: #444a5a;
}

/* Интеграция с Инженерным Радаром (виджет в карточке авто) */
.vr-stock-live-widget {
  margin-top: 18px;
  background: #101115;
  border: 1px solid #262934;
  border-left: 3px solid #e3a868;
  border-radius: 10px;
  padding: 14px 16px;
}

.vr-stock-w-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.vr-stock-w-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #8e949e;
}

.vr-stock-w-status {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
}

.vr-stock-w-status.st-ok {
  background: rgba(39, 174, 96, 0.15);
  color: #2ecc71;
}

.vr-stock-w-status.st-warn {
  background: rgba(243, 156, 18, 0.15);
  color: #f39c12;
}

.vr-stock-w-status.st-err {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
}

.vr-stock-items-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.vr-stock-item-pill {
  background: #181a21;
  border: 1px solid #2a2e3b;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vr-stock-item-pill.pill-avail {
  border-color: rgba(227,168,104, 0.3);
}

.vr-stock-item-pill.pill-out {
  border-color: rgba(231, 76, 60, 0.3);
  opacity: 0.75;
}

.pill-lbl {
  color: #7b818d;
  font-size: 11px;
}

.pill-name {
  color: #fff;
}

.pill-count {
  font-weight: 700;
  color: #e3a868;
}

.vr-stock-w-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid #1a1c22;
}

.btn-radar-stock-open {
  background: transparent;
  border: none;
  color: #e3a868;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.btn-radar-stock-open:hover {
  text-decoration: underline;
}

.btn-radar-deduct-one {
  background: #1c1e26;
  border: 1px solid #2f3442;
  color: #e4e7ec;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-radar-deduct-one:hover {
  background: #252834;
  color: #fff;
  border-color: #e3a868;
}

/* Мобильная адаптация (до 640px / iPhone 390px) */
@media (max-width: 640px) {
  .stock-modal-backdrop {
    padding: 0;
  }
  .stock-modal-dialog {
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  .stock-modal-header {
    padding: 14px 16px;
  }
  .stock-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 12px 16px;
  }
  .stock-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }
  .stock-search-wrap {
    max-width: 100%;
  }
  .stock-action-buttons {
    width: 100%;
    justify-content: stretch;
  }
  .stock-btn-action {
    flex: 1;
    justify-content: center;
  }
  .stock-dropzone-wrap {
    padding: 12px 16px;
  }
  .stock-tabs {
    padding: 8px 16px;
  }
  .stock-table td, .stock-table th {
    padding: 8px 10px;
  }
}
