/* Коробкино · Опись — фирменные токены (korobkino-web/globals.css) */
:root {
  --orange: #f37a1f;
  --orange-hover: #e06a10;
  --orange-dark: #c2410c;
  --cream: #fff8f2;
  --dark: #1a1a1a;
  --dark-soft: #2a2a2a;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #aaa;
  --bg: #fff;
  --bg-alt: #fafafa;
  --bg-page: #f5f5f5;
  --border: #e5e5e5;
  --error: #dc2626;
  --success: #16a34a;
  --warning: #eab308;
  --r-sm: 4px;
  --r-btn: 8px;
  --r-card: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ── Каркас ───────────────────────────────────────────────────────────────── */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--dark);
  color: #fff;
  padding: max(env(safe-area-inset-top, 0px), 8px) 12px 10px;
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 { font-size: 16px; font-weight: 700; margin: 0; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.brand-mark { color: var(--orange); font-weight: 800; letter-spacing: .04em; font-size: 13px; }

.iconbtn {
  width: 40px; height: 40px; border-radius: var(--r-btn);
  display: flex; align-items: center; justify-content: center;
  color: #fff; background: rgba(255,255,255,.08); font-size: 18px; flex: none;
}
.iconbtn:active { background: rgba(255,255,255,.18); }

.main { flex: 1; padding: 12px 12px calc(96px + var(--safe-b)); }

/* ── Карточки ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: 14px; margin-bottom: 10px;
  display: block; width: 100%; text-align: left;
  color: inherit; text-decoration: none;
}
.card, .card * { text-decoration: none; }
.card:active { background: var(--bg-alt); }
.card-title { font-weight: 600; font-size: 16px; margin: 0 0 2px; }
.card-sub { font-size: 13px; color: var(--text-secondary); margin: 0; }
.card-stats { display: flex; gap: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.stat b { display: block; font-size: 17px; font-weight: 700; line-height: 1.2; }
.stat span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Позиция в списке ─────────────────────────────────────────────────────── */
.item-row { display: flex; gap: 12px; align-items: center; padding: 10px; }
.item-thumb {
  width: 72px; height: 72px; border-radius: var(--r-btn); flex: none;
  background: var(--bg-alt) center/cover no-repeat;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 22px; position: relative;
}
.item-thumb .count {
  position: absolute; right: -5px; bottom: -5px;
  background: var(--dark); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 2px 6px; border: 2px solid #fff;
}
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* именно --none, а не .empty: .empty — это пустой экран с большими отступами */
.item-name--none { color: var(--text-muted); font-weight: 400; font-style: italic; }
.item-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-author {
  font-size: 11px; color: var(--orange-dark); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-qty {
  flex: none; text-align: center; min-width: 56px;
  background: var(--cream); border: 1px solid var(--orange);
  border-radius: var(--r-btn); padding: 6px 4px;
}
.item-qty b { display: block; font-size: 18px; font-weight: 700; line-height: 1.1; }
.item-qty span { font-size: 10px; color: var(--orange-dark); text-transform: uppercase; }
.item-seq { font-size: 11px; color: var(--text-muted); font-weight: 700; min-width: 18px; }

/* ── Формы ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-secondary); margin-bottom: 6px;
}
.label .opt { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.input, textarea.input {
  width: 100%; padding: 13px 14px; border: 1px solid var(--border);
  border-radius: var(--r-btn); background: #fff; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(243,122,31,.18); }
textarea.input { resize: vertical; min-height: 76px; }

/* ── Кнопки ───────────────────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border-radius: var(--r-btn);
  font-weight: 600; font-size: 16px;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:active { background: var(--orange-hover); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-dark:active { background: var(--dark-soft); }
.btn-ghost { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: #fff; border: 1px solid var(--error); color: var(--error); }
.btn:disabled { opacity: .5; }

/* ── Счётчик количества ───────────────────────────────────────────────────── */
.qty-box {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--cream); border: 2px solid var(--orange);
  border-radius: var(--r-card); padding: 8px;
}
.qty-btn {
  width: 60px; border-radius: var(--r-btn); background: #fff;
  border: 1px solid var(--orange); color: var(--orange-dark);
  font-size: 26px; font-weight: 700; line-height: 1;
}
.qty-btn:active { background: var(--orange); color: #fff; }
.qty-input {
  flex: 1; text-align: center; font-size: 30px; font-weight: 700;
  border: none; background: transparent; min-width: 0; padding: 6px 0;
}
.qty-input:focus { outline: none; }

/* ── Фото-сетка ───────────────────────────────────────────────────────────── */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo {
  position: relative; aspect-ratio: 1; border-radius: var(--r-btn);
  overflow: hidden; background: var(--bg-alt); border: 1px solid var(--border);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .rm {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px;
  border-radius: 999px; background: rgba(0,0,0,.62); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1;
}
.photo .main-badge {
  position: absolute; left: 0; bottom: 0; background: var(--orange); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 6px; letter-spacing: .04em;
}
.photo.pending::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23f37a1f' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M12 2v4M12 18v4M4.9 4.9l2.9 2.9M16.2 16.2l2.9 2.9M2 12h4M18 12h4M4.9 19.1l2.9-2.9M16.2 7.8l2.9-2.9'/%3E%3C/svg%3E") center/24px no-repeat;
}
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--orange); border-radius: var(--r-btn);
  background: var(--cream); color: var(--orange-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.photo-add span { font-size: 26px; line-height: 1; }
.photo-add small { font-size: 10px; font-weight: 700; text-transform: uppercase; }
.photo-add:active { background: #ffe9d6; }

/* ── Нижняя панель ────────────────────────────────────────────────────────── */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: #fff; border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + var(--safe-b));
  display: flex; gap: 8px;
}
.bottombar .btn { flex: 1; }
.bottombar .btn.narrow { flex: 0 0 58px; }

/* ── Статус синхронизации ─────────────────────────────────────────────────── */
.sync {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.1);
  color: #fff; flex: none;
}
.sync .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--success); flex: none; }
.sync.pending .dot { background: var(--warning); }
.sync.offline .dot { background: var(--error); }

/* ── Приёмка по штрихкодам ────────────────────────────────────────────────── */
.kind-tag {
  display: inline-block; vertical-align: 2px; margin-right: 6px;
  background: var(--dark); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .05em; padding: 1px 6px; border-radius: var(--r-sm);
}

.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind-pick input { position: absolute; opacity: 0; pointer-events: none; }
.kind-pick span {
  display: block; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-btn);
  background: #fff; line-height: 1.3;
}
.kind-pick b { display: block; font-size: 15px; }
.kind-pick small { font-size: 12px; color: var(--text-secondary); }
.kind-pick input:checked + span { border: 2px solid var(--orange); background: var(--cream); padding: 11px; }

.cam-box {
  position: relative; border-radius: var(--r-card); overflow: hidden; background: #000;
  margin-bottom: 10px; border: 3px solid var(--dark);
  aspect-ratio: 4 / 3; max-height: 42vh; width: 100%;
}
.cam-box video { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Прицел: рамка + «лазер» по центру — куда наводить штрихкод */
.cam-aim {
  position: absolute; left: 6%; right: 6%; top: 28%; bottom: 28%;
  border: 2px solid rgba(255,255,255,.85); border-radius: 8px; pointer-events: none;
}
.cam-aim i { position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: var(--error); box-shadow: 0 0 6px var(--error); }
/* Пауза после скана: камера «выключена» на секунду */
.cam-pause {
  position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: rgba(22,163,74,.72); color: #fff; text-align: center;
}
.cam-pause b { font-size: 46px; line-height: 1; }
.cam-pause-code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 18px; font-weight: 700; word-break: break-all; padding: 0 12px; }
.cam-pause-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: #fff; transform-origin: left; }
.cam-box.paused { border-color: var(--success); }
.cam-box.paused .cam-pause { display: flex; }
.cam-box.paused .cam-pause-bar { animation: cam-countdown 1.5s linear forwards; /* = CAM_PAUSE_MS */ }
@keyframes cam-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Полоса паллет: куда сейчас складываем */
.pallet-bar { display: flex; gap: 6px; align-items: stretch; margin-bottom: 8px; }
/* Лента паллет прокручивается, а «+ Паллета» всегда на виду справа */
.pallet-scroll {
  flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pallet-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 12px; border-radius: 999px; line-height: 1.15;
  border: 1px solid var(--border); background: #fff; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; text-align: center;
}
.chip i { display: block; font-style: normal; font-size: 10px; font-weight: 400; color: var(--text-muted); }
.chip.is-active {
  background: var(--dark); border-color: var(--dark); color: #fff;
}
.chip.is-active i { color: rgba(255,255,255,.7); }
.chip-new { border: 1px dashed var(--orange); color: var(--orange-dark); background: var(--cream); }

.last-scan {
  background: var(--cream); border: 2px solid var(--orange); border-radius: var(--r-card);
  padding: 12px 14px; margin-bottom: 10px; text-align: center;
}
.ls-code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 24px; font-weight: 700;
  letter-spacing: .03em; word-break: break-all; line-height: 1.25;
}
.ls-name { font-size: 14px; font-weight: 600; line-height: 1.25; margin-bottom: 4px; }
.ls-unknown { color: var(--error); font-weight: 600; }
.ls-note { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.ls-note b { color: var(--text); font-size: 15px; }
.ls-note.is-new { color: var(--orange-dark); font-weight: 600; }
.ls-hint { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }

.bc-form { display: flex; gap: 8px; margin-bottom: 4px; }
.bc-form .input { flex: 1; min-width: 0; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.bc-form .input::placeholder { font-family: Inter, system-ui, -apple-system, sans-serif; }
.bc-form .btn { width: 56px; flex: none; padding: 0; font-size: 22px; }

.scan-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-btn);
  padding: 6px 6px 6px 12px; margin-bottom: 6px;
}
.scan-row.is-last { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(243,122,31,.18); }
.scan-row.is-unknown { background: var(--cream); }
.scan-main { flex: 1; min-width: 0; }
.scan-name {
  font-size: 14px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.scan-row.is-unknown .scan-name { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.scan-sub {
  font-size: 11px; color: var(--text-secondary); margin-top: 2px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scan-sub b { color: var(--orange-dark); }
.card-file { overflow-wrap: anywhere; }
.scan-row.is-unknown .scan-sub { color: var(--orange-dark); font-family: inherit; }
.scan-btn {
  width: 40px; height: 40px; flex: none; border-radius: var(--r-btn);
  border: 1px solid var(--border); background: #fff; font-size: 20px; font-weight: 700;
  color: var(--text-secondary);
}
.scan-btn:active { background: var(--bg-alt); }
.scan-qty {
  min-width: 52px; height: 40px; flex: none; border-radius: var(--r-btn); padding: 0 8px;
  background: var(--cream); border: 1px solid var(--orange);
  font-size: 18px; font-weight: 700;
}

.card-link .card-title::after { content: ' ›'; color: var(--text-muted); }
.hint-box {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: 12px 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.45;
}

/* ── Статус приёмки, регламент, сотрудники ────────────────────────────────── */
.badge {
  display: inline-block; vertical-align: 1px; margin-left: 6px;
  font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; letter-spacing: .03em;
}
.badge-open { background: var(--cream); color: var(--orange-dark); border: 1px solid var(--orange); }
.badge-done { background: #eaf7ee; color: #15803d; border: 1px solid #86d39b; }
.tag-photo { background: var(--text-secondary); }

.status-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--orange);
  border-radius: var(--r-card); padding: 10px 12px; margin-bottom: 10px;
}
.status-box.is-done { border-left-color: var(--success); background: #f6fbf7; }
.status-box b { display: block; font-size: 14px; }
.status-box span { font-size: 12px; color: var(--text-secondary); }
.status-acts { margin-left: auto; display: flex; gap: 6px; }
.status-acts .btn { width: auto; padding: 9px 14px; font-size: 13px; }
.status-note { font-size: 12px; color: var(--text-secondary); margin-left: auto; }

.step {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: 12px; margin-bottom: 10px;
}
.step.is-done { border-color: var(--success); }
.step-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.step-num {
  flex: none; width: 26px; height: 26px; border-radius: 999px; background: var(--dark); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.step.is-done .step-num { background: var(--success); }
.step-title { font-size: 15px; font-weight: 600; }
.step-title .opt { font-weight: 400; color: var(--text-muted); font-size: 13px; }
.step-hint { font-size: 12px; color: var(--text-secondary); }
.step-photo { position: relative; border-radius: var(--r-btn); overflow: hidden; }
.step-photo img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.step-photo .rm {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 999px;
  background: rgba(0,0,0,.62); color: #fff; display: flex; align-items: center; justify-content: center;
}

.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--orange); }

/* Выбор вида приёмки: две крупные карточки, а не мелкий переключатель */
.pick { display: grid; gap: 10px; }
.pick-item input { position: absolute; opacity: 0; pointer-events: none; }
.pick-item span {
  display: block; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-card);
  background: #fff; line-height: 1.35;
}
.pick-item b { display: block; font-size: 16px; }
.pick-icon { font-size: 26px; line-height: 1.1; margin-bottom: 4px; }
.pick-item small { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.pick-item input:checked + span { border: 2px solid var(--orange); background: var(--cream); padding: 13px; }

.user-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.user-row.is-off { opacity: .55; }
.user-main { flex: 1; min-width: 160px; }
.user-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.user-acts .btn { width: auto; padding: 9px 12px; font-size: 13px; }

.scan-qty.as-text { display: flex; align-items: center; justify-content: center; background: var(--bg-alt); border-color: var(--border); }

.linkbtn {
  display: block; width: 100%; margin-top: 14px; padding: 10px;
  font-size: 14px; color: var(--orange-dark); font-weight: 600; text-align: center;
}
.pick-item span.is-only { border: 2px solid var(--orange); background: var(--cream); padding: 13px; }
.item-thumb.is-warn { background: var(--cream); border-color: var(--error); color: var(--error); font-size: 11px; font-weight: 700; }

/* Свайп по карточке — под ней красная подложка «Удалить» */
.swipe { position: relative; border-radius: var(--r-card); overflow: hidden; margin-bottom: 10px; }
.swipe .card { margin-bottom: 0; position: relative; transition: transform .18s ease-out; touch-action: pan-y; }
.swipe-act {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 22px; background: var(--error); color: #fff; font-weight: 700; font-size: 15px;
}
.swipe.will-delete .swipe-act { background: #b91c1c; }
.swipe.will-delete .swipe-act span::before { content: '✕ '; }

/* Главный экран: три модуля */
.mod-card { display: flex; align-items: center; gap: 14px; padding: 16px 14px; }
.mod-icon { font-size: 30px; flex: none; }
.mod-body { flex: 1; min-width: 0; }
.mod-title { display: block; font-size: 19px; font-weight: 700; }
.mod-hint { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 2px; line-height: 1.35; }
.mod-count {
  flex: none; text-align: center; min-width: 58px; padding: 6px 8px; border-radius: var(--r-btn);
  background: var(--cream); border: 1px solid var(--orange);
  font-size: 18px; font-weight: 700; color: var(--orange-dark);
}
.mod-count i { display: block; font-style: normal; font-size: 9px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }

/* ── Прочее ───────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 56px 20px; color: var(--text-secondary); }
.empty .big { font-size: 46px; margin-bottom: 10px; }
.empty p { margin: 4px 0; }

.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin: 18px 0 8px;
}

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(84px + var(--safe-b)); z-index: 60;
  background: var(--dark); color: #fff; padding: 13px 16px; border-radius: var(--r-btn);
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(10px); transition: .18s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--error); }

.login-wrap { min-height: 100dvh; display: flex; flex-direction: column;
  justify-content: center; padding: 24px; background: var(--dark); }
.login-card { background: #fff; border-radius: var(--r-card); padding: 26px; }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .mark { font-size: 22px; font-weight: 800; letter-spacing: .04em; }
.login-logo .mark span { color: var(--orange); }
.login-logo p { margin: 4px 0 0; font-size: 13px; color: var(--text-secondary); }

.hidden { display: none !important; }
