/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  height: 38px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface2); border-color: var(--border-strong); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }

.btn-ship {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-ship:hover:not(:disabled) { background: #1f7a34; border-color: #1f7a34; }
.btn-ship--empty { opacity: .55; }

.btn-tasks {
  /* Наследуем все метрики от .btn (height: 38px, padding: 0 18px,
     display: inline-flex, align-items: center, gap: 6px) — задаём
     только variant-specific цвета и рамку, чтобы высота/ширина
     гарантированно совпадали с .btn-primary / .btn-ship. */
  background: linear-gradient(135deg, #8b3a3a 0%, #5c5c66 100%);
  color: #fff;
  border-color: #5c5c66;
}
.btn-tasks:hover:not(:disabled) {
  background: linear-gradient(135deg, #a03f3f 0%, #6b6b75 100%);
  border-color: #6b6b75;
}
.kb-ship-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .25);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.kb-tasks-pending,
.kb-tasks-active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}
.kb-tasks-pending { background: var(--warning); }
.kb-tasks-active  { background: var(--primary); }
.kb-tasks-pending[hidden],
.kb-tasks-active[hidden] { display: none; }

.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 15px; }
.btn-full { width: 100%; }

/* Три ключевые кнопки тулбара — одинаковая минимальная ширина, чтобы
   «+ Новый заказ», «📦 Отгрузки», «📋 Мои задачи» выглядели ровно. */
.toolbar > .btn-primary,
.toolbar > .btn-ship,
.toolbar > .btn-tasks {
  min-width: 160px;
  justify-content: center;
}

/* ── Form fields ────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.input, .select, textarea {
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input:focus, .select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}
.input::placeholder { color: var(--text-subtle); }

/* Поле с inline-ошибкой (aria-invalid="true") — красная рамка.
   Ставит/снимает showFormError/clearFormError (frontend/js/app.js). */
.input[aria-invalid="true"],
.select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 20%, transparent);
}
.input[aria-invalid="true"]:focus,
.select[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 30%, transparent);
}

/* Inline-блок ошибки формы, добавляемый showFormError в конец <form>. */
.alert.form-error-inline {
  margin-top: 8px;
}

/* Колонка «Позиции» в модалке «Заказы на отгрузке» (kanban.js:openShipmentsModal).
   Мелкий шрифт, перенос длинных строк в пределах ячейки, max-width чтобы
   позиции не раздували ширину таблицы на узких экранах. */
.ship-items {
  display: inline-block;
  max-width: 280px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
  white-space: normal;
  word-break: break-word;
}
.ship-items--empty {
  color: var(--text-subtle);
}

textarea { height: auto; padding: 10px 12px; resize: vertical; }

.select { appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ── Form grid ──────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-step { background: var(--primary-light); color: var(--primary); }
.badge-simple { background: var(--warning-light); color: var(--warning); }
.badge-production { background: var(--info-light); color: var(--info); }
.badge-gasket { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.badge-resale { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-awaiting-supply { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-archived { background: var(--surface2); color: var(--text-muted); }
.badge-partial  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-awaiting { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.badge-idle     { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-priority-low    { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.badge-priority-normal { background: var(--surface2); color: var(--text-muted); }
.badge-priority-high   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Имя исполнителя под бейджом этапа в списке заказов */
.executor-name {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.executor-none { margin-top: 3px; }

/* Маркер-полоса слева у строки: красная (ожидание поставки) > зелёная (исполняется) > оранжевая (простаивает) */
tr.not-executing td:first-child {
  border-left: 3px solid var(--warning);
}
tr.executing td:first-child {
  border-left: 3px solid var(--success);
}
tr.awaiting-supply td:first-child {
  border-left: 3px solid var(--danger);
}

.badge-unpaid  { background: var(--danger-light); color: var(--danger); }
.badge-partial { background: var(--warning-light); color: var(--warning); }
.badge-paid    { background: var(--success-light); color: var(--success); }
.badge-postpay { background: var(--info-light); color: var(--info); }

/* Step badges */
.step-0 { background: #f1f3f5; color: #495057; }
.step-1 { background: #e0f2fe; color: #0369a1; }
.step-2 { background: #ede9fe; color: #5b21b6; }
.step-3 { background: #dbeafe; color: #1e40af; }
.step-4 { background: #fef9c3; color: #854d0e; }
.step-5 { background: #fef3c7; color: #92400e; }
.step-6 { background: #ffedd5; color: #9a3412; }
.step-7 { background: #fce7f3; color: #9d174d; }
.step-8 { background: #d1fae5; color: #065f46; }
.step-9 { background: #dcfce7; color: #166534; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1200px; }

/* Ресайзабельная модалка (для просмотра файлов) — handle в правом нижнем углу. v0.3.25 */
.modal.modal-resizable {
  resize: both;
  overflow: auto;
  min-width: 400px;
  min-height: 300px;
  max-width: 95vw;
  max-height: 95vh;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__title { font-size: 16px; font-weight: 600; }

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 18px;
  transition: background .15s;
}
.modal__close:hover { background: var(--surface2); }

.modal__body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Section card ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Step item list ─────────────────────────────────────────────────────── */
.step-list { display: flex; flex-direction: column; gap: 6px; }
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.step-item__num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-item__done .step-item__num { background: var(--success-light); color: var(--success); }
.step-item__rejected .step-item__num { background: var(--danger-light); color: var(--danger); }
.step-item__rollback .step-item__num { background: #fef3c7; color: #92400e; }

.ship-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ship-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  flex-wrap: wrap;
}
.ship-row__name { font-weight: 600; font-size: 13px; flex: 1; min-width: 120px; }
.ship-row__qty { font-size: 12px; color: var(--text-muted); }
.ship-row__input { display: flex; align-items: center; gap: 8px; }
.ship-row__input label { font-size: 12px; color: var(--text-muted); }

.step-item__body { flex: 1; min-width: 0; }
.step-item__label { font-weight: 500; font-size: 13px; }
.step-item__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
