/* Мобильный интерфейс склада: крупные цели нажатия, никаких мелких кнопок.
   С этим работают стоя, часто в перчатках, поэтому минимальная высота
   интерактивного элемента — 44 px, а поля ввода 16 px, иначе iOS зумит
   страницу при фокусе. */

:root {
  --ink: #16202a;
  --muted: #6b7785;
  --line: #dfe4ea;
  --bg: #f6f7f9;
  --card: #fff;
  --accent: #2a78d6;
  --good: #0a8a0a;
  --warn: #c98500;
  --bad: #d03b3b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 760px; margin: 0 auto;
  /* 96px снизу — высота панели вкладок плюс воздух. */
  padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
}

/* Шапка — только опознание, без навигации. */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: #fff;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
}
.bar .brand { font-weight: 700; font-size: 17px; }
.bar .who { font-size: 14px; color: #9fb0c2; overflow: hidden; text-overflow: ellipsis;
            white-space: nowrap; max-width: 55%; }
.inline { display: inline; margin: 0; }

/* Нижняя панель вкладок. На телефоне это единственное место, куда большой
   палец дотягивается без перехвата аппарата. Фиксирована, поэтому main
   получает отступ снизу — иначе последняя кнопка страницы уходит под неё. */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 7px; font-size: 11px; text-decoration: none;
  color: var(--muted); min-height: 52px;
}
.tabs a .ic { font-size: 19px; line-height: 1; }
.tabs a.on { color: var(--accent); font-weight: 600; }

/* Карточки */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Плитки на главной */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: inherit; }
.tile .n { font-size: 26px; font-weight: 700; display: block; line-height: 1.1; }
.tile .l { font-size: 13px; color: var(--muted); }

/* Формы */
label { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 12px; font-size: 16px; /* 16px — иначе iOS зумит */
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
  min-height: 44px;
}
textarea { min-height: 88px; resize: vertical; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 12px 18px; font-size: 16px; font-weight: 600;
  border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  text-decoration: none; cursor: pointer; margin-top: 14px; width: 100%;
}
/* Модификаторы навешиваются и на <a class="btn secondary">, и на голую
   <button class="secondary"> — второе встречается в формах, где класс btn
   не нужен. Без button-селекторов такие кнопки молча оставались синими:
   «Искать», «Загрузить» и «Выйти» выглядели главным действием страницы. */
.btn.secondary, button.secondary { background: #eef1f5; color: var(--ink); }
.btn.danger, button.danger { background: var(--bad); color: #fff; }
.btn.good, button.good { background: var(--good); color: #fff; }
/* Кнопка перед карточкой или плитками: у .btn margin-bottom нет, у .card
   нет margin-top — без этого правила они слипаются вплотную. */
.btn + .card, .btn + .tiles, button + .card { margin-top: 14px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }

/* Список */
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a { display: flex; gap: 12px; align-items: center; padding: 13px 2px; text-decoration: none; color: inherit; min-height: 44px; }
.list .t { flex: 1; min-width: 0; }
.list .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; }

/* Статусы */
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.pill.in_stock { background: #e4f0fb; color: #1c5fa8; }
.pill.listed  { background: #fdf1dc; color: #8a5d00; }
.pill.sold    { background: #e2f4e2; color: #0a6b0a; }
.pill.draft   { background: #f3e6e6; color: #9b3030; }
.pill.written_off { background: #ecebe8; color: #6b6b6b; }

.err { background: #fdecec; border: 1px solid #f5c2c2; color: #9b2222; padding: 11px 13px; border-radius: 10px; margin-bottom: 12px; }
.ok  { background: #e7f5e7; border: 1px solid #b9dfb9; color: #14651b; padding: 11px 13px; border-radius: 10px; margin-bottom: 12px; word-break: break-all; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.big-code { font-size: 30px; font-weight: 700; letter-spacing: .1em; }

/* Сканер */
.cam { position: relative; width: 100%; aspect-ratio: 3/4; max-height: 62vh;
       background: #000; border-radius: var(--radius); overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Рамка прицела: без неё непонятно, куда наводить, и человек держит телефон
   слишком далеко — тогда QR не читается. */
.reticle { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
           width: 62%; aspect-ratio: 1; border: 3px solid rgba(255,255,255,.9);
           border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }

/* Загрузка фото. Нативный input отрисовывается как «Choose File / No file
   chosen» — по-английски и с крохотной целью нажатия. Прячем его и делаем
   кнопкой саму подпись. */
.file input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0;
                         overflow: hidden; clip: rect(0 0 0 0); }
.file .fake {
  display: flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 12px 18px; font-size: 16px; font-weight: 600;
  border: 1px dashed var(--line); border-radius: 10px;
  background: #fff; color: var(--accent); cursor: pointer;
}
.file input[type=file]:focus-visible + .fake { outline: 2px solid var(--accent); }
