/* === iter-2: стили рабочего места сборщика === */

/* HTML5 атрибут hidden должен побеждать любые display:flex/grid/block ниже. */
[hidden] { display: none !important; }

.app-body { max-width: 1280px; }

/* === Tabs (повторяет визуал dm-buyer) === */
.tabs {
  display: flex;
  gap: 12px;
  margin: 0 0 22px;
}
.tabs .tab {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
  font-weight: 600;
}
.tabs .tab:hover { background: #f0f4ff; }
.tabs .tab.active {
  background: linear-gradient(135deg, #eff4ff 0%, #ffffff 70%);
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.tabs .tab-icon { font-size: 1.4rem; }
.tabs .tab-text { display: flex; flex-direction: column; gap: 2px; }
.tabs .tab-label { font-size: .98rem; }
.tabs .tab-sub   { font-size: .78rem; color: var(--muted); font-weight: 400; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel[hidden] { display: none !important; }

/* === Layout сборки === */
.pick-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .pick-grid { grid-template-columns: 1fr; }
}
.pick-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 16px;
}

/* === Зелёный/красный счётчик === */
.counter-box {
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  transition: transform .12s ease;
}
.counter-icon {
  font-size: 1.4rem;
  font-weight: 800;
}
.counter-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.counter-pct  { font-size: 1.4rem; font-weight: 700; }
.counter-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; opacity: .7; }
.counter-sub   { font-size: .8rem; }
.counter-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.5);
  overflow: hidden;
  margin: 4px 0;
}
.counter-progress > div {
  height: 100%;
  background: rgba(255,255,255,.95);
  transition: width .25s;
}

.counter-ok  {
  background: linear-gradient(160deg, #16a34a 0%, #22c55e 100%);
  color: #f0fdf4;
  border-color: #16a34a;
  box-shadow: 0 6px 18px -8px rgba(22,163,74,.65);
}
.counter-err {
  background: linear-gradient(160deg, #dc2626 0%, #ef4444 100%);
  color: #fef2f2;
  border-color: #dc2626;
  box-shadow: 0 6px 18px -8px rgba(220,38,38,.55);
}

@keyframes pulse-ok {
  0%   { transform: scale(1.0); box-shadow: 0 0 0 0 rgba(34,197,94,.65); }
  60%  { transform: scale(1.04); box-shadow: 0 0 0 18px rgba(34,197,94,0); }
  100% { transform: scale(1.0); }
}
.counter-ok.flash { animation: pulse-ok .55s ease-out; }

@keyframes pulse-err {
  0%   { transform: scale(1.0); box-shadow: 0 0 0 0 rgba(239,68,68,.65); }
  60%  { transform: scale(1.04); box-shadow: 0 0 0 18px rgba(239,68,68,0); }
  100% { transform: scale(1.0); }
}
.counter-err.flash { animation: pulse-err .55s ease-out; }

/* === Активная позиция / лог === */
.active-line-card { padding: 14px 16px; }
.active-line-name { font-weight: 700; font-size: 1rem; color: var(--text); margin-top: 2px; }
.active-line-gtin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.active-line-qty  { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; }
.card-title-sm { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }

.recent-list { list-style: none; padding: 0; margin: 0; max-height: 280px; overflow-y: auto; }
.recent-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: .85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.recent-list li.ok    { background: #ecfdf5; color: #065f46; }
.recent-list li.err   { background: #fef2f2; color: #991b1b; }
.recent-list li button { padding: 2px 8px; font-size: .8rem; background: transparent; color: inherit; border: 1px solid currentColor; }

.pick-meta { gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.pick-order-title { font-weight: 700; font-size: 1.05rem; }

/* === Скан карта === */
.scan-card { border: 2px dashed var(--border-strong); padding: 16px 20px; }
.scan-input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  padding: 14px 16px;
  border: 2px solid var(--primary-soft);
  border-radius: 10px;
  outline: none;
  transition: border-color .12s, background .12s;
  background: #fff;
}
.scan-input:focus { border-color: var(--primary); background: #f8faff; }
.scan-hint { margin-top: 6px; }
.scan-card .scan-banner { margin-top: 12px; font-size: 1rem; padding: 14px; }

/* === Таблицы === */
.lines-table, .orders-table, .gtin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.lines-table th, .orders-table th, .gtin-table th {
  background: var(--surface-2);
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
}
.lines-table td, .orders-table td, .gtin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.lines-table tr.active-line { background: #eff6ff; }
.lines-table .progress-cell { min-width: 200px; }
.lines-table .progress-cell .progress { margin-bottom: 4px; }

button.success-btn { background: #16a34a; }
button.success-btn:hover { background: #15803d; }
button.danger-btn  { background: #ef4444; }
button.danger-btn:hover { background: #dc2626; }
button.small { padding: 6px 10px; font-size: .85rem; }

.field label { display: block; }
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  font: inherit;
  background: #fff;
}

.muted.small { font-size: .82rem; }

.pick-empty { text-align: center; padding: 40px; }
.pick-empty button { margin-top: 14px; }

/* === Скан-ошибка overlay === */
.scan-error-overlay {
  position: fixed;
  inset: 0;
  background: rgba(220,38,38,.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scan-overlay-in .15s ease-out;
}
@keyframes scan-overlay-in {
  from { background: rgba(220,38,38,0); }
  to   { background: rgba(220,38,38,.92); }
}
.scan-error-card {
  background: #fff;
  padding: 36px 48px;
  border-radius: 18px;
  max-width: 720px;
  text-align: center;
  box-shadow: 0 30px 80px -10px rgba(0,0,0,.4);
  animation: scan-shake .35s ease-out;
}
@keyframes scan-shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(12px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
  100% { transform: translateX(0); }
}
.scan-error-icon { font-size: 5rem; color: #dc2626; line-height: 1; margin-bottom: 8px; }
.scan-error-title { font-size: 2rem; font-weight: 800; color: #991b1b; }
.scan-error-message { font-size: 1.1rem; color: #1a1a1a; margin: 12px 0; }

/* === Status-banner состояния === */
.scan-banner.ok    { animation: scan-ok-flash .35s ease-out; }
@keyframes scan-ok-flash {
  0%   { background: var(--success-bg); transform: scale(1); }
  40%  { background: #6ee7b7; transform: scale(1.02); }
  100% { background: var(--success-bg); transform: scale(1); }
}

/* === Крупные поля для тачпада / мышки === */
.big-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  font-family: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.big-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.big-field { display: flex; flex-direction: column; gap: 6px; }
.big-field label { font-weight: 500; }

button.big-action {
  font-size: 1.05rem;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: 12px;
}

/* === Карточки позиций нового заказа === */
.new-order-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.new-line-card {
  display: grid;
  grid-template-columns: 1fr 160px 50px;
  gap: 14px;
  align-items: end;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s, background .15s;
}
.new-line-card.invalid {
  border-color: #fca5a5;
  background: #fff5f5;
}
.new-line-card .qty-block { display: flex; flex-direction: column; gap: 6px; }
.new-line-card .qty-block label { font-size: .8rem; color: var(--muted); }
.new-line-card .qty-input { text-align: center; font-variant-numeric: tabular-nums; }

.new-line-remove {
  width: 50px;
  height: 50px;
  align-self: end;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  font-size: 1.4rem;
  border: 1px solid var(--border-strong);
  padding: 0;
  cursor: pointer;
}
.new-line-remove:hover { background: var(--error-bg); color: var(--error-fg); border-color: #fca5a5; }

@media (max-width: 700px) {
  .new-line-card { grid-template-columns: 1fr; }
  .new-line-remove { width: 100%; height: 44px; }
}

/* === Кастомный GTIN-picker === */
.gtin-picker { position: relative; }
.gtin-picker-input { width: 100%; }
.gtin-picker-input.has-pick { background: #f0f9ff; border-color: #93c5fd; }
.gtin-picker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 18px 42px -12px rgba(0,0,0,.22);
  z-index: 50;
  padding: 4px 0;
}
.gtin-picker-list { display: flex; flex-direction: column; }
.gtin-picker-item {
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: block;
  width: 100%;
  font: inherit;
  border-radius: 0;
  min-height: 56px;
}
.gtin-picker-item:last-child { border-bottom: none; }
.gtin-picker-item:hover, .gtin-picker-item.kbfocus {
  background: #eff4ff;
}
.gtin-picker-item-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-size: .98rem;
}
.gtin-picker-item-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
  color: var(--muted);
}
.gtin-picker-loading,
.gtin-picker-empty {
  padding: 14px 16px;
  font-size: .9rem;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  box-shadow: 0 14px 36px -10px rgba(0,0,0,.4);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .25s, transform .25s;
  z-index: 2000;
  max-width: 360px;
  font-weight: 500;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error   { background: #b91c1c; }
.toast.toast-success { background: #15803d; }
.toast.toast-warn    { background: #b45309; }
