:root {
  --bg: #f5f6fa; --card: #fff; --ink: #161827; --txt: #2b2e40; --muted: #6b7088; --line: #e6e8f0; --line2: #d5d8e3;
  --accent: #6a45f5; --accent-soft: #efebff; --ok: #15803d; --ok-soft: #e7f7ec; --warn: #b45309; --warn-soft: #fdf3e2;
  --bad: #dc2626; --bad-soft: #fdecec; --info: #0369a1; --info-soft: #e5f4fc;
  --tg: #229ed9; --max: #6a3df5; --site: #64748b;
  --r: 12px; --side: 232px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 14px; color: var(--txt);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overflow-y: scroll; scrollbar-gutter: stable; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; color: var(--ink); letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- каркас ---------- */
.layout { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #c9cbe0; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.logo .crm-mark { display: block; flex: none; width: 32px; height: 32px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #c9cbe0; font-weight: 500; }
.nav a:hover { background: #ffffff10; color: #fff; }
.nav a.on { background: #ffffff18; color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.side .brandpick { margin-top: auto; }
.side label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8a8daa; padding: 0 12px; }
.side select { width: 100%; margin-top: 6px; background: #ffffff12; border: 1px solid #ffffff20; color: #fff; border-radius: 10px; padding: 9px 10px; }
.side select option { color: var(--ink); }
.side .me { font-size: 12px; padding: 12px 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side .me span:nth-child(2) { flex: 1; }
.side .meAva { display: block; flex: none; width: 28px; height: 28px; }
.side .me button { background: none; border: 0; color: #8a8daa; cursor: pointer; padding: 0; }
.main { padding: 24px 28px 60px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .grow { flex: 1; }

/* ---------- элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.input, select.input, textarea.input { height: 38px; border: 1px solid var(--line2); border-radius: 10px; padding: 0 12px; background: #fff; outline: none; min-width: 0; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; padding-right: 30px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236b7088' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--ink); color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #f0f1f6; color: var(--txt); }
.pill.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, currentColor); }
.st-new { background: var(--info-soft); color: var(--info); }
.st-confirmed { background: var(--accent-soft); color: var(--accent); }
.st-packed { background: var(--warn-soft); color: var(--warn); }
.tabs#st button { display: inline-flex; align-items: center; }
.stdot { width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; flex: none; background: var(--line2); }
.st-new-dot { background: var(--info); }
.st-confirmed-dot { background: var(--accent); }
.st-packed-dot { background: var(--warn); }
.st-shipped-dot { background: #c2410c; }
.st-delivered-dot { background: var(--ok); }
.st-cancelled-dot { background: var(--bad); }
.st-shipped { background: #fff1e6; color: #c2410c; }
.st-delivered { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: var(--bad-soft); color: var(--bad); }
.src-telegram { color: var(--tg); } .src-max { color: var(--max); } .src-site { color: var(--site); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 6px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: #fafaff; }

/* ---------- сводка ---------- */
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .val { font-size: 24px; font-weight: 700; color: var(--ink); margin: 6px 0 4px; letter-spacing: -.02em; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }
.chart-box { width: 100%; min-height: 180px; }
.chart { display: block; max-width: 100%; height: auto; }
.chart text { font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.funnel .row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 8px; }
.bar { height: 24px; background: #f0f1f6; border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; min-width: 2px; }
.list-rows .r { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.list-rows .r:last-child { border-bottom: 0; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: #7a4a06; margin-bottom: 14px; }
.alert.info { background: var(--info-soft); color: #0c4a6e; }

/* ---------- переписки ---------- */
.inbox { display: grid; grid-template-columns: 340px 1fr 280px; height: calc(100vh - 100px); min-height: 480px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.inbox.noaside { grid-template-columns: 340px 1fr; }
.conv-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.conv-list .filters { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.conv-list .items { overflow-y: auto; flex: 1; }
.conv { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv:hover { background: #fafaff; }
.conv.on { background: var(--accent-soft); }
.ava { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; position: relative; flex: none; }
.ava small { position: absolute; right: -2px; bottom: -2px; width: 15px; height: 15px; border-radius: 50%; border: 2px solid #fff; }
.conv .t { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .p { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .m { text-align: right; font-size: 11px; color: var(--muted); display: grid; gap: 4px; justify-items: end; }
.conv .m .badge { margin: 0; }
/* непрочитанные — как в Telegram: синий кружок со счётчиком, жирное имя и текст */
.unread-dot { background: #3390ec; color: #fff; border-radius: 99px; min-width: 22px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; line-height: 1; }
.conv.unread .t { font-weight: 800; }
.conv.unread .p { color: var(--ink); font-weight: 500; }
.conv.unread .m > span { color: #3390ec; font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .03em; }
/* строки товаров в формах заказа */
.irow { display: grid; grid-template-columns: 1fr 90px 60px 86px 34px; gap: 6px; margin-bottom: 6px; }
.irow .btn { padding: 0; }
@media (max-width: 560px) { .irow { grid-template-columns: 1fr 1fr 34px; } .irow [data-n] { grid-column: 1 / -1; } .irow [data-v] { grid-column: 1 / -1; } }
[hidden] { display: none !important; }
/* канбан */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kcol { flex: 1 0 132px; min-width: 0; background: #e9ecf1; border-radius: 12px; min-height: 140px; transition: box-shadow .12s; --c: var(--muted); --cs: #eceef2; }
.kcol[data-st="new"] { --c: #0b5f97; --cs: #e3f1fa; }
.kcol[data-st="assembling"] { --c: #4b46c9; --cs: #ecebfb; }
.kcol[data-st="marking"] { --c: #7a3fa8; --cs: #f3e9fb; }
.kcol[data-st="packed"] { --c: #8f4a06; --cs: #fcefd9; }
.kcol[data-st="shipped"] { --c: #a33a0b; --cs: #fde9dc; }
.kcol[data-st="at_pickup"] { --c: #0f6b6b; --cs: #dff3f2; }
.kcol[data-st="delivered"] { --c: #17693a; --cs: #e2f4e8; }
.kcol[data-st="cancelled"] { --c: #8a2b3c; --cs: #f8e4e8; background: #f4e9eb; }
.kcol[data-st="returned"] { --c: #a8201a; --cs: #fde6e4; background: #f7e8e6; }
.kcol.over { box-shadow: inset 0 0 0 2px var(--c); }
.kcol-h { border-radius: 12px 12px 0 0; padding: 8px 10px; border-top: 4px solid var(--c); background: var(--cs); color: var(--c); display: grid; gap: 2px; }
.kcol-h b { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
.kcol-h .kname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcol-h .ksum { font-size: 12px; font-weight: 600; white-space: nowrap; }
.kfold { border: 0; background: none; padding: 0; color: var(--c); font-size: 11px; font-weight: 600; text-decoration: underline; cursor: pointer; justify-self: start; }
.kcol-b { display: grid; gap: 8px; padding: 8px; max-height: calc(100vh - 300px); overflow-y: auto; }
.ksep { flex: 0 0 2px; align-self: stretch; background: var(--line2); border-radius: 2px; }
.kcol.folded { flex: 0 0 44px; }
.kcol.folded .kcol-b, .kcol.folded .ksum { display: none; }
.kcol.folded .kcol-h { border-radius: 12px; min-height: 140px; padding: 10px 0; cursor: pointer; justify-items: center; align-content: start; }
.kcol.folded .kcol-h b { writing-mode: vertical-rl; gap: 8px; justify-content: flex-start; }
.kcol.folded .kcol-h .kname { overflow: visible; }
.kcard { min-width: 0; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; box-shadow: 0 1px 2px rgba(20,20,40,.04); display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.kcard:hover { border-color: #c9c9e6; }
.kcard.dragging { opacity: .35; }
.kghost { position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; cursor: grabbing; box-shadow: 0 12px 30px rgba(20,20,40,.22); }
.kc-top { display: flex; gap: 2px 6px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; color: var(--ink); }
.kc-name { font-weight: 600; overflow: hidden; min-width: 0; flex: 1 1 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kc-top:has(.kc-name) { flex-wrap: nowrap; }
.kc-age { font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.kc-age.late { color: #a8201a; font-weight: 700; }
.kc-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; min-height: 20px; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600; background: #eceef2; color: #58606f; }
.tag.ok { background: #e2f4e8; color: #17693a; } .tag.acc { background: #ecebfb; color: #4b46c9; }
.tag.warn { background: #fcefd9; color: #8f4a06; } .tag.ret { background: #fde6e4; color: #a8201a; }
.kempty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 0; }
.kchips { display: none; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.kchips button { flex: none; height: 32px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--line2); background: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.kchips button.fin { color: #a8201a; border-color: #eec4c0; }
.retbox { display: grid; gap: 6px; justify-items: start; background: #fde6e4; color: #6d1410; border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; }
.retbox .muted { color: #7c3a36; }
.rrow { display: flex; gap: 8px; align-items: center; min-height: 34px; }
.st-assembling { background: #ecebfb; color: #4b46c9; } .st-assembling-dot { background: #4b46c9; }
.st-marking { background: #f3e9fb; color: #7a3fa8; } .st-marking-dot { background: #7a3fa8; }
.st-at_pickup { background: #dff3f2; color: #0f6b6b; } .st-at_pickup-dot { background: #0f6b6b; }
.st-returned { background: #fde6e4; color: #a8201a; } .st-returned-dot { background: #a8201a; }
/* телефон: колонки листаются по одной, сверху — быстрый переход к этапу */
@media (max-width: 900px) {
  .kanban { scroll-snap-type: x mandatory; }
  .kcol, .kcol.folded { flex: 0 0 88%; scroll-snap-align: start; }
  .kcol.folded .kcol-b { display: grid; } .kcol.folded .ksum { display: block; } .kcol.folded .kcol-h { min-height: 0; padding: 8px 10px; justify-items: stretch; cursor: default; border-radius: 12px 12px 0 0; } .kcol.folded .kcol-h b { writing-mode: horizontal-tb; justify-content: space-between; }
  .kcol-b { max-height: none; } .kfold, .ksep { display: none; } .kchips { display: flex; }
}
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.chat-head .grow { flex: 1; min-width: 0; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #f8f9fc; }
.msg { max-width: 72%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.msg-media { display: block; max-width: min(320px, 100%); max-height: 360px; border-radius: 10px; margin-bottom: 4px; }
.msg-media.sticker { width: 160px; height: auto; max-height: 160px; object-fit: contain; border-radius: 0; }
.msg.has-sticker { background: transparent !important; border-color: transparent !important; }
.msg-audio { display: block; width: 260px; max-width: 100%; margin-bottom: 4px; }
.msg-file { display: inline-block; margin-bottom: 4px; text-decoration: underline; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.in { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.out .meta { color: #e4ddff; }
.msg.note { background: #fff8db; border: 1px dashed #e7c84b; align-self: center; max-width: 85%; }
.msg.failed { background: var(--bad-soft); color: var(--bad); border: 1px solid #f5c2c2; }
.msg.failed .meta { color: var(--bad); }
.day { align-self: center; font-size: 11px; color: var(--muted); background: #eceef5; padding: 2px 10px; border-radius: 99px; margin: 6px 0; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.composer textarea { width: 100%; min-height: 44px; max-height: 180px; }
.composer .row { display: flex; gap: 8px; align-items: center; }
.composer .row .grow { flex: 1; }
.chat-aside { border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- модалки, тосты ---------- */
.overlay { position: fixed; inset: 0; background: #0f1020aa; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 24px); }
#toast div { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px #0003; }
#toast div.bad { background: var(--bad); }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #f0f1f6; padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
pre.code { display: block; padding: 12px; white-space: pre-wrap; margin: 8px 0; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); }
.login .logo { color: var(--ink); justify-content: center; font-size: 20px; padding-bottom: 20px; }

/* ---------- мобильная версия ---------- */
.mnav { display: none; }
@media (max-width: 1180px) {
  .inbox { grid-template-columns: 300px 1fr; }
  .chat-aside { display: none; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  /* телефон: меню — выезжающая левая колонка */
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 84vw); height: 100dvh; z-index: 70; transform: translateX(-102%); transition: transform .2s ease; overflow-y: auto; padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  body.menu-open .side { transform: none; box-shadow: 0 0 40px #0006; }
  .sback { position: fixed; inset: 0; background: #0f102080; z-index: 69; display: none; }
  body.menu-open .sback { display: block; }
  body.menu-open { overflow: hidden; }
  .main { padding: 0 12px 30px; }
  .mtop { display: flex !important; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--bg); padding: calc(8px + env(safe-area-inset-top)) 0 8px; margin-bottom: 8px; }
  .mburger { position: relative; width: 42px; height: 42px; flex: none; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-size: 20px; cursor: pointer; }
  .mburger .badge { position: absolute; top: -5px; right: -7px; margin: 0; font-size: 10px; padding: 0 5px; min-width: 16px; }
  .mtitle { flex: 1; min-width: 0; font-size: 17px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mtop select { width: 42%; max-width: 170px; height: 40px; }
  /* окна (заказ, покупатель) на телефоне — на весь экран, со своей прокруткой, ✕ всегда сверху */
  .overlay { padding: 0; place-items: stretch; overscroll-behavior: contain; }
  .modal { width: 100%; max-height: none; height: 100dvh; border-radius: 0; padding: 0 14px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .modal > .head:first-child, .modal > h2:first-child { position: sticky; top: 0; z-index: 3; background: #fff; margin: 0 -14px 10px !important; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--line); }
  body:has(.overlay) { overflow: hidden; }
  .kv { grid-template-columns: auto minmax(0, 1fr); }
  .kv dd { overflow-wrap: anywhere; }
  .ptable-wrap { border: 0; background: none; overflow: visible; }
  .ptable thead { display: none; }
  .ptable, .ptable tbody { display: block; }
  .ptable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; }
  .ptable td { padding: 0; border: 0; }
  .ptable td.pt-bc { grid-column: 1 / -1; grid-row: 2; }
  .ptable .price { width: 96px !important; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .mnav { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--ink); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .mnav a { color: #c9cbe0; display: grid; justify-items: center; gap: 2px; font-size: 9.5px; min-width: 0; overflow: hidden; white-space: nowrap; padding: 8px 0 7px; position: relative; }
  .mnav a.on { color: #fff; }
  .mnav svg { width: 20px; height: 20px; }
  .mnav .badge { position: absolute; top: 3px; left: 55%; font-size: 10px; padding: 0 5px; min-width: 16px; }
  .mbrand { display: block !important; }
  .inbox, .inbox.noaside { grid-template-columns: 1fr; height: calc(100vh - 150px); }
  .inbox.has-chat .conv-list { display: none; }
  .inbox:not(.has-chat) .chat { display: none; }
  .inbox.has-chat .chat { position: fixed; left: 0; right: 0; top: 0; bottom: 0; height: auto; z-index: 45; background: #fff; padding-bottom: env(safe-area-inset-bottom); }
  .inbox.has-chat .chat-head { padding: 8px 10px; }
  .inbox.has-chat .msgs { overscroll-behavior: contain; }
  body:has(.inbox.has-chat) { overflow: hidden; }
  body:has(.inbox.has-chat) .mnav { display: none; }
  .msg { max-width: 88%; }
  .input, select.input, textarea.input { font-size: 16px; }
  .funnel .row { grid-template-columns: 110px 1fr 70px; }
  .hide-m { display: none; }
  #toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
  .composer label { min-height: 40px; }
  .composer input[type=checkbox] { width: 20px; height: 20px; }
}
a[href^="tel:"] { white-space: nowrap; }
.mbrand, .mtop { display: none; }
.tick { letter-spacing: -2px; margin-left: 3px; font-weight: 700; }
.msg.out .tick.seen { color: #9ff0c2; }
.back-m { display: none; }
@media (max-width: 860px) { .back-m { display: inline-flex; } }

/* ---------- этап заказа в карточке ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.steps span { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: #eceef2; color: var(--muted); white-space: nowrap; }
.steps span.done { background: var(--ok-soft); color: var(--ok); }
.steps span.on { background: var(--accent); color: #fff; font-weight: 700; }
.stage { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 0 0 14px; background: #fafaff; display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.btn.big { height: 50px; font-size: 16px; font-weight: 600; width: 100%; }
.stage-more { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 10px; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.pick.done { background: var(--ok-soft); border-color: transparent; }
.pick .pq { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 700; }
.pick .pq button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line2); background: #fff; font-size: 18px; cursor: pointer; }
.pick .pq button:disabled { opacity: .35; cursor: default; }
/* ---------- канбан: выбор нескольких заказов ---------- */
.kcheck { display: inline-grid; place-items: center; width: 26px; height: 26px; margin: -4px 2px -4px -5px; vertical-align: middle; cursor: pointer; }
.kcheck input, .kbulk input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.kbulk { display: flex; align-items: center; gap: 6px; justify-content: space-between; flex-wrap: wrap; margin-top: 4px; font-size: 12px; font-weight: 600; }
.kbulk label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.kbulk .btn { height: 28px; padding: 0 8px; white-space: nowrap; }
/* ---------- сканер камерой на весь экран ---------- */
body.noscroll { overflow: hidden; }
.scan { position: fixed; inset: 0; z-index: 48; background: #000; color: #fff; display: flex; flex-direction: column; justify-content: space-between; }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-aim { position: absolute; left: 9%; top: 30%; width: 82%; height: 24%; border: 3px solid #ffffff90; border-radius: 18px; pointer-events: none; transition: left .12s, top .12s, width .12s, height .12s, border-color .15s; }
.scan-aim.seek { border-color: #facc15; border-radius: 10px; }
.scan-aim.sq { border-radius: 8px; }
.scan-aim.lock { border-color: #22c55e; box-shadow: 0 0 0 4px #22c55e55; border-radius: 10px; }
.scan.flash-ok .scan-aim { animation: scan-ok .6s; }
.scan.flash-bad .scan-aim { animation: scan-bad .6s; }
@keyframes scan-ok { 0%, 60% { border-color: #22c55e; box-shadow: 0 0 0 6px #22c55e66; } }
@keyframes scan-bad { 0%, 60% { border-color: #ef4444; box-shadow: 0 0 0 6px #ef444466; } }
.scan-top { position: relative; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
.scan-hint { font-size: 18px; font-weight: 700; line-height: 1.25; padding: 12px 14px; border-radius: 14px; background: #000000c4; overflow-wrap: anywhere; }
.scan-hint.ok { background: #15803d; }
.scan-hint.bad { background: #b91c1c; }
.scan-sub { font-size: 14px; margin-top: 6px; padding: 0 6px; text-shadow: 0 1px 3px #000, 0 0 8px #000; }
.scan-bot { position: relative; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: #000000c4; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.scan-list { max-height: 24vh; overflow-y: auto; display: grid; gap: 4px; font-size: 14px; }
.scan-list .sl { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 9px; background: #ffffff24; }
.scan-list .sl.done { background: #15803dcc; }
.scan-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sbtn { height: 52px; border-radius: 14px; border: 0; font: inherit; font-size: 15px; font-weight: 600; background: #ffffff30; color: #fff; cursor: pointer; padding: 0 10px; }
.sbtn.warn { background: #b45309; }
.sbtn.main { grid-column: 1 / -1; height: 62px; font-size: 18px; background: var(--accent); }
.sbtn:disabled { opacity: .45; cursor: default; }
.scan-page { position: absolute; inset: 0; z-index: 2; background: #f4f5f8; color: #14151f; display: flex; flex-direction: column; }
.scan-page[hidden] { display: none; }
.sp-body { flex: 1; overflow-y: auto; padding: calc(18px + env(safe-area-inset-top)) 14px 12px; }
.sp-foot { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.sp-foot .sbtn { background: #e6e8ee; color: #14151f; }
.sp-foot .sbtn.main { background: var(--accent); color: #fff; }
.sp-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.sp-q { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sp-q button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-size: 18px; cursor: pointer; }

/* Товарные остатки: группы → товары → фасовки */
.inv-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.inv-kpi { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font: inherit; color: var(--txt); }
.inv-kpi b { font-size: 20px; color: var(--ink); }
.inv-kpi span { font-size: 12px; color: var(--muted); }
button.inv-kpi { cursor: pointer; }
.inv-kpi.warn b { color: var(--warn); } .inv-kpi.bad b { color: var(--bad); }
.inv-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.inv-tools #invQ { flex: 1 1 240px; font-size: 16px; }
.inv-low { display: inline-flex; align-items: center; gap: 6px; }
.inv-low .input { width: 64px; height: 32px; text-align: center; font-size: 16px; }
.inv-group { margin-bottom: 18px; }
.inv-gh { font-size: 15px; margin: 0 0 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.inv-prod { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; overflow: hidden; }
.inv-prod.open { border-color: var(--line2); box-shadow: 0 2px 10px rgba(22, 24, 39, .05); }
.inv-ph { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: none; border: 0; cursor: pointer; font: inherit; color: var(--txt); text-align: left; }
.inv-ph:hover { background: #fafbfd; }
.inv-caret { color: var(--muted); transition: transform .15s; flex: none; }
.inv-prod.open .inv-caret { transform: rotate(90deg); }
.inv-pn { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.inv-pn b { overflow-wrap: anywhere; }
.inv-pq { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 50%; }
.pill.st-out { background: var(--bad-soft); color: var(--bad); } .pill.st-low { background: var(--warn-soft); color: var(--warn); }
.inv-rows { border-top: 1px solid var(--line); }
.inv-row { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 14px 10px 38px; border-top: 1px solid var(--line); border-left: 3px solid transparent; }
.inv-row:first-child { border-top: 0; }
.inv-row.s-out { background: #fff8f8; border-left-color: var(--bad); } .inv-row.s-low { background: #fffaf2; border-left-color: var(--warn); }
.inv-v { display: flex; flex-direction: column; }
.inv-bc { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 0; }
.inv-bc .pill { padding-right: 2px; }
.pill-x { border: 0; background: none; cursor: pointer; font-size: 13px; width: 22px; height: 22px; color: var(--muted); }
.pill-x:hover { color: var(--bad); }
.inv-q { display: flex; align-items: center; gap: 6px; }
.inv-q .qty { width: 84px; text-align: center; font-size: 16px; }
.inv-row.s-out .qty { color: var(--bad); font-weight: 700; }
@media (max-width: 700px) {
  .inv-kpis { grid-template-columns: 1fr 1fr; }
  .inv-ph { flex-wrap: wrap; } .inv-pq { max-width: none; width: 100%; justify-content: flex-start; padding-left: 22px; }
  .inv-row { grid-template-columns: minmax(0, 1fr) auto; padding-left: 14px; }
  .inv-bc { grid-column: 1 / -1; order: 3; }
}
.hl, tr.hl td { background: var(--accent-soft) !important; transition: background .3s; }
/* Карточка товара для сайта */
.pc-h { font-size: 15px; margin: 18px 0 8px; }
.pc-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }
.pc-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.pc-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.pc-ph { position: relative; border: 1px solid var(--line, #e5e7eb); border-radius: 10px; padding: 6px; background: #fff; display: grid; gap: 6px; }
.pc-ph img { width: 100%; height: 110px; object-fit: contain; }
.pc-n { position: absolute; top: 4px; left: 4px; background: #111827; color: #fff; font-size: 12px; font-weight: 700; border-radius: 99px; min-width: 22px; height: 22px; display: grid; place-items: center; }
.pc-act { display: flex; justify-content: space-between; gap: 4px; }
.pc-act .btn { min-width: 32px; min-height: 30px; justify-content: center; }
.pc-extra { border: 1px solid var(--line, #e5e7eb); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.pc-extra summary { cursor: pointer; font-weight: 600; }
.pc-extra summary::marker { color: var(--accent); }
/* Полная форма создания товара */
.np-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; align-items: start; }
.np-upload { min-height: 174px; border: 2px dashed var(--line, #d8dbe3); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px; text-align: center; cursor: pointer; background: var(--soft, #f8f9fb); transition: .15s; }
.np-upload:hover, .np-upload.drag { border-color: var(--accent); background: var(--accent-soft); }
.np-upload.has-photos { min-height: 72px; }
.np-upload-icon { font-size: 28px; }
.np-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.np-thumb { position: relative; aspect-ratio: 1; border: 1px solid var(--line, #e5e7eb); border-radius: 8px; overflow: hidden; background: #fff; }
.np-thumb img { width: 100%; height: 100%; object-fit: contain; }
.np-thumb span { position: absolute; left: 3px; top: 3px; min-width: 18px; height: 18px; border-radius: 99px; background: #111827; color: #fff; font-size: 10px; display: grid; place-items: center; }
.np-thumb button { position: absolute; right: 2px; top: 2px; width: 24px; height: 24px; border: 0; border-radius: 99px; background: rgba(185,28,28,.9); color: #fff; cursor: pointer; }
.np-price { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(100px, .55fr) minmax(130px, .8fr); gap: 10px; }
.np-count { float: right; color: var(--muted); font-weight: 400; font-size: 12px; }
.np-actions { position: sticky; bottom: -16px; z-index: 2; margin: 16px -16px -16px; padding: 12px 16px 16px; background: var(--card, #fff); border-top: 1px solid var(--line, #e5e7eb); box-shadow: 0 -8px 18px rgba(20,20,40,.06); }
.np-actions .btn.primary:disabled { opacity: 1; color: var(--muted); background: var(--line); border-color: var(--line); }
@media (max-width: 600px) {
  .np-grid { grid-template-columns: 1fr; } .np-upload { min-height: 120px; }
  .np-price { grid-template-columns: minmax(0, 1fr) 110px; } .np-price .field:last-child { grid-column: 1 / -1; }
  .np-actions { display: grid !important; grid-template-columns: 1fr 1fr; margin: 16px -14px -14px; padding: 10px 14px 14px; }
  .np-actions #npNeed { grid-column: 1 / -1; text-align: center; }
  .np-actions .btn { width: 100%; }
}
.pc-act .btn:disabled { opacity: .35; cursor: default; }

a[href^="tel:"] { white-space: nowrap; }

/* заметная кнопка закрытия окна */
.xbtn { flex: none; height: 38px; padding: 0 14px; border: 0; border-radius: 99px; background: #1f2033; color: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.xbtn:active { transform: scale(.96); }
  
@media (max-width: 860px) { body.kb .inbox.has-chat .chat { top: var(--vvt, 0px); bottom: auto; height: var(--vvh, 100dvh); } }

/* Движение покупателей */
.flow-g { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.flow-col h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink); }
.flow-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.flow-t { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.flow-t .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.flow-t .val { font-size: 22px; font-weight: 700; color: var(--ink); margin: 4px 0 2px; }
.flow-t.up .val { color: var(--ok); } .flow-t.down .val { color: #b91c1c; }
.flow-t .val .delta { font-size: 22px; }
.flow-lost { margin-top: 10px; } .flow-lost summary { cursor: pointer; font-weight: 600; color: var(--accent); }
@media (max-width: 900px) { .flow-g { grid-template-columns: 1fr; } }
/* Задачи */
.late { color: #b91c1c; font-weight: 600; }
.pill.tst-new { background: #eef2ff; color: #3730a3; } .pill.tst-in_progress { background: var(--warn-soft); color: #7a4a06; } .pill.tst-done { background: var(--ok-soft); color: var(--ok); }
.modal.task-modal { width: min(1100px, 96vw); max-width: none; }
.task-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.task-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.task-desc { background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-wrap: anywhere; max-height: 300px; overflow: auto; }
.task-meta { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; margin: 14px 0; font-size: 14px; }
.task-meta dt { color: var(--muted); } .task-meta dd { margin: 0; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.task-chat { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; min-height: 420px; max-height: 70vh; background: #f7f8fc; }
.tc-head { padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; background: #fff; border-radius: 10px 10px 0 0; }
.tc-feed { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.tf-sys { align-self: center; text-align: center; font-size: 12px; color: var(--muted); background: #eceef5; border-radius: 99px; padding: 3px 10px; max-width: 95%; }
.tf-msg { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; max-width: 88%; overflow-wrap: anywhere; }
.tf-msg.me { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.tf-msg.result { border: 2px solid var(--ok); background: var(--ok-soft); }
.tf-res { font-size: 12px; font-weight: 700; color: var(--ok); margin-bottom: 4px; }
.tf-who { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.tc-form { border-top: 1px solid var(--line); padding: 10px; background: #fff; border-radius: 0 0 10px 10px; }
.tc-form textarea { width: 100%; height: auto; padding: 8px 10px; resize: vertical; font-size: 16px; }
.tc-bar { display: flex; gap: 8px; align-items: center; margin-top: 6px; } .tc-bar label { display: flex; gap: 6px; align-items: center; }
@media (max-width: 860px) { .task-grid { grid-template-columns: 1fr; } .task-chat { max-height: none; min-height: 360px; } .task-meta { grid-template-columns: 110px 1fr; } table.tasks th:nth-child(4), table.tasks td:nth-child(4) { display: none; } }

/* Сегменты */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; background: #fff; }
.seg button { border: 0; background: none; height: 34px; padding: 0 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.sm button { height: 28px; padding: 0 9px; font-size: 13px; }
.modal.narrow { width: min(440px, 100%); }
.btn.warn { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn.sm.danger, .btn.danger-solid { background: #ef4444; border-color: #ef4444; color: #fff; }
.st-ok { color: var(--ok); } .st-bad { color: var(--bad); } .st-warn { color: var(--warn); }
/* Оплата */
.modal.pay-modal { padding: 0; width: min(520px, 100%); overflow: hidden auto; }
.pay-top { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; padding: 16px 20px 0; }
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; margin-bottom: 10px; }
.xbtn.light { background: rgba(255,255,255,.2); height: 32px; }
.muted-l { color: rgba(255,255,255,.8); }
.pay-sum { font-size: 34px; font-weight: 800; line-height: 1.2; margin: 2px 0; }
.pay-tabs { display: flex; gap: 4px; margin-top: 14px; }
.pay-tabs button { flex: 1; border: 0; background: rgba(255,255,255,.15); color: #fff; font: inherit; font-weight: 700; padding: 10px; border-radius: 10px 10px 0 0; cursor: pointer; }
.pay-tabs button.on { background: #fff; color: #1d4ed8; }
.pay-body { padding: 16px 20px 20px; display: grid; gap: 10px; }
.pay-it { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.pay-it.refund { background: #fff8f8; }
.pay-it-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; } .pay-it-h b { font-size: 18px; }
.pay-kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; margin: 0; font-size: 14px; } .pay-kv dt { color: var(--muted); } .pay-kv dd { margin: 0; }
.pay-kv.box { background: #f7f8fc; border-radius: 10px; padding: 12px; }
@media (max-width: 760px) { .modal.pay-modal { padding: 0; } .pay-top { padding-top: calc(12px + env(safe-area-inset-top)); } }
/* Диск */
.disk { position: relative; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; font-weight: 600; } .crumbs a { cursor: pointer; color: var(--accent); } .crumbs span { color: var(--muted); }
.disk-t td { vertical-align: middle; } .disk-t .fi { margin-right: 8px; font-size: 18px; }
.disk-t .fname { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; } .disk-t .btn.sm { margin-left: 4px; }
.table-wrap.flat { border: 0; box-shadow: none; }
.disk-drop { display: none; position: absolute; inset: 0; border: 3px dashed var(--accent); border-radius: 14px; background: rgba(106,69,245,.08); align-items: center; justify-content: center; font-weight: 700; color: var(--accent); font-size: 18px; }
.disk.drag .disk-drop { display: flex; }
/* Карточка покупателя */
.cu-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 14px; align-items: start; }
.cu-left { display: grid; gap: 14px; }
.cu-hero { display: flex; gap: 14px; align-items: center; }
.cu-ava { flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.cu-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pill.cu-disc { background: #fee2e2; color: #b91c1c; }
.cu-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cu-kpi > div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; } .cu-kpi b { display: block; font-size: 16px; margin-top: 2px; overflow-wrap: anywhere; }
.label { font-size: 12px; color: var(--muted); font-weight: 600; }
.cu-lt { display: grid; grid-template-columns: 1fr auto; gap: 14px; }
.cu-disc-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; } .cu-disc-row .input { width: 70px; }
.cu-bonus { background: linear-gradient(135deg, #fef3c7, #fde68a); border-radius: 12px; padding: 10px 14px; min-width: 120px; } .cu-bonus b { font-size: 26px; display: block; }
.cu-right { display: flex; flex-direction: column; min-height: 560px; padding: 0; overflow: hidden; }
.cu-tabs { margin: 12px; align-self: flex-start; }
.cu-body { flex: 1; display: flex; flex-direction: column; padding: 0 14px 14px; min-height: 0; }
.cu-feed { background: #f7f8fc; border: 1px solid var(--line); border-radius: 10px 10px 0 0; max-height: 62vh; min-height: 380px; }
.cu-body .tc-form { border: 1px solid var(--line); border-top: 0; }
@media (max-width: 1000px) { .cu-grid { grid-template-columns: 1fr; } .cu-right { min-height: 0; } .cu-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .cu-lt { grid-template-columns: 1fr; } .cu-tabs { overflow-x: auto; flex-wrap: nowrap; max-width: calc(100% - 24px); } .cu-tabs button { white-space: nowrap; } }

.disk-t .dm { display: none; }
@media (max-width: 760px) { .disk-t .dm { display: block; } .disk-t td:last-child { white-space: nowrap; } .disk-t .btn.sm { margin-left: 2px; padding: 0 8px; } .disk-t .fname { display: inline; } }

@media (min-width: 861px) { .sback { display: none !important; } }

/* История заказа (как в Битриксе) */
.oh-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0 8px; }
.oh-t { font-size: 13px; } .oh-t td { vertical-align: top; } .oh-t td:last-child { overflow-wrap: anywhere; } .oh-t a { cursor: pointer; color: var(--accent); }
.oh-t tr.oh-view td { color: var(--muted); }
.oh-k { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef0f6; color: #475069; }
.oh-st { background: #e0e7ff; color: #3730a3; } .oh-pay { background: #dcfce7; color: #166534; } .oh-ref { background: #fee2e2; color: #b91c1c; }
.oh-ed { background: #fef3c7; color: #92400e; } .oh-task { background: #ede9fe; color: #5b21b6; } .oh-view { background: #f3f4f6; color: #6b7280; }
@media (max-width: 760px) {
  .oh-t thead { display: none; } .oh-t tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .oh-t td { padding: 0; border: 0; } .oh-t td:nth-child(1) { grid-column: 1; } .oh-t td:nth-child(2) { grid-column: 2; font-weight: 600; }
  .oh-t td:nth-child(3), .oh-t td:nth-child(4) { grid-column: 1 / -1; }
}

.cu-bline { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.link-a { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* задачи: быстрые шаблоны/сроки и блок задач в заказе (как в amoCRM/Битрикс24) */
.tk-chips{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}
.chip{border:1px solid var(--line,#ddd);background:transparent;border-radius:999px;padding:4px 10px;font:inherit;font-size:13px;cursor:pointer;color:inherit}
.chip:hover{border-color:#7c5cff}.chip.on{background:#7c5cff;border-color:#7c5cff;color:#fff}
.tk-order{background:#efeaff;color:#5b3fd6;margin-left:8px}
.rec-box{border:1px solid var(--line);background:#fafbfd;border-radius:10px;padding:12px;margin:-2px 0 12px}
.rec-days{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.rec-days label{cursor:pointer}.rec-days input{position:absolute;opacity:0;pointer-events:none}
.rec-days span{display:grid;place-items:center;min-width:38px;height:34px;padding:0 8px;border:1px solid var(--line);border-radius:9px;background:#fff;font-size:13px;font-weight:600}
.rec-days input:checked+span{background:var(--accent);border-color:var(--accent);color:#fff}.rec-days.month span{min-width:34px;padding:0 5px}
.rec-pill{background:#e8f5ff;color:#17658a;white-space:nowrap}
.otasks{border:1px solid var(--line,#e5e5e5);border-radius:10px;padding:10px 12px;margin:0 0 14px}
.otasks-h{display:flex;align-items:center;gap:8px;margin-bottom:6px}
.otask{display:flex;align-items:center;gap:10px;padding:6px 0;border-top:1px solid var(--line,#eee);flex-wrap:wrap}
.otask:first-of-type{border-top:0}.otask a{cursor:pointer;flex:1;min-width:140px}
.otask.done a{text-decoration:line-through;opacity:.6}.otask.late .small{color:#d33}
.ock{width:20px;height:20px;border-radius:50%;border:2px solid #b9b9c6;background:none;cursor:pointer;font-size:12px;line-height:1;color:#fff;flex:none;padding:0}
.ock:hover:not(:disabled){border-color:#2aa760;background:#e8f7ee}.otask.done .ock{background:#2aa760;border-color:#2aa760}

/* ======================================================================
   Удобство как в amoCRM / Битрикс24: группы меню, поиск, «+ Создать»,
   карточка заказа в две колонки, воронка этапов стрелками, быстрые фильтры
   ====================================================================== */
/* меню по группам */
.side .nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: #ffffff30 transparent; }
.nav-g { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #9a9db8; padding: 12px 12px 4px; }
.nav-g:first-child { padding-top: 0; }
.nav a { padding: 8px 12px; position: relative; }
.nav a.on { background: #ffffff1c; box-shadow: inset 3px 0 0 #a28bff; }
.side .brandpick { padding-top: 10px; }

/* верхняя панель: поиск и «Создать» */
.topbar { display: flex; align-items: center; gap: 12px; margin: -8px 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.topbar .grow { flex: 1; }
.topbar .btn svg { width: 16px; height: 16px; }
.gsearch { display: flex; align-items: center; gap: 10px; width: min(520px, 100%); height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; color: var(--muted); cursor: text; font-size: 14px; text-align: left; }
.gsearch:hover { border-color: var(--muted); }
.gsearch svg { width: 18px; height: 18px; flex: none; }
.gsearch span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd { font: 600 11px/1 ui-monospace, Consolas, monospace; color: var(--muted); background: #f0f1f6; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; padding: 4px 6px; white-space: nowrap; }
.qmenu { position: fixed; z-index: 80; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 34px rgba(20, 22, 40, .18); padding: 6px; min-width: 220px; display: grid; }
.qmenu button { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border: 0; background: none; border-radius: 8px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-align: left; }
.qmenu button:hover { background: var(--accent-soft); }
.qmenu button span { width: 22px; text-align: center; }
.mico { display: none; }

/* окно поиска */
.overlay.gs-overlay { place-items: start center; padding-top: 10vh; }
.modal.gs-modal { width: min(680px, 100%); padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: 76vh; }
.gs-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.gs-top > svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.gs-in { flex: 1; min-width: 0; border: 0; outline: none; font-size: 17px; height: 40px; background: none; color: var(--ink); }
.gs-top .xbtn { height: 34px; padding: 0 12px; }
.gs-r { overflow-y: auto; padding: 6px 8px 10px; }
.gs-hint { padding: 12px 10px; margin: 0; }
.gs-g { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.gs-it { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--txt); min-height: 44px; }
.gs-it:hover, .gs-it.on { background: var(--accent-soft); }
.gs-ic { width: 24px; text-align: center; flex: none; }
.gs-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-main b { color: var(--ink); }

/* заказы: быстрые фильтры и подсказка */
.ofilters { margin-bottom: 12px; }
.qf { display: flex; gap: 6px; flex-wrap: wrap; }
.qf button { height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line2); background: #fff; font: inherit; font-size: 13px; font-weight: 600; color: var(--txt); cursor: pointer; white-space: nowrap; }
.qf button b { color: var(--muted); font-weight: 700; margin-left: 2px; }
.qf button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.qf button.on b { color: #c9cbe0; }
.khelp { position: relative; }
.khelp summary { list-style: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line2); background: #fff; display: grid; place-items: center; font-weight: 700; color: var(--muted); cursor: pointer; }
.khelp summary::-webkit-details-marker { display: none; }
.khelp[open] summary { background: var(--ink); color: #fff; border-color: var(--ink); }
.khelp > div { position: absolute; z-index: 20; top: 36px; left: 0; width: min(360px, 80vw); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 22, 40, .15); padding: 12px 14px; font-size: 13px; line-height: 1.45; }
.kcol-b { max-height: calc(100vh - 330px); }

/* карточка заказа: шапка, стрелки этапов, две колонки */
.modal.order-modal { width: min(1200px, 96vw); padding: 20px 22px; }
.oc-head { margin-bottom: 4px !important; gap: 8px; }
.oc-total { font-size: 20px; color: var(--ink); white-space: nowrap; margin-right: 4px; }
.chev { display: flex; margin: 0 0 16px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chev::-webkit-scrollbar { display: none; }
.chev > * { --c: #5b6275; --cs: #eceef2; flex: 1 0 auto; height: 34px; display: flex; align-items: center; justify-content: center; padding: 0 14px 0 22px; margin-right: -6px; border: 0; font: inherit; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eceef2; color: #5b6275; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); }
.chev > :first-child { padding-left: 14px; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
.chev [data-st="new"] { --c: #0b5f97; --cs: #e3f1fa; } .chev [data-st="assembling"] { --c: #4b46c9; --cs: #ecebfb; }
.chev [data-st="marking"] { --c: #7a3fa8; --cs: #f3e9fb; } .chev [data-st="packed"] { --c: #8f4a06; --cs: #fcefd9; }
.chev [data-st="shipped"] { --c: #a33a0b; --cs: #fde9dc; } .chev [data-st="at_pickup"] { --c: #0f6b6b; --cs: #dff3f2; }
.chev [data-st="delivered"] { --c: #17693a; --cs: #e2f4e8; } .chev [data-st="cancelled"] { --c: #8a2b3c; --cs: #f8e4e8; } .chev [data-st="returned"] { --c: #a8201a; --cs: #fde6e4; }
.chev .done { background: var(--cs); color: var(--c); }
.chev .on { background: var(--c); color: #fff; font-weight: 700; }
.chev .can { cursor: pointer; background: #fff; color: var(--c); box-shadow: inset 0 0 0 2px var(--cs); }
.chev .can.done { background: var(--cs); }
.chev .can:hover { filter: brightness(.95); text-decoration: underline; text-underline-offset: 2px; }
.oc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.oc-left { display: grid; gap: 12px; min-width: 0; }
.oc-left > div:empty { display: none; }
.oc-left .stage { margin: 0; }
.oc-left .retbox { margin: 0; }
.oc-sec { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; min-width: 0; }
.oc-sec h3 { font-size: 13px; margin: 0 0 10px; color: var(--ink); text-transform: uppercase; letter-spacing: .04em; }
.oc-sec textarea { width: 100%; }
.oc-paid { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; cursor: pointer; }
.oc-paid input { width: 18px; height: 18px; margin: 0; }
.oc-right { position: sticky; top: 0; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: #fafbfd; padding: 10px 12px 12px; }
.oc-tabs { margin-bottom: 10px; }
.oc-tabs .badge { margin-left: 4px; font-size: 10px; padding: 0 6px; min-width: 18px; }
.oc-tabs button.on .badge { background: #fff; color: var(--accent); }
.oc-pane { min-width: 0; }
.oc-pane .oh-head { margin: 0 0 8px; }
.oc-pane .table-wrap { max-height: calc(100vh - 290px); overflow: auto; background: #fff; }
.oc-pane .otasks { margin: 0; background: #fff; }
.oc-chat { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; height: calc(100vh - 300px); min-height: 340px; }
.oc-chat .msgs { padding: 12px; }
.oc-chat .msg { max-width: 85%; font-size: 13px; }

/* сводка: «Требует внимания» */
.todo-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.todo { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: #fff; border: 1px solid var(--line); color: var(--txt); min-height: 64px; }
.todo b { font-size: 18px; color: var(--ink); }
.todo .muted { display: block; }
.todo-ic { width: 38px; height: 38px; border-radius: 10px; background: #f0f1f6; display: grid; place-items: center; font-size: 18px; flex: none; }
.todo-go { margin-left: auto; font-size: 22px; color: var(--muted); }
.todo.hot { border-color: #d8cdfd; background: #faf8ff; }
.todo.hot .todo-ic { background: var(--accent-soft); }
.todo.hot:hover { border-color: var(--accent); }
.todo.ok .todo-ic { background: var(--ok-soft); color: var(--ok); font-weight: 800; }
a.kpi-link { color: inherit; display: block; }
a.kpi-link:hover { border-color: var(--accent); }

/* переписки: значок канала на аватарке */
.ava small { display: grid; place-items: center; width: 17px; height: 17px; }
.ava small svg { width: 10px; height: 10px; }

/* переписки на компьютере — под верхней панелью */
@media (min-width: 861px) { .inbox { height: calc(100vh - 156px); } }

@media (max-width: 1100px) {
  .oc-grid { grid-template-columns: 1fr; }
  .oc-right { position: static; }
  .oc-pane .table-wrap { max-height: none; }
  .oc-chat { height: 60vh; }
}
@media (max-width: 860px) {
  .topbar { display: none; }
  .mico { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 10px; border: 1px solid var(--line2); background: #fff; color: var(--ink); cursor: pointer; padding: 0; }
  .mico svg { width: 20px; height: 20px; }
  .mico.acc { background: var(--accent); border-color: var(--accent); color: #fff; }
  .mtop select { width: auto; max-width: 132px; flex: none; }
  .modal.order-modal { width: 100%; padding: 0 14px calc(18px + env(safe-area-inset-bottom)); }
  .oc-total { font-size: 16px; }
  .oc-head h2 { font-size: 16px; }
  .chev > * { height: 32px; font-size: 12px; flex: 0 0 auto; }
  .overlay.gs-overlay { padding-top: 0; place-items: stretch; }
  .modal.gs-modal { max-height: none; height: 100dvh; border-radius: 0; padding: 0; }
  .modal.gs-modal > .gs-top:first-child { padding-top: calc(10px + env(safe-area-inset-top)); }
  .gs-in { font-size: 17px; }
  .gs-it { flex-wrap: wrap; }
  .gs-it > .nowrap, .gs-it > .muted { margin-left: 34px; }
  .khelp > div { left: auto; right: -60px; }
  .qf { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .ofilters { gap: 8px; }
  .todo-row { grid-template-columns: 1fr; }
}
@media (max-width: 380px) { .mtop select { display: none; } }
/* имя покупателя на карточке не рвём посреди слова: если не влезает рядом со сроком, срок уходит на следующую строку */
.kc-top:has(.kc-name) { flex-wrap: wrap; }
.kc-name { flex: 1 1 auto; overflow-wrap: break-word; }
.oc-chat .msgs > :first-child { margin-top: auto; }
/* на телефоне полоса этапов прокручивается — затухание справа подсказывает, что там ещё этапы */
@media (max-width: 860px) { .chev { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 24px; } }

/* ---------- промоутеры и кабинет партнёра ---------- */
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover, th.sortable.on { color: var(--ink); }
.pr-table td { vertical-align: top; }
.pr-cmp .row { grid-template-columns: 160px 1fr 120px; }
.pr-cmp .bar { position: relative; }
.pr-cmp .bar > i { position: absolute; left: 0; top: 0; }
.pr-cmp .bar > i.pr-cut { background: #f59e0b; top: 6px; height: 12px; border-radius: 4px; }
.pr-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.pr-box .label { font-weight: 700; color: var(--ink); margin-bottom: 8px; font-size: 13px; }
.pr-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.pr-num { width: 68px; text-align: center; padding: 0 6px; }
.pr-code { font-size: 16px; }
.pr-msg { white-space: pre-wrap; background: #fff; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; color: var(--ink); }
.pr-fc-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.pr-fc-top .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.pr-big { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; margin: 4px 0 2px; }
.pr-slider { display: grid; gap: 4px; min-width: min(320px, 100%); }
.pr-slider input { width: 100%; accent-color: var(--accent); }
.cu-prom { border: 1px dashed var(--line2); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.cu-prom .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.pr-pill { background: #fff4e0; color: #9a5b00; }
.pt-top { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.pt-top .logo { color: var(--ink); padding: 0; }
.pt-wrap { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }
.pt-code { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.pt-code b.mono { font-size: 26px; color: var(--accent); }
@media (max-width: 700px) {
  .pr-cmp .row { grid-template-columns: 90px 1fr 90px; }
  .pt-wrap { padding: 14px 12px 40px; } .pt-top { padding: 10px 12px; }
  .pr-big { font-size: 22px; }
}

/* промоутеры: лидеры/отстающие, выплаты */
.pr-lead { color: inherit; text-decoration: none; align-items: flex-start; }
.pr-lead:hover b { color: var(--accent); }
.pr-medal { font-size: 22px; line-height: 1; }
.pr-why { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.pr-why .pill { white-space: normal; height: auto; min-height: 22px; }
.pill.pr-warn { background: #fff1e6; color: #b45309; }
.pr-bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pr-bulk select { width: auto; max-width: 100%; }
.pr-opts { display: grid; gap: 6px; }
.pr-opt { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.pr-opt > span { flex: 1; }
.pr-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
#prtabs { margin-left: 8px; }
@media (max-width: 760px) { #prtabs { margin-left: 0; width: 100%; overflow-x: auto; } }

/* доходы и расходы (P&L) */
#pltabs { margin-left: 8px; }
.pl-month { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.pl-month b { font-size: 18px; }
.pl-month b::first-letter { text-transform: uppercase; }
.pl-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.pl-table td { vertical-align: top; }
.pl-table .pl-h td { font-weight: 700; padding-top: 14px; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .03em; }
.pl-table .pl-sub td:first-child { padding-left: 22px; }
.pl-table .pl-total td { font-weight: 700; border-top: 1px solid var(--line); }
.pl-table .pl-profit td { font-weight: 800; font-size: 16px; border-top: 2px solid var(--txt); color: var(--ok); }
.pl-table .pl-profit.neg td { color: var(--bad); }
.pl-col:hover rect:first-child { fill: rgba(124, 92, 255, .06); }
.ex-form { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0 10px; }
.ex-form .ex-note { grid-column: 1 / -1; }
#excs { max-width: 100%; }
@media (max-width: 900px) { .pl-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { #pltabs { margin-left: 0; width: 100%; } .ex-form { grid-template-columns: 1fr 1fr; } .ex-form label:first-child { grid-column: 1 / -1; } }
/* ---------- движение товаров: приход · расход · история ---------- */
.show-m { display: none; }
.st-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.st-period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.st-dates { display: inline-flex; align-items: center; gap: 6px; }
.st-dates .input { width: auto; }
.st-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-kinds { margin-bottom: 12px; }
.st-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.st-filters #shq { flex: 1; min-width: 220px; }
.st-filters #shk { width: auto; min-width: 180px; }
.st-sum { margin: 0 0 8px; }
.st-table td { vertical-align: top; }
.st-table tr.st-void td { opacity: .55; }
.pill.st-in { background: var(--ok-soft); color: var(--ok); }
.pill.st-out { background: var(--bad-soft); color: var(--bad); }
.st-more { text-align: center; margin: 12px 0; }
.st-meta .r { gap: 12px; }
.st-meta .r > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.st-pick { display: flex; gap: 6px; }
.st-pick .input { flex: 1; }
.st-res { border: 1px solid var(--line); border-radius: 10px; margin-top: 4px; max-height: 260px; overflow-y: auto; background: #fff; }
.st-ri { display: flex; width: 100%; justify-content: space-between; gap: 10px; align-items: center; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 9px 10px; font: inherit; cursor: pointer; color: var(--txt); }
.st-ri:last-child { border-bottom: 0; }
.st-ri:hover, .st-ri.on { background: #f5f5ff; }
.st-lines { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.st-line { display: grid; grid-template-columns: minmax(0, 1fr) 110px 130px 34px; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.st-line:last-child { border-bottom: 0; }
.st-line.flash { animation: stflash 1s ease-out; }
@keyframes stflash { from { background: var(--accent-soft); } to { background: transparent; } }
.st-lq, .st-lc { display: flex; align-items: center; gap: 4px; }
.st-lq .input, .st-lc .input { width: 100%; min-width: 0; padding: 0 8px; }
.st-total { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
@media (max-width: 860px) {
  .show-m { display: block; }
  .st-kpis { grid-template-columns: 1fr 1fr; }
  .st-filters #shq { min-width: 0; flex-basis: 100%; }
  .st-table th, .st-table td { padding: 9px 8px; }
  .st-line { grid-template-columns: minmax(0, 1fr) 96px 34px; }
  .st-line .st-ln { grid-column: 1 / -1; }
  .st-line .st-lc { grid-column: 1 / 3; }
  .st-line:not(:has(.st-lc)) .st-lq { grid-column: 1 / 3; }
}

/* ---------- Заказ поставщику ---------- */
.sp-empty { max-width: 640px; }
.sp-params { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 8px; }
.sp-params label { display: grid; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.sp-params .input { width: 130px; }
.sp-how { margin: 0 0 12px; }
.sp-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sp-tools #spq { width: 300px; max-width: 100%; }
.sp-blank { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-table td { padding: 8px 12px; }
.sp-table th { padding: 8px 12px; vertical-align: bottom; }
.sp-table .sp-name { min-width: 260px; }
.sp-table .sp-name > div:first-child { font-weight: 600; line-height: 1.3; }
.sp-table tr.sp-g td { background: #fafbfd; font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 12px; }
.sp-table tr.sp-on td { background: #f3fbf5; }
.sp-table tr.sp-on td.sp-name { box-shadow: inset 3px 0 0 #22a35a; }
.sp-nocrm { color: #a16207; }
.sp-low { color: #c0392b; font-weight: 700; }
.sp-qcell { white-space: nowrap; }
.sp-q { width: 84px; text-align: right; height: 34px; }
.sp-undo { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; width: 26px; height: 26px; margin-left: 2px; border-radius: 6px; }
.sp-undo:hover { background: #f0f1f6; color: var(--ink); }
.sp-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; justify-content: flex-end; margin-top: 12px; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 -6px 18px rgba(20, 24, 40, .06); }
.sp-sum { display: grid; text-align: right; gap: 2px; }
.sp-sum b { font-size: 18px; }
.sp-bar .btn { height: 44px; padding: 0 20px; }
.sp-conf { max-height: 46vh; overflow: auto; border-top: 1px solid var(--line); }
.sp-conf .r, .sp-lines .r { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.sp-conf-total { display: flex; justify-content: space-between; padding: 10px 0; font-size: 17px; }
.sp-ord { margin-bottom: 12px; padding: 14px 16px; }
.sp-ord-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sp-ord-a { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sp-lines { margin-top: 10px; border-top: 1px solid var(--line); }
.sp-st-c { background: #e0f2fe; color: #0c4a6e; }
.sp-st-r { background: #dcfce7; color: #166534; }
.sp-st-x { background: #f1f2f6; color: var(--muted); }
@media (max-width: 860px) {
  .sp-params .input { width: 100%; }
  .sp-params label { flex: 1 1 30%; min-width: 96px; }
  .sp-params .grow { display: none; }
  .sp-params #spreset { width: 100%; }
  .sp-tools #spq { width: 100%; font-size: 16px; }
  .sp-blank { max-width: 60%; }
  .sp-wrap { overflow: visible; background: none; border: 0; }
  .sp-table, .sp-table tbody { display: block; }
  .sp-table thead { display: none; }
  .sp-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
  .sp-table tr.sp-g { background: none; border: 0; padding: 8px 2px 2px; margin: 0; }
  .sp-table tr.sp-g td { background: none; padding: 0; }
  .sp-table td { display: block; border: 0; padding: 0; background: none !important; box-shadow: none !important; }
  .sp-table tr.sp-on { border-color: #22a35a; background: #f3fbf5; }
  .sp-table .sp-name { flex: 1 1 100%; min-width: 0; margin-bottom: 4px; }
  .sp-table td[data-l]:not(.sp-qcell):not(.sp-s) { font-size: 13px; text-align: left; }
  .sp-table td[data-l]:not(.sp-qcell):not(.sp-s)::before { content: attr(data-l) ": "; color: var(--muted); font-weight: 400; }
  .sp-table .sp-qcell { display: flex !important; align-items: center; gap: 4px; flex: 1 1 auto; margin-top: 6px; order: 9; }
  .sp-table .sp-s { margin-top: 6px; margin-left: auto; order: 10; font-weight: 700; }
  .sp-q { width: 110px; height: 40px; font-size: 16px; }
  .sp-bar { margin: 12px -2px 0; padding: 10px 12px; }
  .sp-bar .btn { flex: none; padding: 0 14px; }
  .sp-sum { text-align: left; flex: 1; }
}
