/* ASIA.SHIP — складское приложение.
   Дизайн-токены те же, что в клиентском приложении и на сайте.
   Отличие: крупнее шрифты и кнопки — человек работает стоя, одной рукой,
   часто в перчатках. Минимальная зона нажатия 56px. */

:root {
  --red: #FF1027;
  --red-deep: #c90d1f;
  --ink: #0d0d0d;
  --muted: #6f757d;
  --faint: #a9aeb5;
  --rule: #e4e7ea;
  --band: #f4f5f7;
  --paper: #ffffff;
  --page: #eef0f2;
  --green: #1a8a52;
  --green-bg: #e3f5ea;
  --amber: #b8730f;
  --amber-bg: #fdf1de;
  --blue: #1663B0;
  --tint-red: rgba(255, 16, 39, .09);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f3f5;
    --muted: #949aa2;
    --faint: #5f656d;
    --rule: #2a2e33;
    --band: #1f2226;
    --paper: #17191c;
    --page: #0e1012;
    --green: #34c07a;
    --green-bg: rgba(52, 192, 122, .15);
    --amber: #e3a646;
    --amber-bg: rgba(227, 166, 70, .15);
    --blue: #4a9de8;
    --tint-red: rgba(255, 16, 39, .15);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

svg { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Экраны ── */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.on { display: flex; }

/* ── Шапка ── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.top .logo {
  width: 104px; height: 30px; flex-shrink: 0;
  background: url("../assets/logo.png") no-repeat left center / contain;
}
@media (prefers-color-scheme: dark) {
  .top .logo { background-image: url("../assets/logo-dark.png"); }
}
.top h1 { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.who {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.who .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.who .dot.off { background: var(--amber); }

.body { flex: 1; padding: 16px 16px calc(24px + var(--safe-bottom)); }

/* ── Вход ── */
.login {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 32px 24px;
  background: var(--paper);
}
.login .logo-big {
  width: 200px; height: 58px; margin-bottom: 36px;
  background: url("../assets/logo.png") no-repeat center / contain;
}
@media (prefers-color-scheme: dark) {
  .login .logo-big { background-image: url("../assets/logo-dark.png"); }
}
.login h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; text-align: center; }
.login p { font-size: 15px; color: var(--muted); text-align: center; margin: 10px 0 28px; max-width: 30ch; }
.pin {
  width: 100%; max-width: 320px; text-align: center;
  font-size: 30px; font-weight: 800; letter-spacing: .3em; text-indent: .3em;
  font-variant-numeric: tabular-nums;
  padding: 18px; border: 2px solid var(--rule); border-radius: 16px;
  background: var(--band); margin-bottom: 14px;
}
.pin::placeholder { color: var(--faint); letter-spacing: .2em; }

/* «Запомнить меня». Настоящий чекбокс спрятан, но остаётся на месте:
   так работают клавиатура и озвучка экрана, а рисуем мы свой квадрат —
   системный на телефоне слишком мелкий, чтобы попасть в перчатке. */
.remember {
  width: 100%; max-width: 320px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--band);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.remember input { position: absolute; opacity: 0; width: 0; height: 0; }
.remember .box {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid var(--rule); background: var(--paper);
  display: grid; place-items: center; transition: background .12s, border-color .12s;
}
.remember .box svg { width: 15px; height: 15px; color: #fff; opacity: 0; transform: scale(.6);
  transition: opacity .12s, transform .12s; }
.remember input:checked + .box { background: var(--red); border-color: var(--red); }
.remember input:checked + .box svg { opacity: 1; transform: scale(1); }
.remember input:focus-visible + .box { outline: 3px solid var(--red); outline-offset: 2px; }
.remember-text { display: flex; flex-direction: column; line-height: 1.3; }
.remember-text b { font-size: 15px; font-weight: 700; }
.remember-text span { font-size: 13px; color: var(--muted); }

/* Пауза после перебора кода */
.locked {
  width: 100%; max-width: 320px; margin-top: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 16px; border-radius: 16px;
  background: #fdecee; color: #b3001b; text-align: center;
}
.locked svg { width: 26px; height: 26px; }
.locked b { font-size: 15px; font-weight: 750; }
.locked span { font-size: 14px; font-variant-numeric: tabular-nums; opacity: .85; }
@media (prefers-color-scheme: dark) {
  .locked { background: #3a0d14; color: #ff8c9c; }
}

/* Ручной ввод трека: крупно, потому что номер длинный и его сверяют глазами */
.track-input {
  width: 100%; font-size: 22px; font-weight: 800; letter-spacing: .04em;
  font-variant-numeric: tabular-nums; text-transform: uppercase;
  padding: 18px 16px; border: 2px solid var(--rule); border-radius: 16px;
  background: var(--paper);
}
.track-input::placeholder { color: var(--faint); font-weight: 700; letter-spacing: .02em; }

/* ── Кнопки ── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 60px; padding: 0 20px;
  border-radius: 16px; font-size: 17px; font-weight: 800;
}
.btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:active { background: var(--red-deep); }
.btn-green { background: var(--green); color: #fff; }
.btn-line { border: 2px solid var(--rule); color: var(--ink); background: var(--paper); }
.btn-ghost { color: var(--muted); font-size: 15px; font-weight: 700; min-height: 48px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-sm { min-height: 48px; font-size: 15px; border-radius: 14px; }

/* ── Сканер во весь экран ──
   Тёмный фон всегда, независимо от темы: камера сама по себе тёмная,
   а светлые панели вокруг кадра слепят в полумраке склада. */
.scanner { background: #0b0e14; color: #fff; }

.sc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 0;
}
.sc-round {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.sc-round svg { width: 22px; height: 22px; }
.sc-pill {
  display: flex; align-items: center; gap: 9px;
  min-height: 46px; padding: 0 20px; border-radius: 100px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font-size: 16px; font-weight: 700;
}
.sc-pill svg { width: 20px; height: 20px; }
.sc-round:active, .sc-pill:active { background: rgba(255, 255, 255, .22); }

.sc-title { text-align: center; padding: 22px 28px 20px; }
.sc-title h2 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; }
.sc-title p { font-size: 15px; color: rgba(255, 255, 255, .62); margin-top: 6px; }

.sc-view { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
.sc-view video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Прицел — одна горизонтальная линия: штрихкод сканируют поперёк,
   и линия прямо показывает, куда его подвести */
.sc-line {
  position: absolute; left: 14%; right: 14%; top: 50%; height: 2px;
  background: var(--red); box-shadow: 0 0 10px rgba(255, 16, 39, .9);
  transform: translateY(-50%); pointer-events: none;
}
.sc-line.hit { animation: hit .3s ease; }
@keyframes hit {
  0% { box-shadow: 0 0 10px rgba(255,16,39,.9) }
  50% { background: #38d17a; box-shadow: 0 0 26px rgba(56,209,122,1); left: 8%; right: 8% }
  100% { box-shadow: 0 0 10px rgba(255,16,39,.9) }
}

.sc-fail {
  position: absolute; inset: 0; z-index: 2; background: #0b0e14;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 28px 26px;
  text-align: center; font-size: 15px; line-height: 1.5;
}
.sc-fail svg { width: 42px; height: 42px; opacity: .5; }
.sc-fail > span { max-width: 28ch; color: rgba(255, 255, 255, .8); }
.sc-fail .btn-line { border-color: rgba(255, 255, 255, .3); color: #fff; background: transparent; }

.sc-foot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 92px; padding: 16px 18px calc(16px + var(--safe-bottom));
}
/* Статус загрузки распознавателя — под кадром, а не поверх него */
.sc-status {
  font-size: 13.5px; font-weight: 600; color: rgba(255, 255, 255, .7);
  text-align: center; max-width: 30ch; line-height: 1.45;
}
.sc-torch {
  display: flex; align-items: center; gap: 9px;
  min-height: 50px; padding: 0 22px; border-radius: 100px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font-size: 15px; font-weight: 700;
}
.sc-torch svg { width: 20px; height: 20px; }
.sc-torch.on { background: #fff; color: #0b0e14; }

/* Кнопка запуска сканера на главном экране */
.scan-cta {
  width: 100%; display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 30px 20px; border-radius: 22px;
  background: var(--red); color: #fff; font-size: 19px; font-weight: 800;
}
.scan-cta:active { background: var(--red-deep); }
.scan-cta-ic {
  width: 64px; height: 64px; border-radius: 20px;
  background: rgba(255, 255, 255, .18);
  display: flex; align-items: center; justify-content: center;
}
.scan-cta-ic svg { width: 32px; height: 32px; }

/* ── Запросы клиентов на доп. фото ── */
.req-cta {
  width: 100%; display: flex; align-items: center; gap: 14px;
  margin-top: 12px; padding: 16px 18px; border-radius: 18px;
  background: var(--amber-bg); border: 1px solid transparent; text-align: left;
}
.req-ic {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  background: var(--amber); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.req-ic svg { width: 22px; height: 22px; }
.req-body { flex: 1; min-width: 0; }
.req-body b { display: block; font-size: 16px; font-weight: 800; color: var(--amber); }
.req-body span { display: block; font-size: 13px; color: var(--amber); opacity: .8; margin-top: 1px; }
.req-n {
  min-width: 30px; height: 30px; padding: 0 9px; border-radius: 100px; flex-shrink: 0;
  background: var(--amber); color: #fff; font-size: 15px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* Что просит клиент — цитата в карточке приёмки */
.card.ask { background: var(--amber-bg); border-color: transparent; }
.ask-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; color: var(--amber);
}
.ask-head svg { width: 17px; height: 17px; }
.card.ask p { font-size: 15px; margin-top: 8px; line-height: 1.5; }

.q-item.tap { cursor: pointer; }
.q-item.tap:active { background: var(--band); }
.q-arrow { width: 18px; height: 18px; color: var(--faint); flex-shrink: 0; }
.q-ic.ask { background: var(--amber-bg); color: var(--amber); }

/* Инструкция при отказе в доступе к камере */
.sc-steps {
  text-align: left; font-size: 14px; line-height: 1.6;
  color: rgba(255, 255, 255, .8); max-width: 34ch;
  display: grid; gap: 6px; margin: 2px 0 4px;
}
.sc-steps b { color: #fff; font-weight: 700; }

/* ── Переключатель языка ── */
.lang-corner {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); right: 16px; z-index: 5;
}
.lang-btn {
  display: flex; align-items: center; gap: 7px;
  min-height: 42px; padding: 0 15px; border-radius: 100px;
  border: 1px solid var(--rule); background: var(--paper);
  font-size: 14px; font-weight: 700; color: var(--muted);
}
.lang-btn svg { width: 17px; height: 17px; }
.lang-btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* ── Кнопка-иконка в шапке ── */
.icon-back {
  width: 40px; height: 40px; margin-left: -8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.icon-back svg { width: 24px; height: 24px; }

/* ── Карточки ── */
.card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 18px; padding: 18px;
}
.card + .card { margin-top: 12px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--muted); }

.track-num {
  font-size: 26px; font-weight: 800; letter-spacing: .01em;
  font-variant-numeric: tabular-nums; margin-top: 4px; word-break: break-all;
}
.track-meta { font-size: 14px; color: var(--muted); margin-top: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800; padding: 6px 12px; border-radius: 100px;
}
.pill svg { width: 15px; height: 15px; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.wait { background: var(--amber-bg); color: var(--amber); }
.pill.new { background: var(--band); color: var(--muted); }

/* ── Фото ── */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--band); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo button {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px;
  border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.photo button svg { width: 14px; height: 14px; }
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--rule); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700;
}
.photo-add svg { width: 24px; height: 24px; }

/* ── Очередь ── */
.queue { display: grid; gap: 10px; }
.q-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: 16px; padding: 14px;
}
.q-ic {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.q-ic svg { width: 21px; height: 21px; }
.q-ic.ok { background: var(--green-bg); color: var(--green); }
.q-ic.wait { background: var(--amber-bg); color: var(--amber); }
.q-body { flex: 1; min-width: 0; }
.q-body b { display: block; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; word-break: break-all; }
.q-body span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; margin: 0 auto 14px; opacity: .3; }
.empty p { font-size: 15px; }

/* ── Итог ── */
.done-hero { text-align: center; padding: 40px 24px 28px; }
.done-mark {
  width: 88px; height: 88px; border-radius: 50%; background: var(--green);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 20px;
  animation: pop .35s cubic-bezier(.2, 1.4, .5, 1);
}
.done-mark svg { width: 44px; height: 44px; color: #fff; }
@keyframes pop { from { transform: scale(.5); opacity: 0 } to { transform: none; opacity: 1 } }
.done-hero h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.done-hero p { font-size: 15px; color: var(--muted); margin-top: 8px; }

/* ── Нижняя панель ── */
.dock {
  position: sticky; bottom: 0; z-index: 10;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--paper); border-top: 1px solid var(--rule);
  display: grid; gap: 10px;
}

/* ── Уведомление ── */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + var(--safe-bottom));
  z-index: 60; background: var(--ink); color: var(--paper);
  padding: 14px 18px; border-radius: 14px; font-size: 14px; font-weight: 700;
  text-align: center; opacity: 0; transform: translateY(10px);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.on { opacity: 1; transform: none; }

/* ── Полоса офлайна ── */
.offline-bar {
  display: none; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; background: var(--amber-bg); color: var(--amber);
  font-size: 13px; font-weight: 800;
}
.offline-bar svg { width: 16px; height: 16px; }
body.offline .offline-bar { display: flex; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--rule);
  font-size: 14px; font-weight: 700; color: var(--muted); background: var(--paper);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tab .n {
  font-size: 12px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 100px; background: var(--red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
