/* ============================================================
   app.css — Стили Telegram Mini App складского учёта v3 (Global Redesign)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  --r-lg: 20px;
  --r-md: 13px;
  --r-sm: 9px;
  
  /* Fallbacks for generic properties if needed elsewhere */
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 16px;
  --gap-lg: 22px;
  --font-xs: 11px;
  --font-sm: 13px;
  --font-md: 15px;
  --font-lg: 17px;
  --font-xl: 20px;
}

[data-theme="light"], :root {
  --bg: #F2F3F5; 
  --surface: #FFFFFF; 
  --surface2: #F7F8FA; 
  --surface3: #ECEEF1;
  --border: #E3E5E9; 
  --border-soft: #EDEEF1;
  --text: #14161A; 
  --text-dim: #6B7280; 
  --text-faint: #9AA0A8;
  --accent: #3366FF; 
  --accent-dim: rgba(51,102,255,.10);
  --success: #16A34A; 
  --success-dim: rgba(22,163,74,.11);
  --danger: #DC2626; 
  --danger-dim: rgba(220,38,38,.10);
  --pending: #9AA0A8; 
  --pending-dim: rgba(154,160,168,.14);
  --scan: #C2760A; 
  --scan-dim: rgba(194,118,10,.12);
}

[data-theme="light"] body, body {
  --tg-theme-bg-color: var(--bg) !important;
  --tg-theme-secondary-bg-color: var(--surface) !important;
  --tg-theme-text-color: var(--text) !important;
  --tg-theme-hint-color: var(--text-faint) !important;
  --tg-theme-button-color: var(--accent) !important;
  --tg-theme-button-text-color: #FFFFFF !important;
}

[data-theme="dark"] {
  --bg: #0B0D10; 
  --surface: #15181C; 
  --surface2: #1B1F24; 
  --surface3: #20252B;
  --border: #262B31; 
  --border-soft: #1D2126;
  --text: #EDEFF2; 
  --text-dim: #8B929B; 
  --text-faint: #565C64;
  --accent: #4D7FFF; 
  --accent-dim: rgba(77,127,255,.14);
  --success: #35D07F; 
  --success-dim: rgba(53,208,127,.14);
  --danger: #FF6461; 
  --danger-dim: rgba(255,100,97,.14);
  --pending: #5B6169; 
  --pending-dim: rgba(91,97,105,.16);
  --scan: #FFB020; 
  --scan-dim: rgba(255,176,32,.14);
}

[data-theme="dark"] body {
  --tg-theme-bg-color: var(--bg) !important;
  --tg-theme-secondary-bg-color: var(--surface) !important;
  --tg-theme-text-color: var(--text) !important;
  --tg-theme-hint-color: var(--text-faint) !important;
  --tg-theme-button-color: var(--accent) !important;
  --tg-theme-button-text-color: #FFFFFF !important;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  position: fixed;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: pan-x pan-y; /* Prevent pinch zoom on iOS but allow scrolling */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--font-md);
  line-height: 1.5;
  color: var(--tg-theme-text-color);
  background-color: var(--tg-theme-bg-color);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ─── Утилиты ───────────────────────────────────────────────── */
.hidden { display: none !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--gap-sm); }
.gap-md { gap: var(--gap-md); }

/* ─── Lucide иконки ─────────────────────────────────────── */
/* Базовые размеры */
[data-lucide], .lucide {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.icon-xs  { width: 13px; height: 13px; }
.icon-sm  { width: 16px; height: 16px; }
.icon-md  { width: 20px; height: 20px; }
.icon-lg  { width: 24px; height: 24px; }
.icon-xl  { width: 32px; height: 32px; }
.icon-header { width: 22px; height: 22px; color: var(--tg-theme-button-color); }

/* ─── Лейаут ────────────────────────────────────────────────── */
#app-root {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* ─── Хедер ─────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--tg-theme-header-bg-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  font-size: var(--font-lg);
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--tg-theme-text-color);
  display: flex;
  align-items: center;
  gap: 7px;
}

.app-title span {
  color: var(--tg-theme-button-color);
}

.ms-status {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
  display: flex;
  align-items: center;
  gap: 5px;
  position: relative;
  padding-left: 14px;
}

.ms-status::before {
  content: '';
  position: absolute;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.ms-status .icon-xs {
  color: var(--tg-theme-hint-color);
  opacity: 0.7;
}

/* ─── Секции ────────────────────────────────────────────────── */
.section {
  padding: 0 var(--gap-md);
}

.section-title {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--tg-theme-hint-color);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: var(--gap-sm);
}

/* ─── Карточки ──────────────────────────────────────────────── */
.card {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  box-shadow: var(--shadow-card);
}

/* Glassmorphism карточка товара */
.product-card {
  background: linear-gradient(
    135deg,
    rgba(42, 171, 238, 0.12) 0%,
    var(--tg-theme-secondary-bg-color) 60%
  );
  border: 1px solid rgba(42, 171, 238, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.card-animate-in {
  animation: cardSlideIn var(--transition-slow) both;
}

.product-name {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--tg-theme-text-color);
  line-height: 1.3;
  margin-bottom: var(--gap-sm);
}

.product-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--tg-theme-text-color);
}

/* Остатки */
.stock-value { font-weight: 700 !important; }
.stock-ok    { color: var(--color-success) !important; }
.stock-low   { color: var(--color-warning) !important; }
.stock-zero  { color: var(--color-error) !important; }

/* ─── Переключатель режима сканирования ─────────────────────── */
.scan-mode-tabs {
  display: flex;
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 3px;
  margin-bottom: var(--gap-md);
}

.scan-mode-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--tg-theme-hint-color);
  font-size: var(--font-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.scan-mode-tab.active {
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
  box-shadow: var(--shadow-btn);
}

/* ─── Зона сканирования ─────────────────────────────────────── */
.scanner-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-preview {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Перекрытие с рамкой прицела */
.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-frame {
  width: 78%;
  height: 44%;
  border: 2px solid rgba(42, 171, 238, 0.8);
  border-radius: var(--radius-md);
  box-shadow:
    0 0 0 4000px rgba(0, 0, 0, 0.45),
    inset 0 0 20px rgba(42, 171, 238, 0.1);
  position: relative;
}

/* Анимированная линия сканирования */
@keyframes scanLine {
  0%   { top: 8%; opacity: 1; }
  95%  { top: 88%; opacity: 1; }
  100% { top: 88%; opacity: 0; }
}

.scanner-frame::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--tg-theme-button-color),
    transparent
  );
  animation: scanLine 2.5s ease-in-out infinite;
  box-shadow: 0 0 8px var(--tg-theme-button-color);
}

/* Угловые маркеры */
.scanner-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--color-info);
  border-style: solid;
}
.scanner-corner.tl { top: -1px; left: -1px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.scanner-corner.tr { top: -1px; right: -1px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.scanner-corner.bl { bottom: -1px; left: -1px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.scanner-corner.br { bottom: -1px; right: -1px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

/* HID режим */
.hid-container {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-lg);
  padding: var(--gap-lg) var(--gap-md);
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-md);
}

.hid-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: rgba(42, 171, 238, 0.08);
  border-radius: var(--radius-lg);
  color: var(--tg-theme-button-color);
  animation: pulse 2s ease-in-out infinite;
}

.hid-icon [data-lucide] {
  width: 38px;
  height: 38px;
  stroke-width: 1.5;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50%       { transform: scale(1.06); opacity: 1; }
}

.hid-hint {
  font-size: var(--font-sm);
  color: var(--tg-theme-hint-color);
  line-height: 1.6;
}

.hid-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

/* ─── Выбор операции ────────────────────────────────────────── */
.op-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-xs);
}

.op-tab {
  padding: 10px 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-hint-color);
  font-size: var(--font-xs);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}

.op-icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.75;
}

.op-tab.active {
  background: rgba(42, 171, 238, 0.15);
  border-color: var(--tg-theme-button-color);
  color: var(--tg-theme-button-color);
}

.op-tab:active { transform: scale(0.95); }

/* ─── Выбор склада ──────────────────────────────────────── */
.select-wrapper {
  position: relative;
}

.select-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--tg-theme-hint-color);
  pointer-events: none;
  z-index: 1;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--tg-theme-hint-color);
  pointer-events: none;
}

select {
  width: 100%;
  padding: 12px 36px 12px 38px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  font-size: var(--font-md);
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

select:focus {
  border-color: var(--tg-theme-button-color);
}

/* ─── Поле количества ───────────────────────────────────────── */
.qty-row {
  display: flex;
  gap: var(--gap-sm);
  align-items: flex-start;
}

.qty-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 100px;
}

.qty-label {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
  font-weight: 500;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  font-size: var(--font-lg);
  font-family: inherit;
  font-weight: 600;
  outline: none;
  transition: border-color var(--transition);
  text-align: center;
}

input[type="number"]:focus,
input[type="text"]:focus {
  border-color: var(--tg-theme-button-color);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  font-size: var(--font-sm);
  font-family: inherit;
  outline: none;
  resize: none;
  height: 72px;
  transition: border-color var(--transition);
}

textarea:focus { border-color: var(--tg-theme-button-color); }
textarea::placeholder,
input::placeholder { color: var(--tg-theme-hint-color); }

/* textarea с иконкой */
.textarea-wrapper {
  position: relative;
}

.textarea-icon {
  position: absolute;
  left: 13px;
  top: 14px;
  width: 15px;
  height: 15px;
  color: var(--tg-theme-hint-color);
  pointer-events: none;
  z-index: 1;
  opacity: 0.6;
}

.textarea-wrapper textarea {
  padding-left: 36px;
}

/* ─── Кнопки ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-md);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
}

.btn [data-lucide] {
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:not(:disabled):active { transform: scale(0.96); }

.btn-primary {
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
  box-shadow: var(--shadow-btn);
  flex: 1;
}

.btn-primary:not(:disabled):hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  border: 1.5px solid var(--border);
}

.btn-danger {
  background: rgba(255, 69, 58, 0.12);
  color: var(--color-error);
  border: 1.5px solid rgba(255, 69, 58, 0.2);
}

.btn-success {
  background: rgba(48, 209, 88, 0.15);
  color: var(--color-success);
  border: 1.5px solid rgba(48, 209, 88, 0.25);
}

.btn-icon {
  padding: 12px;
  width: 46px;
  height: 46px;
  font-size: 20px;
}

.btn-full { width: 100%; }

/* ─── Подсказка «нет товара» ────────────────────────────────── */
.no-product-hint {
  text-align: center;
  padding: var(--gap-lg) var(--gap-md);
  color: var(--tg-theme-hint-color);
  font-size: var(--font-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
}

.no-product-hint .hint-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  opacity: 0.5;
}

.no-product-hint .hint-icon [data-lucide] {
  width: 26px;
  height: 26px;
}

/* ─── Список сессии ─────────────────────────────────────────── */
.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-sm);
}

.session-badge {
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
  font-size: var(--font-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.session-total {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
}

.session-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
  padding-right: 2px;
}

.session-list::-webkit-scrollbar { width: 3px; }
.session-list::-webkit-scrollbar-track { background: transparent; }
.session-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.session-empty {
  text-align: center;
  color: var(--tg-theme-hint-color);
  font-size: var(--font-sm);
  padding: var(--gap-lg) 0;
  font-style: italic;
}
/* ─── SPA Screens ─────────────────────────────────────────── */
.section { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Home Screen */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap-md);
}

.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 16px;
  background: var(--tg-theme-secondary-bg-color);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  color: var(--tg-theme-text-color);
  font-size: var(--font-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.menu-btn:active {
  transform: scale(0.96);
  background: rgba(42, 171, 238, 0.1);
  border-color: rgba(42, 171, 238, 0.3);
}

.menu-icon {
  width: 32px;
  height: 32px;
  color: var(--tg-theme-button-color);
  stroke-width: 1.5;
}

/* Documents List */
.docs-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.doc-card {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
  border: 1px solid transparent;
}

.doc-card:active {
  transform: scale(0.98);
  background: rgba(42, 171, 238, 0.05);
  border-color: rgba(42, 171, 238, 0.2);
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.doc-name {
  font-weight: 600;
  font-size: var(--font-md);
}

.doc-date {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
}

.doc-agent, .doc-sum {
  font-size: var(--font-sm);
  color: var(--tg-theme-hint-color);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.doc-state {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0px 1px 2px rgba(0,0,0,0.5);
}

/* Task Screen */
.task-screen, .tasks-screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: background var(--transition);
  animation: slideIn 0.2s ease both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.session-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.session-item-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--tg-theme-text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-meta {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
}

.session-item-right {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  flex-shrink: 0;
}

.session-item-qty {
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--tg-theme-button-color);
  background: rgba(42, 171, 238, 0.1);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.session-item-price {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
}

.session-remove-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 69, 58, 0.12);
  color: var(--color-error);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  padding: 0;
}

.session-remove-btn [data-lucide] {
  width: 14px;
  height: 14px;
}

.session-remove-btn:hover {
  background: rgba(255, 69, 58, 0.28);
  transform: scale(1.1);
}

/* ─── Блок операций ─────────────────────────────────────────── */
.commit-row {
  display: flex;
  gap: var(--gap-sm);
}

/* ─── Принтер ───────────────────────────────────────────── */
.printer-row {
  display: flex;
  gap: var(--gap-sm);
  align-items: center;
}

.printer-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.printer-bt-icon {
  color: var(--tg-theme-hint-color);
  opacity: 0.6;
  transition: color var(--transition), opacity var(--transition);
}

.connected .printer-bt-icon {
  color: var(--color-success);
  opacity: 1;
}

.printer-status {
  font-size: var(--font-xs);
  color: var(--tg-theme-hint-color);
  transition: color var(--transition);
}

.printer-status.connected {
  color: var(--color-success);
}

.meta-label {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Загрузка ──────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-md);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(42, 171, 238, 0.2);
  border-top-color: var(--tg-theme-button-color);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: var(--font-md);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

/* ─── Тосты (уведомления) ───────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--gap-xs);
  pointer-events: none;
  width: calc(100% - var(--gap-lg) * 2);
  max-width: 440px;
}

.toast {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-success { background: linear-gradient(135deg, #1a6b32, #28a745); }
.toast-error   { background: linear-gradient(135deg, #7a1a1a, #dc3545); }
.toast-warning { background: linear-gradient(135deg, #7a5a00, #ffc107); color: #1c1c1e; }
.toast-info    { background: linear-gradient(135deg, #0d4b6b, var(--tg-theme-button-color)); }

/* ─── Разделитель ───────────────────────────────────────────── */
.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: var(--gap-xs) 0;
}

/* ─── Адаптивность ──────────────────────────────────────────── */
@media (max-width: 380px) {
  .app-header { padding: 12px var(--gap-sm); }
  .section { padding: 0 var(--gap-sm); }
  .op-tab { font-size: 10px; }
}

/* Предотвращаем bounce-скролл на iOS */
body { overscroll-behavior: none; }

/* Safe area для notched устройств */
.app-container {
  padding-bottom: 0;
}

/* ─── Нижнее меню (Tab Bar) ─────────────────────────────────── */
.bottom-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(60px + env(safe-area-inset-bottom));
  background: var(--tg-theme-secondary-bg-color);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 900;
  transition: transform 0.3s ease;
}

.bottom-tab-bar.hidden-bar {
  transform: translateY(100%);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--tg-theme-hint-color);
  padding: 8px 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

.tab-btn span {
  font-size: 10px;
  font-weight: 500;
}

.tab-btn.active {
  color: var(--tg-theme-button-color);
}

/* ─── Редизайн сканера ──────────────────────────────────────── */
.scanner-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
}

.scanner-video-wrapper {
  position: relative;
}

.scanner-overlay-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
  z-index: 10;
}

.scanner-control-btn {
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.2s ease, color 0.2s ease;
}

.scanner-control-btn.active {
  background: rgba(0, 0, 0, 0.8);
  color: var(--tg-theme-button-color);
}

/* Желтая рамка и сканирующая линия */
.scanner-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 40%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}

/* Скрываем дефолтный синий бордер и элементы сканера от html5-qrcode */
#qr-shaded-region {
  border-width: 0 !important;
}
#qr-shaded-region path {
  display: none !important;
}

.scanner-frame::before,
.scanner-frame::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 3px solid #ffcc00;
  box-sizing: border-box;
}

.scanner-frame::before {
  clip-path: polygon(0 0, 20px 0, 20px 3px, 3px 3px, 3px 20px, 0 20px, 0 calc(100% - 20px), 3px calc(100% - 20px), 3px calc(100% - 3px), 20px calc(100% - 3px), 20px 100%, 0 100%);
}

.scanner-frame::after {
  clip-path: polygon(100% 0, calc(100% - 20px) 0, calc(100% - 20px) 3px, calc(100% - 3px) 3px, calc(100% - 3px) 20px, 100% 20px, 100% calc(100% - 20px), calc(100% - 3px) calc(100% - 20px), calc(100% - 3px) calc(100% - 3px), calc(100% - 20px) calc(100% - 3px), calc(100% - 20px) 100%, 100% 100%);
}

.scanner-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: #ffcc00;
  box-shadow: 0 0 10px #ffcc00;
  transform: translateY(-50%);
}

/* ─── Ролевая модель ──────────────────────────────────────────────────────── */
body[data-role="worker"] .admin-only,
body[data-role="manager"] .admin-only,
body[data-role="viewer"] .admin-only {
  display: none !important;
}

body[data-role="worker"] .manager-only,
body[data-role="viewer"] .manager-only {
  display: none !important;
}

/* ============================================================
   NEW V3 CLASSES (Global Redesign)
   ============================================================ */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
}

.appbar {
  display: flex; align-items: center; justify-content: space-between; 
  padding: 8px 18px 10px; flex-shrink: 0;
  background: var(--bg);
  position: sticky; top: 0; z-index: 50;
}
.back { display: flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 600; font-size: 15px; cursor: pointer; }
.back.disabled { opacity: .35; pointer-events: none; }
.title-block { text-align: center; }
.title-block .t1 { font-size: 15px; font-weight: 700; }
.title-block .t2 { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
.appbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 29px; height: 29px; border-radius: 50%; border: 1.3px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-dim); flex-shrink: 0; cursor: pointer; background: var(--surface); }
.icon-btn:active { background: var(--surface3); }

.context { display: flex; align-items: center; justify-content: space-between; padding: 2px 18px 12px; flex-shrink: 0; background: var(--bg); }
.wh { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.wh .ic { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-dim); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.wh .name { color: var(--accent); }
.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); font-weight: 500; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); flex-shrink: 0; }
hr.sep { border: none; height: 1px; background: var(--border-soft); margin: 0 18px; flex-shrink: 0; }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 18px 14px; background: var(--bg); -webkit-overflow-scrolling: touch; }
.content::-webkit-scrollbar { display: none; }
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; animation: fadeIn 0.2s ease; }

.section-label { font-size: 11.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.section-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

/* ===== HOME ===== */
.group-title { font-size: 11.5px; font-weight: 700; color: var(--text-faint); margin: 16px 2px 7px; }
.group-title:first-of-type { margin-top: 0; }
.op-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.op-card { display: flex; align-items: center; gap: 12px; padding: 13px 13px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.op-card:last-child { border-bottom: none; }
.op-card:active { background: var(--surface3); }
.op-ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.op-title { flex: 1; font-size: 14.5px; font-weight: 600; }
.op-badge { background: var(--scan); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.op-chev { color: var(--text-faint); flex-shrink: 0; }

/* ===== DOCS ===== */
.tools-row { display: flex; gap: 7px; margin-bottom: 10px; }
.search-compact { flex: 1; display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 8px 11px; }
.search-compact svg { flex-shrink: 0; color: var(--text-faint); }
.search-compact input { flex: 1; background: none; border: none; color: var(--text); font-size: 12.5px; font-weight: 500; }
.search-compact input:focus { outline: none; }
.search-compact input::placeholder { color: var(--text-faint); }
.filter-row { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 12px; }
.filter-row::-webkit-scrollbar { display: none; }
.fchip { flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; background: var(--surface); border: 1.5px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--text-dim); cursor: pointer; }
.fchip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.date-group-title { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin: 14px 2px 7px; }
.date-group-title:first-child { margin-top: 0; }
.doc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 13px; margin-bottom: 8px; cursor: pointer; }
.doc-card:active { background: var(--surface3); }
.doc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.doc-name { font-size: 14px; font-weight: 700; line-height: 1.3; }
.doc-date { font-size: 11px; color: var(--text-faint); flex-shrink: 0; white-space: nowrap; font-family: 'JetBrains Mono', monospace; margin-top: 1px; }
.doc-bottom { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.status-pill { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 8px; }
.contractor { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-dim); }

/* ===== PRODUCTS ===== */
.products-screen, .documents-screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.products-screen .screen, .documents-screen .screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.products-screen .screen.active, .documents-screen .screen.active {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.prod-search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.prod-search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.prod-search svg { flex-shrink: 0; color: var(--text-faint); }
.prod-search input { flex: 1; background: none; border: none; color: var(--text); font-size: 13px; font-weight: 500; }
.prod-search input:focus { outline: none; }
.prod-search input::placeholder { color: var(--text-faint); }
.scan-fab { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-dim); flex-shrink: 0; cursor: pointer; }
.scan-fab:active { background: var(--surface3); }

.prod-item { position: relative; overflow: hidden; border-bottom: 1px solid var(--border-soft); }
.prod-item:last-child { border-bottom: none; }
.prod-actions { position: absolute; top: 0; right: 0; bottom: 0; width: 88px; display: flex; }
.swipe-action { width: 100%; border: none; background: var(--accent); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 700; cursor: pointer; }
.swipe-action:active { background: var(--accent); filter: brightness(.92); }
.prod-row { display: flex; gap: 10px; padding: 9px 2px; background: var(--bg); position: relative; touch-action: pan-y; will-change: transform; }
.prod-row.dragging { transition: none; }
.prod-row.snap { transition: transform .18s ease; }
.prod-num { width: 16px; flex-shrink: 0; font-size: 10.5px; color: var(--text-faint); font-weight: 600; padding-top: 2px; font-family: 'JetBrains Mono', monospace; }
.prod-info { flex: 1; min-width: 0; }
.prod-name { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-bc { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.prod-stock { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.stock-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.stock-txt { font-size: 12px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

.empty-state { text-align: center; padding: 30px 10px; color: var(--text-faint); font-size: 12.5px; }

/* ===== TABBAR ===== */
.tabbar { flex-shrink: 0; display: flex; padding: 7px 6px 18px; border-top: 1px solid var(--border-soft); background: var(--bg); position: sticky; bottom: 0; z-index: 50; }
.tab-badge { position: absolute; top: -6px; right: -8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 5px; border-radius: 10px; min-width: 16px; text-align: center; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--text-faint); font-size: 10px; font-weight: 600; cursor: pointer; transition: .15s; }
.tab.active { color: var(--accent); }
.tab svg { width: 19px; height: 19px; }

/* ===== BOTTOM SHEET ===== */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(10,12,15,.45); z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 20px 22px;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.32,.72,0,1);
  box-shadow: 0 -20px 50px -20px rgba(0,0,0,.35);
}
.sheet.show { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 3px; margin: 0 auto 16px; }
.sheet-title { font-size: 16px; font-weight: 800; margin-bottom: 3px; }
.sheet-sub { font-size: 12.5px; color: var(--text-dim); margin-bottom: 16px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sheet-label { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px; }
.sheet-input {
  width: 100%; background: var(--surface3); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 13px 14px; font-size: 15px; font-weight: 700; color: var(--text); font-family: 'JetBrains Mono', monospace;
  margin-bottom: 18px; outline: none; box-sizing: border-box;
}
.sheet-input:focus { border-color: var(--accent); }
.sheet-actions { display: flex; gap: 10px; }
.sheet-btn { flex: 1; padding: 13px 0; border-radius: 13px; font-size: 14px; font-weight: 700; text-align: center; cursor: pointer; }
.sheet-btn.ghost { background: var(--surface3); color: var(--text-dim); }
.sheet-btn.primary { background: var(--accent); color: #fff; }
.sheet-btn.primary:active, .sheet-btn.ghost:active { filter: brightness(.95); }

/* ===== TOAST (redefined to match mockup) ===== */
.toast-v3 {
  position: fixed; left: 18px; right: 18px; bottom: 76px; z-index: 1000;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 12.5px;
  border-radius: 12px; padding: 11px 15px; text-align: center;
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: .25s;
}
.toast-v3.show { transform: translateY(0); opacity: 1; }


/* ═══════════════════════════════════════════════════════════════════
   TASK SCREEN — Redesign v65
   Использует CSS-переменные из :root / [data-theme] без маппинга —
   все переменные (--bg, --surface, --accent и т.д.) уже определены.
   ═══════════════════════════════════════════════════════════════════ */

/* Override базовых стилей .task-screen чтобы контент не прокручивался снаружи */
.task-screen {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  overflow: hidden !important;
  padding-bottom: 0 !important;
  position: relative;
}

/* ─── Контекстная панель (склад + действия) ──────────────────── */
.ts-ctx {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 8px;
  flex-shrink: 0;
  gap: 10px;
}
.ts-wh {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 14.5px;
  flex-shrink: 0;
}
.ts-wh-ic {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.ts-wh-name { color: var(--accent); }
.ts-ctx-actions { display: flex; align-items: center; gap: 7px; }

/* Кнопка сброса */
.ts-reset-icon {
  width: 29px; height: 29px;
  border-radius: 9px;
  background: var(--surface3);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
  transition: background .15s, color .15s;
}

/* Кнопка "Провести" */
.ts-cta {
  background: var(--surface3);
  color: var(--text-faint);
  font-size: 13px; font-weight: 700;
  padding: 8px 14px;
  border-radius: 11px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.ts-cta.ready {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(51,102,255,.5);
}
.ts-cta.ready:active { transform: scale(.96); }

/* ─── Строка документа ────────────────────────────────────────── */
.ts-doc-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 8px;
  flex-shrink: 0;
}
.ts-doc-lbl {
  font-size: 11px; font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em;
}
.ts-doc-num {
  font-size: 11px; font-weight: 700;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}
.ts-doc-src {
  font-size: 10.5px; color: var(--text-faint);
  display: flex; align-items: center; gap: 5px;
}

/* ─── Зона сканера ────────────────────────────────────────────── */
.ts-scan-zone { padding: 0 18px 8px; flex-shrink: 0; }

.ts-scanbar {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 9px 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ts-scanbar.armed { border-color: var(--scan); background: var(--scan-dim); }

.ts-sb-ic {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--surface3); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, color .15s;
}
.ts-scanbar.armed .ts-sb-ic { background: var(--scan); color: #1a1200; }

.ts-sb-txt {
  flex: 1; font-size: 13px; font-weight: 600; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ts-scanbar.armed .ts-sb-txt { color: var(--scan); }

.ts-kbd-toggle {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--surface3); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, color .15s;
}
.ts-kbd-toggle.on { background: var(--accent); color: #fff; }

/* Выезжающая панель сканера */
.ts-scan-panel {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .25s ease, opacity .18s ease, margin .25s ease;
}
.ts-scan-panel.open              { opacity: 1; margin-top: 8px; }
.ts-scan-panel.open.mode-view    { max-height: 220px; }
.ts-scan-panel.open.mode-manual  { max-height: 80px; }

.ts-scan-inner {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 10px;
}

/* Видоискатель камеры */
.ts-viewfinder-block { display: none; }
.ts-scan-panel.mode-view .ts-viewfinder-block { display: block; }

.ts-viewfinder {
  position: relative; height: 130px;
  border-radius: var(--r-md);
  background: #08090b; overflow: hidden; margin-bottom: 7px;
}
.ts-corner {
  position: absolute; width: 12px; height: 12px;
  border: 2px solid var(--scan); opacity: .85;
}
.ts-corner.tl { top: 6px;    left: 6px;  border-right: none; border-bottom: none; border-radius: 4px 0 0 0; }
.ts-corner.tr { top: 6px;    right: 6px; border-left: none;  border-bottom: none; border-radius: 0 4px 0 0; }
.ts-corner.bl { bottom: 6px; left: 6px;  border-right: none; border-top: none;    border-radius: 0 0 0 4px; }
.ts-corner.br { bottom: 6px; right: 6px; border-left: none;  border-top: none;    border-radius: 0 0 4px 0; }

.ts-scanline {
  position: absolute; left: 6px; right: 6px; height: 2px;
  background: var(--scan); box-shadow: 0 0 10px 2px var(--scan);
  animation: ts-sweep 1.5s ease-in-out infinite; z-index: 2;
}
@keyframes ts-sweep { 0% { top: 14%; } 50% { top: 78%; } 100% { top: 14%; } }

.ts-vf-status {
  text-align: center; font-size: 11px; font-weight: 600; color: var(--text-dim);
}
.ts-vf-status.err { color: var(--danger); }

/* Ручной ввод */
.ts-manual-block { display: none; }
.ts-scan-panel.mode-manual .ts-manual-block {
  display: flex; gap: 8px; align-items: center;
}
.ts-manual-block input {
  flex: 1;
  background: var(--surface3); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 11px;
  color: var(--text); font-size: 13.5px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.ts-manual-block input:focus { outline: none; border-color: var(--accent); }
.ts-manual-go {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
}

/* ─── Основной контент (скроллируется) ───────────────────────── */
.ts-content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 18px 16px;
}
.ts-content::-webkit-scrollbar { display: none; }

/* ─── Предупреждение об излишках ──────────────────────────────── */
.ts-warn-strip {
  display: flex; align-items: center; gap: 8px;
  background: var(--scan-dim); color: var(--scan);
  border-radius: 11px; padding: 8px 11px;
  font-size: 11.5px; font-weight: 600; margin-bottom: 8px;
}

/* ─── Сводная карточка ────────────────────────────────────────── */
.ts-summary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 12px 10px; margin-bottom: 8px;
}
.ts-sum-top {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.ts-sum-label {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em;
}
.ts-sum-nums {
  font-size: 14.5px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace; color: var(--text);
}
.ts-sum-exp { color: var(--text-faint); font-weight: 600; }

.ts-stack-bar {
  display: flex; height: 7px; border-radius: 4px;
  overflow: hidden; background: var(--surface3); margin-bottom: 9px;
}
.ts-stack-bar span { height: 100%; transition: width .3s; }

.ts-tools-row { display: flex; gap: 7px; }
.ts-tool-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 20px;
  background: var(--surface3); font-size: 11.5px; font-weight: 600;
  color: var(--text-dim); cursor: pointer;
}
.ts-tool-btn.active  { background: var(--accent-dim); color: var(--accent); }
.ts-tool-icon-only   { padding: 6px; width: 28px; height: 28px; justify-content: center; }

/* Легенда-фильтр */
.ts-legend-wrap {
  max-height: 0; overflow: hidden;
  transition: max-height .2s ease, margin .2s ease;
}
.ts-legend-wrap.open { max-height: 60px; margin-top: 8px; }
.ts-legend {
  display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px;
}
.ts-legend::-webkit-scrollbar { display: none; }
.ts-chip {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; padding: 6px 11px; border-radius: 20px;
  background: var(--surface3); border: 1.5px solid transparent;
  font-size: 11.5px; font-weight: 600; color: var(--text-dim); cursor: pointer;
}
.ts-cdot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ts-chip.active { border-color: currentColor; background: var(--surface2); color: var(--text); }

/* Поиск */
.ts-search-wrap {
  max-height: 0; overflow: hidden;
  transition: max-height .2s ease, margin .2s ease;
}
.ts-search-wrap.open { max-height: 50px; margin-top: 8px; }
.ts-search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface3); border-radius: 11px; padding: 8px 11px;
}
.ts-search-box svg  { flex-shrink: 0; color: var(--text-faint); }
.ts-search-box input {
  flex: 1; background: none; border: none;
  color: var(--text); font-size: 13px; font-weight: 500;
}
.ts-search-box input:focus   { outline: none; }
.ts-search-box input::placeholder { color: var(--text-faint); }

/* ─── Строки товаров ──────────────────────────────────────────── */
.ts-item-row {
  padding: 8px 2px;
  border-bottom: 1px solid var(--border-soft);
  transition: background .15s;
}
.ts-item-row:last-child { border-bottom: none; }
.ts-item-row.flash { background: var(--accent-dim); border-radius: 10px; }

.ts-item-main { display: flex; align-items: center; gap: 8px; }

.ts-row-num {
  width: 14px; flex-shrink: 0;
  font-size: 10px; font-weight: 600; color: var(--text-faint);
  text-align: right; font-family: 'JetBrains Mono', monospace;
}

/* Кольцо прогресса */
.ts-ring {
  width: 30px; height: 30px; border-radius: 50%;
  position: relative; flex-shrink: 0;
}
.ts-ring::after {
  content: "";
  position: absolute; inset: 3.5px;
  border-radius: 50%; background: var(--bg);
}
.ts-glyph {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
}

.ts-row-info { flex: 1; min-width: 0; }
.ts-row-nm {
  font-size: 12.5px; font-weight: 600; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.ts-row-bc {
  font-size: 10px; color: var(--text-faint); margin-top: 1px;
  font-family: 'JetBrains Mono', monospace;
}

.ts-row-nums { text-align: right; flex-shrink: 0; }
.ts-ratio {
  font-size: 13.5px; font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ts-ratio:active { opacity: .6; }
.ts-ratio-exp { color: var(--text-faint); font-weight: 600; }
.ts-delta { font-size: 9.5px; font-weight: 700; margin-top: 1px; }

/* Степпер +/- */
.ts-stepper { display: flex; flex-shrink: 0; gap: 2px; }
.ts-stepper button {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .1s, transform .1s;
}
.ts-stepper button:active { opacity: .7; transform: scale(.9); }
.ts-step-dec {
  background: var(--danger-dim); color: var(--danger); border-radius: 8px;
}
.ts-step-inc {
  background: var(--accent-dim); color: var(--accent); border-radius: 8px;
}

.ts-empty {
  text-align: center; padding: 30px 10px;
  color: var(--text-faint); font-size: 12.5px;
}

/* ─── Шторка точного количества (qty-sheet) ───────────────────── */
/* position: fixed → поверх всего, включая таббар */
.ts-qty-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,12,15,.55);
  z-index: 9998; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.ts-qty-backdrop.show { opacity: 1; pointer-events: auto; }

.ts-qty-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px 34px;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  box-shadow: 0 -20px 50px -20px rgba(0,0,0,.4);
}
.ts-qty-sheet.show { transform: translateY(0); }

.ts-qty-handle {
  width: 36px; height: 4px;
  background: var(--border); border-radius: 3px;
  margin: 0 auto 16px;
}
.ts-qty-title  { font-size: 15px; font-weight: 800; margin-bottom: 2px; color: var(--text); }
.ts-qty-sub    {
  font-size: 12px; color: var(--text-dim); margin-bottom: 16px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ts-qty-label  {
  font-size: 11px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px;
}
.ts-qty-input-row {
  display: flex; align-items: baseline; gap: 7px;
  background: var(--surface3); border: 1.5px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}
.ts-qty-input-row input {
  flex: 1; background: none; border: none;
  font-size: 24px; font-weight: 800;
  color: var(--text); font-family: 'JetBrains Mono', monospace;
  min-width: 0; outline: none;
}
.ts-exp-hint {
  font-size: 13px; color: var(--text-faint); font-weight: 600;
  font-family: 'JetBrains Mono', monospace; flex-shrink: 0;
}
.ts-qty-quick-row { display: flex; gap: 7px; margin-bottom: 18px; }
.ts-qty-quick {
  flex: 1; text-align: center; padding: 9px 0;
  border-radius: 11px;
  background: var(--success-dim); color: var(--success);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.ts-qty-zero { background: var(--surface3); color: var(--text-dim); }
.ts-qty-actions { display: flex; gap: 10px; }
.ts-qty-btn {
  flex: 1; padding: 13px 0; border-radius: 13px;
  font-size: 14px; font-weight: 700; text-align: center;
  cursor: pointer; border: none;
}
.ts-qty-ghost   { background: var(--surface3); color: var(--text-dim); }
.ts-qty-primary { background: var(--accent); color: #fff; }



/* Safe Full-Width Lists */
#screen-home .content,
#screen-documents .content,
#screen-tasks .content {
  padding-left: 0;
  padding-right: 0;
}

#screen-home .content > *,
#screen-documents .content > *,
#screen-tasks .content > * {
  padding-left: 18px;
  padding-right: 18px;
}

#screen-home .content > .documents-list,
#screen-documents .content > .documents-list,
#screen-tasks .content > #tasks-list,
.documents-list {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.doc-card {
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  padding-left: 18px !important;
  padding-right: 18px !important;
}

/* ============================================================
   Печать этикеток v2 (Шаблоны МойСклад + Live Preview)
   ============================================================ */
.print-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 24px;
}

/* Карточка статуса принтера */
.printer-status-card {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.printer-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.printer-status-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.printer-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.printer-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.printer-name.connected {
  color: var(--success);
}

.printer-subtext {
  font-size: 11.5px;
  color: var(--text-dim);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background .25s ease, box-shadow .25s ease;
}

.printer-actions-row {
  display: flex;
  gap: 8px;
}

.btn-connect, .btn-disconnect {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 10px;
}

/* Поиск товара */
.search-card {
  position: relative;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  outline: none;
  padding: 6px 0;
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-dropdown-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.search-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background .15s ease;
}

.search-result-row:last-child {
  border-bottom: none;
}

.search-result-row:hover, .search-result-row:active {
  background: var(--surface2);
}

.search-result-name {
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  margin-bottom: 3px;
}

.search-result-meta {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.search-result-bc {
  font-family: 'JetBrains Mono', monospace;
}

.search-result-price {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.search-loading-item, .search-empty-item, .search-error-item {
  padding: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* Секция шаблонов МойСклад */
.templates-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge-subtle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 20px;
}

.templates-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.templates-carousel::-webkit-scrollbar {
  display: none;
}

.template-card {
  flex: 0 0 148px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
}

.template-card:active {
  transform: scale(0.97);
}

.template-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent);
}

.template-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.template-card-icon {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.template-card.active .template-card-icon {
  color: var(--accent);
}

.template-card-size {
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.template-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-fields {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.field-tag {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 4px;
}

.template-loading-skeleton, .template-empty, .template-error {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  width: 100%;
}

/* Секция живого предпросмотра */
.print-details-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge-size {
  font-size: 11.5px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface2);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.label-preview-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
  border-radius: var(--r-lg);
  background: #111418;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
}

/* Реалистичная наклейка */
.label-sticker {
  width: 100%;
  max-width: 320px;
  background: #FFFFFF;
  color: #111111;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  position: relative;
  transition: all .25s ease;
  user-select: none;
  overflow: hidden;
}

.sticker-exact-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: #FFFFFF;
}

.label-elem {
  position: absolute;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  overflow: hidden;
  line-height: 1.15;
  color: #000;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
}

.elem-name {
  color: #000;
  word-break: break-word;
  padding: 0 4px;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.elem-name span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}

.elem-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  padding: 2px;
}

.label-elem-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.label-no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #999;
  border: 1px dashed #ccc;
  border-radius: 4px;
}

.elem-static {
  color: #000;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 500;
  justify-content: center;
  text-align: center;
}

.elem-article {
  color: #000;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
  text-align: center;
}

.elem-price {
  color: #000;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  text-align: center;
}

.elem-date {
  color: #222;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 500;
  justify-content: center;
  text-align: center;
  overflow: visible;
}

.elem-barcode {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.barcode-svg-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.barcode-svg-element {
  width: 100%;
  height: 100%;
  display: block;
}

.sticker-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
}

.sticker-title {
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.25;
  color: #000;
  text-align: left;
}

.sticker-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fallback-img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 4px;
}

.fallback-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}

.sticker-barcode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
}

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

/* Управление печатью */
.print-controls-card {
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qty-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qty-control-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.qty-btn:active {
  transform: scale(0.92);
}

.qty-input-field {
  width: 44px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  outline: none;
}

.quick-copies-pills {
  display: flex;
  gap: 8px;
}

.pill-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}

.pill-btn:hover, .pill-btn:active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.print-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-print-main {
  padding: 13px 8px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(51, 102, 255, 0.35);
  white-space: nowrap;
}

.btn-pdf-main {
  padding: 13px 8px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn-pdf-main:hover, .btn-pdf-main:active {
  background: var(--surface3);
  border-color: var(--text-dim);
}


/* ============================================================
   Order Detail Screen (Детальная карточка заказа)
   ============================================================ */

.order-detail-screen {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 24px;
}

.od-agent-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 16px 10px;
}

.od-positions-list {
  display: flex;
  flex-direction: column;
}

.od-pos-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.od-pos-row:last-child {
  border-bottom: none;
}

.od-pos-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.od-pos-info {
  flex: 1;
  min-width: 0;
}

.od-pos-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.od-pos-barcode {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.od-pos-qty {
  text-align: right;
  flex-shrink: 0;
}

.od-qty-fact {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.od-qty-plan {
  font-size: 12px;
  color: var(--text-dim);
}

.od-qty-rem {
  font-size: 10px;
  color: var(--pending);
  margin-top: 2px;
}

.od-linked-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.od-linked-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.od-linked-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.od-linked-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.od-linked-date {
  font-size: 11px;
  color: var(--text-dim);
}

/* ============================================================
   QR Settings — категории товаров
   ============================================================ */

.qr-categories-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.qr-cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  cursor: pointer;
  transition: background 0.15s;
}

.qr-cat-item:active {
  background: var(--surface3);
}

.qr-cat-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.qr-cat-name {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.qr-cat-path {
  font-size: 11px;
  color: var(--text-dim);
}

/* ─── Warehouse Selector Bars ─────────────────────────────────────────────── */
.home-wh-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
}

.home-wh-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.home-wh-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.home-wh-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}

.home-wh-select {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  width: 100%;
}

.doc-wh-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 10px;
}

.doc-wh-bar svg {
  color: var(--accent);
  flex-shrink: 0;
}

.doc-wh-select {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

