/* Ревизия склада — стили. Мобильный сценарий первичен (375px без гориз. прокрутки). */
* { box-sizing: border-box; }
:root {
  --red-bg: #fde8ec;      /* 1С < МойСклад — розово-красный */
  --red-border: #f5b8c4;
  --yellow-bg: #fff8dc;   /* 1С > МойСклад — светло-жёлтый */
  --yellow-border: #f0e0a0;
  --gray-bg: #f2f2f2;     /* не найдена в 1С */
  --accent: #2563eb;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #16a34a;
}
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: #fafafa; font-size: 15px; }

.topbar { background: #1e293b; color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
.brand { font-weight: 700; white-space: nowrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { color: #cbd5e1; text-decoration: none; padding: 6px 10px; border-radius: 6px;
  white-space: nowrap; font-size: 14px; }
.tabs a.active { background: #334155; color: #fff; font-weight: 600; }
.tabs a:active { background: #475569; }
.logout-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.who { color: #94a3b8; font-size: 13px; }

.freshness { background: #ecfdf5; color: #065f46; padding: 6px 12px; font-size: 13px;
  border-bottom: 1px solid #d1fae5; }
.freshness.stale { background: #fef2f2; color: #991b1b; border-color: #fecaca; font-weight: 600; }

.content { padding: 12px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 20px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 16px 0 8px; }
.muted { color: var(--muted); font-size: 13px; }

.btn { display: inline-block; border: none; border-radius: 8px; padding: 10px 16px;
  font-size: 15px; cursor: pointer; background: var(--accent); color: #fff; text-decoration: none; }
.btn:active { opacity: .85; }
.btn-secondary { background: #64748b; }
.btn-danger { background: #dc2626; }
.btn-ghost { background: transparent; color: #cbd5e1; border: 1px solid #475569; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; margin-bottom: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type="search"], .toolbar select {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
  min-width: 0; }
.toolbar input[type="search"] { flex: 1 1 160px; }
.progress-line { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* Таблица-ведомость: на мобильном — карточки, на десктопе — таблица */
.sheet { width: 100%; }
.group-header { background: #e2e8f0; font-weight: 700; padding: 8px 10px; border-radius: 8px;
  margin: 14px 0 6px; position: sticky; top: 48px; z-index: 10; display: flex;
  justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.group-header .gcount { font-weight: 400; color: var(--muted); font-size: 12px; white-space: nowrap; }

.item { background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; }
.item.red { background: var(--red-bg); border-color: var(--red-border); }
.item.yellow { background: var(--yellow-bg); border-color: var(--yellow-border); }
.item.nolink { background: var(--gray-bg); }
.item.checked { opacity: .72; }
.item-top { display: flex; gap: 8px; align-items: flex-start; }
.item-name { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; }
.item-name .art { color: var(--muted); font-size: 12px; display: block; }
.check-wrap { flex-shrink: 0; padding-top: 2px; }
.check-wrap input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--ok); }
.qtys { display: flex; gap: 14px; margin: 8px 0 4px; font-size: 14px; flex-wrap: wrap; }
.qtys .q b { font-size: 16px; }
.qtys .q span { color: var(--muted); font-size: 11px; display: block; }
.item-controls { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.item-controls input[type="number"] { width: 96px; padding: 8px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; }
.item-controls input[type="text"] { flex: 1 1 150px; padding: 8px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; min-width: 0; }
.save-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-left: 4px;
  background: transparent; transition: background .3s; flex-shrink: 0; align-self: center; }
.save-dot.saving { background: #f59e0b; }
.save-dot.saved { background: var(--ok); }
.save-dot.error { background: #dc2626; }

/* Обычные таблицы (сверка, залежавшиеся, история, связки) */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; }
table.data td.wrap { white-space: normal; min-width: 200px; }
table.data th { background: #f8fafc; position: sticky; top: 0; cursor: pointer; user-select: none; }
table.data th .arrow { font-size: 10px; color: var(--muted); }
table.data tr.red td { background: var(--red-bg); }
table.data tr.yellow td { background: var(--yellow-bg); }
table.data tr.nolink td { background: var(--gray-bg); }

.badge { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.badge.auto { background: #dcfce7; color: #166534; }
.badge.confirmed { background: #dbeafe; color: #1e40af; }
.badge.question { background: #fef3c7; color: #92400e; }
.badge.notfound { background: #fee2e2; color: #991b1b; }
.badge.rejected { background: #f3f4f6; color: #6b7280; }
.badge.open { background: #fee2e2; color: #991b1b; }
.badge.resolved { background: #dcfce7; color: #166534; }

/* Формы */
.form-page { max-width: 420px; margin: 8vh auto; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; }
.error-msg { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; padding: 10px;
  border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.ok-msg { background: #ecfdf5; color: #065f46; border: 1px solid #d1fae5; padding: 10px;
  border-radius: 8px; margin-bottom: 12px; font-size: 14px; }

.stats-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  min-width: 100px; }
.stat b { font-size: 20px; display: block; }
.stat span { font-size: 12px; color: var(--muted); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; }

@media (min-width: 768px) {
  .content { padding: 20px; }
  .item-name { font-size: 15px; }
}
