/* ─────────────────────────────────────────────────────────────
   Склад оборудования
   Визуальный язык: гастрольный кофр. Угольный корпус, тёплая
   «трафаретная» краска вместо чистого белого, единственный акцент —
   янтарь гафферской ленты. Коды моноширинным: их сверяют глазами
   с наклейкой на кейсе.
   ───────────────────────────────────────────────────────────── */

:root {
  --void:    #141517;
  --panel:   #1d1f22;
  --panel-2: #26292d;
  --line:    #33373c;
  --line-soft: #292c30;

  --ink:      #e9e6e1;
  --ink-dim:  #9b9893;
  --ink-faint:#6f6d69;

  --tape:     #f2b134;
  --tape-dim: #8a6519;
  --tally:    #e05252;
  --tally-bg: #341c1c;
  --live:     #5bbd72;
  --live-bg:  #1a2f20;
  --transit:   #e0a13f;
  --transit-bg:#2f2512;

  --r-panel: 10px;
  --r-control: 7px;
  --r-plate: 2px;

  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--void);
  color: var(--ink);
  padding-bottom: 72px;
}

/* ── Шапка и вкладки ───────────────────────────────────────── */

header.topbar {
  background: var(--void);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

header.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

header.topbar h1 a {
  color: var(--ink);
  text-decoration: none;
}

/* Полоска гафферской ленты у названия — метка «это наше хозяйство» */
header.topbar h1 a::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--tape);
  border-radius: 1px;
  margin-right: 9px;
  vertical-align: -2px;
}

.operator-badge {
  font-size: 13px;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  white-space: nowrap;
}

.operator-badge:hover { border-color: var(--ink-faint); color: var(--ink); }

nav.tabbar {
  display: flex;
  overflow-x: auto;
  gap: 2px;
  background: var(--void);
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  position: sticky;
  top: 53px;
  z-index: 9;
  scrollbar-width: none;
}

nav.tabbar::-webkit-scrollbar { display: none; }

nav.tabbar a {
  padding: 11px 12px 10px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink-dim);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

nav.tabbar a:hover { color: var(--ink); }

nav.tabbar a.active {
  color: var(--ink);
  border-bottom-color: var(--tape);
}

main {
  max-width: 940px;
  margin: 0 auto;
  padding: 22px 20px;
}

/* ── Поверхности ───────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-panel);
  padding: 18px;
  margin-bottom: 14px;
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.card h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }

/* align-items: start — иначе короткая панель растягивается по самой длинной */
.grid { display: grid; gap: 12px; align-items: start; }
/* min(…, 100%) — иначе на узком экране колонка шире вьюпорта и страница едет вбок */
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }

/* ── Счётчики: одна тихая строка, а не три одинаковые плитки ── */

.tally-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 26px;
  padding: 2px 2px 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
}

.tally-item { display: flex; align-items: baseline; gap: 8px; }

.tally-item .figure {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.tally-item .caption { font-size: 13px; color: var(--ink-dim); }

.tally-item.is-out .figure { color: var(--transit); }

/* Старые плитки статистики — оставлены для совместимости */
.stat { text-align: center; }
.stat .num { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .caption-text { font-size: 13px; color: var(--ink-dim); }

/* ── Формы ─────────────────────────────────────────────────── */

label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin: 14px 0 5px;
}

label:first-child { margin-top: 0; }

input[type=text], input[type=search], input[type=tel], input[type=date],
input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  font-size: 15px;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--ink);
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--tape);
  outline-offset: -1px;
  border-color: var(--tape);
}

input::placeholder, textarea::placeholder { color: var(--ink-faint); }
select option { background: var(--panel-2); color: var(--ink); }
textarea { resize: vertical; min-height: 62px; }

/* ── Кнопки ────────────────────────────────────────────────── */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  padding: 9px 15px;
  font-size: 14.5px;
  font-family: inherit;
  font-weight: 550;
  cursor: pointer;
  background: var(--tape);
  color: #20180a;
  text-decoration: none;
}

button:hover, .btn:hover { background: #ffc94d; }

button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--tape);
  outline-offset: 2px;
}

button:disabled { background: var(--panel-2); color: var(--ink-faint); cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { background: var(--panel-2); border-color: var(--ink-faint); }

/* Удаление не должно быть самой яркой кнопкой на экране: спокойная по
   умолчанию, краснеет под курсором, когда намерение уже подтверждено движением */
.btn-danger { background: transparent; color: var(--tally); border-color: var(--line); }
.btn-danger:hover { background: var(--tally-bg); border-color: var(--tally); color: #ff8080; }

.btn-block { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

/* ── Поле сканирования: главный элемент интерфейса ─────────── */

.scan-box { display: flex; gap: 10px; }

.scan-box input {
  flex: 1;
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.04em;
  padding: 15px 16px;
  background: var(--void);
  border: 1px solid var(--line);
  border-left: 3px solid var(--tape);
  border-radius: var(--r-control);
}

.scan-box input::placeholder { letter-spacing: 0; font-family: inherit; }
.scan-box button { padding-left: 22px; padding-right: 22px; }

.scan-hint { font-size: 13px; color: var(--ink-faint); margin: 9px 0 0; }

/* ── Таблицы ───────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-soft);
}

th {
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }

.code { font-family: var(--mono); font-size: 13px; color: var(--ink-dim); letter-spacing: 0.02em; }

/* Характеристики карточки: колонками, а не перечислением через точки */
.meta-spec {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 13.5px;
  color: var(--ink-dim);
  margin-top: 9px;
}
.meta-spec a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.meta-spec a:hover { border-bottom-color: var(--tape); }

/* ── Состояния: плашки, как лента на кофре ─────────────────── */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--r-plate);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}

.badge.in_stock { background: var(--live-bg); color: var(--live); }
.badge.issued   { background: var(--transit-bg); color: var(--transit); }
.badge.type     { background: var(--panel-2); color: var(--ink-dim); }

/* ── Строки списка: слева кромка состояния ─────────────────── */

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
  cursor: pointer;
}

/* min-width:0 — без него длинный текст не даёт строке сжаться на телефоне */
.list-item > div { min-width: 0; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--panel-2); }
.list-item.state-in_stock { border-left-color: var(--live); }
.list-item.state-issued { border-left-color: var(--transit); }

.list-item .name { font-weight: 550; letter-spacing: -0.005em; }

.list-item .meta {
  color: var(--ink-dim);
  font-size: 13px;
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.list-item .meta .code { color: var(--ink-faint); }

/* ── Мелочи ────────────────────────────────────────────────── */

.muted { color: var(--ink-dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 10px;
}

.section-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.section-head .count { font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.stat-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.stat-line:last-child { border-bottom: none; }
.stat-line b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Чипы выбранного оборудования ──────────────────────────── */

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--tape);
  border-radius: var(--r-plate);
  padding: 7px 11px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.chip .code { font-size: 12.5px; }

.chip button.chip-remove {
  background: none;
  border: none;
  color: var(--ink-faint);
  padding: 0;
  font-size: 15px;
  line-height: 1;
}
.chip button.chip-remove:hover { background: none; color: var(--tally); }

/* Подтверждение, что скан долетел: короткая вспышка ленты */
@keyframes chip-land {
  from { background: var(--tape-dim); border-left-color: var(--ink); }
  to   { background: var(--panel-2); border-left-color: var(--tape); }
}
.chip.just-added { animation: chip-land 600ms ease-out; }

/* ── Уведомления ───────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-dim);
  color: var(--ink);
  padding: 11px 17px;
  border-radius: var(--r-control);
  font-size: 14px;
  z-index: 100;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}

.toast.error { border-left-color: var(--tally); }
.toast.success { border-left-color: var(--live); }

/* ── Подпись получателя ────────────────────────────────────── */

.signature-pad-wrap {
  /* белый независимо от темы: чернила тёмные, и так же подпись выглядит на бумаге */
  border: 1px dashed var(--line);
  border-radius: var(--r-control);
  background: #fff;
  touch-action: none;
}

/* ── Содержимое контейнера ─────────────────────────────────── */

.contents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 11px;
}

.content-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-control);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel-2);
}
.content-card:hover { border-color: var(--tape); }

.content-card .thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--void);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
}
.content-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.content-card .info { padding: 8px 9px 9px; }
.content-card .info .name { font-size: 12.5px; font-weight: 550; line-height: 1.3; }
.content-card .info .meta { font-size: 11px; color: var(--ink-dim); margin-top: 4px; }

/* ── Фото ──────────────────────────────────────────────────── */

.photo-upload { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.photo-upload .preview {
  width: 88px;
  height: 88px;
  border-radius: var(--r-control);
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-upload .preview img { width: 100%; height: 100%; object-fit: cover; }

.assign-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.assign-row > div { flex: 1; min-width: 165px; }

/* ── Пустые состояния: приглашение к действию ──────────────── */

.empty-state {
  text-align: center;
  color: var(--ink-dim);
  padding: 34px 14px;
  font-size: 14px;
}

.empty-state strong { display: block; color: var(--ink); font-weight: 550; margin-bottom: 4px; }

/* ── Печатные этикетки ─────────────────────────────────────────
   Класс namespace-ится: короткое имя .label конфликтовало с
   подписями в интерфейсе и красило их в белый прямоугольник.
   ───────────────────────────────────────────────────────────── */

.sticker-sheet { display: flex; flex-wrap: wrap; gap: 6px; }

.sticker {
  width: var(--sticker-w, 58mm);
  height: var(--sticker-h, 40mm);
  padding: 1.5mm;
  background: #fff;
  color: #000;
  border: 1px dashed #999;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.sticker-name {
  font-size: 2.7mm;
  line-height: 1.2;
  font-weight: 700;
  text-align: center;
  max-height: 6.5mm;
  overflow: hidden;
  width: 100%;
}

.sticker-sub {
  font-size: 2.1mm;
  color: #444;
  text-align: center;
  width: 100%;
  margin-top: 0.3mm;
}

.sticker-barcode-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.8mm;
}

.sticker-barcode { width: 100%; height: 100%; }

.print-only { display: none; }

@media print {
  header.topbar, nav.tabbar, .no-print { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
  .print-only { display: block; color: #000; }
  main { max-width: none; padding: 0; }
  .sticker-sheet { display: block; gap: 0; }
  .sticker { border: none; break-after: page; page-break-after: always; }
  .sticker:last-child { break-after: auto; page-break-after: auto; }
}

/* ── Телефон ───────────────────────────────────────────────── */

@media (max-width: 560px) {
  main { padding: 16px 14px; }
  .card { padding: 15px; }
  .tally-row { gap: 18px; }
  .tally-item .figure { font-size: 25px; }
  .scan-box { flex-direction: column; }
  .scan-box button { width: 100%; }
  header.topbar { padding: 12px 14px 10px; }
  nav.tabbar { top: 49px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
