/* ============================================================
   Pack-Check — Industrial Precision UI
   Шрифты: Albert Sans (UI), JetBrains Mono (числа/коды)
   Тема: deep blue-black с акцентом ультрамарин и амбер
   ============================================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  /* Surfaces */
  --bg:        #0A0F1C;
  --bg-card:   #0F1726;
  --bg-card2:  #131C2E;
  --bg-hover:  #1A2440;
  --bg-input:  #08101F;

  /* Lines */
  --line:      #1F2942;
  --line-2:    #2D3A5F;

  /* Text */
  --fg:        #E8ECF7;
  --fg-2:      #B8C0D6;
  --muted:     #8A93AE;
  --dim:       #5A627A;

  /* Brand */
  --accent:    #5B8FFF;
  --accent-2:  #4A7AE6;
  --amber:     #FFB020;
  --teal:      #14E3B5;

  /* Status */
  --ok:        #10B981;
  --warn:      #F59E0B;
  --err:       #EF4444;

  /* Type */
  --font-ui:   "Albert Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Effects */
  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;
  --shadow: 0 20px 60px -15px rgba(0,0,0,0.6), 0 8px 20px -10px rgba(0,0,0,0.5);
}

html, body {
  margin: 0; padding: 0; min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px; line-height: 1.45;
  background: var(--bg); color: var(--fg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}

/* Subtle grid texture for industrial feel */
body.screen-pack { background-image:
  radial-gradient(circle at 0% 0%, rgba(91,143,255,0.05) 0%, transparent 35%),
  radial-gradient(circle at 100% 100%, rgba(255,176,32,0.03) 0%, transparent 40%);
  background-attachment: fixed;
}

button, select, input { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--font-mono); font-feature-settings: "ss01", "cv05"; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 38, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 30;
}
.brand {
  font-weight: 800; font-size: 16px; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 8px;
}
.user-box {
  flex: 1; color: var(--muted); font-size: 13px;
  font-family: var(--font-mono); font-weight: 500;
}
.btn-ghost {
  background: var(--bg-card); border: 1px solid var(--line); color: var(--fg);
  padding: 8px 12px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: border-color .15s, background .15s, transform .1s;
}
.btn-ghost:hover { border-color: var(--line-2); background: var(--bg-hover); }
.btn-ghost:active { transform: scale(0.97); }

/* ============================================================
   Login
   ============================================================ */
.screen-login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(91,143,255,0.12) 0%, transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(255,176,32,0.07) 0%, transparent 45%);
}
.login-card {
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-card2) 100%);
  padding: 36px 32px; border-radius: var(--r-lg);
  width: 100%; max-width: 380px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.login-card .hint { color: var(--muted); margin: 6px 0 28px; font-size: 13px; }
.login-card label { display: block; margin: 14px 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.login-card input {
  display: block; width: 100%; margin-top: 8px;
  padding: 12px 14px; font-size: 15px;
  background: var(--bg-input); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,143,255,0.15); }
.login-card button {
  width: 100%; padding: 13px; margin-top: 18px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  background: var(--accent); color: #fff; border: 0;
  border-radius: var(--r-sm); cursor: pointer;
  transition: background .15s, transform .1s;
}
.login-card button:hover { background: var(--accent-2); }
.login-card button:active { transform: translateY(1px); }
.login-card .error { color: var(--err); margin-top: 14px; font-size: 13px; min-height: 18px; }

/* ============================================================
   Main grid
   ============================================================ */
.main-grid {
  padding: 16px; max-width: 1400px; margin: 0 auto;
  display: grid; gap: 16px; grid-template-columns: 1fr;
}
@media (min-width: 1000px) {
  .main-grid { grid-template-columns: 380px 1fr; align-items: start; padding: 20px; gap: 20px; }
}
@media (min-width: 1300px) {
  .main-grid { grid-template-columns: 420px 1fr; }
}

.scanner-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (min-width: 1000px) {
  .scanner-col { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; padding-right: 4px; }
  .scanner-col::-webkit-scrollbar { width: 6px; }
  .scanner-col::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
}

/* ============================================================
   Counters
   ============================================================ */
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.counter {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 8px;
  text-align: center; position: relative; overflow: hidden;
}
.counter::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0.3;
}
.counter span {
  display: block; font-family: var(--font-mono); font-size: 28px; font-weight: 700;
  line-height: 1.1; letter-spacing: -0.02em; font-feature-settings: "tnum";
}
.counter label {
  display: block; margin-top: 4px;
  color: var(--muted); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.counter.ok     { color: var(--ok); }
.counter.ok span     { color: var(--ok); }
.counter.remain { color: var(--amber); }
.counter.remain span { color: var(--amber); }

/* ============================================================
   Scan input
   ============================================================ */
.input-wrap {
  display: flex; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--line);
  padding: 6px; border-radius: var(--r-lg);
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(91,143,255,0.18);
}
#scanInput {
  flex: 1; min-width: 0;
  padding: 14px 16px; font-size: 18px; font-weight: 500;
  background: transparent; color: var(--fg); border: 0;
  font-family: var(--font-mono); letter-spacing: 0.04em;
}
#scanInput:focus { outline: none; }
#scanInput::placeholder { color: var(--dim); font-family: var(--font-ui); letter-spacing: 0; font-weight: 400; }
.btn-camera {
  padding: 0 18px; font-size: 20px; flex-shrink: 0;
  background: var(--bg-input); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; transition: all .15s;
}
.btn-camera:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ============================================================
   Result panel
   ============================================================ */
.result {
  padding: 16px 18px; border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--bg-card);
  min-height: 84px;
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.result.empty { color: var(--muted); font-size: 13px; }
.result.ok        { border-color: var(--ok);   background: linear-gradient(180deg, rgba(16,185,129,0.10) 0%, rgba(16,185,129,0.02) 100%); }
.result.duplicate { border-color: var(--warn); background: linear-gradient(180deg, rgba(245,158,11,0.10) 0%, rgba(245,158,11,0.02) 100%); }
.result.not_found, .result.wrong_state { border-color: var(--err); background: linear-gradient(180deg, rgba(239,68,68,0.10) 0%, rgba(239,68,68,0.02) 100%); }
.result h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.result .muted { color: var(--muted); font-size: 13px; margin-top: 4px; }
.result .small { font-size: 12px; }

/* Расширенный результат скана с составом */
.scan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.scan-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.scan-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.scan-meta .num {
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  font-feature-settings: "tnum"; letter-spacing: -0.01em;
}
.scan-meta .num .hash { color: var(--dim); margin-right: 2px; }
.scan-meta-line {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--fg-2); margin: 4px 0 12px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--line);
}
.scan-meta-line .lbl {
  color: var(--muted); text-transform: uppercase;
  font-size: 10px; letter-spacing: 0.1em; font-weight: 600; margin-right: 4px;
}

table.scan-items { width: 100%; border-collapse: collapse; font-size: 12px; }
table.scan-items thead th {
  text-align: left; padding: 4px 6px 8px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  border-bottom: 1px solid var(--line);
}
table.scan-items thead th.num { text-align: right; }
table.scan-items tbody td {
  padding: 8px 6px; border-bottom: 1px dashed rgba(31,41,66,0.5);
  vertical-align: top;
}
table.scan-items tbody tr:last-child td { border-bottom: 0; }
table.scan-items .col-code { font-family: var(--font-mono); color: var(--accent); font-size: 11px; white-space: nowrap; }
table.scan-items .col-art  { font-family: var(--font-mono); color: var(--fg-2);  font-size: 11px; white-space: nowrap; }
table.scan-items .col-name { color: var(--fg); line-height: 1.4; }
table.scan-items .col-qty  {
  text-align: right; font-family: var(--font-mono); font-weight: 700;
  color: var(--amber); font-feature-settings: "tnum"; white-space: nowrap;
}
table.scan-items .col-qty .x { color: var(--dim); margin-right: 1px; }

.scan-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-primary.small, .btn-secondary.small { padding: 7px 12px; font-size: 12px; }

/* ============================================================
   Camera
   ============================================================ */
.camera-box {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line); background: #000;
}
.camera-box video { width: 100%; max-height: 50vh; display: block; }
.camera-controls {
  position: absolute; top: 8px; right: 8px;
  display: flex; gap: 6px;
}
.camera-controls .btn-ghost {
  background: rgba(15,23,38,0.85); backdrop-filter: blur(8px);
}

/* Прицельная рамка поверх видео */
.camera-box::after {
  content: ""; position: absolute; inset: 22% 12% 22% 12%;
  border: 2px solid rgba(91,143,255,0.7);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
  pointer-events: none;
}

/* ============================================================
   User stats
   ============================================================ */
.user-stats { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.user-stats h4 {
  margin: 0 0 10px; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600;
}
.userstat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 14px; border-top: 1px solid var(--line);
}
.userstat-row:first-of-type { border-top: 0; }
.userstat-row b { font-family: var(--font-mono); color: var(--accent); font-feature-settings: "tnum"; }

/* ============================================================
   Orders column — tabs + filters + list
   ============================================================ */
.orders-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--line);
  background: var(--bg-card); border-radius: var(--r) var(--r) 0 0;
  padding: 0 4px;
}
.tab {
  background: transparent; border: 0; color: var(--muted);
  padding: 12px 18px; font-size: 13px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s;
  letter-spacing: -0.005em;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab .badge {
  background: var(--bg-input); color: var(--fg); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 7px; border-radius: 9px; font-weight: 600;
  font-feature-settings: "tnum";
}
.tab.active .badge { background: var(--accent); color: #fff; border-color: var(--accent); }

.filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 600px) { .filters { grid-template-columns: 1fr auto auto; } }
.filters input, .filters select {
  padding: 10px 12px; background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px;
  transition: border-color .15s;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }
.filters select { min-width: 140px; cursor: pointer; }

.orders-list { display: flex; flex-direction: column; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; background: var(--bg-card); border: 1px dashed var(--line); border-radius: var(--r); font-size: 14px; }

/* ============================================================
   Order card — компактная плитка
   ============================================================ */
.order-card {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; cursor: pointer;
  transition: border-color .15s, transform .1s, background .15s;
  position: relative; overflow: hidden;
}
.order-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0; transition: opacity .15s;
}
.order-card:hover { border-color: var(--line-2); background: var(--bg-card2); }
.order-card:hover::before { opacity: 1; }
.order-card.packed { opacity: 0.55; }
.order-card.packed::before { background: var(--ok); opacity: 1; }

.oc-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.oc-head .num {
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  letter-spacing: -0.01em; font-feature-settings: "tnum"; color: var(--fg);
}
.oc-shk { margin: 0 0 8px; }
.oc-shk code {
  background: var(--bg-input); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: var(--r-sm);
  color: var(--accent); font-size: 13px; font-weight: 500;
  letter-spacing: 0.04em;
}
.oc-items { font-size: 13px; line-height: 1.55; margin: 0 0 10px; }
.item-row { padding: 1px 0; color: var(--fg-2); }
.item-row .qty {
  display: inline-block; min-width: 28px;
  font-family: var(--font-mono); color: var(--muted); font-weight: 500;
  font-feature-settings: "tnum";
}
.item-row code.small { color: var(--dim); font-size: 11px; margin-left: 4px; }
.oc-foot {
  display: flex; justify-content: space-between; font-size: 12px;
  color: var(--muted); padding-top: 10px; border-top: 1px solid var(--line);
}
.oc-foot .price { font-family: var(--font-mono); font-weight: 600; color: var(--fg-2); }

/* Мета-блок карточки: Организация / Дата заказа */
.oc-meta {
  display: grid; grid-template-columns: 1fr;
  gap: 4px 12px; margin: 0 0 10px;
  padding: 8px 10px; background: var(--bg-input);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.oc-meta-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.oc-meta-row .oc-lbl {
  flex: 0 0 auto; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600;
  min-width: 92px;
}
.oc-meta-row .oc-val {
  flex: 1 1 auto; min-width: 0;
  font-size: 13px; color: var(--fg-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.oc-meta-row .oc-val.mono { font-family: var(--font-mono); font-size: 12px; font-feature-settings: "tnum"; color: var(--fg-2); }

/* Mini-таблица позиций в карточке списка */
.oc-items-table {
  width: 100%; border-collapse: collapse;
  font-size: 12px; line-height: 1.4;
  table-layout: fixed;
}
.oc-items-table thead th {
  text-align: left; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); padding: 4px 6px 4px 0;
  border-bottom: 1px solid var(--line);
}
.oc-items-table thead th.num { text-align: right; }
.oc-items-table tbody td {
  padding: 4px 6px 4px 0;
  border-bottom: 1px dashed var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oc-items-table tbody tr:last-child td { border-bottom: 0; }
.oc-items-table .col-code { font-family: var(--font-mono); color: var(--accent); font-size: 11px; width: 80px; }
.oc-items-table .col-art  { font-family: var(--font-mono); color: var(--fg-2);  font-size: 11px; width: 90px; }
.oc-items-table .col-name { color: var(--fg); font-size: 12px; }
.oc-items-table .col-qty  {
  text-align: right; width: 50px;
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  color: var(--accent); font-feature-settings: "tnum";
}
.oc-items-table .col-qty .x { color: var(--dim); margin-right: 1px; font-weight: 400; }
.oc-items-empty { font-size: 12px; color: var(--muted); margin: 0 0 10px; padding: 6px 0; }
.oc-items-more { font-size: 11px; color: var(--muted); padding: 4px 0 0; font-style: italic; }

@media (max-width: 720px) {
  .oc-items-table .col-code, .oc-items-table .col-art { width: auto; max-width: 70px; }
  .oc-meta-row .oc-lbl { min-width: 80px; font-size: 10px; }
}

/* ============================================================
   Chips
   ============================================================ */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--bg-input); color: var(--fg-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.mp     { background: rgba(91,143,255,0.13); color: var(--accent);    border-color: rgba(91,143,255,0.35); }
.chip.org    { background: rgba(255,176,32,0.10);  color: var(--amber);     border-color: rgba(255,176,32,0.30); }
.chip.ok     { background: rgba(16,185,129,0.13);  color: var(--ok);        border-color: rgba(16,185,129,0.35); }
.chip.warn   { background: rgba(245,158,11,0.10);  color: var(--warn);      border-color: rgba(245,158,11,0.30); }
.chip.dim    { background: var(--bg-input);        color: var(--muted);     border-color: var(--line); }

/* ============================================================
   MODAL — Industrial Order Card
   ============================================================ */
.modal {
  position: fixed; inset: 0;
  background: rgba(5, 9, 18, 0.78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 16px;
  overflow-y: auto;
  animation: fadeIn .2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%; max-width: 760px;
  margin: 24px auto;
  box-shadow: var(--shadow);
  position: relative;
  animation: rise .3s cubic-bezier(.2,.7,.3,1);
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--bg-input); border: 1px solid var(--line); color: var(--fg);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  font-size: 14px; display: grid; place-items: center;
  transition: all .15s; z-index: 2;
}
.modal-close:hover { background: var(--err); border-color: var(--err); color: #fff; }

/* Заголовок модалки */
.m-head {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
}
.m-eyebrow {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.18em;
  font-weight: 600; margin-bottom: 6px;
}
.m-title-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.m-num {
  font-family: var(--font-mono); font-weight: 700;
  font-size: 28px; letter-spacing: -0.02em;
  color: var(--fg); font-feature-settings: "tnum";
}
.m-num .hash { color: var(--dim); margin-right: 4px; }
.m-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* Метаданные — две колонки */
.m-meta {
  padding: 18px 28px; display: grid;
  grid-template-columns: 1fr; gap: 12px 24px;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 560px) {
  .m-meta { grid-template-columns: 1fr 1fr; }
}
.m-meta-cell { display: flex; flex-direction: column; gap: 3px; }
.m-meta-cell .lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 600;
}
.m-meta-cell .val {
  font-size: 14px; color: var(--fg-2); font-weight: 500;
}
.m-meta-cell .val.mono {
  font-family: var(--font-mono); font-feature-settings: "tnum";
}

/* Барcode секция */
.m-barcode-section {
  padding: 24px 28px;
  background:
    repeating-linear-gradient(
      45deg, transparent, transparent 12px,
      rgba(91,143,255,0.025) 12px, rgba(91,143,255,0.025) 24px);
  border-bottom: 1px solid var(--line);
}
.m-barcode-eyebrow {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.m-barcode-eyebrow .dot { width: 6px; height: 6px; background: var(--amber); border-radius: 50%; box-shadow: 0 0 8px var(--amber); }
.m-barcode-eyebrow .text {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em;
  font-weight: 700; color: var(--amber);
}

.m-barcode-panel {
  background: #FFFFFF;
  border-radius: var(--r);
  padding: 22px 28px 18px;
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.05),
    0 6px 16px -8px rgba(0,0,0,0.5);
}
/* Угловые скобки — индустриальный декор */
.m-barcode-panel::before, .m-barcode-panel::after,
.m-barcode-panel > .corner-tl, .m-barcode-panel > .corner-br {
  content: ""; position: absolute;
  width: 14px; height: 14px;
  border: 2px solid #1F2942;
}
.m-barcode-panel::before { top: 8px; left: 8px;     border-right: 0; border-bottom: 0; }
.m-barcode-panel::after  { top: 8px; right: 8px;    border-left: 0;  border-bottom: 0; }
.m-barcode-panel > .corner-bl { bottom: 8px; left: 8px;  border-right: 0; border-top: 0; }
.m-barcode-panel > .corner-br { bottom: 8px; right: 8px; border-left: 0;  border-top: 0; }

.m-barcode-panel svg { display: block; width: 100%; height: auto; max-height: 110px; }
.m-barcode-caption {
  margin-top: 8px; text-align: center;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase;
}

.m-actions {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px;
}
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  border: 0; padding: 11px 16px;
  border-radius: var(--r-sm); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; color: var(--fg);
  border: 1px solid var(--line); padding: 11px 16px;
  border-radius: var(--r-sm); font-weight: 500; font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: all .15s;
}
.btn-secondary:hover { border-color: var(--line-2); background: var(--bg-hover); }

/* Состав */
.m-items {
  padding: 22px 28px 26px;
}
.m-items-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px;
}
.m-items h3 {
  margin: 0; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg);
}
.m-items-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  font-feature-settings: "tnum";
}

.positions-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.positions-table thead th {
  text-align: left; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted);
  padding: 8px 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.positions-table thead th.num { text-align: right; }
.positions-table tbody td {
  padding: 11px 8px;
  border-bottom: 1px dashed rgba(31,41,66,0.6);
  vertical-align: top;
}
.positions-table tbody tr:last-child td { border-bottom: 0; }
.positions-table tbody tr:hover { background: rgba(91,143,255,0.04); }

.positions-table .col-idx {
  font-family: var(--font-mono); color: var(--dim);
  font-size: 11px; font-feature-settings: "tnum"; width: 28px;
}
.positions-table .col-code {
  font-family: var(--font-mono); color: var(--accent);
  font-size: 12px; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.positions-table .col-art {
  font-family: var(--font-mono); color: var(--fg-2);
  font-size: 12px; white-space: nowrap;
}
.positions-table .col-name {
  color: var(--fg); line-height: 1.4;
}
.positions-table .col-qty {
  text-align: right; font-family: var(--font-mono);
  font-weight: 700; color: var(--amber);
  font-feature-settings: "tnum"; white-space: nowrap;
}
.positions-table .col-qty .x { color: var(--dim); margin-right: 2px; }

.positions-empty {
  text-align: center; color: var(--muted);
  padding: 24px; border: 1px dashed var(--line); border-radius: var(--r); font-size: 13px;
}

/* Footer мета */
.m-footer-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 14px 28px;
  border-top: 1px solid var(--line);
  background: var(--bg-card2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: 11px; color: var(--muted);
}
.m-footer-meta .pair { display: inline-flex; gap: 6px; align-items: baseline; }
.m-footer-meta .pair b { color: var(--fg-2); font-family: var(--font-mono); font-weight: 500; }

/* Таймлайн обработки заказа в модалке: 4 шага */
.m-timeline {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  position: relative;
}
.m-timeline::before {
  content: ""; position: absolute;
  left: 8%; right: 8%; top: 8px; height: 2px;
  background: var(--line); z-index: 0;
}
.m-timeline .step {
  position: relative; padding-top: 22px;
  text-align: center; min-width: 0; z-index: 1;
}
.m-timeline .step .dot {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--line);
  transition: all .2s;
}
.m-timeline .step.done .dot { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.m-timeline .step.current .dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,143,255,0.18); animation: pulse 1.6s ease-in-out infinite; }
.m-timeline .step .lab { font-size: 11px; font-weight: 600; color: var(--fg-2); text-transform: uppercase; letter-spacing: 0.04em; }
.m-timeline .step.pending .lab { color: var(--muted); }
.m-timeline .step .when { font-size: 10px; color: var(--muted); margin-top: 2px; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(91,143,255,0.18); }
  50%      { box-shadow: 0 0 0 6px rgba(91,143,255,0.08); }
}
@media (max-width: 720px) {
  .m-timeline { grid-template-columns: repeat(2, 1fr); gap: 12px 0; }
  .m-timeline::before { display: none; }
}

/* ============================================================
   Result panel (scan feedback)
   ============================================================ */
.result a.label-link, .label-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 8px 14px;
  background: var(--accent); color: #fff !important;
  border-radius: var(--r-sm); font-weight: 600; font-size: 13px;
  text-decoration: none;
}

/* ============================================================
   Admin
   ============================================================ */
.screen-admin .admin-main { padding: 24px; max-width: 920px; margin: 0 auto; display: grid; gap: 20px; }
.admin-main section { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px; }
.admin-main h2 { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.admin-main h3 { margin: 22px 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; }
.admin-main label { display: block; margin: 12px 0; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.admin-main input, .admin-main select {
  display: block; width: 100%; padding: 10px 12px; margin-top: 6px;
  background: var(--bg-input); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14px;
}
.admin-main input:focus, .admin-main select:focus { outline: none; border-color: var(--accent); }
.admin-main button {
  padding: 11px 22px; background: var(--accent); color: #fff;
  border: 0; border-radius: var(--r-sm); cursor: pointer;
  font-size: 14px; font-weight: 600;
}
.ok-badge { color: var(--ok); margin-left: 12px; font-size: 14px; }

table.history { width: 100%; border-collapse: collapse; font-size: 13px; }
table.history th, table.history td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); }
table.history th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
table.history code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); }
.r-ok { color: var(--ok); font-weight: 600; }
.r-duplicate { color: var(--warn); font-weight: 600; }
.r-not_found, .r-wrong_state { color: var(--err); font-weight: 600; }

/* ============================================================
   Анимации
   ============================================================ */
@keyframes flash { 0%{ opacity:1 } 100%{ opacity: 0.55 } }
.flash { animation: flash .4s ease-out; }

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

/* Кастомный скроллбар у модалки и листов */
.modal::-webkit-scrollbar, .orders-list::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-thumb, .orders-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.modal::-webkit-scrollbar-track, .orders-list::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   ▼▼▼  V2 — единая система кнопок, карточек, адаптива  ▼▼▼
   ============================================================ */

/* === Кнопки: общая база ============================================ */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-tertiary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; min-height: 40px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
  white-space: nowrap;
}
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-ghost:focus-visible,
.btn-danger:focus-visible, .btn-tertiary:focus-visible {
  outline: none; box-shadow: 0 0 0 3px rgba(91,143,255,0.35);
}
.btn-primary:active, .btn-secondary:active, .btn-ghost:active,
.btn-danger:active, .btn-tertiary:active { transform: translateY(1px); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-ghost:disabled,
.btn-danger:disabled, .btn-tertiary:disabled {
  opacity: 0.45; cursor: not-allowed; transform: none !important;
}

/* === Primary: главное действие экрана =============================== */
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 4px 14px -6px rgba(91,143,255,0.55);
}
.btn-primary:hover { background: var(--accent-2); }

/* === Secondary: вторичное (outline) ================================ */
.btn-secondary {
  background: var(--bg-card); color: var(--fg); border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--line-2); background: var(--bg-hover); }

/* === Ghost: иконки в шапке/мелочи ==================================== */
.btn-ghost {
  background: var(--bg-card); border-color: var(--line); color: var(--fg);
  padding: 8px 12px; min-height: 36px; font-size: 13px; font-weight: 500;
}
.btn-ghost:hover { border-color: var(--line-2); background: var(--bg-hover); }

/* === Danger: деструктивные действия ================================== */
.btn-danger {
  background: transparent; color: var(--err); border-color: rgba(239,68,68,0.45);
}
.btn-danger:hover { background: rgba(239,68,68,0.08); border-color: var(--err); }

/* === Tertiary: текстовая ссылка-кнопка =============================== */
.btn-tertiary {
  background: transparent; color: var(--fg-2); border-color: transparent; padding: 8px 10px;
}
.btn-tertiary:hover { color: var(--fg); background: var(--bg-card2); }

/* === Размеры ========================================================= */
.btn-lg  { min-height: 54px; padding: 14px 22px; font-size: 16px; border-radius: var(--r); }
.btn-sm, .btn-primary.small, .btn-secondary.small {
  min-height: 32px; padding: 7px 12px; font-size: 12px; gap: 6px;
}

/* === Loading-состояние =============================================== */
.btn-primary.is-loading, .btn-secondary.is-loading, .btn-ghost.is-loading,
.btn-danger.is-loading, .btn-tertiary.is-loading {
  position: relative; color: transparent !important; pointer-events: none;
}
.btn-primary.is-loading::after, .btn-secondary.is-loading::after, .btn-ghost.is-loading::after,
.btn-danger.is-loading::after, .btn-tertiary.is-loading::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; left: 50%; top: 50%; margin: -7px 0 0 -7px;
  color: var(--fg);
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === Карточка: статус-полоса слева (разные цвета по состоянию) ====== */
.order-card { padding-left: 18px; }
.order-card::before { width: 4px; opacity: 1; }   /* всегда видна, не только на hover */
.order-card[data-state="pending"]::before { background: var(--accent); }
.order-card[data-state="packed"]::before  { background: var(--ok); }
.order-card[data-state="syncing"]::before { background: var(--warn); }
.order-card[data-state="synced"]::before  { background: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.order-card.packed { opacity: 0.7; }              /* мягче чем 0.55 — позиции читать */

/* === Мини-таймлайн на карточке (4 точки) ============================ */
.oc-progress {
  position: relative; display: grid; grid-template-columns: repeat(4, 1fr);
  margin: 0 0 10px; padding: 12px 4px 4px;
}
.oc-progress::before {
  content: ""; position: absolute; left: 12.5%; right: 12.5%;
  top: 17px; height: 2px; background: var(--line); z-index: 0;
}
.oc-progress .ps {
  position: relative; z-index: 1; display: flex; flex-direction: column;
  align-items: center; min-width: 0; gap: 4px;
}
.oc-progress .ps .d {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--line); transition: all .2s;
}
.oc-progress .ps.done .d { background: var(--ok); border-color: var(--ok); }
.oc-progress .ps.current .d { background: var(--accent); border-color: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.oc-progress .ps .lab { font-size: 9px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; font-weight: 600; }
.oc-progress .ps.done .lab,
.oc-progress .ps.current .lab { color: var(--fg-2); }

/* === Шапка: бейдж pending в МС ======================================= */
.tb-badge-pending {
  display: none; align-items: center; gap: 6px; margin-left: auto;
  padding: 4px 10px; background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.35);
  color: var(--warn); border-radius: 999px; font-size: 12px; font-weight: 600;
  font-family: var(--font-mono); font-feature-settings: "tnum";
}
.tb-badge-pending.is-on { display: inline-flex; }
.tb-badge-pending::before { content: "⟳"; animation: spin 2s linear infinite; }

/* === Тосты ========================================================== */
.toast-stack {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  background: var(--bg-card); border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--fg);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.6);
  animation: toastIn .25s ease-out;
  display: flex; align-items: baseline; gap: 8px; max-width: 360px;
}
.toast.ok    { border-left-color: var(--ok); }
.toast.warn  { border-left-color: var(--warn); }
.toast.err   { border-left-color: var(--err); }
.toast b { color: var(--fg); font-weight: 700; font-family: var(--font-mono); }
.toast .muted { color: var(--muted); font-size: 11px; }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* === Анимация только что обновлённой карточки ======================= */
@keyframes cardPing {
  0%   { box-shadow: 0 0 0 0 rgba(91,143,255,0.5); }
  100% { box-shadow: 0 0 0 12px rgba(91,143,255,0); }
}
.order-card.just-updated { animation: cardPing .9s ease-out; }

/* === АДАПТИВ: ≤1000 — узкие фильтры, ≤720 — one-column =============== */
@media (max-width: 1000px) {
  .main-grid { grid-template-columns: 1fr !important; }
  .filters { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  body.screen-pack { padding-bottom: env(safe-area-inset-bottom); }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .brand { font-size: 14px; }
  .topbar .user-box { display: none; }   /* экономим место */
  .scanner-col {
    position: sticky; top: 56px; z-index: 20;
    background: var(--bg); padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 8px;
  }
  .counters { gap: 6px; }
  .counter { padding: 8px 10px; }
  .counter span { font-size: 22px; }
  .input-wrap input#scanInput {
    min-height: 54px; font-size: 17px;   /* iOS не зумит при focus */
  }
  .orders-col { padding: 0 8px 80px; }
  .order-card { padding: 12px 14px 12px 18px; }
  .oc-meta { padding: 6px 8px; gap: 2px 8px; }
  .oc-meta-row .oc-lbl { min-width: 78px; font-size: 9px; }
  .oc-meta-row .oc-val { font-size: 12px; }
  .oc-progress { grid-template-columns: repeat(4, 1fr); padding: 8px 0 2px; }
  .oc-progress::before { top: 12px; }
  .oc-progress .ps .lab { font-size: 8px; }
  /* Mini-таблица: жмём Код+Артикул в один моно-блок */
  .oc-items-table .col-art { display: none; }
  .oc-items-table .col-code { width: auto; max-width: 70px; }
  /* Модалка ниже занимает всю высоту */
  .modal-card { width: 100% !important; max-height: 100vh !important; border-radius: 0 !important; }
  .toast-stack { left: 8px; right: 8px; bottom: 8px; }
  .toast { max-width: none; }
}

/* ============================================================
   ▼▼▼  V3 — СВЕТЛАЯ ТЕМА + компактная карточка + фото товара ▼▼▼
   ============================================================ */

/* Полная замена палитры на светлую */
:root {
  --bg:        #F4F6FA;
  --bg-card:   #FFFFFF;
  --bg-card2:  #FAFBFD;
  --bg-hover:  #EEF1F7;
  --bg-input:  #FFFFFF;

  --line:      #E2E6EE;
  --line-2:    #C5CCD8;

  --fg:        #0F1828;
  --fg-2:      #3D4760;
  --muted:     #7A839A;
  --dim:       #B0B7C7;

  --accent:    #2563EB;
  --accent-2:  #1D4ED8;
  --amber:     #D97706;
  --teal:      #0EA371;

  --ok:        #059669;
  --warn:      #D97706;
  --err:       #DC2626;

  --shadow: 0 12px 32px -12px rgba(15,24,40,0.12), 0 2px 6px -2px rgba(15,24,40,0.06);
}

/* Светлый фон с лёгкими пастельными акцентами */
body.screen-pack {
  background-image:
    radial-gradient(circle at 0% 0%, rgba(37,99,235,0.04) 0%, transparent 35%),
    radial-gradient(circle at 100% 100%, rgba(217,119,6,0.025) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Топбар — белый с границей */
.topbar {
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15,24,40,0.02);
}

/* Карточка заказа: светлая, мягкая тень */
.order-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15,24,40,0.04);
  padding: 12px 14px 12px 16px;     /* компактнее */
}
.order-card:hover {
  background: var(--bg-card);
  border-color: var(--line-2);
  box-shadow: 0 4px 12px -4px rgba(15,24,40,0.08);
}

/* Один компактный ряд: организация + дата */
.oc-line {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin: 6px 0 8px;
  padding: 6px 10px; background: var(--bg-card2);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.oc-line .oc-org {
  flex: 1 1 auto; min-width: 0;
  color: var(--fg-2); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oc-line .oc-date { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
/* Старый блок oc-meta больше не используется в renderOrders, но если где-то остался — компактим */
.oc-meta { padding: 6px 8px; }

/* Mini-ШК внутри foot — без тяжёлой плитки */
.shk-mini {
  background: var(--bg-card2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 4px;
  color: var(--accent); font-size: 11px;
}

/* Чип статуса заказа: «На сборке» / «Собран» — единственный визуальный индикатор */
.chip.status {
  font-weight: 700; padding: 4px 10px; font-size: 11px;
  border: 1px solid transparent;
}
.chip.status.warn {
  background: #FEF3C7; color: #92400E; border-color: #FCD34D;
}
.chip.status.ok {
  background: #D1FAE5; color: #065F46; border-color: #6EE7B7;
}
.chip.status.big { font-size: 13px; padding: 6px 14px; }

/* MP/Org chip — мягче */
.chip.mp  { background: #DBEAFE; color: #1E40AF; border: 1px solid #93C5FD; }
.chip.org { background: var(--bg-card2); color: var(--fg-2); border: 1px solid var(--line); }

/* Полоса слева: 3px, два состояния */
.order-card { padding-left: 14px; }
.order-card::before { width: 3px; }
.order-card[data-state="pending"]::before { background: var(--warn); }
.order-card[data-state="packed"]::before  { background: var(--ok); }
.order-card.packed { opacity: 0.78; background: #FBFCFE; }

/* Старый прогресс убран — на всякий случай прячем если где-то остался */
.oc-progress { display: none !important; }

/* === Фото товара === */
.thumb {
  width: 32px; height: 32px;
  object-fit: cover; border-radius: 4px;
  background: var(--bg-card2); border: 1px solid var(--line);
  display: block;
}
.thumb-empty {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--bg-card2); border: 1px solid var(--line);
  border-radius: 4px; font-size: 16px; color: var(--dim);
}
.oc-items-table .col-img { width: 36px; padding: 3px 6px 3px 0; }
.positions-table .col-img { width: 56px; padding: 6px; }
.positions-table .col-img .thumb,
.positions-table .col-img .thumb-empty { width: 48px; height: 48px; font-size: 22px; }
.scan-items .col-img { width: 50px; padding: 4px; }
.scan-items .col-img .thumb,
.scan-items .col-img .thumb-empty { width: 44px; height: 44px; font-size: 20px; }

/* === Модалка для низкой квалификации: крупный № + большой статус === */
.m-title-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.m-num { font-size: 28px; font-weight: 800; }
.m-num .hash { color: var(--muted); margin-right: 4px; font-weight: 600; }

/* Кнопки в модалке — крупные для пальцев */
.m-actions { gap: 10px; flex-wrap: wrap; }
.m-actions .btn-primary { min-height: 48px; font-size: 15px; padding: 12px 22px; }

/* Картинки и таблицы на светлом — мягкие границы */
.positions-table thead th, .scan-items thead th, .oc-items-table thead th {
  color: var(--muted); border-bottom-color: var(--line);
}
.positions-table tbody td, .scan-items tbody td, .oc-items-table tbody td {
  border-bottom-color: var(--line);
}
.positions-table tbody tr:hover { background: rgba(37,99,235,0.04); }

/* Бейдж pending в светлой теме */
.tb-badge-pending {
  background: #FEF3C7; border-color: #FCD34D; color: #92400E;
}

/* Тосты в светлой теме */
.toast { background: #FFFFFF; border-color: var(--line-2); color: var(--fg); }
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--err); }

/* Input скан-окна — светлый */
.scanner-col input#scanInput,
.input-wrap input#scanInput {
  background: #FFFFFF; color: var(--fg); border: 1.5px solid var(--line);
}
.input-wrap input#scanInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

/* Counters светлые */
.counter { background: var(--bg-card); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,24,40,0.03); }
.counter span { color: var(--fg); }
.counter.ok span { color: var(--ok); }
.counter.remain span { color: var(--warn); }
.counter label { color: var(--muted); }

/* Tabs светлые */
.tab { color: var(--muted); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab .badge { background: var(--bg-card2); color: var(--fg-2); border: 1px solid var(--line); }

/* Login-карточка светлая */
.screen-login {
  background:
    radial-gradient(circle at 30% 20%, rgba(37,99,235,0.08) 0%, transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(217,119,6,0.05) 0%, transparent 45%),
    var(--bg);
}
.login-card { background: #FFFFFF; box-shadow: var(--shadow); }
.login-card input { background: #FFFFFF; }

/* Модалка backdrop светлый */
.modal { background: rgba(15,24,40,0.45); backdrop-filter: blur(4px); }
.modal-card { background: #FFFFFF; box-shadow: 0 24px 64px -16px rgba(15,24,40,0.30); }

/* Admin светлая */
.screen-admin { background: var(--bg); }
.admin-main section { background: var(--bg-card); border-color: var(--line); box-shadow: 0 1px 2px rgba(15,24,40,0.04); }
.admin-main input, .admin-main select { background: #FFFFFF; }

/* Result-панель скан-результата светлая */
.result { background: var(--bg-card); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,24,40,0.04); }
.result.empty { background: var(--bg-card2); color: var(--muted); }
.result.ok { border-left: 3px solid var(--ok); background: #ECFDF5; }
.result.duplicate { border-left: 3px solid var(--warn); background: #FFFBEB; }
.result.not_found, .result.wrong_state { border-left: 3px solid var(--err); background: #FEF2F2; }

/* Скроллбар светлый */
.modal::-webkit-scrollbar-thumb, .orders-list::-webkit-scrollbar-thumb { background: var(--line-2); }

/* ============================================================
   ▼▼▼  V4 — компактный список + hover-popup + scan-overlay  ▼▼▼
   Чёткие 1px-рамки везде, фото — главный визуальный якорь
   ============================================================ */

/* Чуть более контрастная линия, чтобы НЕ сливалось */
:root {
  --line:   #D7DCE6;       /* было #E2E6EE */
  --line-2: #B8C0CF;       /* было #C5CCD8 */
}

/* === Компактная карточка с шапкой и жирным списком позиций === */
.order-card.compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 8px 14px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(15,24,40,0.02);
  cursor: pointer;
  position: relative;
  overflow: visible;       /* чтобы фото при :hover могло вылезать */
}
/* Шапка: фото + текст */
.order-card.compact .oc-head-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
}
.order-card.compact .oc-head-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.order-card.compact:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px -4px rgba(37,99,235,0.18);
}
.order-card.compact::before {
  width: 3px; height: auto; top: 8px; bottom: 8px;
  border-radius: 2px;
}
.order-card.compact[data-state="pending"]::before { background: var(--warn); }
.order-card.compact[data-state="packed"]::before  { background: var(--ok); }

.oc-photo {
  width: 56px; height: 56px; flex: 0 0 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-card2);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.oc-photo .thumb,
.oc-photo .thumb-empty {
  width: 56px !important; height: 56px !important;
  border-radius: 0; border: 0;
  font-size: 26px;
}

.oc-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.oc-row1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.oc-row1 .num {
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  color: var(--fg); letter-spacing: -0.01em;
}
.oc-row1 .num .hash { color: var(--muted); margin-right: 2px; font-weight: 600; }
.oc-row2 {
  font-size: 12px; color: var(--fg-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.35;
}
.oc-row2 b { color: var(--fg); font-weight: 700; }
.oc-row3 {
  display: flex; gap: 8px; align-items: baseline; justify-content: space-between;
  font-size: 11px;
}
.oc-row3 .shk-mini { font-size: 11px; padding: 1px 5px; }
.oc-row3 .oc-when { color: var(--muted); font-size: 11px; }

/* Старая (некомпактная) карточка остаётся скрытой за compact */

/* === Hover-popup === */
.hover-popup {
  position: fixed; z-index: 80;
  width: 420px; max-height: 70vh; overflow: auto;
  background: #FFFFFF;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 24px 48px -12px rgba(15,24,40,0.25), 0 4px 12px -4px rgba(15,24,40,0.10);
  padding: 14px 14px 12px;
  font-size: 13px;
  animation: popIn .12s ease-out;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.hover-popup .pp-head {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.hover-popup .pp-head .num {
  font-family: var(--font-mono); font-weight: 800; font-size: 16px;
}
.hover-popup .pp-org {
  font-size: 13px; font-weight: 600; color: var(--fg-2);
  margin: 8px 0 4px; line-height: 1.35;
}
.hover-popup .pp-meta {
  font-size: 11px; color: var(--muted); margin: 0 0 10px;
}
.hover-popup .pp-meta b { color: var(--fg-2); font-weight: 600; font-family: var(--font-mono); }

.hover-popup .pp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 96px);
  gap: 8px;
  padding: 4px 0;
  justify-content: start;
}
.pp-tile {
  width: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-card2);
  padding: 4px;
  position: relative;
  transition: transform .15s, box-shadow .15s, z-index 0s;
}
.pp-tile:hover {
  transform: scale(1.6);
  z-index: 5;
  background: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 12px 32px -8px rgba(37,99,235,0.30);
}
.pp-photo-wrap { width: 86px; height: 86px; }
.pp-photo-wrap .thumb,
.pp-photo-wrap .thumb-empty {
  width: 86px !important; height: 86px !important;
  border-radius: 4px;
  font-size: 30px;
}
.pp-tile .pp-text { margin-top: 4px; }
.pp-tile .pp-code {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: var(--accent); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pp-tile .pp-art {
  font-family: var(--font-mono); font-size: 9px;
  color: var(--fg-2); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pp-tile .pp-name {
  font-size: 10px; color: var(--fg);
  line-height: 1.25; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.pp-tile .pp-qty {
  position: absolute; top: 2px; right: 2px;
  background: var(--accent); color: #FFFFFF;
  font-family: var(--font-mono); font-weight: 700; font-size: 11px;
  padding: 2px 6px; border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.hover-popup .pp-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.hover-popup .shk-mini.big { font-size: 13px; padding: 3px 8px; }

/* === Fullscreen scan-overlay === */
.scan-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15,24,40,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
  animation: ovIn .18s ease-out;
}
@keyframes ovIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.scan-overlay .so-card {
  background: #FFFFFF;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  width: 100%; max-width: 1100px; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 32px 80px -20px rgba(15,24,40,0.5);
  animation: cardIn .2s ease-out;
}
@keyframes cardIn {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.scan-overlay.is-ok .so-card { border-left: 6px solid var(--ok); }
.scan-overlay.is-dup .so-card { border-left: 6px solid var(--warn); }

.so-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}
.so-title {
  font-size: 22px; font-weight: 800; letter-spacing: -0.01em;
}
.scan-overlay.is-ok .so-title { color: var(--ok); }
.scan-overlay.is-dup .so-title { color: var(--warn); }

.so-meta {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 14px 24px 6px;
}
.so-meta .so-num {
  font-family: var(--font-mono); font-size: 28px; font-weight: 800;
  letter-spacing: -0.02em; color: var(--fg);
}
.so-meta .so-num .hash { color: var(--muted); margin-right: 4px; font-weight: 600; }

.so-line {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 0 24px 14px;
  font-size: 14px; color: var(--fg-2);
}
.so-line span { padding: 4px 10px; background: var(--bg-card2); border: 1px solid var(--line); border-radius: 6px; }

.so-warn {
  margin: 0 24px 12px; padding: 10px 14px;
  background: #FFFBEB; border: 1px solid #FCD34D; color: #92400E;
  border-radius: 8px; font-size: 13px;
}

.so-grid {
  flex: 1 1 auto; overflow: auto;
  padding: 8px 24px 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.so-tile {
  background: var(--bg-card2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s, box-shadow .12s;
}
.so-tile:hover { border-color: var(--accent); box-shadow: 0 6px 16px -6px rgba(37,99,235,0.20); }
.so-tile .so-photo {
  width: 100%; aspect-ratio: 1; max-width: 144px; align-self: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: #FFFFFF; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.so-tile .so-photo .thumb,
.so-tile .so-photo .thumb-empty {
  width: 100% !important; height: 100% !important;
  border: 0; border-radius: 0;
  font-size: 38px;
}
.so-text { display: flex; flex-direction: column; gap: 2px; }
.so-code {
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.so-art {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.so-name {
  font-size: 13px; color: var(--fg); font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 34px;
}
.so-qty {
  margin-top: 4px;
  display: inline-flex; align-self: flex-start;
  background: var(--accent); color: #FFFFFF;
  font-family: var(--font-mono); font-weight: 800; font-size: 16px;
  padding: 4px 12px; border-radius: 6px;
}

.so-actions {
  padding: 14px 24px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end;
  background: var(--bg-card2);
  border-radius: 0 0 14px 14px;
}
.so-actions .btn-primary,
.so-actions .btn-secondary { min-height: 56px; font-size: 15px; padding: 14px 22px; }

/* result-inline — короткая полоска подтверждения в боковой панели */
.result-inline {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 14px; font-weight: 600;
}
.result-inline.ok { color: var(--ok); }
.result-inline.duplicate { color: var(--warn); }

/* Mobile-адаптации */
@media (max-width: 720px) {
  .order-card.compact {
    grid-template-columns: 56px 1fr;
    padding: 8px 10px 8px 12px;
  }
  .oc-photo, .oc-photo .thumb, .oc-photo .thumb-empty {
    width: 56px !important; height: 56px !important;
  }
  .hover-popup {
    position: fixed; left: 8px !important; right: 8px !important; top: 50% !important;
    transform: translateY(-50%);
    width: auto; max-width: calc(100vw - 16px); max-height: 80vh;
  }
  .hover-popup .pp-grid { grid-template-columns: repeat(auto-fill, 86px); }
  .pp-tile { width: 86px; }
  .pp-tile:hover { transform: none; }      /* hover-zoom только на десктопе */

  .scan-overlay { padding: 0; }
  .scan-overlay .so-card { max-width: 100vw; max-height: 100vh; border-radius: 0; border-left-width: 4px; }
  .so-head { padding: 12px 14px; }
  .so-title { font-size: 18px; }
  .so-meta { padding: 10px 14px 4px; }
  .so-meta .so-num { font-size: 22px; }
  .so-line { padding: 0 14px 10px; gap: 8px; font-size: 12px; }
  .so-grid {
    padding: 8px 12px 12px; gap: 10px;
    grid-template-columns: repeat(2, 1fr);
  }
  .so-actions { padding: 10px 12px; }
  .so-actions .btn-primary,
  .so-actions .btn-secondary { min-height: 48px; flex: 1 1 auto; }
}

/* ============================================================
   ▼▼▼  V5 — жирный список позиций + image-zoom on hover  ▼▼▼
   Возврат таблицы позиций в карточку (Код · Артикул · Наим. · Кол.) — все жирно.
   Hover на фото = scale, без отдельного popup'а.
   ============================================================ */

/* Скрываем legacy hover-popup (больше не используется) */
.hover-popup { display: none !important; }

/* Список позиций — главное наименование крупно, qty крупная плашка справа */
.oc-positions {
  list-style: none; margin: 0; padding: 8px 0 0;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.oc-pos {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: #FFFFFF;
  border: 1px solid var(--line);
}
.oc-pos:hover { border-color: var(--accent); background: #F4F8FF; }
.oc-pos-photo {
  width: 48px; height: 48px;
  border: 1px solid var(--line);
  border-radius: 5px; overflow: visible;
  background: #FFFFFF;
  display: inline-flex; align-items: center; justify-content: center;
}
.oc-pos-photo .thumb,
.oc-pos-photo .thumb-empty {
  width: 46px !important; height: 46px !important;
  border: 0; border-radius: 4px;
  font-size: 22px;
}
.oc-pos-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.oc-pos-name {
  font-size: 15px; font-weight: 700;
  color: #0F1828;                                 /* почти-чёрный для max-контраста */
  line-height: 1.3;
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.oc-pos-meta {
  font-family: var(--font-mono);
  font-size: 11.5px; font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.oc-pos-qty {
  font-family: var(--font-mono); font-weight: 800;
  font-size: 18px; line-height: 1;
  color: #FFFFFF; background: var(--accent);
  padding: 8px 14px; border-radius: 8px;
  font-feature-settings: "tnum";
  min-width: 56px; text-align: center;
  box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
.oc-pos-more {
  list-style: none; padding: 6px 10px;
  font-size: 12px; color: var(--muted); font-style: italic;
  border-top: 1px dashed var(--line); margin-top: 2px;
}

/* Шапка карточки — текст без фото, ИП крупно, дата справа */
.order-card.compact .oc-row1 {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.order-card.compact .oc-row1 .num {
  font-size: 16px; font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.01em; color: #0F1828;
}
.order-card.compact .oc-row1 .oc-when {
  margin-left: auto;
  color: var(--muted); font-size: 12px; font-feature-settings: "tnum";
}
.order-card.compact .oc-row2 {
  display: flex; gap: 12px; align-items: baseline;
  font-size: 13px; line-height: 1.35; color: var(--fg-2);
  margin-top: 2px;
}
.order-card.compact .oc-row2 .oc-org {
  flex: 1 1 auto; min-width: 0;
  font-weight: 600; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.order-card.compact .oc-row2 .oc-summary {
  flex: 0 0 auto; color: var(--muted); font-size: 12px;
}
.order-card.compact .oc-row2 .oc-summary b { color: var(--fg); font-weight: 700; }
.order-card.compact .oc-row2 .shk-mini {
  background: var(--bg-card2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 4px; color: var(--accent);
  font-size: 11px;
}

/* === Image-zoom при hover на ЛЮБОЕ фото thumb (наводишь — увеличивается, отвёл — пропало) === */
/* Работает только на устройствах с hover (десктоп с мышью). На touch — никаких scale. */
@media (hover: hover) and (pointer: fine) {
  .oc-photo, .oc-pos-photo,
  .pp-photo-wrap,
  .oc-items-table .col-img,
  .positions-table .col-img,
  .scan-items .col-img {
    overflow: visible;        /* чтоб img мог вылезать за пределы ячейки */
  }
  .oc-photo .thumb:hover,
  .oc-pos-photo .thumb:hover,
  .col-img .thumb:hover {
    transform: scale(4);
    transform-origin: left center;
    z-index: 200;
    position: relative;
    border: 2px solid var(--accent);
    box-shadow: 0 16px 40px -12px rgba(15,24,40,0.40);
    border-radius: 4px;
    transition: transform .15s ease-out, box-shadow .15s ease-out;
    background: #FFFFFF;
  }
  /* Для thumb-empty (📦) тоже scale, но менее агрессивный */
  .oc-photo .thumb-empty:hover,
  .oc-pos-photo .thumb-empty:hover {
    transform: scale(2);
    transform-origin: left center;
    z-index: 200;
    position: relative;
    border-color: var(--accent);
    box-shadow: 0 8px 20px -6px rgba(15,24,40,0.30);
    transition: transform .15s ease-out, box-shadow .15s ease-out;
  }
  /* Если плитки в правом краю — origin справа, чтобы не уехало за экран */
  .so-grid .so-tile:nth-child(4n) .thumb:hover,
  .pp-grid .pp-tile:nth-last-child(-n+1) .thumb:hover { transform-origin: right center; }
}

/* Mobile: никаких hover-эффектов на фото */
@media (hover: none), (pointer: coarse) {
  .oc-photo .thumb:hover,
  .oc-pos-photo .thumb:hover,
  .col-img .thumb:hover { transform: none !important; }
}

/* Узкий экран: фото 40, наименование в 2 строки, qty компактнее */
@media (max-width: 720px) {
  .oc-pos {
    grid-template-columns: 40px 1fr auto;
    gap: 8px; padding: 6px 8px;
  }
  .oc-pos-photo { width: 40px; height: 40px; }
  .oc-pos-photo .thumb, .oc-pos-photo .thumb-empty {
    width: 38px !important; height: 38px !important;
  }
  .oc-pos-name {
    font-size: 13.5px; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .oc-pos-meta { font-size: 10.5px; }
  .oc-pos-qty { font-size: 15px; padding: 6px 10px; min-width: 44px; }
  .order-card.compact .oc-row2 { flex-wrap: wrap; gap: 4px 12px; }
  .order-card.compact .oc-row2 .oc-org { flex: 1 1 100%; }
}

/* ============================================================
   ▼▼▼  V7 — модалка карточки заказа: секции + крупные позиции  ▼▼▼
   ============================================================ */

.modal-card { padding: 0 !important; }
#modalBody { padding: 0; display: flex; flex-direction: column; gap: 16px; }

/* Шапка */
.m-head.v7 {
  padding: 22px 26px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #FFFFFF 0%, var(--bg-card2) 100%);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.m-head.v7 .m-title-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.m-head.v7 .m-num {
  font-family: var(--font-mono); font-weight: 800;
  font-size: 32px; letter-spacing: -0.02em; color: #0F1828;
  line-height: 1.1;
}
.m-head.v7 .m-num .hash { color: var(--muted); margin-right: 4px; font-weight: 600; }
.m-head.v7 .m-mp { margin-top: 8px; }
.m-head.v7 .chip.mp {
  font-size: 13px; font-weight: 700; padding: 5px 12px;
  background: #DBEAFE; color: #1E3A8A; border: 1px solid #93C5FD;
}

/* Meta-сетка 4 колонки (auto-fill минимум 200px) */
.m-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  margin: 0 26px;
  background: var(--line);     /* линии-сепараторы между ячейками */
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.m-meta-grid .m-meta-cell {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 14px;
  background: #FFFFFF;
}
.m-meta-grid .m-meta-cell.wide { grid-column: 1 / -1; }
.m-meta-grid .lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--muted); letter-spacing: 0.06em;
}
.m-meta-grid .val {
  font-size: 14px; font-weight: 600; color: var(--fg);
  line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-meta-grid .val.strong { font-weight: 700; }
.m-meta-grid .val.mono { font-family: var(--font-mono); font-size: 13px; font-feature-settings: "tnum"; }
.m-meta-grid .val.accent { color: var(--accent); font-size: 16px; font-weight: 800; }

/* Секция (Что собрать / Штрихкод) */
.m-section {
  margin: 0 26px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.m-section-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--line);
}
.m-section-head h3 {
  margin: 0; font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-2);
  display: inline-flex; align-items: center; gap: 8px;
}
.m-section-head h3 .ico { font-size: 16px; }
.m-section-head .m-section-stat {
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.m-section-head .m-section-stat b {
  color: var(--accent); font-family: var(--font-mono); font-weight: 800;
  font-size: 14px;
}

/* Список позиций в модалке: фото 64 + наименование 16px black + qty крупно */
.m-positions {
  list-style: none; margin: 0; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.m-pos {
  display: grid;
  grid-template-columns: 28px 64px 1fr auto;
  gap: 12px; align-items: center;
  padding: 10px 12px;
  background: var(--bg-card2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.m-pos:hover { border-color: var(--accent); background: #F4F8FF; }
.m-pos-idx {
  font-family: var(--font-mono); font-weight: 700;
  font-size: 13px; color: var(--muted);
  text-align: right; font-feature-settings: "tnum";
}
.m-pos-photo {
  width: 64px; height: 64px;
  border: 1px solid var(--line);
  border-radius: 6px; overflow: visible;
  background: #FFFFFF;
  display: inline-flex; align-items: center; justify-content: center;
}
.m-pos-photo .thumb,
.m-pos-photo .thumb-empty {
  width: 62px !important; height: 62px !important;
  border: 0; border-radius: 5px;
  font-size: 28px;
}
.m-pos-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.m-pos-name {
  font-size: 16px; font-weight: 700;
  color: #0F1828;
  line-height: 1.3;
  letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.m-pos-meta {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 500;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-pos-qty {
  font-family: var(--font-mono); font-weight: 800;
  font-size: 22px; line-height: 1;
  color: #FFFFFF; background: var(--accent);
  padding: 10px 18px; border-radius: 8px;
  font-feature-settings: "tnum";
  min-width: 72px; text-align: center;
  box-shadow: 0 2px 4px rgba(37,99,235,0.30);
}

/* Штрихкод секция */
.m-section .m-barcode-panel {
  background: #FFFFFF;
  padding: 18px;
  display: flex; justify-content: center; align-items: center;
  border-bottom: 1px solid var(--line);
}
.m-section .m-barcode-panel svg {
  max-width: 100%; height: auto;
}
.m-section .m-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--bg-card2);
}
.m-section .m-actions .btn-primary { flex: 1 1 auto; min-height: 56px; font-size: 15px; }
.m-section .m-actions .btn-secondary { min-height: 56px; }

/* Кнопка-крестик в углу карточки модалки — сделать чётче */
.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--line);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 18px; color: var(--fg-2);
  cursor: pointer;
  position: absolute; top: 12px; right: 12px;
  z-index: 5;
}
.modal-close:hover { background: var(--bg-hover); color: var(--err); border-color: var(--err); }

/* Mobile-адаптация модалки */
@media (max-width: 720px) {
  #modalBody { gap: 10px; padding-bottom: 16px; }
  .m-head.v7 { padding: 16px 16px 10px; border-radius: 0; }
  .m-head.v7 .m-num { font-size: 24px; }
  .m-meta-grid { margin: 0 12px; grid-template-columns: 1fr 1fr; }
  .m-meta-grid .m-meta-cell { padding: 8px 10px; }
  .m-meta-grid .val { font-size: 13px; }
  .m-meta-grid .val.accent { font-size: 14px; }
  .m-section { margin: 0 12px; }
  .m-section-head { padding: 10px 12px; }
  .m-positions { padding: 8px; gap: 6px; }
  .m-pos {
    grid-template-columns: 56px 1fr auto;
    padding: 8px 10px; gap: 10px;
  }
  .m-pos-idx { display: none; }
  .m-pos-photo { width: 56px; height: 56px; }
  .m-pos-photo .thumb, .m-pos-photo .thumb-empty {
    width: 54px !important; height: 54px !important; font-size: 24px;
  }
  .m-pos-name { font-size: 14px; }
  .m-pos-meta { font-size: 11px; }
  .m-pos-qty { font-size: 18px; padding: 8px 12px; min-width: 56px; }
  .m-section .m-actions .btn-primary, .m-section .m-actions .btn-secondary { flex: 1 1 100%; min-height: 52px; }
}
