:root {
  --bg: #f6f9fc;
  --card: #ffffff;
  --ink: #0a2540;
  --muted: #687385;
  --line: #e3e8ee;
  --accent: #635bff;
  --accent-ink: #ffffff;
  --ok: #0e9f6e;
  --warn: #f5a623;
  --bad: #e5484d;
  --info: #0ea5e9;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; max-width: 100%; overflow-x: hidden; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: #1f2937; color: #fff;
}
header.top .brand { font-weight: 700; letter-spacing: .3px; }
header.top .who { margin-left: auto; font-size: 12px; opacity: .85; text-align: right; }
header.top .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--ok); }
header.top .dot.off { background: var(--warn); }

main { flex: 1; padding: 12px; max-width: 1100px; width: 100%; margin: 0 auto; }

nav.bottom {
  position: sticky; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
nav.bottom button {
  background: none; border: 0; padding: 8px 4px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
nav.bottom button .ico { font-size: 18px; line-height: 1; }
nav.bottom button.active { color: var(--accent); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.title { font-weight: 650; }
h2 { font-size: 18px; margin: 6px 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.ожидает { background: #f3f4f6; color: #4b5563; }
.chip.в-работе, .chip.вработе { background: #fef3c7; color: #92400e; }
.chip.готово { background: #d1fae5; color: #065f46; }
.chip.брак { background: #fee2e2; color: #991b1b; }
.chip.открыта { background: #e0e7ff; color: #3730a3; }
.chip.warn { background: #fef3c7; color: #92400e; }
.chip.брак { background: #fee2e2; color: #991b1b; }

button.btn, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
}
button.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.btn.small { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
button.btn:active { transform: translateY(1px); }
button.icon { border: 0; background: none; font-size: 20px; cursor: pointer; }

input[type=checkbox], input[type=radio] { width: auto; margin: 0; flex: none; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
label.fld { display: block; margin-bottom: 10px; }
label.fld span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.list { display: grid; gap: 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.part { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.op-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); margin-top: 8px; }
.badge-over { display: inline-block; background: #fee2e2; color: #991b1b; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; }

.banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.banner-item { display: inline-block; background: #fff; border-radius: 999px; padding: 1px 8px; margin: 2px 2px 0 0; font-weight: 600; }
.banner-item.over { background: #dc2626; color: #fff; }
.card-urgent { background: #fff5f5; border-color: #fca5a5; }
.card-overdue { background: #fee2e2; border-color: #ef4444; }
.nav-count { display: inline-block; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; margin-left: 4px; vertical-align: top; }
.ops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.op { font-size: 12px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fafafa; cursor: pointer; }
.op.готово { background: #ecfdf5; border-color: #a7f3d0; }
.op.в-работе { background: #fffbeb; border-color: #fde68a; }

.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 260px; margin: 16px auto 0; }
.pinpad button { padding: 16px; font-size: 20px; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 18px 0; font-size: 26px; letter-spacing: 6px; }

.sync-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #374151; color: #d1d5db; }
.sync-badge.pending { background: #7c2d12; color: #fed7aa; }

#modal-root .backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
#modal-root .sheet {
  background: var(--card); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 16px;
  max-height: 88vh; overflow: auto;
}
@media (min-width: 760px) {
  #modal-root .backdrop { align-items: center; }
  #modal-root .sheet { border-radius: 16px; }
  main { padding: 18px 24px 80px; }
  nav.bottom { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; width: 560px; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
}

.code { font-family: ui-monospace, Consolas, monospace; background: #f3f4f6; padding: 10px 12px; border-radius: 10px; margin: 8px 0; font-size: 16px; letter-spacing: 1px; }

.card-ready { background: #fffbeb; border-color: #f59e0b; box-shadow: inset 0 0 0 1px #fbbf24; }
.card-confirmed { background: #ecfdf5; border-color: #34d399; box-shadow: inset 0 0 0 1px #6ee7b7; }


/* ---------- палитра и сквозной процесс (в стиле Stripe/Linear) ---------- */
.top { background: #0a2540; color: #fff; }
.top .brand { color: #fff; letter-spacing: .2px; }
.top .icon, .top .who { color: #e3e8ee; }
.card { box-shadow: 0 1px 2px rgba(10, 37, 64, .05); border-color: var(--line); }
.btn { background: #fff; border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: #c7d2e0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4f46e5; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
a { color: var(--accent); }

.chip.ch-new { background: #e0f2fe; color: #075985; }
.chip.ch-prod { background: #eef2ff; color: #4338ca; }
.chip.ch-ready { background: #fef3c7; color: #92400e; }
.chip.ch-ok { background: #dcfce7; color: #166534; }
.chip.ch-done { background: #e2e8f0; color: #334155; }
.chip.ch-stock { background: #d1fae5; color: #065f46; }
.chip.ch-ship { background: #e0f2fe; color: #075985; }

.segmented { display: flex; gap: 6px; background: #eef2f7; padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.seg { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: 13px; }
.seg.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(10, 37, 64, .12); }

.stepper { display: flex; align-items: flex-start; gap: 4px; margin: 12px 0; padding: 12px 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.step { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 62px; flex: 1; }
.step-dot { width: 14px; height: 14px; border-radius: 50%; background: #e3e8ee; border: 2px solid #cbd5e1; }
.step.done .step-dot { background: var(--ok); border-color: var(--ok); }
.step.current .step-dot { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 91, 255, .18); }
.step-label { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; }
.step.done .step-label { color: var(--ok); }
.step.current .step-label { color: var(--accent); font-weight: 700; }
.step-line { height: 2px; background: #e3e8ee; flex: 0 0 12px; margin-top: 6px; }
.step-line.done { background: var(--ok); }

.bar { height: 6px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.card-new { background: #f8faff; border-color: #c7d2fe; }
.card-done { background: #f8fafc; border-color: #e2e8f0; }
.card-ready { background: #fffbeb; border-color: #f59e0b; }
.card-confirmed { background: #f0fdf4; border-color: #22c55e; }

.tbl th { background: #f6f9fc; color: var(--muted); font-weight: 600; }

.chip.ch-bad { background: #fee2e2; color: #991b1b; }


/* ---------- тёмная тема ---------- */
[data-theme="dark"] {
  --bg: #0b1220;
  --card: #121c2e;
  --ink: #e8eef8;
  --muted: #94a3b8;
  --line: #22304a;
  --accent: #7c7cff;
  --accent-ink: #ffffff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #38bdf8;
}
[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
[data-theme="dark"] .top { background: #060d18; border-bottom: 1px solid #16233a; }
[data-theme="dark"] .card { background: var(--card); border-color: var(--line); box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
[data-theme="dark"] .part, [data-theme="dark"] .dop { background: #0f1a2b; }
[data-theme="dark"] .btn { background: #16223a; border-color: #22304a; color: var(--ink); }
[data-theme="dark"] .btn.ghost { background: transparent; }
[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .segmented { background: #0f1a2b; }
[data-theme="dark"] .seg.active { background: #1b2740; color: #fff; box-shadow: none; }
[data-theme="dark"] .tbl th { background: #101a2b; color: var(--muted); }
[data-theme="dark"] .tbl td { border-color: #1b2740; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: #0f1a2b; color: var(--ink); border-color: #22304a;
}
[data-theme="dark"] .sheet { background: var(--card); color: var(--ink); }
[data-theme="dark"] .backdrop { background: rgba(2, 8, 20, .7); }
[data-theme="dark"] nav.bottom { background: #060d18; border-top: 1px solid #16233a; }
[data-theme="dark"] nav.bottom button { color: #94a3b8; }
[data-theme="dark"] nav.bottom button.active { color: #fff; background: #16223a; }
[data-theme="dark"] .banner { background: #2a1f12; border-color: #7c4a12; color: #fde9c8; }
[data-theme="dark"] .banner .btn { background: #3a2a15; border-color: #7c4a12; color: #fde9c8; }
[data-theme="dark"] .nav-count { background: var(--accent); color: #fff; }
[data-theme="dark"] .chip.ch-new { background: rgba(56,189,248,.16); color: #7dd3fc; }
[data-theme="dark"] .chip.ch-prod { background: rgba(124,124,255,.18); color: #c7c7ff; }
[data-theme="dark"] .chip.ch-ready { background: rgba(251,191,36,.18); color: #fcd34d; }
[data-theme="dark"] .chip.ch-ok { background: rgba(52,211,153,.18); color: #6ee7b7; }
[data-theme="dark"] .chip.ch-done { background: rgba(148,163,184,.16); color: #cbd5e1; }
[data-theme="dark"] .chip.ch-stock { background: rgba(52,211,153,.2); color: #6ee7b7; }
[data-theme="dark"] .chip.ch-ship { background: rgba(56,189,248,.18); color: #7dd3fc; }
[data-theme="dark"] .chip.ch-bad { background: rgba(248,113,113,.18); color: #fca5a5; }
[data-theme="dark"] .card-new { background: #101c30; border-color: #25365a; }
[data-theme="dark"] .card-ready { background: #241d10; border-color: #7c5a12; }
[data-theme="dark"] .card-confirmed { background: #0f241c; border-color: #1f6f4e; }
[data-theme="dark"] .card-done { background: #0f1724; border-color: #1b2740; }
[data-theme="dark"] .card-overdue { background: #2a1414; border-color: #7f1d1d; }
[data-theme="dark"] .card-urgent { background: #2a2210; border-color: #7c5a12; }
[data-theme="dark"] .sync-badge { background: #16223a; color: #cbd5e1; }
[data-theme="dark"] .stepper { background: var(--card); border-color: var(--line); }
[data-theme="dark"] .step-line { background: #22304a; }
[data-theme="dark"] .bar { background: #16223a; }
[data-theme="dark"] .muted { color: var(--muted); }
[data-theme="dark"] .empty { color: var(--muted); }
[data-theme="dark"] a { color: #a5b4fc; }


/* ---------- нижнее меню: горизонтальная прокрутка ---------- */
nav.bottom {
  display: flex !important;
  grid-template-columns: none !important;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav.bottom::-webkit-scrollbar { display: none; }
nav.bottom button {
  flex: 0 0 auto;
  min-width: 66px;
  padding: 8px 6px;
  scroll-snap-align: center;
  background: transparent;
  border: 0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  position: relative;
}
nav.bottom button.active { color: var(--accent); background: rgba(99, 91, 255, .10); font-weight: 700; }
nav.bottom button .ico { font-size: 18px; line-height: 1; }
[data-theme="dark"] nav.bottom button.active { color: #c7c7ff; background: #16223a; }

/* ---------- нижнее меню: полноширинная прокручиваемая лента ---------- */
nav.bottom {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  transform: none !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(10, 37, 64, .06);
  display: flex !important;
  grid-template-columns: none !important;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
}
nav.bottom::-webkit-scrollbar { display: none; }
nav.bottom button {
  flex: 0 0 auto;
  min-width: 66px;
  padding: 8px 6px;
  scroll-snap-align: center;
  font-size: 11px;
}
main { padding-bottom: 88px; }
[data-theme="dark"] nav.bottom { background: #060d18; border-top: 1px solid #16233a; box-shadow: none; }

/* ---------- шапка: крупные кнопки и аккуратный текст ---------- */
header.top { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
header.top .brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}
header.top .who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  justify-content: flex-end;
}
header.top .icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  border-radius: 10px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 2;
}
header.top .icon.gear {
  background: rgba(255, 255, 255, .12);
  outline: 1px solid rgba(255, 255, 255, .18);
}
header.top .icon:active { background: rgba(255, 255, 255, .22); }


/* ---------- значки станков в «Смене» ---------- */
.mstrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.mstrip::-webkit-scrollbar { display: none; }
.mchip {
  flex: 0 0 112px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(10, 37, 64, .05);
}
.mchip.ok { border-top-color: var(--ok); }
.mchip.warn { border-top-color: var(--warn); }
.mchip.bad { border-top-color: var(--bad); }
.mchip:active { transform: scale(.97); }
.mchip .mi { font-size: 26px; line-height: 1.1; }
.mchip .mn { font-size: 12px; font-weight: 700; text-align: center; line-height: 1.2; }
.mchip .mq { font-size: 10px; color: var(--muted); text-align: center; }
.mchip .mh { font-size: 10px; color: var(--muted); }
[data-theme="dark"] .mchip { background: #121c2e; border-color: #22304a; }


/* ---------- векторные иконки меню ---------- */
.ico-svg { display: block; width: 20px; height: 20px; flex: 0 0 auto; }
nav.bottom button .ico { display: flex; align-items: center; justify-content: center; height: 22px; font-size: 0; }
nav.bottom button .ico .ico-svg { width: 21px; height: 21px; }
nav.bottom button.active .ico-svg { stroke-width: 2.1; }
header.top .icon .ico-svg { width: 21px; height: 21px; }
header.top .icon { font-size: 0; }
header.top .icon.gear .ico-svg { width: 20px; height: 20px; }


/* ---------- ПК-версия в мобильной раскладке ---------- */
[data-layout="mobile"] body {
  background: #dfe7f0;
  display: flex;
  justify-content: center;
}
[data-layout="mobile"] #app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(10, 37, 64, .18);
  position: relative;
  overflow-x: hidden;
}
[data-layout="mobile"] main { max-width: 100%; padding: 14px 14px 96px; }
[data-layout="mobile"] header.top { position: sticky; top: 0; z-index: 20; width: 100%; }
[data-layout="mobile"] nav.bottom {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: 0 !important;
  transform: translateX(-50%) !important;
  width: 100% !important;
  max-width: 480px;
  border-radius: 0 !important;
}
[data-theme="dark"][data-layout="mobile"] body { background: #060d18; }
[data-theme="dark"][data-layout="mobile"] #app { box-shadow: 0 0 40px rgba(0, 0, 0, .6); }

/* шапка: не обрезать название, сжимать имя пользователя */
header.top .brand { flex: 0 0 auto; max-width: 62%; }
header.top .who { flex: 1 1 auto; overflow: hidden; }
/* ---------- ПК-версия: десктопная раскладка ---------- */
[data-layout="desktop"] body { background: var(--bg); }
[data-layout="desktop"] #app {
  display: grid;
  grid-template-columns: 236px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  max-width: 100%;
}
[data-layout="desktop"] header.top { grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; }
[data-layout="desktop"] nav.side {
  grid-column: 1;
  grid-row: 2;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 12px 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
[data-layout="desktop"] nav.side .side-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 4px 8px 8px;
}
[data-layout="desktop"] nav.side button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  position: relative;
}
[data-layout="desktop"] nav.side button:hover { background: rgba(99, 91, 255, .08); }
[data-layout="desktop"] nav.side button.active { background: rgba(99, 91, 255, .14); color: var(--accent); font-weight: 700; }
[data-layout="desktop"] nav.side button .ico { display: flex; width: 22px; height: 22px; align-items: center; justify-content: center; }
[data-layout="desktop"] nav.side .side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-layout="desktop"] nav.side .nav-count { position: static; margin-left: auto; }
[data-layout="desktop"] main {
  grid-column: 2;
  grid-row: 2;
  max-width: 1180px;
  width: 100%;
  padding: 20px 28px 40px;
  margin: 0;
}
[data-theme="dark"][data-layout="desktop"] nav.side { background: #121c2e; border-right-color: #22304a; }
[data-theme="dark"][data-layout="desktop"] nav.side button:hover { background: rgba(124, 124, 255, .12); }
[data-theme="dark"][data-layout="desktop"] nav.side button.active { background: rgba(124, 124, 255, .2); color: #c7c7ff; }


/* ---------- значки станков в «Смене»: только иконка и название ---------- */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin: 4px 0 8px; }
.mcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 14px;
  padding: 16px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(10, 37, 64, .05);
  transition: transform .12s, box-shadow .12s;
}
.mcard:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(10, 37, 64, .10); }
.mcard.ok { border-top-color: var(--ok); }
.mcard.warn { border-top-color: var(--warn); }
.mcard.bad { border-top-color: var(--bad); }
.mcard .mi { font-size: 30px; line-height: 1; }
.mcard .mn { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.25; }
[data-theme="dark"] .mcard { background: #121c2e; border-color: #22304a; }


/* ---------- иконки оборудования (SVG из открытых наборов) ---------- */
.eq-svg { width: 34px; height: 34px; display: block; color: var(--ink); }
.mcard .mi { display: flex; align-items: center; justify-content: center; min-height: 36px; }
[data-theme="dark"] .eq-svg { color: #e8eef8; }
.mcard .mi .eq-svg { width: 34px; height: 34px; }


/* ---------- форма заказа: липкие кнопки и сообщение об ошибке ---------- */
.sheet-actions {
  position: sticky;
  bottom: -16px;
  margin: 12px -16px -16px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  z-index: 2;
}
.form-err {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(229, 72, 77, .1);
  border: 1px solid rgba(229, 72, 77, .35);
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
}
[data-theme="dark"] .sheet-actions { background: var(--card); border-top-color: #22304a; }


/* ---------- выбор статуса задания ---------- */
.task-line { align-items: center; gap: 10px; }
.op-select {
  flex: 0 0 auto;
  min-width: 148px;
  padding: 8px 30px 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.op-select.queue { border-color: #cbd5e1; color: #475569; background-color: #f1f5f9; }
.op-select.run { border-color: rgba(99, 91, 255, .5); color: var(--accent); background-color: rgba(99, 91, 255, .10); }
.op-select.ok { border-color: rgba(14, 159, 110, .45); color: var(--ok); background-color: rgba(14, 159, 110, .10); }
.op-select:disabled { opacity: .55; cursor: not-allowed; }
[data-theme="dark"] .op-select.queue { background-color: #16233a; color: #94a3b8; border-color: #22304a; }
[data-theme="dark"] .op-select.run { background-color: rgba(124, 124, 255, .15); }
[data-theme="dark"] .op-select.ok { background-color: rgba(14, 159, 110, .16); }


/* ---------- строки операций с выбором статуса ---------- */
.ops { display: flex; flex-direction: column; gap: 6px; }
.ops .task-line {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.ops .task-line:last-of-type { border-bottom: 0; }
.ops .task-line .grow { min-width: 0; flex: 1 1 auto; }
.op-line .op-select, .ops .op-select {
  width: 168px;
  min-width: 168px;
  max-width: 168px;
  flex: 0 0 auto;
  box-sizing: border-box;
}
@media (max-width: 560px) {
  .ops .task-line { flex-wrap: wrap; }
  .op-line .op-select, .ops .op-select { width: 100%; min-width: 0; max-width: 100%; }
}


/* ---------- выбор станков галочками в новом заказе ---------- */
.op-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; background: var(--bg); }
.op-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.eq-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 6px;
}
.eq-check {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  background: var(--card);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.eq-check:hover { border-color: rgba(99, 91, 255, .45); }
.eq-check input { accent-color: #22c55e; width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; }
.eq-check .eq-ico { display: flex; width: 22px; height: 22px; flex: 0 0 auto; }
.eq-check .eq-ico .eq-svg { width: 22px; height: 22px; }
.eq-check .eq-nm { line-height: 1.2; overflow-wrap: anywhere; word-break: break-word; }
.eq-check:has(input:checked) {
  background: #dcfce7;
  border-color: #4ade80;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .18);
}
[data-theme="dark"] .op-row { background: #0f1a2b; }
[data-theme="dark"] .eq-check { background: #121c2e; border-color: #22304a; }
[data-theme="dark"] .eq-check:has(input:checked) { background: rgba(34, 197, 94, .18); border-color: #22c55e; }


/* ---------- опасное действие ---------- */
.btn.danger { background: rgba(229, 72, 77, .10); color: var(--bad); border: 1px solid rgba(229, 72, 77, .45); }
.btn.danger:hover { background: rgba(229, 72, 77, .18); }
[data-theme="dark"] .btn.danger { background: rgba(229, 72, 77, .16); color: #ff8a8d; }


/* ---------- выполненный заказ (на складе) ---------- */
.order-done {
  background: #e9fbf0 !important;
  border-color: #86efac !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .12);
}
.order-done .title { color: #0b6b3a; }
[data-theme="dark"] .order-done { background: rgba(34, 197, 94, .14) !important; border-color: #22c55e !important; }
[data-theme="dark"] .order-done .title { color: #a7f3c9; }


/* ---------- шаг «На складе» зелёным, когда продукция уже на складе ---------- */
.step.stock-active .step-dot {
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 0 0 4px rgba(14, 159, 110, .22);
}
.step.stock-active .step-label {
  color: var(--ok);
  font-weight: 800;
}


/* ---------- выполненные операции в карточке заказа ---------- */
.ops .task-line.done-op {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 4px;
}
.ops .task-line.done-op .title { color: #0b6b3a; }
.ops .task-line.done-op .muted { color: #15803d; }
[data-theme="dark"] .ops .task-line.done-op {
  background: rgba(34, 197, 94, .16);
  border-color: #22c55e;
}
[data-theme="dark"] .ops .task-line.done-op .title { color: #a7f3c9; }


/* ---------- зоны в карточке станка: выполняется / очередь / выполнено ---------- */
.zone {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid #94a3b8;
  background: #f8fafc;
}
.zone-run { border-left-color: var(--accent); background: rgba(99, 91, 255, .06); }
.zone-queue { border-left-color: #94a3b8; background: #f8fafc; }
.zone-done { border-left-color: var(--ok); background: #e9fbf0; }
.zone-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.zone-ico { font-size: 15px; }
.zone-title { font-weight: 800; font-size: 15px; color: var(--ink); }
.zone-run .zone-title { color: var(--accent); }
.zone-done .zone-title { color: #0b6b3a; }
.zone-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(10, 37, 64, .08);
  color: var(--ink);
}
.zone-done .zone-count { background: rgba(14, 159, 110, .16); color: #0b6b3a; }
.zone .op-line { border-bottom: 1px dashed rgba(10, 37, 64, .14); }
.zone .op-line:last-child { border-bottom: 0; }
.zone-empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
[data-theme="dark"] .zone { background: #0f1a2b; border-color: #22304a; }
[data-theme="dark"] .zone-run { background: rgba(124, 124, 255, .10); }
[data-theme="dark"] .zone-done { background: rgba(34, 197, 94, .12); }
[data-theme="dark"] .zone-done .zone-title, [data-theme="dark"] .zone-done .zone-count { color: #a7f3c9; }

.zone-ico { display: flex; width: 18px; height: 18px; align-items: center; justify-content: center; }
.zone-ico .ico-svg { width: 17px; height: 17px; }
.zone-run .zone-ico { color: var(--accent); }
.zone-queue .zone-ico { color: #64748b; }
.zone-done .zone-ico { color: var(--ok); }


/* ---------- очередь с заданиями подсвечивается оранжевым ---------- */
.zone-queue-active {
  border-left-color: #f59e0b;
  background: #fff7ed;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .14);
}
.zone-queue-active .zone-title { color: #b45309; }
.zone-queue-active .zone-ico { color: #d97706; }
.zone-queue-active .zone-count { background: rgba(245, 158, 11, .22); color: #b45309; }
[data-theme="dark"] .zone-queue-active {
  background: rgba(245, 158, 11, .12);
  border-left-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, .18);
}
[data-theme="dark"] .zone-queue-active .zone-title { color: #fbbf24; }
[data-theme="dark"] .zone-queue-active .zone-count { background: rgba(245, 158, 11, .25); color: #fbbf24; }


/* ---------- индикатор связи с сервером (шестерёнка у названия) ---------- */
.brand { display: flex; align-items: center; gap: 7px; }
.conn-gear {
  display: inline-flex;
  width: 27px;
  height: 27px;
  align-items: center;
  justify-content: center;
  color: var(--ok);
  transition: color .2s, filter .2s;
}
.conn-gear svg { width: 25px; height: 25px; }
.conn-gear.on {
  color: #16a34a;
  filter: drop-shadow(0 0 4px rgba(22, 163, 74, .55));
}
.conn-gear.off {
  color: #dc2626;
  filter: drop-shadow(0 0 4px rgba(220, 38, 38, .5));
}
.conn-gear.off svg { animation: conn-spin 6s linear infinite; }
@keyframes conn-spin { to { transform: rotate(360deg); } }
[data-theme="dark"] .conn-gear.on { color: #22c55e; }
[data-theme="dark"] .conn-gear.off { color: #f87171; }


/* ---------- узкие экраны: строки заданий не выходят за экран ---------- */
@media (max-width: 640px) {
  .op-line { flex-wrap: wrap; align-items: flex-start; row-gap: 8px; }
  .op-line .grow, .ops .task-line .grow { min-width: 0; flex: 1 1 100%; }
  .op-line .op-select, .ops .task-line .op-select { width: 100%; min-width: 0; flex: 1 1 100%; }
  .ops .task-line .title, .op-line .title { white-space: normal; overflow-wrap: anywhere; }
  .ops .task-line .muted, .op-line .muted { white-space: normal; overflow-wrap: anywhere; }
  .op-line > .chip, .ops .task-line > .chip { flex: 0 0 auto; }
  .op-line > .btn, .ops .task-line > .btn { flex: 1 1 100%; }
}


/* ---------- название в шапке: полное на ПК, сокращённое на телефоне + логин ---------- */
.brand-full { display: inline; }
.brand-short { display: none; }
.brand-user { color: #cbd5e1; font-weight: 600; font-size: 13px; margin-left: 2px; white-space: nowrap; }
@media (max-width: 640px) {
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .brand-user { font-size: 12px; }
}


/* на телефоне логин уже в названии — подпись пользователя справа не дублируем */
@media (max-width: 640px) {
  .who .who-text { display: none; }
  .who { gap: 4px; }
}


/* ---------- иконка выгрузки Excel ---------- */
.ico-excel { width: 20px; height: 20px; display: block; border-radius: 3px; box-shadow: 0 0 0 1px rgba(29, 111, 66, .35); }


/* ---------- кнопки Excel / настройки / выход прижаты к правому краю шапки ---------- */
.hdr-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }


/* ---------- заказы, объединённые по одному договору ---------- */
.contract-card { border-left: 4px solid var(--accent); }
.contract-orders { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.contract-order {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: #f8fafc; cursor: pointer;
}
.contract-order:hover { border-color: rgba(99, 91, 255, .45); background: rgba(99, 91, 255, .05); }
.contract-order .chip { flex: 0 0 auto; }
[data-theme="dark"] .contract-order { background: #0f1a2b; }
[data-theme="dark"] .contract-order:hover { background: rgba(124, 124, 255, .10); }


/* ---------- новый заказ: несколько деталей ---------- */
.part-entry { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.part-draft { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; background: #f8fafc; }
.part-draft .btn { flex: 0 0 auto; }
[data-theme="dark"] .part-entry { background: var(--card); }
[data-theme="dark"] .part-draft { background: #0f1a2b; }

/* окно просмотра файлов */
.sheet.sheet-file {
  width: 96vw !important;
  max-width: 96vw !important;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.sheet.sheet-file #file-zoom-box {
  flex: 1 1 auto;
  max-height: none !important;
}
.sheet.sheet-file-full {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0 !important;
}

/* ===== нижняя панель: 5 разделов с иконками ===== */
nav.bottom {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 2px;
  overflow: visible !important;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
nav.bottom button {
  min-width: 0 !important;
  flex: 1 1 0 !important;
  padding: 5px 2px 3px !important;
  gap: 2px !important;
  border-radius: 12px;
  font-size: 10.5px;
  position: relative;
}
nav.bottom button .ico { height: 24px; }
nav.bottom button .ico .ico-svg { width: 23px; height: 23px; }
nav.bottom button .lbl { font-size: 10.5px; font-weight: 600; line-height: 1.1; letter-spacing: .1px; }
nav.bottom button.active { color: #2dd4bf !important; background: transparent !important; }
nav.bottom button.active .ico-svg { stroke-width: 2.2; }
nav.bottom .nav-count {
  position: absolute;
  top: 1px;
  left: 50%;
  margin-left: 7px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: #f87171;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
[data-theme="dark"] nav.bottom button.active { color: #2dd4bf !important; background: transparent !important; }

/* меню «Ещё» */
.navmore { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.navmore button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  position: relative;
}
.navmore button .ico-svg { width: 22px; height: 22px; flex: 0 0 auto; }
.navmore button:active { transform: scale(.98); }
.navmore .nav-count { position: absolute; top: 6px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: #f87171; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }

/* значки станков в шапке заказа */
.eq-mini-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.eq-mini {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--accent);
}
.eq-mini .ico-svg { width: 17px; height: 17px; }
.eq-mini-hint { font-size: 12px; opacity: .75; margin-left: 2px; }
[data-theme="dark"] .eq-mini { background: #121c2e; border-color: #22304a; }

/* Задачи: подсветка отправленных и выполненных */
.card.task-sent-pending { background: #fff7d6; border: 2px solid #f2c200; }
.card.task-sent-done { background: #effaf3; border: 2px solid #21a366; }
[data-theme="dark"] .card.task-sent-pending { background: #3a331a; border-color: #c9a400; }
[data-theme="dark"] .card.task-sent-done { background: #12301f; border-color: #2fbe7a; }

/* Отметка выполнения — только после того, как задачу закрыл получатель */
.task-done-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: #21a366; color: #fff; font-size: 18px; font-weight: 700;
  flex: 0 0 auto;
}

/* два счётчика на иконке «Заказы» в нижнем меню: слева заявки (оранжевый), справа в производстве */
.nav-badge-left, .nav-badge-right {
  position: absolute;
  top: 1px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.nav-badge-left { left: calc(50% - 24px); background: #f59e0b; }
.nav-badge-right { right: calc(50% - 24px); background: #2563eb; }

/* маркеры на карточках станков: жёлтый — очередь, синий — выполняется сейчас */
.mcard { position: relative; }
.eq-badge {
  position: absolute;
  top: 4px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  z-index: 2;
}
.eq-badge-queue { left: 6px; background: #f59e0b; }
.eq-badge-run { right: 6px; background: #2563eb; }

/* стрелка «доступно обновление» — вращается по часовой стрелке */
.upd-spin { display: inline-flex; width: 22px; height: 22px; margin-left: 8px; color: #2563eb; animation: upd-spin 1s linear infinite; }
.upd-spin svg { width: 100%; height: 100%; }
@keyframes upd-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }


/* ---------- таблица готовой продукции в стиле 1С ---------- */
.prod-table-wrap { overflow: auto; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
.prod-tbl { width: 100%; min-width: 940px; border-collapse: collapse; font-size: 12.5px; }
.prod-tbl thead th { position: sticky; top: 0; background: #f1f5f9; border-bottom: 1px solid #cbd5e1; padding: 6px 8px; text-align: left; white-space: nowrap; z-index: 1; }
.prod-tbl tbody td { padding: 6px 8px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
.prod-tbl tbody tr:nth-child(even) { background: #f8fafc; }
.prod-tbl tbody tr:hover { background: #eff6ff; }
.prod-tbl td.num, .prod-tbl th.num { text-align: right; }
.tbl-sort { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; white-space: nowrap; }
[data-theme="dark"] .prod-table-wrap { background: #0f172a; border-color: #22304a; }
[data-theme="dark"] .prod-tbl thead th { background: #16213a; border-bottom-color: #2a3b57; }
[data-theme="dark"] .prod-tbl tbody td { border-bottom-color: #1c2a42; }
[data-theme="dark"] .prod-tbl tbody tr:nth-child(even) { background: #111c2e; }
[data-theme="dark"] .prod-tbl tbody tr:hover { background: #1b2a44; }

/* ---------- история проверок: 3 колонки ---------- */
.qc-hist-list { display: flex; flex-direction: column; gap: 10px; }
.qc-hist { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "c1 c2 c3 c4"; gap: 12px; align-items: center; }
.qc-c1 { grid-area: c1; min-width: 0; }
.qc-c2 { grid-area: c2; min-width: 0; }
.qc-c3 { grid-area: c3; min-width: 0; }
.qc-c4 { grid-area: c4; text-align: right; }
.qc-lbl { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .02em; }
.qc-note { font-size: 12px; margin-top: 4px; }
@media (max-width: 720px) {
  .qc-hist { grid-template-columns: 1fr 1fr; grid-template-areas: "c1 c1" "c2 c3" "c4 c4"; gap: 8px 12px; }
  .qc-c4 { text-align: left; }
}
[data-theme="dark"] .qc-lbl { color: #94a3b8; }

/* ---------- встроенный просмотр печатных форм ---------- */
.doc-toolbar { position: sticky; top: 0; z-index: 2; background: inherit; padding-bottom: 6px; }
.doc-frame { width: 100%; height: 68vh; min-height: 420px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
@media (max-width: 720px) { .doc-frame { height: 62vh; } }

/* ---------- компактный экран станка на телефоне ---------- */
.eq-zones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.eq-zones .zone { min-width: 0; }
@media (min-width: 721px) {
  .eq-zones .zone { max-height: calc(100vh - 330px); overflow: auto; }
  .eq-zones .zone-head { flex-wrap: wrap; }
  .eq-zones .op-line .title { font-size: 13px; }
}
@media (max-width: 720px) {
  .eq-detail { font-size: 12px; }
  .eq-detail .eq-card { padding: 10px !important; margin-top: 6px !important; }
  .eq-detail .eq-card .title { font-size: 16px !important; }
  .eq-detail .eq-card .row.between { margin-top: 6px !important; align-items: center; }
  .eq-detail .eq-card .muted { font-size: 11px; }
  .eq-detail .eq-card .bar { display: none; }
  .eq-detail .eq-card .actions { margin-top: 6px; gap: 4px; }
  .eq-detail .eq-card .actions .btn { padding: 4px 8px; font-size: 11px; }
  .eq-detail .eq-card .btn.danger { padding: 4px 8px; font-size: 11px; }
  .eq-zones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; align-items: start; }
  .eq-zones .zone { padding: 7px !important; min-width: 0; margin: 0 !important; max-height: calc(100vh - 300px); overflow: auto; }
  .eq-zones .zone-head { padding: 0 !important; gap: 3px; align-items: center; flex-wrap: wrap; }
  .eq-zones .zone-ico { display: none; }
  .eq-zones .zone-title { font-size: 11px; line-height: 1.15; font-weight: 700; }
  .eq-zones .zone-count { font-size: 11px; padding: 1px 6px; }
  .eq-zones .zone-empty { font-size: 10px; padding: 2px 0; line-height: 1.25; }
  .eq-zones .op-line { flex-direction: column; align-items: stretch; gap: 3px; padding: 4px 0 !important; }
  .eq-zones .op-line .title { font-size: 11px !important; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .eq-zones .op-line .muted { display: none; }
  .eq-zones .op-line .row { display: none; }
  .eq-zones .op-line .btn, .eq-zones .op-line select { font-size: 10px !important; padding: 2px 4px !important; max-width: 100%; }
}

/* мобильная карточка станка: на 30% ниже, без дублей статуса */
@media (max-width: 720px) {
  .eq-detail .eq-card { padding: 8px 10px !important; margin-top: 4px !important; }
  .eq-detail .eq-card .title { font-size: 15px !important; line-height: 1.15 !important; }
  .eq-detail .eq-card .eq-meta { display: none; }
  .eq-detail .eq-card .eq-status-label { display: none; }
  .eq-detail .eq-card .eq-status-text { font-size: 13px !important; }
  .eq-detail .eq-card .eq-status-chip { display: none; }
  .eq-detail .eq-card .row.between { margin-top: 2px !important; }
  .eq-detail .eq-card .muted { font-size: 10.5px; line-height: 1.25; }
  .eq-detail .eq-card .actions { margin-top: 4px; gap: 4px; }
  .eq-detail .eq-card .actions .btn { padding: 3px 7px; font-size: 10.5px; }
  .eq-detail .eq-card .btn.danger { padding: 3px 6px !important; font-size: 10.5px !important; }
  .eq-detail .eq-card .btn[data-action="edit-equipment"] { padding: 3px 6px !important; font-size: 10.5px !important; }
}

/* скрытие складских действий в мобильной версии */
@media (max-width: 720px) { .hide-mobile { display: none !important; } }

/* ---------- мобильные компактные карточки и таблицы ---------- */
@media (max-width: 720px) {
  .task-card, .msg-card { padding: 8px 10px !important; margin-bottom: 6px !important; }
  .task-card .title, .msg-card .title { font-size: 13px !important; line-height: 1.2 !important; }
  .task-card .muted, .msg-card .muted { font-size: 10.5px !important; line-height: 1.25 !important; }
  .task-card .task-when { color: var(--muted, #6b7280); }
  .task-card .btn, .msg-card .btn { font-size: 10.5px !important; padding: 2px 6px !important; }
  .task-card .row, .msg-card .row { margin-top: 4px !important; }
  .prod-table-wrap { overflow-x: hidden !important; }
  .prod-tbl { width: 100% !important; table-layout: fixed !important; font-size: 10px !important; }
  .prod-tbl th, .prod-tbl td { padding: 3px 2px !important; white-space: normal !important; word-break: break-word; }
  .prod-table-wrap, .prod-tbl, .prod-tbl tbody { width: 100% !important; max-width: 100% !important; min-width: 0 !important; overflow-x: hidden !important; box-sizing: border-box; }
  .prod-tbl thead { display: none !important; }
  .prod-tbl, .prod-tbl tbody { display: block !important; }
  .prod-tbl tr { display: block !important; position: relative; padding: 6px 34px 6px 8px !important; border-bottom: 1px solid var(--line, #e5e7eb); }
  .prod-tbl td { display: inline !important; border: 0 !important; padding: 0 4px 0 0 !important; font-size: 10.5px !important; }
  .prod-tbl td:nth-child(2) { display: block !important; font-size: 11.5px !important; padding-right: 0 !important; }
  .prod-tbl td:nth-child(2) .muted { font-size: 9.5px !important; }
  .prod-tbl td:nth-child(3) { color: var(--muted, #6b7280); }
  .prod-tbl td:nth-child(4) { font-weight: 700; }
  .prod-tbl td:nth-child(7) { color: var(--muted, #6b7280); }
  .prod-tbl td:nth-child(8) { font-weight: 700; }
  .prod-tbl tr { height: auto !important; min-height: 0 !important; line-height: 1.35 !important; }
  .prod-tbl td:nth-child(9) { display: block !important; position: absolute !important; right: 8px; top: 8px; margin: 0; padding: 0 !important; float: none; }
  .prod-tbl td:nth-child(8) { padding-right: 26px !important; }
  .prod-tbl td:nth-child(9) .btn { padding: 2px 6px !important; font-size: 13px !important; }
  .prod-tbl td:nth-child(1), .prod-tbl td:nth-child(5),
  .prod-tbl td:nth-child(6) { display: none !important; }
  .prod-tbl .muted { font-size: 9.5px !important; }
  .tbl { font-size: 10px !important; }
  .tbl th, .tbl td { padding: 3px 2px !important; }
}

/* выбор материала со склада в заказе */
.mat-picker { position: fixed; inset: 0; z-index: 3000; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; padding: 8px; }
.mat-picker-sheet { background: #fff; color: #111; width: min(760px, 100%); max-height: 88vh; overflow: auto; border-radius: 14px; padding: 12px; }
.mp-list { max-height: 55vh; overflow: auto; }
.mp-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
@media (max-width: 720px) {
  .mat-picker-sheet { max-height: 92vh; padding: 10px; }
  .mp-list { max-height: 60vh; }
  .mp-row { font-size: 12px; padding: 6px 2px; }
}

/* ---------- iOS / PWA ---------- */
@supports (-webkit-touch-callout: none) {
  html, body { -webkit-touch-callout: none; overscroll-behavior-y: none; }
  input, select, textarea { font-size: 16px !important; }
  @media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top); }
  }
}

/* ---------- рабочий чат ---------- */
.chat-win { position: fixed; right: 16px; bottom: 16px; width: 340px; height: 440px; background: #fff; color: #111; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 38px rgba(15,23,42,.22); display: flex; flex-direction: column; z-index: 2600; overflow: hidden; }
.chat-win.min { height: 44px; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #1f2937; color: #fff; flex: 0 0 auto; }
.chat-head b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .chat-min, .chat-head .chat-x { background: transparent; border: 0; color: #fff; cursor: pointer; font-size: 13px; padding: 2px 4px; opacity: .9; }
.chat-body { flex: 1 1 auto; overflow: auto; padding: 8px; background: #f8fafc; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; margin: 4px 0; }
.chat-msg.mine { align-items: flex-end; }
.chat-bubble { max-width: 82%; padding: 6px 9px; border-radius: 10px; background: #fff; border: 1px solid #e2e8f0; font-size: 13px; line-height: 1.35; white-space: pre-wrap; word-break: break-word; }
.chat-msg.mine .chat-bubble { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.chat-time { font-size: 10px; color: #94a3b8; margin-top: 2px; }
.chat-empty { color: #64748b; font-size: 12px; padding: 10px; text-align: center; }
.chat-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #e2e8f0; flex: 0 0 auto; }
.chat-input input { flex: 1; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; min-width: 0; }
.chat-picker { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.chat-user { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; text-align: left; cursor: pointer; width: 100%; }
.chat-user:hover { background: #f8fafc; }
.chat-avatar { width: 34px; height: 34px; border-radius: 50%; background: #eef2ff; color: #4338ca; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
@media (max-width: 720px) { .chat-win { right: 8px; left: 8px; bottom: 64px; width: auto; height: 60vh; } }

.nav-count.chat-count { background: #16a34a !important; color: #fff !important; box-shadow: 0 0 0 2px rgba(22,163,74,.18); }

.chat-head { cursor: grab; touch-action: none; user-select: none; }
.chat-win.dragging .chat-head { cursor: grabbing; }
.chat-win.dragging { opacity: .96; box-shadow: 0 18px 50px rgba(15,23,42,.32); }

.chat-win.min .chat-body, .chat-win.min .chat-input { display: none !important; }

.chat-read { font-size: 10px; color: #16a34a; margin-top: 1px; font-weight: 600; }

.chat-win.full { left: 50% !important; top: 50% !important; right: auto !important; bottom: auto !important; transform: translate(-50%, -50%); width: min(920px, 94vw) !important; height: min(82vh, 900px) !important; }
.chat-win.full .chat-body { padding: 12px; }
.chat-win.full .chat-bubble { max-width: 70%; font-size: 14px; }

.chat-head .chat-snd { background: transparent; border: 0; color: #fff; cursor: pointer; font-size: 13px; padding: 2px 4px; opacity: .9; }

.chat-attach { background: transparent; border: 1px solid #cbd5e1; border-radius: 8px; cursor: pointer; padding: 4px 8px; font-size: 15px; }
.chat-file { margin-top: 4px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px 8px; font-size: 12px; color: #1f2937; cursor: pointer; text-align: left; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chat-msg.mine .chat-file { background: rgba(0,0,0,.22); border-color: rgba(255,255,255,.45); color: #fff; }
.chat-file { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chat-file span { white-space: nowrap; opacity: .85; }
.chat-img { max-width: 220px; max-height: 180px; border-radius: 8px; margin-top: 4px; display: block; subject-fit: cover; }

.chat-reply { border-left: 3px solid rgba(79,70,229,.7); background: rgba(79,70,229,.08); border-radius: 6px; padding: 4px 8px; margin: 2px 0 4px; max-width: 82%; font-size: 11px; color: #475569; }
.chat-reply b { display: block; font-size: 11px; color: #4338ca; }
.chat-msg.mine .chat-reply { align-self: flex-end; border-left-color: #4f46e5; background: #eef2ff; color: #475569; }
.chat-msg.mine .chat-reply b { color: #4338ca; }
.chat-reply-btn { background: transparent; border: 0; cursor: pointer; color: #64748b; font-size: 12px; padding: 0 4px; opacity: .75; }
.chat-reply-btn:hover { opacity: 1; }
.chat-reply-bar { display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-top: 1px solid #e2e8f0; background: #eef2ff; font-size: 11px; color: #475569; }
.chat-reply-bar b { color: #4338ca; }
.chat-reply-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-bar button { background: transparent; border: 0; cursor: pointer; color: #64748b; }

.chat-upload { font-size: 10px; color: #64748b; white-space: nowrap; }

.chat-body { overflow-anchor: none; }

.inv-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.inv-toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.inv-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #64748b; min-width: 170px; }
.inv-field span { font-size: 11px; }
.inv-field select, .inv-field input { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; background: #fff; color: #1e293b; }
.inv-field input[readonly] { background: #f8fafc; }
.inv-search { flex: 1; min-width: 180px; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.inv-scroll { max-height: 420px; overflow: auto; border: 1px solid #cbd5e1; border-radius: 6px; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.inv-table th { position: sticky; top: 0; background: #f1f5f9; color: #334155; text-align: left; font-weight: 600; padding: 7px 8px; border-bottom: 1px solid #cbd5e1; border-right: 1px solid #e2e8f0; white-space: nowrap; }
.inv-table th.num, .inv-table td.num { text-align: right; }
.inv-table td { padding: 6px 8px; border-bottom: 1px solid #eef2f7; border-right: 1px solid #f1f5f9; color: #1e293b; }
.inv-table tbody tr { cursor: pointer; }
.inv-table tbody tr:hover td { background: #f8fafc; }
.inv-table tbody tr.sel td { background: #eef2ff; box-shadow: inset 2px 0 0 #4f46e5; }
.inv-table th.inv-sort { cursor: pointer; }
.inv-table th.inv-sort.asc::after { content: ' ▲'; font-size: 9px; }
.inv-table th.inv-sort.desc::after { content: ' ▼'; font-size: 9px; }
.inv-foot { margin-top: 8px; font-size: 12px; color: #475569; }

/* Бухгалтерия — оформление в стиле 1С */
.acc-page { background: #fff; border: 1px solid #d7dce2; border-radius: 6px; padding: 0; overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.acc-head { padding: 10px 14px 8px; border-bottom: 1px solid #e4e8ee; background: linear-gradient(#fbfcfd,#f4f6f9); }
.acc-head h2 { margin: 0; font-size: 17px; color: #1f3b63; font-weight: 700; }
.acc-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 10px; background: #f7f9fb; border-bottom: 1px solid #d7dce2; }
.acc-tabs .seg { border: 1px solid transparent; border-bottom: 0; background: #eef1f5; color: #334155; border-radius: 4px 4px 0 0; padding: 7px 11px; font-size: 12.5px; margin-top: 4px; }
.acc-tabs .seg.active { background: #fff; color: #1f3b63; font-weight: 700; border-color: #d7dce2; box-shadow: inset 0 2px 0 #2f5597; }
.acc-body { padding: 12px 14px 14px; background: #fff; }
.acc-page .card { background: #fff; border: 1px solid #e0e5eb; border-radius: 4px; box-shadow: none; padding: 12px; margin-bottom: 10px; }
.acc-page .card .title { font-size: 13.5px; font-weight: 700; color: #1f3b63; border-bottom: 1px solid #e4e8ee; padding-bottom: 6px; margin-bottom: 8px; }
.acc-page .muted { color: #6b7787; }
.acc-page .btn { background: #f4f6f9; border: 1px solid #c9d0d9; color: #22303f; border-radius: 4px; box-shadow: none; }
.acc-page .btn:hover { background: #e9eef5; }
.acc-page .btn.primary { background: #2f5597; border-color: #2a4d8a; color: #fff; }
.acc-page .btn.primary:hover { background: #2a4d8a; }
.acc-page .btn.small { padding: 4px 9px; font-size: 12px; }
.acc-page .fld span { font-size: 11px; color: #6b7787; }
.acc-page .fld input, .acc-page .fld select { border: 1px solid #c9d0d9; border-radius: 4px; background: #fff; padding: 5px 7px; font-size: 12.5px; }
.acc-page .card > .row.between { padding: 6px 0; border-bottom: 1px solid #eef1f5; }
.acc-page .card > .row.between:last-child { border-bottom: 0; }
.acc-page .chip { border-radius: 3px; font-size: 11px; }
.acc-page .actions { gap: 6px; }
.acc-page .empty { color: #6b7787; background: #f8fafc; border: 1px dashed #d7dce2; border-radius: 4px; padding: 10px; }
.acc-page .inv-scroll { border-color: #c9d0d9; border-radius: 3px; }
.acc-page .inv-table th { background: #eceff3; color: #22303f; border-color: #cdd4dc; font-size: 12px; padding: 5px 7px; }
.acc-page .inv-table td { border-color: #e4e8ee; padding: 4px 7px; font-size: 12.5px; }
.acc-page .inv-table tbody tr.sel td { background: #dfe8f6; box-shadow: inset 2px 0 0 #2f5597; }
.acc-page .inv-table tbody tr:hover td { background: #f2f6fb; }

.sheet:has(.doc-form) { max-width: 1180px; width: 96vw; }
.doc-form { display: flex; flex-direction: column; gap: 8px; }
.doc-title { font-size: 16px; font-weight: 700; color: #1f3b63; }
.doc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-head { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 8px 12px; background: #f7f9fb; border: 1px solid #e0e5eb; border-radius: 4px; padding: 10px; }
.doc-head .fld span { font-size: 11px; color: #6b7787; }
.doc-head .fld input { font-size: 12.5px; }
.doc-toolbar { display: flex; gap: 10px; align-items: center; }
.doc-scroll { border: 1px solid #c9d0d9; border-radius: 4px; overflow: auto; max-height: 330px; }
.doc-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; background: #fff; }
.doc-tbl th { position: sticky; top: 0; background: #eceff3; border-bottom: 1px solid #cdd4dc; border-right: 1px solid #e2e8f0; color: #22303f; padding: 5px 6px; text-align: left; white-space: nowrap; }
.doc-tbl td { border-bottom: 1px solid #e4e8ee; border-right: 1px solid #f1f5f9; padding: 4px 6px; }
.doc-tbl td.num, .doc-tbl th.num { text-align: right; }
.doc-tbl select, .doc-tbl input { border: 1px solid #c9d0d9; border-radius: 3px; padding: 3px 4px; font-size: 12.5px; max-width: 100%; }
.doc-tbl select { max-width: 260px; }
.doc-foot { font-size: 12.5px; color: #475569; }

.sheet.sheet-wide { max-width: 1180px !important; width: 96vw; }

.chat-emoji-panel { position: absolute; right: 8px; bottom: 54px; width: 264px; max-height: 200px; overflow: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 8px 24px rgba(15,23,42,.18); padding: 6px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 5; }
.chat-emoji { border: 0; background: transparent; cursor: pointer; font-size: 18px; padding: 3px; border-radius: 4px; line-height: 1; }
.chat-emoji:hover { background: #eef2ff; }

/* ---------- оптимизация для телефона / APK ---------- */
@media (max-width: 640px) {
  .acc-tabs, .stock-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .acc-tabs::-webkit-scrollbar, .stock-tabs::-webkit-scrollbar { display: none; }
  .acc-tabs > *, .stock-tabs > * { flex: 0 0 auto; }
  .btn, .btn.small { min-height: 40px; }
  .btn.small { padding-left: 10px; padding-right: 10px; }
  input, select, textarea { font-size: 16px; }
  .card { padding: 10px; }
  .nhe-rate { width: 92px !important; }
}

@media (max-width: 640px) {
  .row { flex-wrap: wrap; }
  .row.between > * { min-width: 0; }
  .inv-scroll { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 640px) {
  .actions { flex-wrap: wrap; }
  .actions > .btn, .actions > button { flex: 1 1 auto; }
  .card > .row:first-child, .card > .row.between:first-child { flex-wrap: wrap; }
}

/* ---------- масштабирование окон под размер телефона ---------- */
@media (max-width: 760px) {
  #modal-root .backdrop { padding: 0; }
  #modal-root .sheet {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 92dvh;
    padding: 14px;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .sheet:has(.doc-form), .sheet.sheet-wide { width: 100vw !important; max-width: 100vw !important; }
  .doc-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-head .fld { min-width: 0; }
  .doc-tbl { font-size: 11.5px; }
  .doc-tbl select, .doc-tbl input { font-size: 16px; }
  .sheet-actions { bottom: -14px; margin: 10px -14px -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  #modal-root .sheet { padding: 11px; max-height: 94dvh; }
  .sheet-actions { bottom: -11px; margin: 8px -11px -11px; padding: 8px 11px calc(8px + env(safe-area-inset-bottom)); }
  .doc-head { grid-template-columns: 1fr; gap: 6px; }
  .doc-tbl th, .doc-tbl td { padding: 3px 4px; }
  .doc-title { font-size: 14px; }
  .btn { font-size: 12px; }
}
@media (max-height: 620px) and (max-width: 760px) {
  #modal-root .sheet { max-height: 96dvh; }
  .doc-scroll { max-height: 240px; }
}

/* ---------- телефон: склад ГП и счета — все строки в ширину экрана ---------- */
@media (max-width: 640px) {
  .card .inv-scroll { overflow-x: hidden; }
  .card .inv-scroll .tbl,
  .inv-scroll .inv-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed;
    font-size: 9.5px;
  }
  .card .inv-scroll .tbl th,
  .card .inv-scroll .tbl td,
  .inv-scroll .inv-table th,
  .inv-scroll .inv-table td {
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    padding: 3px 2px !important;
    vertical-align: top;
  }
  .card .inv-scroll .tbl th,
  .inv-scroll .inv-table th { font-size: 8.5px; line-height: 1.15; }
  .inv-scroll .inv-table .btn,
  .inv-scroll .inv-table select,
  .inv-scroll .inv-table input { font-size: 9px !important; padding: 2px 3px !important; }
  .inv-scroll .inv-table .row { gap: 2px; flex-wrap: wrap; }
  .doc-tbl { table-layout: fixed; width: 100%; font-size: 9.5px; }
  .doc-tbl th, .doc-tbl td { white-space: normal !important; word-break: break-word; padding: 2px 3px !important; }
}

/* ---------- телефон: склад ГП и счета как карточки ---------- */
@media (max-width: 640px) {
  .goods-cards, .inv-cards,
  .goods-cards tbody, .inv-cards tbody { display: block; width: 100%; }
  .goods-cards thead, .inv-cards thead { display: none; }
  .goods-cards tr, .inv-cards tr {
    display: block;
    margin: 7px 0;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--card);
  }
  .goods-cards td, .inv-cards td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    border: 0;
    padding: 2px 0 !important;
    font-size: 11.5px;
    text-align: right;
    white-space: normal !important;
  }
  .goods-cards td::before, .inv-cards td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    text-align: left;
  }
  .goods-cards td.actions-cell, .inv-cards td.actions-cell {
    display: block;
    text-align: left;
    margin-top: 5px;
    padding-top: 5px !important;
    border-top: 1px dashed var(--line);
  }
  .goods-cards td.actions-cell::before, .inv-cards td.actions-cell::before { display: none; }
  .goods-cards tr.goods-group, .goods-cards tr.goods-group td { border: 0; padding: 3px 0 !important; }
  .goods-cards tr.goods-group { margin: 4px 0; background: transparent; }
  .goods-cards tr.goods-total { border-top: 2px solid var(--line); border-radius: 0; }
  .inv-cards .actions-cell .btn { margin: 2px 2px 0 0; }
}

/* ---------- телефон: компактный шрифт склада сырья и ГП ---------- */
@media (max-width: 640px) {
  .mat-sec .tbl { font-size: 9.5px; }
  .mat-sec .tbl th { font-size: 8.5px; line-height: 1.15; }
  .mat-sec .tbl th, .mat-sec .tbl td { padding: 3px 2px !important; }
  .mat-sec .tbl .btn { font-size: 10px !important; padding: 2px 5px !important; }
  .goods-cards td { font-size: 9.5px !important; }
  .goods-cards td::before { font-size: 8.5px !important; }
  .goods-cards td.actions-cell .btn { font-size: 10px !important; padding: 2px 5px !important; }
}

/* ---------- телефон: производство — компактные иконки и подробные подписи ---------- */
.mcard .mtyp, .mcard .mstat { display: none; }
@media (max-width: 720px) {
  .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .mcard { padding: 9px 9px 9px; gap: 4px; border-radius: 12px; align-items: flex-start; }
  .mcard .mi { min-height: 26px; align-self: center; }
  .mcard .mi .eq-svg { width: 28px; height: 28px; }
  .mcard .mn { width: 100%; font-size: 12px; line-height: 1.2; text-align: left; overflow-wrap: anywhere; }
  .mcard .mtyp { display: block; width: 100%; font-size: 10px; line-height: 1.25; color: #64748b; overflow-wrap: anywhere; }
  .mcard .mstat { display: inline-block; margin-top: 2px; padding: 1px 6px; border-radius: 6px; background: #eef2f7; color: #475569; font-size: 9.5px; font-weight: 600; }
  .mcard.ok .mstat { background: #ecfdf5; color: #047857; }
  .mcard.warn .mstat { background: #fffbeb; color: #b45309; }
  .mcard.bad .mstat { background: #fef2f2; color: #b91c1c; }
}

/* ---------- телефон: 3 станка в строку ---------- */
@media (max-width: 720px) {
  .mgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .mcard { padding: 7px 5px 7px; gap: 3px; border-radius: 10px; }
  .mcard .mi { min-height: 22px; }
  .mcard .mi .eq-svg { width: 24px; height: 24px; }
  .mcard .mn { font-size: 10px; line-height: 1.15; text-align: center; }
  .mcard .mtyp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 8.5px;
    line-height: 1.2;
    text-align: center;
  }
  .mcard .mstat { font-size: 8px; padding: 0 4px; margin-top: auto; align-self: flex-start; }
  .mcard .eq-badge { min-width: 14px; height: 14px; line-height: 14px; font-size: 8px; padding: 0 3px; top: 2px; }
  .mcard .eq-badge-queue { left: 3px; }
  .mcard .eq-badge-run { right: 3px; }
}

/* ---------- телефон: склад как на ПК — таблицы с горизонтальной прокруткой ---------- */
@media (max-width: 640px) {
  .card .inv-scroll { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .card .inv-scroll .tbl {
    width: auto !important;
    min-width: 620px !important;
    table-layout: auto !important;
    font-size: 12px !important;
  }
  .card .inv-scroll .tbl th { font-size: 11px !important; white-space: nowrap !important; }
  .card .inv-scroll .tbl td { white-space: nowrap !important; }
  .mat-sec { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mat-sec .tbl {
    width: auto !important;
    min-width: 540px !important;
    table-layout: auto !important;
    font-size: 12px !important;
  }
  .mat-sec .tbl th, .mat-sec .tbl td { padding: 5px 6px !important; white-space: nowrap !important; }
}

/* ---------- телефон: подменю склада в стиле бухгалтерии ---------- */
@media (max-width: 640px) {
  .segmented.stock-segmented {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 0 2px;
    background: #f7f9fb;
    border: 1px solid #d7dce2;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .segmented.stock-segmented::-webkit-scrollbar { display: none; }
  .segmented.stock-segmented .seg {
    flex: 0 0 auto;
    border: 1px solid transparent;
    border-bottom: 0;
    background: #eef1f5;
    color: #334155;
    border-radius: 4px 4px 0 0;
    padding: 8px 10px;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 600;
  }
  .segmented.stock-segmented .seg.active {
    background: #fff;
    color: #1f3b63;
    font-weight: 700;
    border-color: #d7dce2;
    box-shadow: inset 0 2px 0 #2f5597;
  }
}

/* ---------- телефон: подменю склада без прокрутки ---------- */
@media (max-width: 640px) {
  .segmented.stock-segmented {
    overflow: visible;
    flex-wrap: nowrap;
    gap: 2px;
  }
  .segmented.stock-segmented .seg {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 7px 4px;
    font-size: 10.5px;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
    overflow-wrap: break-word;
  }
}

/* ---------- телефон: материалы — 4 колонки в одну строку ---------- */
@media (max-width: 640px) {
  .pres-mobile { width: 100%; table-layout: fixed; font-size: 10.5px; }
  .pres-mobile th, .pres-mobile td { white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; padding: 5px 3px !important; }
  .pres-mobile th:nth-child(1) { width: 56%; }
  .pres-mobile th:nth-child(2), .pres-mobile th:nth-child(3) { width: 22%; }
  .pres-mobile .pres-name { max-width: 0; }
}

/* ---------- телефон: готовая продукция — 5 колонок в одну строку ---------- */
@media (max-width: 640px) {
  .goods-mobile { width: 100% !important; min-width: 0 !important; table-layout: fixed; font-size: 8px; }
  .goods-mobile th, .goods-mobile td { white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; padding: 4px 2px !important; }
  .goods-mobile th:nth-child(1) { width: 32%; }
  .goods-mobile th:nth-child(2) { width: 21%; }
  .goods-mobile th:nth-child(3) { width: 8%; }
  .goods-mobile th:nth-child(4) { width: 13%; }
  .goods-mobile th:nth-child(5) { width: 26%; }
  .goods-mobile .goods-name { max-width: 0; }
}

@media (max-width: 640px) {
  .card .inv-scroll .goods-mobile { width: 100% !important; min-width: 0 !important; table-layout: fixed !important; font-size: 8px !important; }
}

/* ---------- телефон: разграничение столбцов готовой продукции ---------- */
@media (max-width: 640px) {
  .goods-mobile th, .goods-mobile td { border-right: 1px solid #e6ebf1; }
  .goods-mobile th:last-child, .goods-mobile td:last-child { border-right: 0; }
  .goods-mobile th { background: #e9eef5 !important; }
  .goods-mobile th:nth-child(even), .goods-mobile td:nth-child(even) { background: #f4f6f9; }
  .goods-mobile th:nth-child(1), .goods-mobile td:nth-child(1) { background: #fff; }
  .goods-mobile tr.tot td { background: #eef2f7 !important; font-weight: 700; }
}

@media (max-width: 640px) {
  .card .inv-scroll .goods-mobile th,
  .card .inv-scroll .goods-mobile td { font-size: 8px !important; line-height: 1.2 !important; }
}

/* ---------- телефон: архив заказов компактным списком ---------- */
@media (max-width: 640px) {
  .arch-list { display: flex; flex-direction: column; gap: 4px; }
  .arch-head, .arch-row { display: grid; grid-template-columns: 27% 1fr 17% 21%; gap: 5px; align-items: center; }
  .arch-head { padding: 0 8px 3px; font-size: 8.5px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .02em; }
  .arch-row { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 9.5px; line-height: 1.2; cursor: pointer; }
  .arch-no { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
  .arch-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .arch-status { min-width: 0; overflow: hidden; white-space: nowrap; }
  .arch-status .chip { font-size: 8px; padding: 1px 4px; }
  .arch-date { color: #1f3b63; font-size: 8.5px; font-weight: 700; background: #eef2f7; padding: 2px 4px; border-radius: 5px; text-align: center; white-space: nowrap; }
}

/* ---------- телефон: обработанные заявки снабжения списком ---------- */
@media (max-width: 640px) {
  .supply-done-list { display: flex; flex-direction: column; gap: 4px; }
  .supply-done-head, .supply-done-row { display: grid; grid-template-columns: 1fr 26% 26%; gap: 5px; align-items: center; }
  .supply-done-head { padding: 0 8px 3px; font-size: 8.5px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .02em; }
  .supply-done-row { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 10px; line-height: 1.2; }
  .supply-done-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .supply-done-qty { white-space: nowrap; color: #334155; }
  .supply-done-date { white-space: nowrap; text-align: right; color: #1f3b63; font-weight: 700; background: #eef2f7; padding: 2px 4px; border-radius: 5px; }
}

/* ---------- телефон: разделение заявок снабжения ---------- */
@media (max-width: 640px) {
  .supply-done-section { margin-top: 30px; padding-top: 16px; border-top: 2px solid #d7dce2; }
}

/* ---------- телефон: снабжение — потребность и заявки списком ---------- */
@media (max-width: 640px) {
  .supply-need-list, .supply-req-list { display: flex; flex-direction: column; gap: 4px; }
  .supply-need-head, .supply-need-row { display: grid; grid-template-columns: 1fr 22% 19% 20%; gap: 4px; align-items: center; }
  .supply-need-head, .supply-req-head { padding: 0 8px 3px; font-size: 8px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .02em; }
  .supply-need-row { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 9.5px; line-height: 1.2; }
  .supply-need-name, .supply-req-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .supply-def-bad { color: #b91c1c; font-weight: 700; }
  .supply-def-ok { color: #047857; }
  .supply-req-head, .supply-req-row { display: grid; grid-template-columns: 1fr 22% 35%; gap: 5px; align-items: center; }
  .supply-req-row { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 9.5px; }
  .supply-req-qty { white-space: nowrap; }
  .supply-req-sel .op-select { width: 100% !important; min-width: 0 !important; max-width: none !important; font-size: 9px !important; padding: 3px 4px !important; }
}

/* ---------- ПК: пользователи онлайн — салатовый фон карточки ---------- */
.card.user-online { background: #e9fbe9 !important; border-color: #22c55e !important; border-left: 5px solid #22c55e !important; box-shadow: inset 0 0 0 1px #bbf7d0; }
[data-theme="dark"] .card.user-online { background: #14532d !important; border-color: #4ade80 !important; border-left-color: #4ade80 !important; box-shadow: inset 0 0 0 1px #22c55e; }

/* ---------- ПК: склад на всю ширину страницы ---------- */
[data-layout="desktop"] main[data-view="stock"] { max-width: none; }

/* ---------- ПК: склад ГП до низа окна, прокрутка только при заполнении ---------- */
[data-layout="desktop"] main[data-view="stock"] { max-width: none; display: flex; flex-direction: column; padding-bottom: 12px; min-height: 0; height: calc(100vh - 56px) !important; max-height: calc(100vh - 56px) !important; overflow: hidden; box-sizing: border-box; }
[data-layout="desktop"] .stock-page { flex: 1 1 auto; min-height: 0; height: 100%; display: flex; flex-direction: column; }
[data-layout="desktop"] .stock-page.stock-products .goods-report-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
[data-layout="desktop"] .stock-page.stock-products .goods-report-scroll { flex: 1 1 auto; min-height: 0; max-height: none !important; overflow-y: auto; }
[data-layout="desktop"] .stock-page.stock-products .goods-report-scroll table { margin-bottom: 0; }

/* ---------- телефон: нормо-часы помещаются на экран ---------- */
@media (max-width: 640px) {
  .card .inv-scroll .nhe-table { width: 100% !important; min-width: 0 !important; table-layout: fixed !important; font-size: 9px !important; }
  .card .inv-scroll .nhe-table th, .card .inv-scroll .nhe-table td { white-space: normal !important; padding: 4px 3px !important; font-size: 9px !important; line-height: 1.15 !important; vertical-align: middle; }
  .nhe-table th:nth-child(1) { width: 42% !important; }
  .nhe-table th:nth-child(2) { width: 31% !important; }
  .nhe-table th:nth-child(3) { width: 27% !important; }
  .nhe-table .nhe-rate { width: 100% !important; min-width: 0 !important; max-width: none !important; font-size: 11px !important; padding: 3px 2px !important; height: auto !important; }
  #nhe-q { min-width: 0 !important; width: 100% !important; }
  #nhe-found { font-size: 10px !important; }
}

/* ---------- телефон: контроль качества — зоны и списки ---------- */
@media (max-width: 640px) {
  .qc-zone { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
  .qc-zone h3 { margin: 0 0 8px; font-size: 14px; }
  .qc-zone-queue { background: #fff8ec; border-color: #f6d9a8; }
  .qc-zone-history { background: #f8fafc; border-color: #e2e8f0; }
  .qc-list { display: flex; flex-direction: column; gap: 6px; }
  .qc-row { display: flex; gap: 8px; align-items: center; background: var(--card); border: 1px solid #e5eaf0; border-radius: 8px; padding: 8px; }
  .qc-row-main { flex: 1 1 auto; min-width: 0; }
  .qc-row-title { font-weight: 700; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qc-row-sub { font-size: 9.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
  .qc-row .btn.small { min-height: 0; padding: 6px 8px; font-size: 10px; flex: 0 0 auto; }
  .qc-hist-row { padding: 6px 7px; gap: 6px; }
  .qc-hist-row .qc-row-title { font-size: 9.5px; }
  .qc-hist-row .qc-row-sub { font-size: 8px; margin-top: 1px; }
  .qc-hist-row .chip { flex: 0 0 auto; font-size: 7px; padding: 1px 3px; }
}

/* ---------- телефон: контроль качества — таблицы как в бухгалтерии ---------- */
@media (max-width: 640px) {
  .qc-table-wrap { width: 100%; overflow-x: hidden; border: 1px solid #cbd5e1; border-radius: 6px; }
  .qc-table { width: 100% !important; min-width: 0 !important; table-layout: fixed !important; font-size: 8.5px !important; margin: 0 !important; }
  .qc-table th, .qc-table td { padding: 4px 3px !important; font-size: 8.5px !important; line-height: 1.15 !important; white-space: normal !important; word-break: break-word; vertical-align: top; }
  .qc-table th { background: #eceff3 !important; font-size: 8px !important; white-space: nowrap !important; }
  .qc-table .qc-sub { font-size: 7.5px !important; color: #64748b; margin-top: 1px; }
  .qc-table .chip { font-size: 7px !important; padding: 1px 3px !important; }
  .qc-table .btn.small { min-height: 0 !important; padding: 4px 5px !important; font-size: 8px !important; }
  .qc-queue-table th:nth-child(1) { width: 32% !important; }
  .qc-queue-table th:nth-child(2) { width: 20% !important; }
  .qc-queue-table th:nth-child(3) { width: 26% !important; }
  .qc-queue-table th:nth-child(4) { width: 22% !important; }
  .qc-hist-table th:nth-child(1) { width: 32% !important; }
  .qc-hist-table th:nth-child(2) { width: 20% !important; }
  .qc-hist-table th:nth-child(3) { width: 20% !important; }
  .qc-hist-table th:nth-child(4) { width: 15% !important; }
  .qc-hist-table th:nth-child(5) { width: 13% !important; }
  .qc-act { text-align: right; }
}

/* ---------- телефон: подменю бухгалтерии в две строки ---------- */
@media (max-width: 640px) {
  .acc-page .acc-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; overflow: visible; flex-wrap: wrap; }
  .acc-page .acc-tabs > * { flex: none; min-width: 0; width: auto; padding: 6px 3px; font-size: 9.5px; line-height: 1.15; white-space: normal; text-align: center; }
}

/* ---------- телефон: бухгалтерия — минималистичная сводка ---------- */
@media (max-width: 640px) {
  .acc-mini { display: flex; flex-direction: column; gap: 10px; }
  .acc-mini-hero, .acc-mini-sec, .acc-mini-tools { background: #fff; border: 1px solid #dfe5ec; border-radius: 8px; padding: 12px; }
  .acc-mini-label { font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
  .acc-mini-total { font-size: 26px; font-weight: 700; color: #1f3b63; letter-spacing: -.5px; line-height: 1.1; margin-top: 2px; }
  .acc-mini-total span { font-size: 12px; font-weight: 600; color: #64748b; }
  .acc-mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid #eef1f5; }
  .acc-mini-kpis span { display: block; font-size: 8px; color: #64748b; text-transform: uppercase; }
  .acc-mini-kpis b { font-size: 11px; color: #22303f; }
  .acc-mini-note { font-size: 9px; color: #64748b; margin-top: 7px; line-height: 1.3; }
  .acc-mini-links { display: flex; gap: 6px; margin-top: 10px; }
  .acc-mini-btn { min-height: 0 !important; padding: 6px 9px !important; font-size: 9px !important; border: 1px solid #c9d0d9; background: #f4f6f9; color: #22303f; border-radius: 5px; }
  .acc-mini-btn.primary { background: #2f5597; border-color: #2a4d8a; color: #fff; }
  .acc-mini-h, .acc-mini-h2 { font-size: 11px; font-weight: 700; color: #1f3b63; margin: 0 0 7px; }
  .acc-mini-h2 { margin-top: 10px; border-top: 1px solid #eef1f5; padding-top: 8px; }
  .acc-mini-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .acc-mini-count { border: 1px solid #dfe5ec; background: #f8fafc; border-radius: 6px; padding: 7px 4px; text-align: center; color: #334155; }
  .acc-mini-count b { display: block; font-size: 17px; color: #1f3b63; line-height: 1; }
  .acc-mini-count span { display: block; font-size: 8px; margin-top: 3px; }
  .acc-mini-doc { display: flex; align-items: center; gap: 7px; padding: 7px 0; border-top: 1px solid #eef1f5; }
  .acc-mini-doc-main { flex: 1; min-width: 0; }
  .acc-mini-doc-main b { display: block; font-size: 10px; color: #22303f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .acc-mini-doc-main span { display: block; font-size: 8.5px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .acc-mini-doc-act { display: flex; gap: 4px; flex: 0 0 auto; }
  .acc-mini-empty { font-size: 9px; color: #64748b; }
  .acc-mini-tools { padding: 0; overflow: hidden; }
  .acc-mini-tools > summary { cursor: pointer; font-size: 10px; font-weight: 700; color: #1f3b63; padding: 11px 12px; list-style: none; }
  .acc-mini-tools > summary::-webkit-details-marker { display: none; }
  .acc-mini-tools > summary::after { content: '▾'; float: right; color: #64748b; }
  .acc-mini-tools[open] > summary::after { content: '▴'; }
  .acc-mini-tool { border-top: 1px solid #eef1f5; padding: 10px 12px; }
  .acc-mini-tool > label { font-size: 9px; color: #64748b; display: block; margin-bottom: 5px; }
  .acc-mini-row { display: flex; gap: 5px; margin-top: 5px; }
  .acc-mini-row select { flex: 1; min-width: 0; font-size: 10px !important; padding: 5px !important; height: auto !important; }
}

/* ---------- телефон: сводка — два склада ---------- */
@media (max-width: 640px) {
  .acc-mini-wh { background: #fff; border: 1px solid #dfe5ec; border-radius: 9px; padding: 14px; }
  .acc-mini-wh-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .acc-mini-wh-name { font-size: 10px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
  .acc-mini-link { min-height: 0 !important; padding: 0 !important; border: 0 !important; background: transparent !important; color: #2f5597 !important; font-size: 9px !important; font-weight: 600; }
  .acc-mini-wh-value { font-size: 28px; font-weight: 700; color: #1f3b63; letter-spacing: -.5px; line-height: 1.1; margin-top: 6px; }
  .acc-mini-wh-value span { font-size: 12px; font-weight: 600; color: #64748b; }
  .acc-mini-wh-meta { font-size: 9.5px; color: #64748b; margin-top: 5px; }
}

/* ---------- телефон: счёта, поступления, накладные — карточки-строки ---------- */
.show-mobile { display: none; }
@media (max-width: 640px) {
  .show-mobile { display: block; }
  .m-doc-list { display: flex; flex-direction: column; gap: 6px; }
  .m-doc { background: #fff; border: 1px solid #dfe5ec; border-radius: 8px; padding: 9px 10px; }
  .m-doc.sel { border-color: #2f5597; box-shadow: inset 3px 0 0 #2f5597; }
  .m-doc-head { display: flex; align-items: center; gap: 6px; font-size: 8.5px; color: #64748b; }
  .m-doc-num { margin-left: auto; font-weight: 600; color: #334155; font-size: 8.5px; text-align: right; }
  .m-doc-head .chip { flex: 0 0 auto; font-size: 7px; padding: 1px 4px; }
  .m-doc-title { font-size: 11px; font-weight: 700; color: #22303f; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; }
  .m-doc-sub { font-size: 9px; color: #64748b; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-doc-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 10px; color: #1f3b63; }
  .m-doc-meta b { font-size: 12px; }
  .m-doc-meta span { font-size: 8.5px; color: #64748b; }
  .m-doc-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; padding-top: 6px; border-top: 1px solid #eef1f5; }
  .m-doc-metrics span { display: block; font-size: 7.5px; color: #64748b; }
  .m-doc-metrics b { display: block; font-size: 10px; color: #22303f; margin-top: 1px; }
  .m-doc-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; padding-top: 6px; border-top: 1px solid #eef1f5; }
  .m-doc-actions .btn.small { min-height: 0 !important; padding: 5px 7px !important; font-size: 8.5px !important; }
}

/* ---------- телефон: счета покупателям — список, открытие по нажатию ---------- */
@media (max-width: 640px) {
  .m-doc-tap { cursor: pointer; }
  .m-doc-open { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; padding-top: 6px; border-top: 1px solid #eef1f5; font-size: 8.5px; color: #2f5597; font-weight: 600; }
  .m-doc-open span { font-size: 15px; line-height: 1; color: #94a3b8; }
}

/* ---------- телефон: поиск в счетах покупателям ---------- */
@media (max-width: 640px) {
  .m-cust-search { margin: 0 0 8px; }
  .m-cust-search .inv-search { width: 100%; box-sizing: border-box; }
}

/* ---------- телефон: реестр документов — таблица и поиск ---------- */
@media (max-width: 640px) {
  .docs-mobile-card { padding: 10px; }
  .m-doc-search-wrap { margin-bottom: 8px; }
  .m-doc-search-wrap .inv-search { width: 100%; box-sizing: border-box; }
  .docs-mobile-tbl { border: 1px solid #dfe5ec; border-radius: 7px; overflow: hidden; }
  .docs-mobile-head, .docs-mobile-row { display: grid; grid-template-columns: 22% 1fr 23%; gap: 5px; align-items: center; }
  .docs-mobile-head { background: #eceff3; padding: 6px 8px; font-size: 8px; font-weight: 700; color: #475569; text-transform: uppercase; }
  .docs-mobile-row { padding: 7px 8px; border-top: 1px solid #eef1f5; background: #fff; cursor: pointer; }
  .docs-mobile-date { font-size: 8.5px; color: #475569; white-space: nowrap; }
  .docs-mobile-name { min-width: 0; }
  .docs-mobile-name b { display: block; font-size: 9.5px; color: #22303f; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
  .docs-mobile-name small { display: block; margin-top: 2px; font-size: 8px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .docs-mobile-row .chip { font-size: 7px; padding: 1px 3px; text-align: center; }
}

/* ---------- ПК: компактная форма заказа с вкладками ---------- */
[data-layout="desktop"] .ord-auto { font-size: 11px; color: #94a3b8; margin: -4px 0 8px; }
[data-layout="desktop"] .ord-adv { margin: 8px 0; border: 1px solid #e2e8f0; border-radius: 8px; padding: 0 10px; background: #f8fafc; }
[data-layout="desktop"] .ord-adv > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: #334155; padding: 9px 0; list-style: none; }
[data-layout="desktop"] .ord-adv > summary::-webkit-details-marker { display: none; }
[data-layout="desktop"] .ord-adv > summary::after { content: '▾'; float: right; color: #94a3b8; }
[data-layout="desktop"] .ord-adv[open] > summary::after { content: '▴'; }
[data-layout="desktop"] .ord-adv-body { padding-bottom: 8px; }
[data-layout="desktop"] .ord-tabs { display: flex; gap: 4px; margin: 12px 0 10px; border-bottom: 1px solid #e2e8f0; }
[data-layout="desktop"] .ord-tab { flex: 1; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; background: #eef1f5; color: #475569; padding: 9px 10px; font-size: 12px; font-weight: 600; }
[data-layout="desktop"] .ord-tab.active { background: #fff; color: #1f3b63; border-color: #d7dce2; box-shadow: inset 0 2px 0 #6c5ce7; }
[data-layout="desktop"] .ord-pane-hidden { display: none; }
[data-layout="desktop"] .ord-pane > h3 { display: none; }

/* ---------- телефон: компактная форма заказа с вкладками ---------- */
@media (max-width: 640px) {
  .ord-auto { font-size: 10px; color: #94a3b8; margin: -4px 0 8px; }
  .ord-adv { margin: 8px 0; border: 1px solid #e2e8f0; border-radius: 8px; padding: 0 10px; background: #f8fafc; }
  .ord-adv > summary { cursor: pointer; font-size: 10px; font-weight: 600; color: #334155; padding: 9px 0; list-style: none; }
  .ord-adv > summary::-webkit-details-marker { display: none; }
  .ord-adv > summary::after { content: '▾'; float: right; color: #94a3b8; }
  .ord-adv[open] > summary::after { content: '▴'; }
  .ord-adv-body { padding-bottom: 8px; }
  .ord-tabs { display: flex; gap: 4px; margin: 10px 0 9px; border-bottom: 1px solid #e2e8f0; }
  .ord-tab { flex: 1; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; background: #eef1f5; color: #475569; padding: 9px 6px; font-size: 10px; font-weight: 600; }
  .ord-tab.active { background: #fff; color: #1f3b63; border-color: #d7dce2; box-shadow: inset 0 2px 0 #6c5ce7; }
  .ord-pane-hidden { display: none; }
  .ord-pane > h3 { display: none; }
}

/* ---------- телефон: компактная карточка новой детали ---------- */
@media (max-width: 640px) {
  .part-compact { background: #fff; border: 1px solid #dfe5ec; border-radius: 9px; padding: 12px; }
  .part-compact > .row.between { margin-bottom: 4px; }
  .part-compact > .row.between b { font-size: 14px; color: #1f3b63; }
  .part-compact .part-zone { margin-top: 2px; padding-top: 6px; border-top: 1px solid #eef1f5; }
  .part-compact .part-zone > span { font-size: 10px; font-weight: 700; color: #1f3b63; }
  .part-compact .eq-list { display: grid !important; grid-template-columns: 1fr 1fr; gap: 5px !important; }
  .part-compact .eq-check { min-height: 0 !important; padding: 7px 6px !important; border-radius: 6px !important; font-size: 8.5px !important; gap: 5px !important; }
  .part-compact .eq-check .eq-ico { width: 20px !important; height: 20px !important; }
  .part-compact .eq-check .eq-nm { font-size: 8.5px !important; line-height: 1.15 !important; }
  .part-files { margin: 8px 0; border: 1.5px dashed #b9c5d4; border-radius: 8px; background: #f8fafc; padding: 0 9px; }
  .part-files > summary { cursor: pointer; font-size: 10px; color: #334155; list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 9px 0; }
  .part-files > summary::-webkit-details-marker { display: none; }
  .part-files > summary span { font-size: 8px; color: #94a3b8; }
  .part-files[open] > summary { margin-bottom: 6px; border-bottom: 1px solid #eef1f5; }
  .part-compact #part-add { margin-top: 8px; }
  .part-compact .pm-row { display: grid !important; grid-template-columns: 1fr 1fr 30px; gap: 4px !important; align-items: end !important; }
  .part-compact .pm-row > .fld { min-width: 0 !important; width: auto !important; }
  .part-compact .pm-row > .fld:nth-child(1) { grid-column: 1 / -1; }
  .part-compact .pm-row > .fld:nth-child(2) { grid-column: 1; }
  .part-compact .pm-row > .fld:nth-child(3) { grid-column: 2; }
  .part-compact .pm-row > .pm-del { grid-column: 3; grid-row: 2; align-self: center; height: 28px; margin-top: 0; min-height: 0 !important; padding: 0 !important; border: 1px solid #fca5a5 !important; background: #fff5f5 !important; color: #dc2626 !important; border-radius: 7px; }
  .part-compact .pm-row > .pm-cost { grid-column: 1 / -1; padding-bottom: 0 !important; }
}

/* ---------- телефон: поиск материала по вводу ---------- */
@media (max-width: 640px) {
  .part-compact .pm-mat-fld { position: relative; }
  .part-compact .pm-suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 25; margin-top: 2px; background: #fff; border: 1px solid #cfd8e3; border-radius: 7px; box-shadow: 0 8px 20px rgba(15,23,42,.15); max-height: 190px; overflow-y: auto; }
  .part-compact .pm-sug { padding: 8px 9px; border-bottom: 1px solid #eef1f5; cursor: pointer; }
  .part-compact .pm-sug:last-child { border-bottom: 0; }
  .part-compact .pm-sug b { display: block; font-size: 9.5px; color: #22303f; line-height: 1.2; }
  .part-compact .pm-sug span { display: block; font-size: 8px; color: #64748b; margin-top: 2px; }
  .part-compact .pm-sug-empty { padding: 9px; font-size: 8.5px; color: #64748b; }
}

/* ---------- телефон: вложения заказа — гибридный блок ---------- */
@media (max-width: 640px) {
  .order-files { margin-top: 10px; }
  .order-files-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
  .order-files-head b { font-size: 11px; color: #1f3b63; }
  .order-files-note { font-size: 8px; color: #94a3b8; margin-top: 2px; }
  .order-files-add { min-height: 0 !important; padding: 6px 8px !important; font-size: 8.5px !important; border: 1px solid #c7c0f5; background: #f4f2ff; color: #4c3bb5; border-radius: 6px; }
  .order-files-drop { width: 100%; margin-top: 9px; border: 1.5px dashed #b9c5d4; border-radius: 9px; background: #f8fafc; padding: 16px 10px; text-align: center; display: block; color: #64748b; }
  .order-files-drop .ic { display: block; font-size: 24px; line-height: 1; color: #6c5ce7; }
  .order-files-drop b { display: block; font-size: 10px; color: #334155; margin-top: 6px; }
  .order-files-drop span { display: block; font-size: 8px; margin-top: 3px; }
  .order-files-drop small { display: block; font-size: 7.5px; color: #94a3b8; margin-top: 5px; }
  .order-files-list { margin-top: 7px; border: 1px solid #dfe5ec; border-radius: 8px; overflow: hidden; background: #fff; }
  .order-file { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid #eef1f5; }
  .order-file:first-child { border-top: 0; }
  .order-file-ic { width: 28px; height: 28px; border-radius: 6px; background: #eef2f7; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: 0 0 auto; }
  .order-file-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 0; color: #22303f; }
  .order-file-main b { display: block; font-size: 9px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .order-file-main span { display: block; font-size: 7.5px; color: #94a3b8; margin-top: 1px; }
  .order-file .btn.small { min-height: 0 !important; padding: 3px 6px !important; font-size: 9px !important; }
}



/* ---------- телефон: файлы заказа в форме нового заказа ---------- */
@media (max-width: 640px) {
  .ord-files { margin: 8px 0 7px; background: #fff; border: 1px solid #dfe5ec; border-radius: 9px; padding: 9px; }
  .ord-files-head { display: flex; align-items: center; gap: 8px; }
  .ord-files-head b { font-size: 11px; color: #1f3b63; }
  .ord-files-head span { font-size: 8px; color: #94a3b8; }
  .ord-files-add { margin-left: auto; min-height: 0 !important; padding: 6px 8px !important; font-size: 8.5px !important; border: 1px solid #c7c0f5; background: #f4f2ff; color: #4c3bb5; border-radius: 6px; }
  .ord-files-empty { border: 1.5px dashed #b9c5d4; border-radius: 8px; background: #f8fafc; padding: 9px 8px; text-align: center; margin-top: 6px; }
  .ord-files-ic { font-size: 20px; line-height: 1; color: #6c5ce7; }
  .ord-files-t { font-size: 9.5px; font-weight: 700; color: #334155; margin-top: 4px; }
  .ord-files-d { font-size: 7.5px; color: #64748b; margin-top: 2px; line-height: 1.3; }
  .ord-files-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 9px; }
  .ord-file-tile { border: 1px solid #dfe5ec; background: #fff; border-radius: 7px; padding: 5px; font-size: 8.5px; font-weight: 600; color: #334155; display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 0; }
  .ord-file-tile .ic { font-size: 14px; }
  .ord-files-list { margin-top: 8px; }
  .ord-file-row { display: flex; align-items: center; gap: 7px; padding: 7px 0; border-top: 1px solid #eef1f5; }
  .ord-file-row:first-child { border-top: 0; }
  .ord-file-ic { width: 26px; height: 26px; border-radius: 5px; background: #eef2f7; display: flex; align-items: center; justify-content: center; font-size: 12px; flex: 0 0 auto; }
  .ord-file-main { flex: 1; min-width: 0; }
  .ord-file-main b { display: block; font-size: 8.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #22303f; }
  .ord-file-main span { display: block; font-size: 7.5px; color: #94a3b8; margin-top: 1px; }
  .ord-file-del { flex: 0 0 auto; border: 1px solid #fecaca; background: #fff5f5; color: #dc2626; border-radius: 5px; font-size: 9px; padding: 3px 5px; }
}


/* ---------- телефон: зоны формы нового заказа, акцентные полосы ---------- */
@media (max-width: 640px) {
  .ord-mobile-only { display: block; }
  .ord-zone-title { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #2f5bb7; margin-bottom: 6px; }
  .ord-main-block { background: #fff; border: 1px solid #dfe5ec; border-left: 3px solid #5b8def; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
  .ord-files { border-left: 3px solid #8b5cf6 !important; }
  .ord-files-head b { color: #6b4fd8 !important; }
  .ord-files-empty { cursor: pointer; }
  .ord-files-choice { display: none; gap: 6px; margin-top: 5px; }
  .ord-files-choice .ord-file-tile { flex: 1; }
  .ord-adv { border-left: 3px solid #94a3b8 !important; }
  .ord-adv > summary { color: #475569 !important; }
  .ord-tab:nth-child(1).active { box-shadow: inset 0 2px 0 #5b8def; }
  .ord-tab:nth-child(2).active { box-shadow: inset 0 2px 0 #8b5cf6; }
}


/* ---------- ПК: зоны формы заказа и файлы ---------- */
[data-layout="desktop"] .ord-main-block { background: #fff; border: 1px solid #dfe5ec; border-left: 3px solid #5b8def; border-radius: 8px; padding: 10px; margin-bottom: 10px; }
[data-layout="desktop"] .ord-zone-title { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #2f5bb7; margin-bottom: 6px; }
[data-layout="desktop"] .ord-files { display: block; background: #fff; border: 1px solid #dfe5ec; border-left: 3px solid #8b5cf6; border-radius: 9px; padding: 10px; margin: 8px 0; }
[data-layout="desktop"] .ord-files-head { display: flex; align-items: center; gap: 8px; }
[data-layout="desktop"] .ord-files-head b { font-size: 12px; color: #6b4fd8; }
[data-layout="desktop"] .ord-files-head span { font-size: 10px; color: #94a3b8; }
[data-layout="desktop"] .ord-files-add { margin-left: auto; border: 1px solid #c7c0f5; background: #f4f2ff; color: #4c3bb5; border-radius: 6px; padding: 6px 9px; font-size: 10px; font-weight: 600; }
[data-layout="desktop"] .ord-files-empty { border: 1.5px dashed #b9c5d4; border-radius: 8px; background: #f8fafc; padding: 14px 12px; text-align: center; margin-top: 8px; cursor: pointer; }
[data-layout="desktop"] .ord-files-ic { font-size: 24px; line-height: 1; color: #6c5ce7; }
[data-layout="desktop"] .ord-files-t { font-size: 11px; font-weight: 700; color: #334155; margin-top: 5px; }
[data-layout="desktop"] .ord-files-d { font-size: 9px; color: #64748b; margin-top: 3px; }
[data-layout="desktop"] .ord-files-choice { display: none; gap: 8px; margin-top: 8px; }
[data-layout="desktop"] .ord-files-choice .ord-file-tile { flex: 1; border: 1px solid #dfe5ec; background: #fff; border-radius: 7px; padding: 8px; font-size: 10px; font-weight: 600; color: #334155; display: flex; align-items: center; justify-content: center; gap: 6px; }
[data-layout="desktop"] .ord-files-list { margin-top: 8px; }
[data-layout="desktop"] .ord-file-row { display: flex; align-items: center; gap: 9px; padding: 8px 2px; border-top: 1px solid #eef1f5; }
[data-layout="desktop"] .ord-file-row:first-child { border-top: 0; }
[data-layout="desktop"] .ord-file-ic { width: 30px; height: 30px; border-radius: 6px; background: #eef2f7; display: flex; align-items: center; justify-content: center; font-size: 14px; flex: 0 0 auto; }
[data-layout="desktop"] .ord-file-main { flex: 1; min-width: 0; }
[data-layout="desktop"] .ord-file-main b { display: block; font-size: 11px; font-weight: 600; color: #22303f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-layout="desktop"] .ord-file-main span { display: block; font-size: 9px; color: #94a3b8; margin-top: 1px; }
[data-layout="desktop"] .ord-file-del { border: 1px solid #fecaca; background: #fff5f5; color: #dc2626; border-radius: 5px; font-size: 10px; padding: 4px 7px; }
[data-layout="desktop"] .ord-adv { border-left: 3px solid #94a3b8; }
[data-layout="desktop"] .ord-tab:nth-child(1).active { box-shadow: inset 0 2px 0 #5b8def; }
[data-layout="desktop"] .ord-tab:nth-child(2).active { box-shadow: inset 0 2px 0 #8b5cf6; }
[data-layout="desktop"] .part-files-pc { display: block; border: 1.5px dashed #b9c5d4; border-radius: 8px; background: #f8fafc; padding: 10px; margin-top: 4px; }
[data-layout="desktop"] .part-files-pc > span { display: block; margin-bottom: 6px; color: #475569; font-size: 10px; }
/* вложения в карточке заказа на ПК */
[data-layout="desktop"] .order-files { margin-top: 12px; background: #fff; border: 1px solid #dfe5ec; border-left: 3px solid #8b5cf6; border-radius: 9px; padding: 10px; }
[data-layout="desktop"] .order-files-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
[data-layout="desktop"] .order-files-head b { font-size: 12px; color: #6b4fd8; }
[data-layout="desktop"] .order-files-note { font-size: 9px; color: #94a3b8; margin-top: 2px; }
[data-layout="desktop"] .order-files-add { border: 1px solid #c7c0f5; background: #f4f2ff; color: #4c3bb5; border-radius: 6px; padding: 6px 9px; font-size: 10px; font-weight: 600; }
[data-layout="desktop"] .order-files-drop { width: 100%; margin-top: 9px; border: 1.5px dashed #b9c5d4; border-radius: 8px; background: #f8fafc; padding: 13px 10px; text-align: center; color: #64748b; display: block; }
[data-layout="desktop"] .order-files-drop .ic { display: block; font-size: 22px; color: #6c5ce7; line-height: 1; }
[data-layout="desktop"] .order-files-drop b { display: block; font-size: 11px; color: #334155; margin-top: 5px; }
[data-layout="desktop"] .order-files-drop span { display: block; font-size: 9px; margin-top: 2px; }
[data-layout="desktop"] .order-files-drop small { display: block; font-size: 8px; color: #94a3b8; margin-top: 4px; }
[data-layout="desktop"] .order-files-list { margin-top: 8px; border: 1px solid #dfe5ec; border-radius: 8px; overflow: hidden; }
[data-layout="desktop"] .order-file { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-top: 1px solid #eef1f5; }
[data-layout="desktop"] .order-file:first-child { border-top: 0; }
[data-layout="desktop"] .order-file-ic { width: 30px; height: 30px; border-radius: 6px; background: #eef2f7; display: flex; align-items: center; justify-content: center; font-size: 14px; flex: 0 0 auto; }
[data-layout="desktop"] .order-file-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 0; color: #22303f; }
[data-layout="desktop"] .order-file-main b { display: block; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-layout="desktop"] .order-file-main span { display: block; font-size: 9px; color: #94a3b8; margin-top: 1px; }
[data-layout="desktop"] .app-back { font-size: 18px !important; font-weight: 700; width: 34px; }

/* ---------- ПК: двухколоночная форма заказа ---------- */
[data-layout="desktop"] .sheet.ord-form {
  max-width: min(1180px, 96vw) !important;
  width: 96vw;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 8px 16px;
  align-items: start;
}
[data-layout="desktop"] .sheet.ord-form > h2,
[data-layout="desktop"] .sheet.ord-form > .ord-auto,
[data-layout="desktop"] .sheet.ord-form > #order-err,
[data-layout="desktop"] .sheet.ord-form > .sheet-actions { grid-column: 1 / -1; }
[data-layout="desktop"] .sheet.ord-form > .ord-left { grid-column: 1; min-width: 0; }
[data-layout="desktop"] .sheet.ord-form > .ord-right { grid-column: 2; min-width: 0; }
[data-layout="desktop"] .sheet.ord-form .ord-tabs { margin-top: 0; }
[data-layout="desktop"] .sheet.ord-form .ord-pane { min-height: 0; }
[data-layout="desktop"] .sheet.ord-form .ord-left .ord-main-block { margin-top: 0; }
[data-layout="desktop"] .sheet.ord-form .ord-left .ord-files { margin: 8px 0; }
[data-layout="desktop"] .sheet.ord-form .ord-left .ord-adv { margin: 8px 0; }
[data-layout="desktop"] .sheet.ord-form .part-entry { border: 0; padding: 0; margin-top: 6px; }
@media (max-width: 1199px) {
  [data-layout="desktop"] .sheet.ord-form { display: block; max-width: 560px !important; width: 100%; }
}

[data-layout="desktop"] .pm-mat-fld { position: relative; }
[data-layout="desktop"] .pm-suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: 2px; background: #fff; border: 1px solid #cfd8e3; border-radius: 7px; box-shadow: 0 10px 24px rgba(15,23,42,.16); max-height: 220px; overflow-y: auto; }
[data-layout="desktop"] .pm-sug { padding: 8px 10px; border-bottom: 1px solid #eef1f5; cursor: pointer; }
[data-layout="desktop"] .pm-sug:last-child { border-bottom: 0; }
[data-layout="desktop"] .pm-sug b { display: block; font-size: 11px; color: #22303f; }
[data-layout="desktop"] .pm-sug span { display: block; font-size: 9px; color: #64748b; margin-top: 1px; }
[data-layout="desktop"] .pm-sug-empty { padding: 9px 10px; font-size: 10px; color: #64748b; }

/* индикатор отправки вложений */
.order-file-pending { opacity: .85; }
.order-file-pending .order-file-ic { background: #eef2ff; }
.order-file-pending span { color: #6b4fd8 !important; }
.ord-file-row .ord-file-main span { color: #94a3b8; }

/* спиннеры загрузки */
.spinner { width: 16px; height: 16px; border: 2px solid #cbd5e1; border-top-color: #6c5ce7; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.doc-loading { display: flex; align-items: center; gap: 8px; min-height: 120px; justify-content: center; color: #64748b; font-size: 13px; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 8px; }

.m-doc-search-wrap { display: flex; align-items: center; gap: 6px; }
.m-doc-search-wrap .inv-search { flex: 1; min-width: 0; }
.m-doc-search-wrap .btn { flex: 0 0 auto; }
