:root {
  --bg: #F4F2EC;
  --surface: #FFFFFF;
  --ink: #17191D;
  --muted: #6B6F76;
  --line: #E3E0D6;
  --navy: #1E2A44;
  --navy-ink: #FFFFFF;
  --scan: #DA3B2F;
  --scan-soft: #FBE4E1;
  --good: #276B45;
  --good-soft: #E1F0E6;
  --warn: #B8791A;
  --warn-soft: #FBEBD3;
  --radius: 10px;
  --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161A;
    --surface: #1D2025;
    --ink: #F0EFEA;
    --muted: #9A9DA5;
    --line: #303339;
    --navy: #0F1626;
    --navy-ink: #F0EFEA;
    --scan: #FF6B5E;
    --scan-soft: #3A2320;
    --good: #6FD494;
    --good-soft: #1D2E23;
    --warn: #E8B25C;
    --warn-soft: #332A17;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; padding-bottom: 40px; }

h1, h2 { font-weight: 800; margin: 0 0 4px; }
.muted { color: var(--muted); }
.muted.small { font-size: 12px; }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.badge-blue { background: var(--good-soft); color: var(--good); }
.badge-gray { background: var(--warn-soft); color: var(--warn); }

.topbar {
  background: var(--navy);
  color: var(--navy-ink);
  padding: 18px 20px 0;
}
.topbar-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 980px;
  margin: 0 auto;
  padding-bottom: 14px;
}
.topbar h1 { font-size: 19px; display: flex; align-items: center; gap: 8px; }
.brand-icon { height: 28px; width: 28px; object-fit: contain; border-radius: 6px; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; opacity: 0.9; }
.link-btn {
  background: none; border: none; color: var(--navy-ink); text-decoration: underline;
  cursor: pointer; font-family: var(--font-ui); font-size: 14px; padding: 0;
}
.inline { display: inline; }

.tabs-row {
  display: flex; gap: 6px; max-width: 980px; margin: 0 auto; padding: 0 0 0;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.tab-btn {
  appearance: none; border: none; background: none; color: var(--navy-ink);
  opacity: 0.7; padding: 12px 16px; font-family: var(--font-ui); font-weight: 700;
  font-size: 14px; cursor: pointer; text-decoration: none; border-bottom: 3px solid transparent;
}
.tab-btn.active { opacity: 1; border-bottom-color: var(--scan); }
.tab-btn:not(.active):hover { opacity: 0.9; }

.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--navy); color: var(--navy-ink);
  padding: 18px 0; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px; padding: 0 18px 16px; margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.12); font-weight: 800; font-size: 17px;
  color: var(--navy-ink); text-decoration: none;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-link {
  display: block; padding: 10px 18px; color: var(--navy-ink); text-decoration: none; font-weight: 600;
  font-size: 14px; border-left: 3px solid transparent; opacity: 0.72;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); opacity: 0.95; }
.sidebar-link.active { opacity: 1; font-weight: 800; border-left-color: var(--scan); background: rgba(255,255,255,0.08); }
.main-area { flex: 1; min-width: 0; }
.main-area .topbar-row, .main-area .tabs-row { max-width: 980px; }
@media (max-width: 860px) {
  .app-shell { flex-direction: column; min-height: 0; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center; overflow-x: auto;
    border-right: none; padding: 8px 0; gap: 0;
  }
  .sidebar-brand { border-bottom: none; padding: 0 12px; margin-bottom: 0; flex-shrink: 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-link { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .sidebar-link.active { border-left-color: transparent; border-bottom-color: var(--scan); }
}

.wrap { max-width: 980px; margin: 24px auto; padding: 0 20px; display: flex; flex-direction: column; gap: 16px; }
.wrap.narrow { max-width: 440px; }

.card, .table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
details.card summary { cursor: pointer; font-weight: 800; font-size: 1.5em; list-style: revert; }
details.card[open] summary { margin-bottom: 10px; }
details.card summary::marker { color: var(--muted); }

.summary-row { display: flex; flex-wrap: wrap; gap: 20px; margin: 10px 0 16px; }
.summary-item { display: flex; flex-direction: column; }
.summary-item b { font-size: 20px; font-weight: 800; }
.summary-item span { font-size: 12px; color: var(--muted); }
.warn-text { color: var(--warn); font-weight: 700; }

.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 360px;
}
.auth-card h1 { font-size: 24px; text-align: center; }
.auth-card > .muted { text-align: center; margin-bottom: 20px; }

label { display: block; font-size: 13px; font-weight: 700; margin: 12px 0 4px; }
input[type=text], input[type=password], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14px;
}
input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: 1px; }

.primary-btn {
  background: var(--navy); color: var(--navy-ink); border: none; border-radius: 8px;
  padding: 10px 18px; font-family: var(--font-ui); font-weight: 700; font-size: 14px;
  cursor: pointer; margin-top: 14px;
}
.primary-btn:hover { opacity: 0.92; }
.ghost-btn {
  background: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  font-family: var(--font-ui); font-weight: 600; font-size: 13px; cursor: pointer; color: var(--ink);
}
.ghost-btn:hover { border-color: var(--navy); }
.danger-btn {
  background: var(--scan-soft); color: var(--scan); border: 1px solid var(--scan-soft);
  border-radius: 8px; padding: 8px 12px; font-family: var(--font-ui); font-weight: 700;
  font-size: 13px; cursor: pointer;
}

/* Выбор продавца на рабочих экранах — тот же алфавитный <select>, что был, просто крупнее:
   легче попасть на сенсорном экране и прочитать, кто выбран, от расстояния. */
.seller-select-big {
  width: auto; max-width: 420px; font-size: 20px; font-weight: 800; padding: 14px 18px;
  border-radius: var(--radius); margin: 8px 0;
}

/* Подвкладки внутри светлой карточки (напр. раздел «Финансы») — .tab-btn из топбара не подходит,
   он рассчитан на тёмный фон (белый текст). */
.subtabs-row { display: flex; flex-wrap: wrap; gap: 6px; }
.subtab-link {
  padding: 8px 14px; border-radius: 8px; font-weight: 700; font-size: 13px;
  color: var(--muted); text-decoration: none; border: 1px solid transparent;
}
.subtab-link:hover { border-color: var(--line); }
.subtab-link.active { color: var(--ink); background: var(--bg); border-color: var(--line); }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 160px; margin: 0; }
.inline-form.small input { flex: 1 1 120px; }
.inline-form .primary-btn, .inline-form .ghost-btn { margin-top: 0; }
.scan-cam-btn {
  flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 19px; line-height: 1; padding: 9px 14px; cursor: pointer;
}
.scan-cam-btn:hover { border-color: var(--navy); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th { text-align: left; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
tr:last-child td { border-bottom: none; }
.row-actions { display: flex; flex-direction: column; gap: 6px; }
.row-actions form { margin: 0; }

.perm-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; align-items: center; }
.perm-grid.small { font-size: 13px; margin: 0; }
.perm-check { display: flex; align-items: center; gap: 4px; font-weight: 400; font-size: inherit; margin: 0; }
.perm-check input { width: auto; }

.seller-tokens { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.token-status { font-size: 14px; margin-bottom: 4px; }

.flash {
  padding: 10px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.flash.error { background: var(--scan-soft); color: var(--scan); }
.flash.success { background: var(--good-soft); color: var(--good); }

.flash-loud {
  padding: 18px 20px; border-radius: 10px; font-size: 20px; font-weight: 800;
  text-align: center; margin-bottom: 4px;
}
.flash-loud.error { background: var(--scan); color: #fff; }
.flash-loud.success { background: var(--good); color: #fff; }

.location-hint { font-size: 22px; font-weight: 700; margin: 8px 0; }

.scan-result-big {
  border-radius: var(--radius); padding: 20px 24px; margin-bottom: 16px; text-align: center;
}
.scan-result-big.in { background: var(--good-soft); border: 2px solid var(--good); }
.scan-result-big.out { background: var(--scan-soft); border: 2px solid var(--scan); }
.scan-result-label { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
.scan-result-article { font-size: 40px; font-weight: 800; line-height: 1.15; margin: 6px 0; word-break: break-word; }
.scan-result-size { font-size: 28px; font-weight: 600; opacity: 0.85; }
.scan-result-qty { font-size: 56px; font-weight: 800; }
.scan-result-big.in .scan-result-qty { color: var(--good); }
.scan-result-big.out .scan-result-qty { color: var(--scan); }
@media (max-width: 720px) {
  .scan-result-article { font-size: 28px; }
  .scan-result-qty { font-size: 40px; }
}

/* Рабочее поле сборки — экран смотрят на вытянутой руке со сканером, не вчитываясь, поэтому
   ключевые данные (артикул, где лежит) крупным шрифтом, а всё второстепенное (категория,
   баркод) сведено в одну компактную строку вместо многострочной таблицы. */
.assembly-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .assembly-grid { grid-template-columns: 1fr; } }
.assembly-sticker-label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.assembly-order-title { font-size: 34px; font-weight: 800; margin: 2px 0 6px; line-height: 1.1; }
.assembly-meta-line { font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.assembly-meta-line b { color: var(--ink); font-weight: 700; }
.assembly-kiz-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center;
}
.assembly-kiz-box.done { background: var(--good-soft); border-color: var(--good); }
.assembly-kiz-box b { font-size: 17px; }
.assembly-kiz-box img { width: 200px; }
.assembly-kiz-box form { width: 100%; }
.assembly-kiz-box input[type=text] { width: 100%; box-sizing: border-box; text-align: center; font-size: 17px; padding: 10px; }

.done-banner {
  background: var(--good-soft); color: var(--good); font-weight: 800; font-size: 15px;
  padding: 12px 14px; border-radius: 8px; margin-bottom: 14px;
}
.sticker-print-area { display: flex; justify-content: center; margin-bottom: 14px; }
.sticker-print-area img { width: 220px; }
.sticker-print-area-multi { flex-wrap: wrap; gap: 10px; }
.sticker-print-area-multi img { width: 140px; }

.item-photo {
  width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
  display: block; margin-bottom: 10px; background: var(--bg);
}
.assembly-grid .item-photo { width: 140px; height: 140px; }
.item-photo-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.item-photo-sm {
  width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line);
  display: block;
}
.sticker-actions {
  display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.auto-note { font-size: 13px; color: var(--good); font-weight: 700; }
.auto-print-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0; }
.auto-print-toggle input { width: auto; }
.queue-hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 4px; }
.queue-hint a { color: var(--muted); }

/* Пошаговый режим листа подбора (/assembly/pick-list/steps) — экран держат в руке у
   стеллажа, а не читают за столом, поэтому шрифт крупнее, чем везде в приложении, и за раз
   видна только одна ячейка. */
.steppick-topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.steppick-topbar a { color: var(--muted); font-size: 14px; font-weight: 700; text-decoration: none; }
.steppick-wrap { max-width: 440px; margin: 0 auto; padding: 16px; }
.steppick-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.steppick-progress .count { font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.steppick-track { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.steppick-fill { height: 100%; background: var(--good); border-radius: 3px; }
.steppick-zone {
  display: inline-block; font-size: 14px; font-weight: 700; color: var(--navy-ink); background: var(--navy);
  padding: 6px 14px; border-radius: 6px; margin-bottom: 10px;
}
.steppick-cell { font-size: 64px; font-weight: 800; line-height: 1; margin: 0 0 18px; letter-spacing: -0.01em; }
.steppick-cell-article { font-size: 30px; line-height: 1.2; word-break: break-word; }
.steppick-zone.warn { background: var(--scan); }
.steppick-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px;
}
.steppick-article { font-size: 24px; font-weight: 800; line-height: 1.25; }
.steppick-size { font-size: 17px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.steppick-qty-row { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; }
.steppick-qty-num { font-size: 44px; font-weight: 800; color: var(--good); }
.steppick-qty-label { font-size: 15px; color: var(--muted); font-weight: 700; }
.steppick-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.steppick-done-btn {
  background: var(--scan); color: #fff; border: none; border-radius: var(--radius); padding: 18px;
  font-size: 19px; font-weight: 800; cursor: pointer; width: 100%; font-family: inherit;
}
.steppick-done-btn:active { opacity: 0.85; }
.steppick-row { display: flex; gap: 10px; }
.steppick-ghost {
  flex: 1; background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: var(--radius); padding: 12px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.steppick-ghost.on { color: var(--good); border-color: var(--good); }
.steppick-final { text-align: center; padding: 60px 16px; }
.steppick-final .big-check { font-size: 56px; margin-bottom: 10px; }
.steppick-final h2 { font-size: 22px; font-weight: 800; margin: 0 0 8px; }
.steppick-final p { font-size: 15px; color: var(--muted); margin: 0 0 20px; }

/* Мини-апп Telegram: быстрый ввод расхода — кнопки-чипы вместо выпадающих списков,
   чтобы не было опечаток и не нужно было целиться пальцем в маленький select. */
.qe-wrap { max-width: 480px; margin: 0 auto; padding: 20px 16px 110px; }
.qe-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 20px 0 8px; }
.qe-label:first-of-type { margin-top: 0; }
.qe-amount {
  width: 100%; padding: 18px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-family: var(--font-mono);
  font-size: 32px; font-weight: 700; text-align: center;
}
.qe-amount:focus { outline: 2px solid var(--navy); outline-offset: 1px; }
.qe-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.qe-chip {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 10px 16px; font-family: var(--font-ui); font-weight: 700;
  font-size: 14px; cursor: pointer;
}
.qe-chip.on { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.qe-chip.unpaid { border-style: dashed; color: var(--muted); }
.qe-chip.unpaid.on { background: var(--muted); color: var(--surface); border-color: var(--muted); border-style: solid; }
.qe-chip-add { border-style: dashed; color: var(--muted); }
.qe-comment {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14px; resize: none;
}
.qe-submit {
  position: sticky; bottom: 16px; margin-top: 26px; width: 100%; padding: 16px;
  background: var(--scan); color: #fff; border: none; border-radius: var(--radius);
  font-size: 17px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.qe-submit:disabled { opacity: 0.4; cursor: default; }
.qe-toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; background: var(--good);
  color: #fff; padding: 12px 16px; border-radius: var(--radius); font-weight: 700;
  text-align: center; transform: translateY(120%); transition: transform 0.2s ease; z-index: 10;
}
.qe-toast.show { transform: translateY(0); }
.qe-recent-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.qe-recent-row:last-child { border-bottom: none; }
.qe-full-link { display: block; text-align: center; margin-top: 22px; color: var(--muted); font-size: 13px; }
