/* ============================================================
   Locomotive — Карточки согласований агента + раздел связок + настройки
   Минималистичный плоский (Flat) дизайн-код без теней и градиентов
   ============================================================ */

:root {
  /* Тёплый бренд (было холодный Tailwind-slate: #fff/#f8fafc/#e2e8f0/#0f172a/#64748b) —
     теперь ivory-поверхности, тёплые нейтрали, бренд-ink, чтобы раздел не выбивался
     из кремового дашборда. Инпуты остаются белыми (заданы отдельно ниже). */
  --loco-surface: #FFFBF1;
  --loco-elev: #F6EFDE;
  --loco-border: rgba(124, 58, 237, 0.12);
  --loco-text: #1f2430;
  --loco-muted: #5b6472;
  --loco-accent: #7c3aed;
  --loco-accent-weak: rgba(124, 58, 237, 0.08);
  --loco-warn: #b45309;
  --loco-warn-weak: #fffbeb;
  --loco-warn-border: #fde68a;
  --loco-ok: #16a34a;
  --loco-ok-weak: #f0fdf4;
  --loco-error: #dc2626;
  --loco-error-weak: #fef2f2;
  --loco-radius: 12px;
}

/* ---------- Карточка согласования в чате ---------- */
.loco-card {
  border: 1px solid var(--loco-border) !important;
  border-radius: var(--loco-radius) !important;
  padding: 18px 20px !important;
  margin: 6px 0 8px;
  background: var(--loco-surface) !important;
  max-width: 560px;
  color: var(--loco-text) !important;
  box-shadow: none !important;
}

.loco-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.loco-badge {
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase;
  padding: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  color: var(--loco-muted) !important;
  flex-shrink: 0;
  box-shadow: none !important;
}

.loco-title {
  font-weight: 600 !important;
  font-size: 15px !important;
  color: var(--loco-text) !important;
}

.loco-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
  gap: 12px 20px !important;
  margin: 14px 0 !important;
}

.loco-fact {
  display: flex;
  flex-direction: column;
  gap: 2px !important;
  background: none !important;
  border: none !important;
  padding: 0 !important;
}

.loco-fact-label {
  font-size: 11px !important;
  opacity: 1 !important;
  font-weight: 500 !important;
  color: var(--loco-muted) !important;
}

.loco-fact-value {
  font-size: 15.5px !important;
  font-weight: 600 !important;
  color: var(--loco-text) !important;
  font-variant-numeric: tabular-nums;
}

.loco-fact-hint {
  font-size: 11px !important;
  opacity: 1 !important;
  color: var(--loco-muted) !important;
}

.loco-proposal {
  margin: 12px 0 4px !important;
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: var(--loco-text) !important;
}

.loco-forecast {
  font-size: 12px !important;
  opacity: 1 !important;
  color: var(--loco-muted) !important;
  margin-bottom: 6px;
}

.loco-warning {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 10px 0 !important;
  padding: 10px 12px !important;
  border-radius: 8px !important;
  font-size: 12.5px !important;
  line-height: 1.45 !important;
  color: var(--loco-warn) !important;
  background: var(--loco-warn-weak) !important;
  border: 1px solid var(--loco-warn-border) !important;
}

.loco-alert .loco-warning { margin-top: 4px; }

/* ---------- Кнопки в карточке ---------- */
.loco-actions {
  display: flex;
  gap: 8px !important;
  margin-top: 16px !important;
  flex-wrap: wrap;
}

.loco-btn {
  appearance: none;
  border: 1px solid var(--loco-border) !important;
  border-radius: 8px !important;
  padding: 7px 16px !important;
  font-size: 13px !important;
  font-weight: 550 !important;
  cursor: pointer;
  background: transparent !important;
  color: var(--loco-text) !important;
  box-shadow: none !important;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.loco-btn:hover { background: var(--loco-elev) !important; }
.loco-btn:disabled { opacity: .45; cursor: default; }
.loco-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--loco-accent-weak); }

.loco-btn-yes {
  background: var(--loco-accent) !important;
  border-color: var(--loco-accent) !important;
  color: #fff !important;
}

.loco-btn-yes:hover { background: var(--loco-accent) !important; filter: brightness(.95); }

.loco-btn-no {
  border-color: var(--loco-border) !important;
  color: var(--loco-muted) !important;
  background: transparent !important;
}

.loco-btn-no:hover {
  color: var(--loco-error) !important;
  background: var(--loco-error-weak) !important;
  border-color: rgba(220, 38, 38, 0.2) !important;
}

.loco-btn-custom {
  border-color: transparent !important;
  color: var(--loco-accent) !important;
}
.loco-btn-custom:hover {
  background: var(--loco-accent-weak) !important;
}

/* «Другой шаг» — инлайн-ряд с числовым вводом */
.loco-custom-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.loco-custom-row[hidden] { display: none; }

.loco-custom-input {
  width: 130px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--loco-border) !important;
  background: var(--loco-surface) !important;
  color: var(--loco-text) !important;
  font-size: 13px;
}

.loco-custom-input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--loco-accent-weak);
  border-color: var(--loco-accent);
}

.loco-custom-input.loco-invalid {
  border-color: var(--loco-error) !important;
  outline: none;
}

/* ---------- Резолюция ---------- */
.loco-resolved {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--loco-border);
  font-size: 13px;
  font-weight: 500;
  color: var(--loco-muted);
}

.loco-card[data-status="approved"] .loco-resolved,
.loco-card[data-status="executed"] .loco-resolved,
.loco-card[data-status="countered"] .loco-resolved { color: var(--loco-ok) !important; }

.loco-card[data-status="declined"] .loco-resolved { color: var(--loco-error) !important; }
.loco-card[data-status="expired"] .loco-resolved { color: var(--loco-warn) !important; }

.loco-card:not([data-status="pending"]) .loco-actions,
.loco-card:not([data-status="pending"]) .loco-custom-row { display: none; }

.loco-resolved[hidden] { display: none; }

/* ---------- Бейдж непрочитанного в сайдбаре ---------- */
.loco-unread-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--loco-accent) !important;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

/* ---------- Бар связки над сообщениями ---------- */
.loco-bundle-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 0 0 8px;
  border: 1px solid var(--loco-border) !important;
  border-radius: 10px;
  background: var(--loco-elev) !important;
  font-size: 13px;
  flex-wrap: wrap;
}

.loco-bundle-bar[hidden] { display: none; }

.loco-bar-title { font-weight: 600; color: var(--loco-text); }

.loco-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--loco-border);
  color: var(--loco-muted);
}

.loco-chip.loco-chip-dry { background: var(--loco-warn-weak); color: var(--loco-warn); }
.loco-chip.loco-chip-live { background: var(--loco-ok-weak); color: var(--loco-ok); }
.loco-chip.loco-chip-paused { background: var(--loco-error-weak); color: var(--loco-error); }

.loco-bar-settings {
  margin-left: auto;
  appearance: none;
  border: 1px solid var(--loco-border);
  background: transparent;
  color: var(--loco-text);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}

.loco-bar-settings:hover { background: var(--loco-border); }

/* ---------- Модал настроек ---------- */
#locoSettingsModal .modal-content {
  max-width: 560px;
  width: calc(100vw - 32px);
}

#locoSettingsForm {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px 14px;
  align-items: center;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 4px;
}

.loco-set-label {
  font-size: 13px;
  line-height: 1.3;
  color: var(--loco-text);
}

.loco-set-label small {
  display: block;
  color: var(--loco-muted);
  font-size: 11px;
}

.loco-set-input,
#locoSettingsForm select {
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--loco-border);
  background: var(--loco-surface);
  color: var(--loco-text);
  font-size: 13px;
  width: 100%;
}

.loco-set-input.loco-invalid { border-color: var(--loco-error); }

.loco-set-row-toggle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--loco-warn-border);
  background: var(--loco-warn-weak);
}

.loco-set-row-toggle .loco-set-label { font-weight: 600; color: var(--loco-warn); }

/* ---------- Журнал решений ---------- */
.loco-log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 56vh;
  overflow-y: auto;
  font-size: 13px;
}

.loco-log-row {
  display: grid;
  grid-template-columns: 84px 200px 1fr;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--loco-elev);
  align-items: baseline;
}

.loco-log-time { color: var(--loco-muted); font-size: 11.5px; white-space: nowrap; }
.loco-log-action { font-weight: 600; color: var(--loco-text); }
.loco-log-detail { color: var(--loco-text); opacity: .8; word-break: break-word; }

@media (max-width: 900px) {
  .loco-facts { grid-template-columns: 1fr; }
  #locoSettingsForm { grid-template-columns: 1fr; }
  .loco-card { max-width: 100%; }
  .loco-log-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ============================================================
   Locomotive — ОТДЕЛЬНЫЙ РАЗДЕЛ (вкладка): обзор, онбординг,
   мастер, деталь.
   ============================================================ */

/* бейдж на вкладке */
.loco-tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; background: var(--loco-warn); color: #fff;
  font-size: 11px; font-weight: 700; animation: loco-pulse 2s infinite;
}
@keyframes loco-pulse { 0%,100%{opacity:1} 50%{opacity:.55} }
.loco-tab-badge[hidden] { display: none; }

/* онбординг */
.loco-empty-hero {
  max-width: 640px; margin: 24px auto; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.loco-empty-icon {
  width: 88px; height: 88px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--loco-elev); color: var(--loco-accent);
}
.loco-empty-title { font-size: 22px; font-weight: 600; margin: 0; color: var(--loco-text); }
.loco-empty-lead { font-size: 14.5px; line-height: 1.5; color: var(--loco-muted); margin: 0; max-width: 540px; }
.loco-how-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; width: 100%; margin: 6px 0; }
.loco-how-step {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 12px;
  border: 1px solid var(--loco-border); border-radius: 12px;
  background: var(--loco-surface); font-size: 12.5px;
  color: var(--loco-text);
}
.loco-how-step b { font-size: 13.5px; color: var(--loco-text); }
.loco-how-step span { color: var(--loco-muted); }
.loco-how-emoji { font-size: 24px; }
.loco-safe-note {
  width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.45;
  color: var(--loco-warn) !important;
  background: var(--loco-warn-weak) !important; border: 1px solid var(--loco-warn-border) !important;
}
.loco-glossary { width: 100%; text-align: left; font-size: 13px; margin-top: 4px; }
.loco-glossary summary { cursor: pointer; font-weight: 600; color: var(--loco-text); padding: 6px 0; }
.loco-glossary p { margin: 6px 0; color: var(--loco-muted); line-height: 1.4; }

/* карточка связки в обзоре */
.loco-tile { cursor: pointer; display: flex; gap: 14px; align-items: center; }
.loco-card-photo {
  width: 64px; height: 64px; flex-shrink: 0; border-radius: 8px; object-fit: cover;
  background: var(--loco-elev);
}
.loco-photo-empty { display: flex; align-items: center; justify-content: center; font-size: 26px; }
.loco-tile-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.loco-tile-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--loco-text); }
.loco-metric-mini { font-size: 12px; color: var(--loco-muted); }
.loco-muted { color: var(--loco-muted); }

/* строка-светофор */
.loco-status-line { font-size: 13px; font-weight: 600; }
.loco-status-line.is-approval { color: var(--loco-warn); }
.loco-status-line.is-stockstop { color: var(--loco-warn); }
.loco-status-line.is-paused { color: var(--loco-muted); }
.loco-status-line.is-archived { color: var(--loco-muted); }
.loco-status-line.is-dry { color: var(--loco-accent); }
.loco-status-line.is-ok { color: var(--loco-ok); }
.loco-status-big { font-size: 15px; }

/* стопка «нужен ответ» */
.loco-attention-stack { margin-bottom: 20px; }
.loco-attention-head { font-weight: 600; font-size: 14px; margin-bottom: 10px; color: var(--loco-text); }
.loco-needs-answer { border: 1px solid var(--loco-border) !important; box-shadow: none !important; margin-bottom: 12px; }
.loco-needs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; margin-bottom: 8px; color: var(--loco-text); }

/* деталь */
.loco-back { display: inline-flex; cursor: pointer; font-weight: 600; color: var(--loco-muted); padding: 4px 0 12px; transition: color .15s; }
.loco-back:hover { color: var(--loco-accent); }
.loco-detail { display: flex; flex-direction: column; gap: 18px; }
.loco-detail-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.loco-detail-photo { width: 56px; height: 56px; }
.loco-detail-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.loco-detail-name { font-size: 18px; font-weight: 600; color: var(--loco-text); }
.loco-quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.loco-detail-approval { border: 1px solid var(--loco-border); border-radius: 12px; padding: 12px 14px; background: var(--loco-surface); }
.loco-detail-approval-head { font-weight: 600; margin-bottom: 8px; color: var(--loco-warn); }

.loco-mode-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; font-size: 13px; flex-wrap: wrap; }
.loco-mode-banner.is-dry { background: var(--loco-accent-weak); border: 1px solid var(--loco-border); color: var(--loco-text); }
.loco-mode-banner.is-live { background: var(--loco-ok-weak); border: 1px solid var(--loco-border); color: var(--loco-text); }

/* таймлайн */
.loco-timeline { display: flex; gap: 6px; }
.loco-phase { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px; border-radius: 12px; text-align: center; border: 1px solid transparent; position: relative; }
.loco-phase:not(:last-child)::after { content: ''; position: absolute; top: 50%; right: -6px; width: 6px; height: 2px; background: var(--loco-border); }
.loco-phase-emoji { font-size: 22px; filter: grayscale(.6); opacity: .5; }
.loco-phase-name { font-size: 11.5px; color: var(--loco-muted); }
.loco-phase.is-done .loco-phase-emoji, .loco-phase.is-done .loco-phase-name { opacity: .85; filter: none; }
.loco-phase.is-current { background: var(--loco-accent-weak); border-color: var(--loco-border); }
.loco-phase.is-current .loco-phase-emoji { filter: none; opacity: 1; }
.loco-phase.is-current .loco-phase-name { color: var(--loco-text); font-weight: 600; }
.loco-substate { font-size: 12.5px; color: var(--loco-muted); text-align: center; margin-top: -8px; }
.loco-substate-stock { color: var(--loco-warn); font-weight: 600; }

.loco-now { font-size: 15px; line-height: 1.5; padding: 14px 16px; border-radius: 12px; background: var(--loco-surface); border: 1px solid var(--loco-border); color: var(--loco-text); }

/* метрики */
.loco-metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.loco-metric { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--loco-border); background: var(--loco-surface); }
.loco-metric-label { font-size: 11px; color: var(--loco-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.loco-metric-value { font-size: 19px; font-weight: 700; margin: 2px 0; color: var(--loco-text); }
.loco-metric-sub { font-size: 11.5px; color: var(--loco-muted); }

/* товары связки */
.loco-skus, .loco-log-preview { border: 1px solid var(--loco-border); border-radius: 12px; padding: 12px 14px; background: var(--loco-surface); }
.loco-skus-head { font-weight: 600; margin-bottom: 8px; }
.loco-sku { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--loco-border); color: var(--loco-text); }
.loco-sku:first-of-type { border-top: none; }
.loco-sku-role { font-weight: 600; }
.loco-sku-id, .loco-sku-stock { color: var(--loco-muted); font-size: 12px; }
.loco-sku-price { font-weight: 600; }
.loco-sku-floor { font-size: 12px; color: var(--loco-ok); }
.loco-sku-cost-btn, .loco-linklike { background: none; border: none; color: var(--loco-accent); cursor: pointer; font-size: 12.5px; padding: 0; text-decoration: underline; }
.loco-cogs-box { display: inline-flex; gap: 6px; align-items: center; }
.loco-cogs-input { width: 110px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--loco-border); background: transparent; color: var(--loco-text); }
.loco-cogs-warn { font-size: 12.5px; color: var(--loco-warn); margin-top: 6px; }
.loco-logp-row { display: flex; gap: 10px; font-size: 12.5px; padding: 3px 0; color: var(--loco-text); }
.loco-logp-time { color: var(--loco-muted); white-space: nowrap; }
.loco-danger-zone { text-align: right; }

/* мастер */
.loco-wizard-content { max-width: 760px; width: calc(100vw - 32px); }
.loco-wizard-steps { display: flex; gap: 10px; padding: 0 24px 14px; }
.loco-wizard-step { font-size: 12.5px; font-weight: 600; opacity: .4; color: var(--loco-text); }
.loco-wizard-step.is-active { opacity: 1; color: var(--loco-accent); }
.loco-wizard-step.is-done { opacity: .7; }
.loco-wizard-hint { font-size: 13px; color: var(--loco-muted); margin: 0 0 10px; }
.loco-catalog-search { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--loco-border); background: var(--loco-surface); color: var(--loco-text); font-size: 13.5px; margin-bottom: 12px; }
.loco-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.loco-pick-card { position: relative; cursor: pointer; border: 1px solid var(--loco-border); border-radius: 12px; padding: 8px; background: var(--loco-surface); transition: border-color .15s; }
.loco-pick-card:hover { border-color: var(--loco-muted); }
.loco-pick-card.is-selected { border-color: var(--loco-accent); box-shadow: 0 0 0 3px var(--loco-accent-weak); }
.loco-pick-card.is-exists { opacity: .55; }
.loco-pick-photo { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--loco-elev); }
.loco-pick-photo.loco-photo-empty { display: flex; align-items: center; justify-content: center; font-size: 30px; }
.loco-pick-badge { position: absolute; top: 12px; left: 12px; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--loco-muted); color: #fff; }
.loco-pick-check { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 50%; background: var(--loco-accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.loco-pick-name { font-size: 12.5px; font-weight: 600; margin-top: 6px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--loco-text); }
.loco-pick-meta { font-size: 11px; color: var(--loco-muted); margin-top: 2px; }
.loco-pick-skel { aspect-ratio: .8; border-radius: 12px; background: linear-gradient(90deg, var(--loco-elev), var(--loco-border), var(--loco-elev)); background-size: 200% 100%; animation: loco-shimmer 1.4s infinite; }
@keyframes loco-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.loco-empty-inline { grid-column: 1/-1; text-align: center; color: var(--loco-muted); padding: 30px 16px; font-size: 13.5px; }
.loco-review-card { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 12px; border: 1px solid var(--loco-border); margin-bottom: 14px; background: var(--loco-surface); }
.loco-review-card img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }
.loco-review-name { font-weight: 650; margin-bottom: 4px; color: var(--loco-text); }
.loco-advanced-toggle { display: inline-block; margin: 14px 0 8px; color: var(--loco-accent); cursor: pointer; text-decoration: underline; }
.loco-advanced-inline { display: grid; gap: 12px; padding: 12px; border-radius: 12px; background: var(--loco-elev); border: 1px solid var(--loco-border); }
.loco-adv-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--loco-text); }
.loco-adv-field input { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--loco-border); background: var(--loco-surface); color: var(--loco-text); font-size: 13.5px; }
.loco-golive-check { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13.5px; font-weight: 600; color: var(--loco-text); }

/* мобильная адаптация */
@media (max-width: 900px) {
  .loco-how-grid { grid-template-columns: 1fr; }
  .loco-pick-grid { grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); }
  .loco-timeline {
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* 5 фаз не влезают в узкий контейнер → раньше последняя карточка резалась
       жёстко у края. Мягкий fade справа читается как «есть ещё, прокрути». */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
  }
  .loco-phase { min-width: 78px; }
  .loco-detail-head { flex-direction: column; align-items: flex-start; }
  .loco-quick-actions { width: 100%; }
}

/* ---------- полировка контраста + раскладка карточки ---------- */
.bot-card-glass.loco-tile { flex-direction: row !important; text-align: left; }

/* ==========================================================================
   Связка-плитки переиспользуют .bot-card-glass, у которой
   общий :hover красит фон тёмным. Держим фон светлым.
   ========================================================================== */
#locomotiveView .bot-card-glass.loco-tile:hover,
#locomotiveView .bot-card-glass.loco-needs-answer:hover,
.bot-card-glass.loco-tile:hover,
.bot-card-glass.loco-needs-answer:hover {
  background: var(--loco-elev) !important;
  border-color: var(--loco-muted) !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
}

/* ==========================================================================
   MINIMALIST FLAT REDESIGN — список связок + заголовок.
   ========================================================================== */

/* --- Карточка связки в списке --- */
#locomotiveView .bots-cards-grid { gap: 10px !important; }

/* thumbnail — плоский пастельный цвет по фазе */
#locomotiveView .loco-thumb {
  width: 48px; height: 48px; flex-shrink: 0; border-radius: 8px;
  object-fit: cover; display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: none !important;
}
#locomotiveView .loco-thumb-empty.loco-ph-prep       { background: #eff6ff; }
#locomotiveView .loco-thumb-empty.loco-ph-semantics  { background: #f5f3ff; }
#locomotiveView .loco-thumb-empty.loco-ph-conversion { background: #f0fdf4; }
#locomotiveView .loco-thumb-empty.loco-ph-scale      { background: #fff7ed; }
#locomotiveView .loco-thumb-empty.loco-ph-stock_stop,
#locomotiveView .loco-tile.is-paused .loco-thumb-empty { background: var(--loco-elev); }

/* тело */
#locomotiveView .loco-tile-body { display: flex !important; flex-direction: column !important; gap: 8px !important; min-width: 0; flex: 1; }
#locomotiveView .loco-tile-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#locomotiveView .loco-tile-name {
  font-size: 14.5px; font-weight: 600; color: var(--loco-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* phase pill — плоский неброский статус-бейдж */
#locomotiveView .loco-phase-pill {
  flex-shrink: 0; font-size: 11px; font-weight: 550; padding: 3px 9px;
  border-radius: 999px; white-space: nowrap; line-height: 1.3;
}
#locomotiveView .loco-phase-pill.loco-ph-prep       { background: #eff6ff; color: #1d4ed8; }
#locomotiveView .loco-phase-pill.loco-ph-semantics  { background: #f5f3ff; color: #6d28d9; }
#locomotiveView .loco-phase-pill.loco-ph-conversion { background: #f0fdf4; color: #15803d; }
#locomotiveView .loco-phase-pill.loco-ph-scale      { background: #fff7ed; color: #c2410c; }
#locomotiveView .loco-phase-pill.loco-ph-stock_stop,
#locomotiveView .loco-phase-pill.is-paused,
#locomotiveView .loco-phase-pill.is-archived { background: var(--loco-elev); color: var(--loco-muted); }
#locomotiveView .loco-phase-pill.is-dry { background: #f5f3ff; color: #6d28d9; }
#locomotiveView .loco-phase-pill.is-approval,
#locomotiveView .loco-phase-pill.is-stockstop { background: var(--loco-warn-weak); color: var(--loco-warn); }

/* индикатор фаз */
#locomotiveView .loco-steps { display: flex; gap: 4px; }
#locomotiveView .loco-step { height: 3px; flex: 1; border-radius: 999px; background: var(--loco-border); }
#locomotiveView .loco-step.is-on { background: var(--loco-accent) !important; opacity: 1; }
#locomotiveView .loco-steps.is-paused .loco-step.is-on { background: var(--loco-muted) !important; }

/* низ карточки */
#locomotiveView .loco-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#locomotiveView .loco-metric-mini { font-size: 12px; font-weight: 550; color: var(--loco-text); }
#locomotiveView .loco-metric-mini.loco-muted { color: var(--loco-muted); font-weight: 500; }
#locomotiveView .loco-tile-go {
  font-size: 12px; color: var(--loco-accent);
  opacity: 0; transform: translateX(-4px); transition: opacity 0.2s ease, transform 0.2s ease;
}
#locomotiveView .loco-tile:hover .loco-tile-go { opacity: 1; transform: translateX(0); }

/* заголовок */
#locomotiveView .bots-page-title { font-size: 24px; font-weight: 600; color: var(--loco-text); }
#locomotiveView .bots-page-subtitle { font-size: 13px; color: var(--loco-muted); margin-top: 3px; }

/* стопка «нужен ответ» */
#locomotiveView .loco-attention-head { font-size: 14px; font-weight: 600; }
#locomotiveView .bot-card-glass.loco-needs-answer {
  border: 1px solid var(--loco-warn-border) !important;
  background: var(--loco-warn-weak) !important;
  box-shadow: none !important;
  border-radius: var(--loco-radius) !important;
}

/* мобильная адаптация карточки */
@media (max-width: 900px) {
  #locomotiveView .loco-tile-top { flex-direction: column; align-items: flex-start; gap: 6px; }
  #locomotiveView .loco-tile-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  #locomotiveView .loco-phase-pill { white-space: normal; max-width: 100%; align-self: flex-start; }
  #locomotiveView .loco-tile-go { opacity: 1; transform: none; }
  #locomotiveView .bots-page-title { font-size: 21px; }
}

/* ==========================================================================
   MINIMALIST FLAT — деталь связки + онбординг.
   ========================================================================== */
#locomotiveView .loco-detail { gap: 16px; }
#locomotiveView .loco-back { font-size: 13px; color: var(--loco-muted); font-weight: 600; }
#locomotiveView .loco-back:hover { color: var(--loco-accent); }
#locomotiveView .loco-detail-name { font-size: 18px; font-weight: 600; color: var(--loco-text); }
#locomotiveView .loco-detail-photo { width: 48px !important; height: 48px !important; border-radius: 8px; }

/* timeline */
#locomotiveView .loco-timeline { gap: 6px; }
#locomotiveView .loco-phase { border-radius: var(--loco-radius); padding: 12px 6px; border: 1px solid var(--loco-border); background: var(--loco-surface); }
#locomotiveView .loco-phase.is-current {
  background: var(--loco-accent-weak) !important; border-color: var(--loco-accent) !important;
  box-shadow: none !important;
}

/* единые карточки: now-line / метрики / товары / журнал */
#locomotiveView .loco-now,
#locomotiveView .loco-metric,
#locomotiveView .loco-skus,
#locomotiveView .loco-log-preview {
  border-radius: var(--loco-radius) !important;
  border: 1px solid var(--loco-border) !important;
  background: var(--loco-surface) !important;
  box-shadow: none !important;
}
#locomotiveView .loco-now { font-size: 14.5px; line-height: 1.5; color: var(--loco-text); }
#locomotiveView .loco-metric-label { font-size: 10px; color: var(--loco-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
#locomotiveView .loco-mode-banner { border-radius: var(--loco-radius); padding: 10px 14px; border: 1px solid var(--loco-border) !important; }
#locomotiveView .loco-detail-approval { border-radius: var(--loco-radius); border: 1px solid var(--loco-warn-border); background: var(--loco-warn-weak); }

/* онбординг */
#locomotiveView .loco-how-grid > * { border-radius: var(--loco-radius); border: 1px solid var(--loco-border); background: var(--loco-surface); }

/* доступность */
@media (prefers-reduced-motion: reduce) {
  .loco-tab-badge, .loco-pick-skel { animation: none !important; }
}

/* ============================================================
   LOCOMOTIVE — РАСКЛАДКА РАЗДЕЛА
   ============================================================ */
#locomotiveView .bots-page-wrapper {
  flex: 0 1 auto !important;
  width: min(880px, 100%) !important;
  max-width: 880px !important;
  margin-inline: auto !important;
  padding: 8px 20px 40px !important;
}
#locomotiveView .bots-page-header { margin-bottom: 18px !important; }

/* обзор */
#locomotiveView #locoList,
#locomotiveView #locoList.bots-cards-grid {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
}
#locomotiveView .bot-card-glass.loco-tile {
  display: flex !important;
  align-items: center;
  gap: 14px;
  padding: 12px 16px !important;
  min-height: auto;
  border: 1px solid var(--loco-border) !important;
  box-shadow: none !important;
  border-radius: var(--loco-radius) !important;
  background: var(--loco-surface) !important;
  transition: background 0.15s ease, border-color 0.15s ease !important;
}
#locomotiveView .loco-thumb { width: 48px !important; height: 48px !important; border-radius: 8px; flex-shrink: 0; }
#locomotiveView .loco-tile-go { font-weight: 500; }

/* деталь */
#locomotiveView .loco-detail { max-width: 100% !important; }
#locomotiveView .loco-metrics { grid-template-columns: repeat(3, 1fr) !important; gap: 10px !important; }

/* CTA Locomotive */
#locomotiveView .bots-add-btn,
#locomotiveView .btn-primary {
  background: var(--loco-accent) !important;
  background-image: none !important;
  box-shadow: none !important;
  border: none !important;
  color: #fff !important;
  border-radius: 8px !important;
}
#locomotiveView .bots-add-btn:hover,
#locomotiveView .btn-primary:hover { filter: brightness(.95); background: var(--loco-accent) !important; }
#locomotiveView .loco-mode-banner .btn-primary { font-weight: 600; }

/* ==========================================================================
   POLISH — деталь связки: таблица товаров, степпер, KPI, журнал, now-line.
   Минимализм сохранён: плоско, без теней/градиентов, светлая тема.
   ========================================================================== */

/* «Что сейчас» — главная строка состояния: лёгкий акцент слева */
#locomotiveView .loco-now {
  border-left: 3px solid var(--loco-accent) !important;
  padding: 13px 16px 13px 15px;
  font-weight: 500;
}
#locomotiveView .loco-now-sub {
  display: block; margin-top: 7px;
  font-size: 12.5px; font-weight: 400; line-height: 1.45;
  color: var(--loco-muted);
}
#locomotiveView .loco-now-act { color: var(--loco-warn); font-weight: 600; }

/* KPI-метрики: значение — герой, единая высота, аккуратные пустые состояния */
#locomotiveView .loco-metric {
  display: flex; flex-direction: column; gap: 3px;
  padding: 13px 15px !important; min-height: 80px; justify-content: center;
}
#locomotiveView .loco-metric-label { letter-spacing: .04em; }
#locomotiveView .loco-metric-value {
  font-size: 20px !important; font-weight: 700; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
#locomotiveView .loco-metric-sub { font-size: 11.5px; }

/* Степпер фаз: пройденные — полноцветные, соединитель — акцентный */
#locomotiveView .loco-phase.is-done .loco-phase-emoji { opacity: .92; filter: none; }
#locomotiveView .loco-phase.is-done .loco-phase-name { color: var(--loco-text); opacity: .85; }
#locomotiveView .loco-phase.is-done::after { background: var(--loco-accent); opacity: .45; }
#locomotiveView .loco-substate {
  margin-top: 2px; padding: 6px 12px; display: inline-block;
  border-radius: 999px; background: var(--loco-accent-weak); color: var(--loco-accent);
  font-weight: 600;
}
#locomotiveView .loco-substate-stock { background: var(--loco-warn-weak); color: var(--loco-warn); }

/* Товары связки — выровненная мини-таблица */
#locomotiveView .loco-skus-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--loco-muted); }
#locomotiveView .loco-sku {
  display: grid !important;
  grid-template-columns: 138px minmax(92px, 1fr) 78px minmax(118px, auto) 58px;
  gap: 8px 14px; align-items: center;
  padding: 9px 10px; margin: 0 -10px;
  border-top: 1px solid var(--loco-border);
  border-radius: 8px; font-size: 13px;
}
#locomotiveView .loco-sku:first-of-type { border-top: none; }
#locomotiveView .loco-sku.is-loco { background: var(--loco-accent-weak); }
#locomotiveView .loco-sku.is-loco + .loco-sku { border-top-color: transparent; }
#locomotiveView .loco-sku-role { display: inline-flex; align-items: center; gap: 6px; color: var(--loco-muted); font-weight: 500; }
#locomotiveView .loco-sku.is-loco .loco-sku-role { color: var(--loco-accent); font-weight: 600; }
#locomotiveView .loco-sku-tag { font-size: 15px; line-height: 1; }
#locomotiveView .loco-sku-id { color: var(--loco-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#locomotiveView .loco-sku-price { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
#locomotiveView .loco-sku-extra { justify-self: start; }
#locomotiveView .loco-sku-stock { text-align: right; color: var(--loco-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#locomotiveView .loco-sku-floor { color: var(--loco-ok); font-size: 12px; white-space: nowrap; }
#locomotiveView .loco-sku-cost-btn {
  text-decoration: none !important;
  border: 1px solid var(--loco-border); border-radius: 999px;
  padding: 5px 13px; font-size: 12px; color: var(--loco-accent);
  background: var(--loco-surface); white-space: nowrap; transition: background .15s ease;
}
#locomotiveView .loco-sku-cost-btn:hover { background: var(--loco-accent-weak); }
#locomotiveView .loco-sku.is-editing .loco-sku-cost-btn { display: none; }

/* Инлайн-редактор себестоимости — на всю ширину строки, удобный */
#locomotiveView .loco-sku .loco-cogs-box {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 8px; padding: 10px 12px;
  background: var(--loco-elev); border: 1px solid var(--loco-border);
  border-radius: 10px;
}
#locomotiveView .loco-sku .loco-cogs-label { font-size: 12.5px; color: var(--loco-muted); }
#locomotiveView .loco-sku .loco-cogs-field {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--loco-border); border-radius: 8px;
  background: var(--loco-surface); padding: 0 10px 0 0;
}
#locomotiveView .loco-sku .loco-cogs-field:focus-within { border-color: var(--loco-accent); box-shadow: 0 0 0 3px var(--loco-accent-weak); }
#locomotiveView .loco-sku .loco-cogs-input {
  width: 92px; padding: 8px 10px; border: none !important; background: transparent !important;
  color: var(--loco-text); font-size: 14px; text-align: right; outline: none;
}
#locomotiveView .loco-sku .loco-cogs-unit { font-size: 13px; color: var(--loco-muted); }
#locomotiveView .loco-sku .loco-cogs-ok { padding: 7px 16px !important; }
#locomotiveView .loco-sku .loco-cogs-cancel {
  appearance: none; border: none; background: none; cursor: pointer;
  color: var(--loco-muted); font-size: 12.5px; padding: 7px 6px;
}
#locomotiveView .loco-sku .loco-cogs-cancel:hover { color: var(--loco-text); }

@media (max-width: 760px) {
  #locomotiveView .loco-sku .loco-cogs-box { margin-top: 4px; }
  #locomotiveView .loco-sku .loco-cogs-field { flex: 1; }
  #locomotiveView .loco-sku .loco-cogs-input { flex: 1; width: auto; }
}

/* ==========================================================================
   ПОДСКАЗКИ «?» — всплывающее пояснение (ховер на десктопе, тап на телефоне)
   ========================================================================== */
#locomotiveView .loco-hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; flex-shrink: 0;
  border-radius: 50%; border: 1px solid var(--loco-border);
  color: var(--loco-muted); font-size: 10px; font-weight: 700; font-style: normal;
  line-height: 1; cursor: help; position: relative; vertical-align: middle;
  user-select: none; text-transform: none; letter-spacing: normal;
  transition: border-color .15s, color .15s, background .15s;
}
#locomotiveView .loco-hint:hover,
#locomotiveView .loco-hint.is-open {
  border-color: var(--loco-accent); color: var(--loco-accent); background: var(--loco-accent-weak);
}
#locomotiveView .loco-hint:focus-visible {
  outline: none; border-color: var(--loco-accent); box-shadow: 0 0 0 3px var(--loco-accent-weak);
}
#locomotiveView .loco-hint::after {
  content: attr(data-loco-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 230px; white-space: normal; text-align: left;
  background: #1f2330; color: #fff;
  font-size: 12px; font-weight: 400; line-height: 1.45; letter-spacing: normal; text-transform: none;
  padding: 9px 11px; border-radius: 9px; box-shadow: 0 10px 28px rgba(2, 6, 23, .24);
  opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease; z-index: 60;
}
#locomotiveView .loco-hint::before {
  content: ''; position: absolute; bottom: calc(100% + 4px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent; border-top-color: #1f2330;
  opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease; z-index: 60;
}
#locomotiveView .loco-hint:hover::after, #locomotiveView .loco-hint:hover::before,
#locomotiveView .loco-hint.is-open::after, #locomotiveView .loco-hint.is-open::before {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* выравнивание меток с эмодзи + подсказкой */
#locomotiveView .loco-metric-label { display: flex; align-items: center; gap: 5px; }
#locomotiveView .loco-skus-head { display: flex; align-items: center; gap: 6px; }
#locomotiveView .loco-mode-banner span { display: inline-flex; align-items: center; gap: 7px; }

/* на узких экранах держим пузырёк подсказки в пределах экрана */
@media (max-width: 760px) {
  #locomotiveView .loco-hint::after { max-width: 74vw; }
  /* левые подсказки растут вправо */
  #locomotiveView .loco-metrics .loco-metric:first-child .loco-hint::after,
  #locomotiveView .loco-skus-head .loco-hint::after,
  #locomotiveView .loco-mode-banner .loco-hint::after {
    left: -4px; right: auto; transform: translateX(0) translateY(4px);
  }
  #locomotiveView .loco-metrics .loco-metric:first-child .loco-hint.is-open::after,
  #locomotiveView .loco-skus-head .loco-hint.is-open::after,
  #locomotiveView .loco-mode-banner .loco-hint.is-open::after {
    transform: translateX(0) translateY(0);
  }
  /* правая (последняя) метрика — пузырёк растёт влево */
  #locomotiveView .loco-metrics .loco-metric:last-child .loco-hint::after {
    left: auto; right: -4px; transform: translateX(0) translateY(4px);
  }
  #locomotiveView .loco-metrics .loco-metric:last-child .loco-hint.is-open::after {
    transform: translateX(0) translateY(0);
  }
}

/* Последние действия — выровненная колонка времени */
#locomotiveView #locoLogPreview .loco-skus-head { margin-bottom: 6px; }
#locomotiveView .loco-logp-row {
  display: grid; grid-template-columns: 84px 1fr; gap: 12px;
  padding: 4px 0; align-items: baseline; font-size: 12.5px;
}
#locomotiveView .loco-logp-time { color: var(--loco-muted); font-variant-numeric: tabular-nums; }
#locomotiveView #locoLogPreview .btn-ghost { margin-top: 8px; }

/* Мобильная адаптация таблицы товаров */
@media (max-width: 760px) {
  #locomotiveView .loco-sku {
    grid-template-columns: 1fr auto;
    grid-template-areas: "role price" "id stock" "extra extra";
    gap: 4px 12px;
  }
  #locomotiveView .loco-sku-role { grid-area: role; }
  #locomotiveView .loco-sku-price { grid-area: price; }
  #locomotiveView .loco-sku-id { grid-area: id; }
  #locomotiveView .loco-sku-stock { grid-area: stock; }
  #locomotiveView .loco-sku-extra { grid-area: extra; }
}

/* ============================================================================
   [Дизайн-полировка под бренд] Возврат мягких теней (флэт-правила выше ставят
   box-shadow:none — этот блок идёт ПОЗЖЕ и при равной специфичности перебивает их)
   + белые инпуты на ivory + стиль отсутствовавшей фазы PRICE_MANEUVER.
   Логику/разметку не трогаем — только внешний вид. Токены уже потеплели (см. :root).
   ============================================================================ */

/* Мягкие брендовые тени вместо flat none — карточки «приподнимаются» над кремом. */
.loco-card,
#locomotiveView .bot-card-glass.loco-tile,
#locomotiveView .loco-now,
#locomotiveView .loco-metric,
#locomotiveView .loco-skus,
#locomotiveView .loco-log-preview,
#locomotiveView .loco-how-grid > * {
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.05),
              0 12px 32px -20px rgba(124, 58, 237, 0.20) !important;
}
#locomotiveView .bot-card-glass.loco-tile:hover {
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.08),
              0 16px 40px -20px rgba(124, 58, 237, 0.28) !important;
  border-color: rgba(124, 58, 237, 0.22) !important;
}
#locomotiveView .bot-card-glass.loco-needs-answer {
  box-shadow: 0 1px 3px rgba(180, 83, 9, 0.06),
              0 12px 32px -20px rgba(180, 83, 9, 0.18) !important;
}
#locomotiveView .loco-phase.is-current {
  box-shadow: 0 1px 3px rgba(124, 58, 237, 0.06),
              0 10px 26px -18px rgba(124, 58, 237, 0.26) !important;
}

/* Инпуты — чистый белый на ivory-поверхностях (крепкий контраст поля, как во всём
   дашборде: белые поля на кремовых карточках). */
.loco-set-input,
.loco-custom-input,
.loco-cogs-input,
#locoSettingsModal input,
#locoSettingsModal select,
#locoSettingsModal textarea {
  background: #FFFFFF !important;
}

/* FSM-фаза PRICE_MANEUVER раньше не имела CSS → рендерился неоформленный pill.
   Тёплый янтарный (в тон бренду) для pill и thumbnail. */
#locomotiveView .loco-phase-pill.loco-ph-price_maneuver { background: #FBF0DD; color: #B45309; }
#locomotiveView .loco-thumb-empty.loco-ph-price_maneuver { background: #FBF0DD; }
