:root {
  --bg: #f2f2f4;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #7a7a82;
  --line: #e2e2e8;
  --brand: #141414;
  --accent: #b3171d;
  --accent-d: #8f1217;
  --ok: #2a7a2a;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px;
  overscroll-behavior: none;
}
input, button, select { font-family: inherit; font-size: 16px; }
.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }
.error { color: var(--accent); font-size: 14px; margin-top: 8px; min-height: 18px; }

/* ── Screens ── */
.screen { display: none; flex-direction: column; height: 100dvh; }
.screen.active { display: flex; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--brand); color: #fff;
  padding: 14px 14px; padding-top: max(14px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 5;
}
.topbar .title { font-weight: 600; font-size: 17px; flex: 1; }
.topbar .badge { background: var(--accent); padding: 3px 9px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 38px; height: 38px; border-radius: 10px; font-size: 20px; cursor: pointer; line-height: 1;
}
.icon-btn:active { background: rgba(255,255,255,.25); }

/* ── Login ── */
#login { align-items: center; justify-content: center; background:
  radial-gradient(120% 80% at 50% 0%, #2a2a2a 0%, #141414 60%); }
.login-box { width: min(90%, 360px); text-align: center; color: #fff; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.brand-mark { background: #fff; color: #141414; font-weight: 800; padding: 8px 10px; border-radius: 8px; letter-spacing: 1px; }
.brand-name { font-weight: 700; letter-spacing: 3px; font-size: 20px; }
.login-box h1 { font-size: 30px; margin-bottom: 4px; }
.login-box .muted { color: rgba(255,255,255,.6); margin-bottom: 26px; }
.login-box input {
  width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid #333;
  background: #1f1f1f; color: #fff; margin-bottom: 12px;
}
.login-box .error { color: #ff8a8a; }

/* ── Buttons ── */
.btn-primary {
  width: 100%; background: var(--accent); color: #fff; border: none;
  padding: 15px; border-radius: var(--radius); font-weight: 700; cursor: pointer;
}
.btn-primary:active { background: var(--accent-d); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 13px 18px; border-radius: var(--radius); cursor: pointer; }
.mini-btn { background: #f0e7e8; color: var(--accent); border: none; padding: 7px 12px; border-radius: 20px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }

/* ── Summary ── */
.summary { display: flex; gap: 10px; padding: 14px 14px 4px; }
.summary .card { flex: 1; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.summary .card .num { font-size: 22px; font-weight: 800; }
.summary .card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Search ── */
.searchbar { padding: 10px 14px; }
.searchbar input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card);
}

/* ── Lists ── */
.list { flex: 1; overflow-y: auto; padding: 4px 14px 100px; -webkit-overflow-scrolling: touch; }
.offer-card, .list-row {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); cursor: pointer;
}
.offer-card:active, .list-row:active { background: #fafafa; }
.offer-card { display: flex; align-items: stretch; gap: 12px; border-left: 4px solid var(--st, transparent); }
.offer-card .oc-body { flex: 1; min-width: 0; }
.oc-status {
  flex: 0 0 auto; align-self: center; width: 18px; height: 18px; border-radius: 50%;
  border: none; padding: 0; cursor: pointer; box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.oc-status:active { transform: scale(.9); }
.offer-card .oc-top { display: flex; justify-content: space-between; align-items: baseline; }
.offer-card .oc-num { font-weight: 700; color: var(--accent); }
.offer-card .oc-sum { font-weight: 800; }
.offer-card .oc-client { margin-top: 4px; font-size: 15px; }
.offer-card .oc-meta { margin-top: 4px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.list-row .lr-title { font-weight: 600; }
.list-row .lr-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── FAB ── */
.fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 18px rgba(179,23,29,.45); cursor: pointer; z-index: 6;
}
.fab:active { background: var(--accent-d); }

/* ── Editor form ── */
.form-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
}
.row { display: flex; gap: 10px; }
.row .grow { flex: 1; }
.row .narrow { width: 120px; }
.picker { display: flex; gap: 8px; align-items: stretch; }
.select-like {
  flex: 1; text-align: left; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
}
.select-like.filled { font-weight: 600; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; font-weight: 700; }

/* ── Items ── */
.items { display: flex; flex-direction: column; gap: 10px; }
.item-card { background: var(--card); border-radius: 12px; padding: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.item-card .ic-name { font-weight: 600; font-size: 15px; }
.item-card .ic-art { font-size: 12px; color: var(--muted); margin-top: 1px; }
.item-card .ic-controls { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.item-card .ic-controls .qp { flex: 1; }
.item-card .ic-controls label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 3px; }
.item-card .ic-controls input { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); text-align: right; }
.item-card .ic-sum { text-align: right; min-width: 92px; font-weight: 700; }
.item-card .ic-del { background: none; border: none; color: var(--accent); font-size: 22px; cursor: pointer; padding: 0 4px; }

/* ── Editor footer ── */
.editor-footer { background: var(--card); border-top: 1px solid var(--line); padding: 12px 14px calc(12px + var(--safe-b)); }
.total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.total strong { font-size: 22px; }

/* ── Bottom sheet ── */
.sheet-overlay, .modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-overlay.open, .modal-overlay.open { display: flex; }
.sheet-panel {
  background: var(--bg); width: 100%; max-width: 640px; height: 82dvh;
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden;
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; font-weight: 700; }
.sheet-head .icon-btn { background: #e6e6ea; color: var(--ink); }

/* ── Modal ── */
.modal-overlay { align-items: center; }
/* Порядок слоёв: модалки (20) → шторка выбора (40) → «новая номенклатура» (50).
   Шторка вызывается ИЗ модалок (напр. добавление позиции в шаблон), поэтому
   должна быть выше них: при равном z-index её перекрывал модал, идущий ниже в DOM. */
.sheet-overlay { z-index: 40; }
/* «Новая номенклатура» открывается ПОВЕРХ шторки и других модалок */
#modal-newnom { z-index: 50; }

/* ── Главная (дашборд) ── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; overflow-y: auto; }
.dash-card { background: var(--card); border-radius: 14px; padding: 14px; border-left: 4px solid var(--c, #2f80ed); cursor: pointer; }
.dash-card:active { opacity: .7; }
.dc-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.dc-line { font-size: 13px; color: var(--muted); margin-top: 3px; }
.dc-line b { color: var(--ink); font-size: 15px; }
.modal { background: var(--card); width: min(92%, 420px); border-radius: 18px; padding: 20px; }
.modal h3 { margin-bottom: 14px; }
.modal input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn-ghost { flex: 1; } .modal-actions .btn-primary { flex: 2; }

/* ── Шаблоны комплектации ── */
.mini-btn-group { display: inline-flex; gap: 8px; }
.mini-btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.modal.modal-wide { width: min(94%, 520px); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head-row h3 { margin: 0; flex: 1; }
.tpl-name-input { flex: 1; margin-bottom: 0 !important; font-weight: 700; }
.tpl-list { max-height: 52vh; overflow-y: auto; }
#tpl-items { max-height: 52vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.tpl-manage-row { background: rgba(94,53,177,.07); border-radius: 10px; }
.tpl-manage-row .lr-title { color: #5E35B1; font-weight: 600; }
#tpl-detail-view .modal-actions .mini-btn { flex: 1; }
.tpl-desc-input { width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  font: inherit; font-size: 12.5px; line-height: 1.4; resize: vertical; margin-bottom: 10px; box-sizing: border-box; }
.tpl-total { margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: #f3f0fa;
  color: #4527A0; font-size: 13px; text-align: right; }
.tpl-total strong { font-weight: 800; }

/* ── Комплект из шаблона в позициях КП ── */
.item-card.is-kit { border-left: 3px solid #5E35B1; }
.item-card .ic-kit {
  margin-top: 6px; padding: 7px 9px; border-radius: 8px;
  background: #f3f0fa; color: #4527A0; font-size: 11.5px; line-height: 1.45;
}

/* ── Чип активного фильтра по позиции (Снабжение) ── */
.pos-filter {
  display: flex; align-items: center; gap: 8px; margin: 0 14px 10px;
  padding: 9px 12px; border-radius: 10px; background: #e8f0fe; border: 1px solid #b6d0f7;
  color: #14539a; font-size: 13px; font-weight: 600;
}
.pos-filter .pf-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-filter .pf-clear {
  background: none; border: none; color: #14539a; font-size: 16px;
  cursor: pointer; padding: 0 2px; line-height: 1;
}
.sup-filter-bar { display: flex; align-items: center; gap: 10px; }

/* ── Карточка заметок раздела ── */
.notes-card {
  margin: 0 14px 12px; padding: 16px 18px; border-radius: var(--radius);
  min-height: 56px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 700; font-size: 15px; user-select: none;
  border: 1.5px solid transparent; transition: background .15s, border-color .15s;
}
.notes-card .nc-label { pointer-events: none; }
.notes-card.empty { background: #ececec; color: #8a8a8a; border-color: #dcdcdc; }
.notes-card.filled { background: #fff2e0; color: #e07b00; border-color: #ffb85c; }
.notes-card:active { filter: brightness(0.97); }
.note-textarea {
  width: 100%; min-height: 220px; resize: vertical; padding: 13px 14px;
  border-radius: 12px; border: 1px solid var(--line); font: inherit; line-height: 1.4;
  margin-bottom: 12px; box-sizing: border-box;
}

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(30px + var(--safe-b)); transform: translateX(-50%) translateY(40px);
  background: #222; color: #fff; padding: 12px 18px; border-radius: 24px; font-size: 14px;
  opacity: 0; transition: .25s; z-index: 60; pointer-events: none; max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Финансы ── */
.mini-select { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; font-size: 14px; color: var(--ink); }
.topbar .mini-select { background: rgba(255,255,255,.14); border-color: transparent; color: #fff; }
.fin-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 40px; -webkit-overflow-scrolling: touch; }
.fin-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.fin-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.fin-card.hero { grid-column: 1 / -1; padding: 18px; }
.fin-card.clickable { cursor: pointer; position: relative; }
.fin-card.clickable::after { content: '›'; position: absolute; top: 10px; right: 12px; color: var(--muted); font-size: 18px; line-height: 1; }
.fin-card.clickable:active { opacity: .6; }
.plan-list { max-height: 55vh; overflow-y: auto; margin: 4px 0 14px; }
.fin-op.tappable { cursor: pointer; }
.fin-op.tappable:active { background: var(--bg); border-radius: 8px; }
.fin-op.is-plan { opacity: .45; }
.btn-ghost.danger { color: #b3171d; }
.fin-card .lbl { font-size: 12px; color: var(--muted); }
.fin-card .val { font-size: 20px; font-weight: 800; margin-top: 3px; letter-spacing: -.3px; }
.fin-card .val-sub { font-size: 12px; font-weight: 700; margin-top: 3px; opacity: .4; }
.fin-card.hero .val { font-size: 30px; }
.fin-block { background: var(--card); border-radius: var(--radius); padding: 16px 14px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.fin-block-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.fin-block-head > span:first-child { font-weight: 700; font-size: 16px; flex: 1; }
.fin-cats { display: flex; flex-direction: column; gap: 12px; }
.fin-cat-row .fc-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.fin-cat-row .fc-sum { color: var(--muted); font-weight: 600; }
.fin-bar { background: #eee; height: 7px; border-radius: 4px; overflow: hidden; }
.fin-bar > i { display: block; height: 7px; background: var(--accent); border-radius: 4px; }
.fin-ops { display: flex; flex-direction: column; }
.fin-op { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fin-op:last-child { border-bottom: none; padding-bottom: 0; }
.fin-op .fo-main { flex: 1; min-width: 0; }
.fin-op .fo-cat { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-op .fo-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
/* Примечание к операции — видимой отдельной строкой (до 2 строк, дальше «…») */
.fo-note {
  font-size: 12px; color: #6a6a72; font-style: italic; line-height: 1.35;
  margin-top: 3px; padding-left: 8px; border-left: 2px solid #d8d8de;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.od-row .fo-note { margin: 0 0 8px; }

/* Заголовок раздела в спецификации (Детали, Покупные изделия, …) */
.spec-group {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); margin: 6px 0 0; padding-bottom: 4px;
  border-bottom: 1.5px solid var(--line);
}
.spec-group:first-child { margin-top: 0; }
.fin-op .fo-amt { font-size: 16px; font-weight: 800; white-space: nowrap; }
.fin-empty { text-align: center; color: var(--muted); padding: 24px; }
.seg { display: flex; gap: 8px; margin: 4px 0 12px; }
.seg button { flex: 1; padding: 12px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; font-size: 15px; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg-status button { font-size: 13px; padding: 10px 6px; }
.seg-status button.on { color: #fff; border-color: transparent; }
.seg-status button[data-v="актуально"].on { background: #2e9b57; }
.seg-status button[data-v="под вопросом"].on { background: #e08a1e; }
.seg-status button[data-v="не актуально"].on { background: #c0392b; }
.modal select { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 10px; background: var(--card); color: var(--ink); }
.fin-quick { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; grid-auto-flow: column; gap: 10px; margin-bottom: 18px; }
.fq-btn { padding: 14px 6px; border: none; border-radius: var(--radius); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.05); cursor: pointer; }
.fq-btn:active { background: #f2f2f4; }
#fq-expense { color: var(--accent); }
#fq-income { color: var(--ok); }
.fin-warn { display: flex; align-items: center; gap: 10px; background: #fff4e5; border: 1px solid #ffd8a8; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 14px; color: #8a4b00; }
.fin-warn span { flex: 1; }
.warn-btn { background: #e8590c; color: #fff; border: none; border-radius: 20px; padding: 8px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.overdue-list { max-height: 52vh; overflow-y: auto; }
.od-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.od-row:last-child { border-bottom: none; }
.od-top { display: flex; justify-content: space-between; gap: 8px; }
.od-cat { font-weight: 600; font-size: 14px; }
.od-amt { font-weight: 700; white-space: nowrap; }
.od-meta { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.od-actions { display: flex; gap: 8px; }
.od-actions button { flex: 1; padding: 8px 4px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.od-fact { color: var(--ok); }
.od-move { color: #e8590c; }
.od-del { color: var(--accent); }

/* Выпадающее меню разделов */
.nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: none; }
.nav-overlay.open { display: block; }
.nav-panel { position: absolute; top: 0; left: 0; width: min(80%, 320px); height: 100%; background: var(--card); box-shadow: 2px 0 20px rgba(0,0,0,.25); overflow-y: auto; padding-bottom: 16px; animation: navIn .18s ease; }
@keyframes navIn { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.nav-head { padding: 18px 18px 10px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 18px; background: none; border: none; text-align: left; font-size: 15px; color: var(--ink); cursor: pointer; }
.nav-item:active { background: var(--bg); }
.nav-item.disabled { color: var(--muted); opacity: .45; cursor: default; }
.nav-letter { width: 26px; height: 26px; flex: none; border-radius: 7px; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.nav-item:not(.disabled) .nav-letter { background: var(--accent); color: #fff; }

/* ── Снабжение ── */
#sup-summary { display: block; padding: 10px 16px 0; font-size: 13px; color: var(--muted); }
.full-select { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 15px; color: var(--ink); }
.sec-actions { display: flex; gap: 8px; }
.sup-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.sup-item:active { background: var(--bg); border-radius: 8px; }
.sup-item .si-main { flex: 1; min-width: 0; }
.sup-item .si-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-item .si-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sup-item .si-sum { font-weight: 800; white-space: nowrap; }
/* Подсказка о несохранённых отметках приёмки */
.receive-hint {
  margin-top: 10px; padding: 9px 12px; border-radius: 10px;
  background: #fff6e5; border: 1px solid #ffcf80; color: #8a5a00;
  font-size: 12.5px; font-weight: 600;
}
/* Галочка приёмки позиции (слева) */
.sup-item .si-check { display: flex; align-items: center; padding: 4px 2px 4px 0; cursor: pointer; }
.sup-item .si-check input { width: 22px; height: 22px; accent-color: #2e9b57; cursor: pointer; margin: 0; }
.sup-item.received .si-name { color: #2e9b57; }
.sup-item.received .si-name::after { content: ' ✓'; font-weight: 700; }
#modal-supitem .select-like { width: 100%; margin-bottom: 10px; }
#modal-supitem .row { margin-bottom: 4px; }

/* ── Выпадающий фильтр статусов (вкл/выкл несколько) ── */
.sup-filter-bar { position: relative; padding: 0 14px 10px; }
.status-dd {
  width: 100%; text-align: left; padding: 11px 14px; border-radius: 12px;
  border: 1px solid #000; background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.status-menu {
  display: none; position: absolute; left: 14px; right: 14px; top: calc(100% - 4px); z-index: 15;
  background: var(--card); border: 1px solid #000; border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.status-menu.open { display: block; }
.status-opt {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px;
}
.status-opt:last-child { border-bottom: none; }
.status-opt:active { background: var(--bg); }
.status-opt .so-dot { width: 13px; height: 13px; border-radius: 50%; border: 1px solid #000; flex: 0 0 auto; }
.status-opt .so-label { flex: 1; color: var(--ink); }
.status-opt:not(.on) .so-label { color: var(--muted); }
.status-opt .so-check { color: var(--accent); font-weight: 800; width: 16px; text-align: center; }

/* ── Склад ── */
#stock-summary { display: block; padding: 10px 16px 0; font-size: 13px; color: var(--muted); }
.stock-filters { display: flex; align-items: center; gap: 12px; padding: 0 14px 8px; }
.stock-filters .mini-select { flex: 1; }
.crit-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); white-space: nowrap; }
.crit-toggle input { width: 18px; height: 18px; }
.stock-card {
  display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); cursor: pointer;
  border-left: 4px solid transparent;
}
.stock-card:active { background: #fafafa; }
.stock-card.crit { border-left-color: var(--accent); }
.stock-card .sc-main { flex: 1; min-width: 0; }
.stock-card .sc-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-card .sc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-card .sc-nums { text-align: right; flex: 0 0 auto; }
.stock-card .sc-qty { font-size: 16px; font-weight: 800; white-space: nowrap; }
.stock-card .sc-qty.crit { color: var(--accent); }
.stock-card .sc-sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.stock-card { align-items: flex-start; }
.stock-card .sc-metrics { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.stock-card .sc-metrics b { color: var(--ink); font-weight: 600; }
.stock-card .sc-metrics .sc-pdf { color: #2f80ed; font-weight: 600; cursor: pointer; }

/* ── Справочники ── */
.ref-tabs { display: flex; gap: 8px; padding: 8px 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
  white-space: nowrap; cursor: pointer; flex: 0 0 auto;
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#ref-form .ref-fl { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; font-weight: 600; }
/* Растягиваем на всю ширину только текстовые поля: у чекбокса свой размер ниже.
   Раньше это правило (в нём есть id — специфичность выше) перебивало
   «.ref-check input», и галочка раздувалась на всю строку. */
#ref-form .ref-fi:not([type="checkbox"]) { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }

/* ══════════════ Десктоп/широкий экран (≥900px): раскладка под ПК ══════════════ */
@media (min-width: 900px) {
  /* Постоянное боковое меню вместо «гамбургера» — только после входа (body.authed) */
  body.authed { padding-left: 240px; }
  .js-nav-open { display: none !important; }
  body.authed #nav-sheet.nav-overlay {
    display: block !important; position: fixed; left: 0; top: 0; bottom: 0;
    width: 240px; background: var(--card); border-right: 1px solid var(--line); z-index: 15;
  }
  #nav-sheet .nav-panel { position: static; width: 100%; height: 100%; box-shadow: none; animation: none; }
  .nav-item { font-size: 15px; }
  .nav-item:hover { background: var(--bg); }

  /* Верхняя панель и «полосы» инструментов ограничиваем по ширине */
  .topbar { padding-left: 22px; padding-right: 22px; }
  .searchbar, .summary, .sup-filter-bar, .stock-filters { max-width: 1280px; margin-left: auto; margin-right: auto; width: 100%; }
  .notes-card, .pos-filter { max-width: 1280px; margin-left: auto; margin-right: auto; width: calc(100% - 44px); }
  .fin-scroll > * { max-width: 1280px; margin-left: auto; margin-right: auto; }

  /* Списки-карточки → сетка в несколько колонок */
  #offers-list, #deals-list, #prod-list, #ship-list, #calib-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px; align-content: start; max-width: 1280px; margin: 0 auto; width: 100%; padding: 14px 22px 80px;
  }
  #offers-list > *, #deals-list > *, #prod-list > *, #ship-list > *,
  #calib-list > * { margin-bottom: 0 !important; }

  /* Построчно (один столбец на всю ширину): Спецификации, Склад, Снабжение */
  #spec-list, #stock-list, #sup-list {
    display: grid; grid-template-columns: 1fr; gap: 10px; align-content: start;
    max-width: 1280px; margin: 0 auto; width: 100%; padding: 14px 22px 80px;
  }
  #spec-list > *, #stock-list > *, #sup-list > * { margin-bottom: 0 !important; }

  /* Дашборд — больше колонок */
  .dash-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); max-width: 1280px; margin: 0 auto; }

  /* Финансы: суммы на ПК не такие «жирные» и крупные, как на телефоне */
  .fin-cards { max-width: 920px; margin-left: auto; margin-right: auto; }
  .fin-card .val { font-size: 19px; font-weight: 600; }
  .fin-card.hero .val { font-size: 25px; font-weight: 700; }
  .fin-op .fo-amt, .summary .card .num, .total strong { font-weight: 700; }

  /* Формы-редакторы по центру, не на всю ширину монитора */
  .form-scroll, .editor-footer { max-width: 780px; margin-left: auto; margin-right: auto; width: 100%; }

  /* Плавающая кнопка «+» — в правом нижнем углу окна */
  .fab { right: 32px; bottom: 32px; }

  /* Модалки и шторка — чуть шире */
  .modal { width: min(560px, 92%); }
  .sheet-overlay { align-items: center; }
  .sheet-panel { max-width: 720px; height: 80vh; border-radius: 18px; }

  /* Курсор-указатель на кликабельном */
  .offer-card, .stock-card, .sup-item, .dash-card, .nav-item, .list-row, .fq-btn { cursor: pointer; }
}

/* ── Отчёты: воронка, динамика, оговорки о неполноте данных ── */
.rep-caveat {
  background: #fff6e5; border: 1px solid #f0d9a8; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px; font-size: 12.5px; line-height: 1.45; color: #6b5726;
}
.rep-caveat b { color: #8a6a12; }
.rep-caveat ul { margin: 6px 0 0; padding-left: 18px; }
.rep-caveat li { margin-bottom: 4px; }
.rep-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.rep-legend span { display: flex; align-items: center; gap: 6px; }
.rep-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.rep-dot-o { background: #c9c9d1; }
.rep-dot-d { background: var(--accent); }
/* Полоса сделок — вторая, поверх шкалы КП, поэтому другого цвета и тоньше */
.fin-bar.rep-bar-d { margin-top: 4px; }
.fin-bar.rep-bar-d > i { background: #2a7a2a; }
.rep-stage .fc-top { align-items: baseline; }
.rep-stage .fc-hint { font-size: 11px; color: var(--muted); font-weight: 400; }

/* ── Остаток на складе у позиции спецификации ──
   Плюс — зелёный, минус — красный (в минус уводит резерв материалов под сделки),
   ноль и «позиции на складе нет» — нейтральный серый. */
.sup-item .si-stock { font-size: 12px; font-weight: 700; margin-top: 3px; }
.sup-item .si-stock.pos { color: #2e9b57; }
.sup-item .si-stock.neg { color: #c0392b; }
.sup-item .si-stock.zero { color: var(--muted); font-weight: 600; }

/* ── Комплект в сделке: «Комплектация: …», перенесённая из КП ──
   Оформление то же, что у комплекта в редакторе КП (.item-card .ic-kit),
   чтобы одна и та же сущность выглядела одинаково на обоих экранах. */
.sup-item.is-kit { border-left: 3px solid #5E35B1; padding-left: 9px; }
.sup-item .si-kit {
  margin-top: 6px; padding: 7px 9px; border-radius: 8px;
  background: #f3f0fa; color: #4527A0; font-size: 11.5px; line-height: 1.45;
  white-space: normal;
}

/* ── Редактирование комплектации в строке КП ── */
.kit-list { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; }
.kit-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kit-row:last-child { border-bottom: none; }
.kit-row .kr-main { flex: 1; min-width: 0; }
.kit-row .kr-name { font-size: 14px; font-weight: 600; }
.kit-row .kr-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kit-row .kr-qty { width: 66px; padding: 8px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); text-align: center; font-size: 14px; }
.kit-row .kr-del { border: none; background: none; font-size: 17px; cursor: pointer; padding: 4px; }
.kit-total { display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 12px; border-top: 1.5px solid var(--line); font-weight: 700; }
.kit-total strong { font-size: 19px; }
/* Строка комплекта в КП кликабельна — показываем это */
.item-card.is-kit .ic-kit { cursor: pointer; }
.item-card.is-kit .ic-kit:active { opacity: .65; }
.ic-kit-edit { display: block; margin-top: 5px; font-size: 11px; font-weight: 700; color: #5E35B1; }

/* ── КП в архиве (переведено в сделку) ── */
.arch-banner {
  background: #efe9fb; border: 1px solid #d3c4f0; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px; font-size: 12.5px; line-height: 1.45; color: #4a3a72;
}
.arch-banner b { color: #3d2a66; }
.offer-card.is-archived { opacity: .82; }
.offer-card.is-archived .oc-status { cursor: default; }
.oc-arch { font-size: 11.5px; font-weight: 700; color: #5E35B1; white-space: nowrap; }

/* Дата поставки на карточке сделки */
.oc-meta .dc-ship { font-size: 12px; font-weight: 700; color: #5E35B1; }

/* Галочка-флаг в карточке справочника (напр. «Требует поверки») */
.ref-check { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px;
  font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; }
/* Селектор с id — вровень по специфичности с «#ref-form .ref-fi», иначе размер
   чекбокса опять перебьётся правилом для текстовых полей. */
#ref-form .ref-check input.ref-fi {
  width: 22px; height: 22px; min-width: 22px; flex: 0 0 auto;
  margin: 0; padding: 0; border-radius: 4px; accent-color: var(--accent);
}
#ref-form .ref-check > span { flex: 1; text-align: left; }

/* Сколько дозаказать по складской позиции: крит. уровень минус остаток и «в пути».
   Красным — это призыв к действию, а не просто пометка «мало». */
.stock-card .sc-need {
  margin-top: 4px; font-size: 12px; font-weight: 800; color: #c0392b;
  white-space: nowrap; line-height: 1.2;
}

/* ── Журнал изменений ── */
.au-row { border-left: 4px solid var(--st, var(--line)); cursor: default; }
.au-row:active { background: var(--card); }
.au-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.au-act { font-size: 11px; font-weight: 800; color: #fff; padding: 2px 8px; border-radius: 20px; }
.au-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-ts { font-size: 12px; color: var(--muted); white-space: nowrap; }
.au-field { font-size: 12px; color: var(--muted); margin-top: 4px; }
.au-change { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 14px; flex-wrap: wrap; }
.au-change .au-old { color: var(--muted); text-decoration: line-through; }
.au-change .au-arrow { color: var(--muted); }
.au-change .au-new { font-weight: 800; color: var(--ink); }
.au-note { font-size: 12px; color: #6a6a72; font-style: italic; margin-top: 3px; }
