/* ==========================================================================
   Склад — стили приложения
   ========================================================================== */

:root {
  --bg: #fbf6f2;
  --bg-soft: #f6ece5;
  --surface: #fffdfc;
  --surface-2: #fdf6f1;
  --surface-3: #f8ebe3;
  --border: #f0ded3;
  --border-strong: #e3c6b7;
  --text: #2a1a14;
  --text-2: #6d4c41;
  --muted: #8a6a5d;
  --accent: #d2471f;
  --accent-2: #d9571f;
  --accent-soft: #fde9e0;
  --on-accent: #ffffff;
  --success: #189e62;
  --success-soft: #e5f7ee;
  --warning: #c07a08;
  --warning-soft: #fdf2df;
  --danger: #c22f21;
  --danger-soft: #fbe9e6;
  --shadow-sm: 0 1px 2px rgba(74, 31, 15, .07);
  --shadow-md: 0 6px 20px -6px rgba(74, 31, 15, .18);
  --shadow-lg: 0 24px 60px -20px rgba(74, 31, 15, .3);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --sidebar: 250px;
  --tabbar-h: 64px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, monospace;
}

/* ------------------------------------------------------------- оформление */
/* Режим (фон и панели) и цвет кнопок — две независимые настройки. */

[data-mode="dark"] {
  --bg: #17100d;
  --bg-soft: #1f1511;
  --surface: #241813;
  --surface-2: #2c1e18;
  --surface-3: #35241d;
  --border: #3d2a22;
  --border-strong: #51382d;
  --text: #f8ece6;
  --text-2: #cfb3a5;
  --muted: #9c7e70;
  --success: #3ecf8e;
  --success-soft: #123127;
  --warning: #e8a63f;
  --warning-soft: #33270f;
  --danger: #ff6a5a;
  --danger-soft: #3d1a15;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
}

/* ---- цвет кнопок в светлом режиме ---- */
[data-accent="orange"] { --accent: #d2471f; --accent-2: #d9571f; --accent-soft: #fde9e0; --on-accent: #ffffff; }
[data-accent="blue"]   { --accent: #2563eb; --accent-2: #3b82f6; --accent-soft: #e3ecff; --on-accent: #ffffff; }
[data-accent="purple"] { --accent: #7c3aed; --accent-2: #8b5cf6; --accent-soft: #efe7fd; --on-accent: #ffffff; }
[data-accent="red"]    { --accent: #dc2626; --accent-2: #ef4444; --accent-soft: #fde8e6; --on-accent: #ffffff; }
[data-accent="green"]  { --accent: #16a34a; --accent-2: #22c55e; --accent-soft: #e2f6e9; --on-accent: #ffffff; }
[data-accent="yellow"] { --accent: #d97706; --accent-2: #f59e0b; --accent-soft: #fdf0d5; --on-accent: #26190a; }
[data-accent="black"]  { --accent: #1f2937; --accent-2: #374151; --accent-soft: #e9ebef; --on-accent: #ffffff; }

/* ---- цвет кнопок в тёмном режиме (мягче и светлее) ---- */
[data-mode="dark"][data-accent="orange"] { --accent: #ff7143; --accent-2: #ff9a5e; --accent-soft: #40221a; --on-accent: #2a120a; }
[data-mode="dark"][data-accent="blue"]   { --accent: #5b8cff; --accent-2: #7aa5ff; --accent-soft: #1b2a4a; --on-accent: #08122a; }
[data-mode="dark"][data-accent="purple"] { --accent: #a78bfa; --accent-2: #c4b5fd; --accent-soft: #2e2447; --on-accent: #140d26; }
[data-mode="dark"][data-accent="red"]    { --accent: #ff6a5a; --accent-2: #ff8a7a; --accent-soft: #3d1a15; --on-accent: #2a0d09; }
[data-mode="dark"][data-accent="green"]  { --accent: #3ecf8e; --accent-2: #5bdcaa; --accent-soft: #123127; --on-accent: #06231a; }
[data-mode="dark"][data-accent="yellow"] { --accent: #fbbf24; --accent-2: #fcd34d; --accent-soft: #33270f; --on-accent: #241a08; }
[data-mode="dark"][data-accent="black"]  { --accent: #e5e7eb; --accent-2: #f3f4f6; --accent-soft: #2a2a2a; --on-accent: #111111; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

a { color: var(--accent); text-decoration: none; }

svg { display: block; }

/* ---------------------------------------------------------------- boot */
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  z-index: 100;
}
.boot-logo {
  width: 72px; height: 72px;
  background: transparent;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.boot-logo img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.boot-title { font-size: 20px; font-weight: 700; letter-spacing: .2px; }
.boot-spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- каркас */
.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}
.brand-mark {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
  background: transparent;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.brand-mark img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong {
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text span { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--text-2);
  font-weight: 550;
  font-size: 14.5px;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-ico { display: grid; place-items: center; }
.nav-ico svg { width: 20px; height: 20px; }
.nav-label { flex: 1; }
.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.sidebar-foot { margin-top: auto; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: left;
}
.user-chip:hover { background: var(--surface-3); }
.user-avatar {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.user-avatar svg { width: 18px; height: 18px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta small { font-size: 11.5px; color: var(--muted); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 28px;
  min-height: 66px;
}
.page-title {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.2px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { display: none; border: none; }

.net-status {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
  transition: background .2s, box-shadow .2s;
}
.net-status.offline { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

.back-btn { display: none; }

.view {
  flex: 1;
  padding: 0 28px 40px;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
}

/* ---------------------------------------------------------------- мобильная навигация */
.tabbar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 40;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  padding-top: 6px;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .tabbar { display: flex; }
  .topbar { padding: 12px 16px; min-height: 58px; }
  .page-title { font-size: 19px; }
  .view { padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px); }
  .topbar-user { display: grid; }
  .back-btn { display: grid; }
  body { font-size: 15.5px; }
}

/* ---------------------------------------------------------------- компоненты */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin: 0 0 10px;
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14.5px;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px -8px var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.06); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-success-soft { background: var(--success-soft); border-color: transparent; color: var(--success); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { min-height: 50px; padding: 0 22px; font-size: 16px; border-radius: 13px; }
.btn-block { width: 100%; }
.btn-icon { min-width: 42px; padding: 0; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn svg { width: 20px; height: 20px; }

/* поля */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 76px; resize: vertical; }
.input::placeholder { color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--danger); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }

.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-wrap .input { padding-left: 38px; }

/* сегменты / чипы */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-3);
  border-radius: 11px;
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
}
.segmented button {
  border: none;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.chip svg { width: 13px; height: 13px; }
.chip .chip-x {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.chip .chip-x:hover { color: var(--danger); }
.chip-mono { font-family: var(--mono); letter-spacing: .3px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- сканер */
.scan-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 20px; align-items: start; }

.scanner-card { overflow: hidden; }

.scanner {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #120c0a;
  overflow: hidden;
}
.scanner video, .scanner #scan-reader, .scanner #scan-reader video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.scanner #scan-reader { border: none !important; }
.scanner-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: #e8d6cc;
  background: radial-gradient(120% 120% at 50% 0%, #2c1d17 0%, #120c0a 70%);
}
.scanner-placeholder .cam-ico {
  width: 66px; height: 66px;
  border-radius: 20px;
  background: rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  color: #fff;
}
.scanner-placeholder .cam-ico svg { width: 32px; height: 32px; }
.scanner-placeholder p { margin: 0; max-width: 300px; line-height: 1.5; font-size: 14px; }

.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
}
.scan-frame {
  width: 74%;
  height: 42%;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(36, 15, 8, .4);
  border: 1px solid rgba(255,255,255,.35);
  position: relative;
}
.scan-frame::before, .scan-frame::after {
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid #fff;
  border-radius: 4px;
}
.scan-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.scan-frame::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.scan-line {
  position: absolute;
  left: 13%;
  right: 13%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ff9a5e, transparent);
  box-shadow: 0 0 12px #ff9a5e;
  animation: scanline 2.1s ease-in-out infinite;
}
@keyframes scanline {
  0%, 100% { top: 30%; opacity: .2; }
  50% { top: 70%; opacity: 1; }
}

.scanner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.scanner-hint {
  font-size: 12.5px;
  color: var(--muted);
  padding: 0 4px 10px;
}

.manual-scan { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.manual-scan .input { font-family: var(--mono); letter-spacing: .5px; }

/* результат сканирования */
.scan-result { padding: 16px; }
.scan-result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 26px 16px;
  color: var(--muted);
}
.scan-result-empty svg { width: 34px; height: 34px; opacity: .5; }

.product-brief { display: flex; flex-direction: column; gap: 14px; }
.pb-head { display: flex; gap: 12px; align-items: flex-start; }
.pb-icon {
  width: 46px; height: 46px;
  flex: 0 0 46px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.pb-icon svg { width: 23px; height: 23px; }
.pb-title { font-size: 17px; font-weight: 700; line-height: 1.25; margin: 0 0 4px; }
.pb-sub { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

.stock-big { display: flex; align-items: baseline; gap: 8px; }
.stock-big b { font-size: 32px; font-weight: 750; letter-spacing: -1px; line-height: 1; }
.stock-big span { color: var(--muted); font-size: 14px; }
.stock-big.low b { color: var(--warning); }
.stock-big.out b { color: var(--danger); }

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
}
.qty-control button {
  width: 40px; height: 40px;
  border-radius: 9px;
  border: none;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  color: var(--text);
}
.qty-control button:hover { background: var(--surface-3); }
.qty-control button svg { width: 18px; height: 18px; }
.qty-control input {
  flex: 1;
  min-width: 0;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  outline: none;
  -moz-appearance: textfield;
}
.qty-control input::-webkit-outer-spin-button,
.qty-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.recent-scans { display: flex; flex-direction: column; gap: 8px; }
.recent-scan {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.recent-scan:hover { background: var(--surface-3); }
.recent-scan .rs-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-scan .rs-qty { font-size: 12.5px; color: var(--muted); }

@media (max-width: 960px) {
  .scan-layout { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- списки / таблицы */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.list-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-row:active { transform: translateY(1px); }

.lr-main { flex: 1; min-width: 0; }
.lr-title { font-weight: 650; font-size: 14.5px; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.lr-sub .mono { font-family: var(--mono); }
.lr-side { display: flex; align-items: center; gap: 14px; }
.lr-qty { text-align: right; }
.lr-qty b { display: block; font-size: 17px; font-weight: 750; line-height: 1.2; letter-spacing: -.3px; }
.lr-qty small { font-size: 11.5px; color: var(--muted); }
.lr-qty.low b { color: var(--warning); }
.lr-qty.out b { color: var(--danger); }

.thumb {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 11px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--text-2);
}
.thumb svg { width: 20px; height: 20px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 700;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .95em; }

.qty-pos { color: var(--success); font-weight: 700; }
.qty-neg { color: var(--danger); font-weight: 700; }

/* ---------------------------------------------------------------- статистика */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat .stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .stat-value { font-size: 24px; font-weight: 750; letter-spacing: -.6px; line-height: 1.1; }
.stat .stat-foot { font-size: 12px; color: var(--muted); }
.stat.accent { background: linear-gradient(150deg, var(--accent), var(--accent-2)); border: none; color: var(--on-accent); box-shadow: 0 12px 30px -14px var(--accent); }
.stat.accent .stat-label, .stat.accent .stat-foot { color: var(--on-accent); opacity: .78; }
.stat.warn .stat-value { color: var(--warning); }
.stat.bad .stat-value { color: var(--danger); }

@media (max-width: 860px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .stat-value { font-size: 21px; }
}

/* ---------------------------------------------------------------- пустое состояние */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 54px 24px;
  color: var(--muted);
}
.empty-ico {
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--muted);
}
.empty-ico svg { width: 30px; height: 30px; }
.empty h3 { margin: 0; font-size: 16px; color: var(--text); }
.empty p { margin: 0; max-width: 380px; font-size: 13.5px; line-height: 1.5; }

/* ---------------------------------------------------------------- документы */
.doc-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.doc-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.doc-ico {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--success-soft);
  color: var(--success);
}
.doc-ico.issue { background: var(--danger-soft); color: var(--danger); }
.doc-ico svg { width: 21px; height: 21px; }
.doc-main { flex: 1; min-width: 0; }
.doc-number { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.doc-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.doc-side { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.doc-sum { font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; }

.doc-items { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.doc-item .di-main { flex: 1; min-width: 0; }
.doc-item .di-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item .di-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.doc-item .di-qty { display: flex; align-items: center; gap: 6px; }
.doc-item .di-qty input { width: 64px; min-height: 34px; padding: 4px 8px; text-align: center; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); }
.doc-item .di-price { width: 92px; min-height: 34px; padding: 4px 8px; text-align: right; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); }

.doc-total {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.doc-total .dt-item { display: flex; flex-direction: column; gap: 2px; }
.doc-total .dt-item small { font-size: 11.5px; color: var(--muted); }
.doc-total .dt-item b { font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  padding: 14px 0;
  display: flex;
  gap: 10px;
  z-index: 5;
  margin-top: auto;
}

/* ---------------------------------------------------------------- настройки */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 760px; }
.settings-card { padding: 18px; border-radius: var(--radius); }
.settings-card h3 { margin: 0 0 4px; font-size: 15.5px; }
.settings-card .desc { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; padding-bottom: 0; }
.settings-row .sr-text { min-width: 0; }
.settings-row .sr-text b { display: block; font-size: 14px; font-weight: 650; }
.settings-row .sr-text small { color: var(--muted); font-size: 12.5px; }

.sr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.addr-box {
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  word-break: break-all;
}

/* ---------------------------------------------------------------- drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 16, 9, .5);
  backdrop-filter: blur(2px);
  z-index: 60;
  opacity: 0;
  transition: opacity .2s;
}
.drawer-backdrop.open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  background: var(--surface);
  z-index: 61;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .24s cubic-bezier(.4, 0, .2, 1);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }
.drawer-foot {
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  background: var(--surface);
}
.drawer-foot .spacer { flex: 1; }

@media (max-width: 860px) {
  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(88vh, 720px);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .drawer.open { transform: translateY(0); }
  .drawer-head::before {
    content: "";
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
  }
  .drawer-head { position: relative; padding-top: 22px; }
}

/* ---------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(38, 16, 9, .55);
  backdrop-filter: blur(3px);
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  transition: opacity .18s;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  width: min(480px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: scale(.97);
  transition: transform .18s;
}
.modal-backdrop.open .modal { transform: scale(1); }
.modal-head { padding: 18px 18px 0; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-head p { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 0 18px 18px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-foot .spacer { flex: 1; }

/* сканер в модальном окне */
.modal-scan { width: min(560px, 100%); }
.modal-scan .modal-body { padding: 0; }
.modal-scan #scan-reader { width: 100% !important; }
.scan-modal-stage { position: relative; background: #120c0a; aspect-ratio: 4/3; overflow: hidden; }
.scan-modal-stage video { position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: cover; }
.scan-modal-stage #scan-reader { position: absolute; inset: 0; }
.scan-modal-status { padding: 12px 18px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- toast */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
@media (max-width: 860px) {
  .toast-root { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px); }
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #2e1c15;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 550;
  animation: toastIn .2s ease-out;
  pointer-events: auto;
}
.toast svg { width: 18px; height: 18px; flex: 0 0 18px; }
.toast.ok svg { color: #7ef0b4; }
.toast.err { background: #3d1713; }
.toast.err svg { color: #ff8f87; }
.toast.info svg { color: #ffb083; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- прочее */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.center { text-align: center; }
.flex-1 { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warn-text { color: var(--warning); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.scroll-y { overflow-y: auto; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.load-more { display: flex; justify-content: center; padding: 14px; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .action-pair { grid-template-columns: 1fr; }
  .doc-sum { display: none; }
  .doc-item { flex-wrap: wrap; gap: 8px; }
  .doc-item .di-main { flex-basis: 100%; }
  .doc-item .di-qty { margin-left: auto; }
  .doc-item .di-price { width: 84px; }
}

/* печать */
@media print {
  .sidebar, .tabbar, .topbar, .sticky-actions, .drawer-foot, .toolbar { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; max-width: none; }
  .drawer, .modal { position: static; box-shadow: none; transform: none; width: auto; height: auto; }
  .drawer-backdrop, .modal-backdrop { display: none; }
}

/* ---------------------------------------------------------------- вход в приложение */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.auth-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand img { width: 56px; height: 56px; object-fit: contain; }
.auth-brand strong { display: block; font-size: 16px; }
.auth-brand span { font-size: 12.5px; color: var(--muted); }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.2px; }
.auth-hint { margin: 0 0 18px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.auth-fields { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.auth-check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.auth-check input { width: 17px; height: 17px; accent-color: var(--accent); }
.auth-foot { margin: 14px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- темы в настройках */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}
.theme-swatch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
}
.theme-swatch:hover { border-color: var(--border-strong); }
.theme-swatch.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.theme-dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); flex: 0 0 18px; }

/* ---------------------------------------------------------------- аккаунт */
.account-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}
.account-avatar {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
}
.account-text { display: flex; flex-direction: column; min-width: 0; }
.account-text strong { font-size: 15.5px; }
.account-text span { font-size: 12.5px; color: var(--muted); }
.users-list { display: flex; flex-direction: column; gap: 8px; }

/* ---------------------------------------------------------------- заказ поставщику */
.order-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px;
}
.order-head h2 { margin: 0 0 4px; font-size: 18px; }
.order-head .desc { margin: 0; font-size: 13.5px; color: var(--muted); }
.order-head-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.order-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.order-chip svg { width: 16px; height: 16px; }
.order-chip.out { background: var(--danger-soft); color: var(--danger); }
.order-chip.low { background: var(--warning-soft); color: var(--warning); }
.order-supplier { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.order-supplier .input { min-width: 200px; max-width: 280px; }
.order-all { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.order-all input { width: 17px; height: 17px; accent-color: var(--accent); }
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.order-row.chosen { border-color: var(--accent); }
.order-check { display: flex; }
.order-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.order-main { display: flex; flex-direction: column; min-width: 0; }
.order-main b { font-size: 14.5px; }
.order-main small { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.order-stock { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.order-stock small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.order-qty { display: flex; align-items: center; gap: 4px; }
.order-qty .input { width: 62px; text-align: center; padding: 6px 4px; }
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 16px;
  line-height: 1;
  color: var(--text-2);
}
.qty-btn:hover { border-color: var(--border-strong); }
.order-sum { min-width: 88px; text-align: right; font-weight: 600; font-size: 13.5px; }
.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  position: sticky;
  bottom: calc(var(--tabbar-h) + 8px);
  z-index: 5;
}
.order-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.order-total { font-size: 14px; }
.btn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11.5px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .order-supplier { width: 100%; }
  .order-supplier .input { flex: 1; max-width: none; }
  .order-row { grid-template-columns: 24px minmax(0, 1fr); align-items: start; }
  .order-stock, .order-qty, .order-sum { grid-column: 2; text-align: left; }
  .order-actions { bottom: calc(var(--tabbar-h) + 4px); }
  .order-buttons { width: 100%; }
  .order-buttons .btn { flex: 1; }
}

/* ---------------------------------------------------------------- печать */
#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
}
.print-page { font: 12px/1.45 "Segoe UI", Arial, sans-serif; color: #000; }
.print-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #000;
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.print-head h1 { font-size: 18px; margin: 0 0 2px; }
.print-head .muted { color: #444; font-size: 11px; }
.print-supplier { text-align: right; font-size: 11px; }
.print-supplier span { display: block; color: #555; }
.print-supplier b { font-size: 13px; }
.print-page table { width: 100%; border-collapse: collapse; }
.print-page th, .print-page td { border: 1px solid #999; padding: 5px 6px; vertical-align: top; }
.print-page th { background: #eee; font-size: 11px; text-align: left; }
.print-page .c { text-align: center; }
.print-page .r { text-align: right; }
.print-page .sub { color: #555; font-size: 10px; }
.print-page .mono { font-family: Consolas, monospace; font-size: 10.5px; }
.print-total { margin-top: 10px; text-align: right; font-size: 13px; }
.print-foot { margin-top: 16px; color: #555; font-size: 10px; }
.order-sum b { display: block; }
.order-sum small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }

/* ---------------------------------------------------------------- выбор записей в истории */
.pick { display: flex; align-items: center; padding-right: 2px; }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* ---------------------------------------------------------------- категории товаров */
.cat-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.cat-tab:hover { border-color: var(--border-strong); }
.cat-tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.cat-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.cat-tab.active .cat-count { background: var(--accent); color: var(--on-accent); }

/* ---------------------------------------------------------------- бренд-ссылка */
a.brand {
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  transition: background .15s;
}
a.brand:hover { background: var(--surface-2); }
a.brand:active { transform: translateY(1px); }

/* ---------------------------------------------------------------- список брака */
.defect-add-row { display: flex; gap: 10px; }
.defect-add-row .input { flex: 1; min-width: 0; }
.defect-list { display: flex; flex-direction: column; gap: 8px; }
.defect-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.defect-row:hover { border-color: var(--border-strong); }
.defect-row.picked { border-color: var(--accent); background: var(--accent-soft); }
.defect-row input[type="checkbox"] {
  width: 18px; height: 18px; margin-top: 4px;
  accent-color: var(--accent); flex: 0 0 18px;
}
.defect-num {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.defect-text { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.45; word-break: break-word; }
.defect-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; align-self: center; }

@media (max-width: 720px) {
  .defect-add-row { flex-direction: column; }
  .defect-meta { display: none; }
}

/* ---------------------------------------------------------------- история отправок брака */
.ship {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 8px;
  overflow: hidden;
}
.ship:last-child { margin-bottom: 0; }
.ship summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 13.5px;
}
.ship summary::-webkit-details-marker { display: none; }
.ship summary::after { content: '▾'; color: var(--muted); font-size: 12px; }
.ship[open] summary::after { content: '▴'; }
.ship-when { color: var(--muted); white-space: nowrap; }
.ship-firm { font-weight: 650; }
.ship-pos { margin-left: auto; color: var(--text-2); white-space: nowrap; }
.ship-who { color: var(--muted); white-space: nowrap; }
.ship-list {
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ship-item { display: flex; gap: 8px; font-size: 14px; line-height: 1.4; }
.ship-num { color: var(--accent); font-weight: 700; min-width: 20px; }

@media (max-width: 640px) {
  .ship-who { display: none; }
  .ship summary { flex-wrap: wrap; }
}

/* ---------------------------------------------------------------- индикатор сети у профиля */
.sidebar-foot { display: flex; align-items: center; gap: 8px; }
.sidebar-foot .user-chip { flex: 1; min-width: 0; }
.user-chip .net-status { flex: 0 0 auto; margin-left: auto; margin-right: 4px; }

/* ---------------------------------------------------------------- действия в истории отправок */
.ship-actions { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.ship-actions .btn { padding: 4px 10px; font-size: 12px; }
.ship-actions .btn svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- печать брака (A4) */
@media print {
  @page { size: A4; margin: 14mm; }
  .defect-print-head {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
    margin-bottom: 16px;
  }
  .defect-print-head h1 { margin: 0 0 6px; font-size: 20pt; }
  .defect-print-sub { font-size: 12pt; font-weight: 600; }
  .defect-print-list { margin: 0; padding-left: 24px; font-size: 12pt; line-height: 1.7; }
  .defect-print-list li { margin-bottom: 6px; }
}

@media (max-width: 860px) {
  .ship-actions .btn span { display: none; }
}

/* ---------------------------------------------------------------- фото накладной в приёмке */
.receipt-photos { margin-bottom: 4px; }
.photo-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-card {
  position: relative;
  width: 132px;
  height: 96px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
  position: absolute;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.photo-del svg { width: 14px; height: 14px; }
.photo-del:hover { background: rgba(200, 40, 20, .85); }

.di-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.di-name-input {
  flex: 1;
  min-width: 160px;
  font: inherit;
  font-weight: 650;
  font-size: 14.5px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.di-name-input:focus { outline: none; border-color: var(--accent); }

/* ---------------------------------------------------------------- действия в списке приёмок */
.doc-actions { display: flex; gap: 6px; margin-top: 2px; }
.doc-act {
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.doc-act:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-3); }
.doc-act.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.doc-act svg { width: 15px; height: 15px; }
