  :root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-subtle: #eef0f3;
    --text: #1f2328;
    --muted: #6b7280;
    --accent: #3b6cff;
    --accent-soft: #eef2ff;
    --ok: #16a34a;
    --ok-bg: #ecfdf3;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --err: #dc2626;
    --err-bg: #fef2f2;
    --shadow: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04);
    --surface2: #fafbfc;
    --hover: #f3f4f6;
    --active-soft: #eef3ff;
    --accent-hover: #2f5ce6;
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a21;
    --surface2: #1d212a;
    --hover: #232834;
    --active-soft: #1e2c4d;
    --border: #2a2f3a;
    --border-subtle: #232834;
    --text: #e6e9ef;
    --muted: #8b93a3;
    --accent: #6d8dff;
    --accent-soft: #1e2745;
    --accent-hover: #5577f5;
    --ok: #34d399;
    --ok-bg: #0e2b1e;
    --warn: #fbbf24;
    --warn-bg: #2e2410;
    --err: #f87171;
    --err-bg: #341a1a;
    --shadow: 0 1px 3px rgba(0,0,0,.5);
  }
  * { box-sizing: border-box; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  body { font-family: -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); margin: 0; }
  .app { display: flex; min-height: 100vh; }
  /* Сайдбар закреплён по высоте экрана (sticky) — при скролле сделок меню и футер остаются на месте */
  .sidebar { width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 0;
    position: -webkit-sticky; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overflow-x: hidden; align-self: flex-start; }
  .nav-item .nav-ic { display: none; width: 18px; height: 18px; flex: none; }
  /* Rail: свёрнутый сайдбар с иконками и подсказками при наведении (десктоп) */
  .sidebar-brand { padding: 0 20px 16px 52px; font-weight: 700; font-size: 15px; border-bottom: 1px solid var(--border); margin-bottom: 10px; white-space: nowrap; color: var(--text); }
  nav.navgroup { display: flex; flex-direction: column; }
  /* Группы меню (дерево по смыслам) */
  .nav-grp { margin-bottom: 6px; }
  .nav-grp-h { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--muted); font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; padding: 10px 20px 4px; cursor: default; opacity: .85; }
  .nav-grp[hidden] { display: none; }
  .sidebar.rail .nav-grp-h { font-size: 0; padding: 0; height: 1px; margin: 6px 14px; background: var(--border); }
  @media (max-width: 720px) {
    .nav-grp-h { cursor: pointer; padding: 12px 20px 6px; font-size: 11.5px; display: flex; justify-content: space-between; align-items: center; }
    .nav-grp-h::after { content: "▾"; font-size: 12px; opacity: .7; transition: transform .15s; }
    .nav-grp.collapsed .nav-grp-h::after { transform: rotate(-90deg); }
    .nav-grp.collapsed .nav-grp-b { display: none; }
  }
  .nav-item { display: block; width: 100%; text-align: left; background: none; border: none; border-right: 2px solid transparent; color: var(--muted); padding: 10px 20px; font-size: 13px; cursor: pointer; }
  .nav-item:hover { background: var(--hover); color: var(--text); }
  .nav-item.active { background: var(--accent-soft); color: var(--accent); border-right-color: var(--accent); font-weight: 600; }
  .sidebar-footer { margin-top: auto; padding: 12px 20px 0; border-top: 1px solid var(--border); }
  .sidebar-footer .btn { width: 100%; margin-top: 8px; }
  main#mainRoot { flex: 1; padding: 24px; overflow-y: auto; min-width: 0; }
  /* Полноэкранные рабочие страницы: без заголовка, минимальные отступы от меню и краёв */
  main#mainRoot:has(.page.active[data-page-content="dialogs"]),
  main#mainRoot:has(.page.active[data-page-content="sandbox"]),
  main#mainRoot:has(.page.active[data-page-content="matching"]) { padding: 10px; overflow-y: hidden; }
  .page { display: none; max-width: 1400px; }
  .page[data-page-content="dialogs"], .page[data-page-content="matching"], .page[data-page-content="sandbox"] { max-width: none; }
  .sbx-msg { max-width: 82%; border-radius: 12px; padding: 7px 11px; font-size: 13px; white-space: pre-wrap; margin: 4px 0; }
  .sbx-in { background: var(--surface2); border-bottom-left-radius: 3px; align-self: flex-start; }
  .sbx-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
  .sbx-agent { background: var(--accent-bg, #eef); border-radius: 12px; padding: 7px 11px; font-size: 13px; white-space: pre-wrap; border-bottom-right-radius: 3px; }
  .sbx-real { background: var(--surface2); border-radius: 12px; padding: 7px 11px; font-size: 13px; white-space: pre-wrap; border-bottom-right-radius: 3px; }
  .ai-part { background: var(--surface); border: 1px solid var(--border); border-radius: 10px 10px 3px 10px; padding: 5px 9px; margin: 4px 0 0; white-space: pre-wrap; font-size: 12.5px; color: var(--text); }
  .ai-part.img { padding: 4px; display: inline-block; }
  .ai-part.img img { max-width: 170px; max-height: 190px; min-width: 60px; min-height: 40px; border-radius: 7px; display: block; background: var(--surface2); }
  .ai-part.img span { display: block; font-size: 10px; color: var(--muted); padding: 2px 3px 0; max-width: 170px; white-space: normal; }
  .ai-parts-n { font-size: 10px; color: var(--muted); margin-left: 6px; text-transform: none; letter-spacing: 0; }
  .aml-row { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
  .aml-row img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
  .aml-row label { display: block; font-size: 10.5px; color: var(--muted); margin: 5px 0 2px; }
  .aml-row input[type=text], .aml-row textarea { width: 100%; font-size: 12.5px; }
  .sbx-lbl { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
  .sbx-row { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
  .sbx-row:hover, .sbx-row.active { background: var(--surface2); }
  .page.active { display: block; }
  .page-title { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
  .page-sub { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
  .page-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
  @media (min-width: 860px) { .page-grid.two-col { grid-template-columns: 1.3fr 1fr; } }
  .page-grid .full { grid-column: 1 / -1; }
  /* Грид-элементы по умолчанию не сжимаются ниже min-content — длинная строка в карточке
     выталкивала соседнюю колонку за край экрана (ловилось на Аналитике). */
  .page-grid > * { min-width: 0; }
  /* overflow-x на всех вьюпортах: после min-width:0 у грид-детей широкая таблица должна
     скроллиться внутри карточки, а не рисоваться поверх соседней */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 20px; box-shadow: var(--shadow); overflow-x: auto; }
  .card h2 { font-size: 13px; margin: 0 0 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
  th { color: var(--muted); font-weight: 500; }
  form { display: flex; flex-direction: column; gap: 10px; }
  fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
  legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
  input, select, textarea { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 13px; width: 100%; }
  input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
  input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  input[type="checkbox"], input[type="radio"] { width: auto; }
  label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
  .row { display: flex; gap: 8px; }
  .row > div { flex: 1; }
  button[type=submit] { background: var(--accent); color: white; border: none; padding: 10px; border-radius: 8px; cursor: pointer; margin-top: 4px; font-weight: 600; }
  button[type=submit]:hover { background: var(--accent-hover); }
  .btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; }
  .btn:hover { background: var(--hover); }
  .btn.danger { border-color: #fecaca; color: var(--err); }
  .msg { font-size: 13px; min-height: 18px; }
  .msg.ok { color: var(--ok); }
  .msg.err { color: var(--err); }
  .credbox { background: var(--ok-bg); border: 1px solid #bbf7d0; border-radius: 8px; padding: 12px; font-size: 13px; line-height: 1.6; }
  .credbox code { background: #d1fae5; padding: 2px 6px; border-radius: 4px; }
  .compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .compare-grid > * { min-width: 0; }
  /* pre-wrap не переносит длинные цельные токены (URL, JSON функций) — без anywhere колонка
     раздувается до min-content и вылетает из карточки */
  .compare-col { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .compare-col h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; color: var(--muted); }
  .compare-col.agent { border-color: #bfd3fe; }
  .compare-col.manager { border-color: #bbf7d0; }
  .msg-bubble { background: var(--hover); border-radius: 8px; padding: 6px 9px; margin-bottom: 6px; overflow-wrap: anywhere; }
  .msg-bubble:last-child { margin-bottom: 0; }
  .fn-chip { display: inline-block; background: #f5f3ff; border: 1px solid #c4b5fd; color: #7c3aed; border-radius: 999px; padding: 3px 10px; font-size: 11px; margin: 2px 4px 6px 0; }
  .test-meta { font-size: 11px; color: var(--muted); margin-top: 10px; }
  .pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; }
  .pill.ok { background: var(--ok-bg); color: var(--ok); }
  .pill.off { background: var(--warn-bg); color: var(--warn); }
  .impersonating { background: var(--warn-bg); border: 1px solid #fde68a; color: var(--warn); padding: 8px 10px; border-radius: 8px; font-size: 12px; }
  .impersonating .btn { width: 100%; margin-top: 6px; }
  .stat { font-size: 22px; font-weight: 700; }
  .stat-label { font-size: 12px; color: var(--muted); }
  .inbox { display: grid; grid-template-columns: 280px 1fr 240px; height: calc(100vh - 20px); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
  .inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
  .inbox-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .inbox-header h2 { margin: 0; font-size: 13px; text-transform: none; }
  .dialogs-list { overflow-y: auto; flex: 1; }
  .dialog-row { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
  .dialog-row:hover { background: var(--hover); }
  .dialog-row.active { background: var(--accent-soft); }
  .dialog-row.unread .name, .dialog-row.unread .preview { font-weight: 700; color: var(--text); }
  .dialog-row .ur-badge { float: right; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; margin: 2px 0 0 6px; }
  .dialog-row .wait-mark { font-size: 10.5px; color: var(--warn); font-weight: 600; }
  .reply-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 6px 12px; border-top: 1px solid var(--border-subtle); font-size: 12px; }
  .reply-bar .btn { font-size: 11.5px; padding: 3px 9px; }
  .notify-bar { display: none; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; }
  .notify-bar .btn { font-size: 12px; }
  .dialog-row .name { font-size: 13px; font-weight: 600; }
  .dialog-row .preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dialog-row .time { font-size: 10px; color: var(--muted); float: right; }
  .dialog-row .listing { font-size: 11px; color: var(--accent); }
  .filter-tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
  .filter-tabs .tab { background: none; border: 1px solid var(--border); color: var(--muted); padding: 4px 8px; border-radius: 999px; font-size: 11px; cursor: pointer; }
  .filter-tabs .tab.active { background: var(--accent); border-color: var(--accent); color: white; }
  .inbox-thread-wrap { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border-right: 1px solid var(--border); }
  .m-thread-bar, .m-side-backdrop, #stockPane, #notesPane, #mSideClose { display: none; }
  .cc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
  .cc-head .avatar { width: 40px; height: 40px; }
  .cc-name { font-size: 15px; font-weight: 700; }
  .cc-contacts { font-size: 12.5px; }
  .cc-sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
  .cc-src { display: inline-flex; align-items: center; gap: 5px; background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px 4px 5px; font-size: 12px; cursor: pointer; color: var(--text); }
  .cc-src.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
  .cc-hint { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
  .cc-row { display: flex; gap: 8px; font-size: 12px; padding: 3px 0; border-top: 1px dashed var(--border-subtle); }
  .cc-row span { color: var(--muted); min-width: 78px; flex: none; }
  .cc-row b { font-weight: 500; min-width: 0; word-break: break-word; }
  .cc-bio { font-size: 12px; font-style: italic; color: var(--muted); padding: 3px 0; }
  .tpl-pop { position: absolute; bottom: calc(100% + 6px); left: 10px; right: 10px; max-width: 460px; max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 50; padding: 6px; }
  .tpl-pop input { width: 100%; font-size: 13px; margin-bottom: 4px; }
  .tpl-pop .tpl-cat { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px 2px; }
  .tpl-pop .tpl-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 8px; cursor: pointer; color: var(--text); font-size: 13px; }
  .tpl-pop .tpl-item:hover { background: var(--hover); }
  .tpl-pop .tpl-item small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
  .compose { position: relative; }
  .tpl-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border-subtle); font-size: 13px; }
  .tpl-row .b { white-space: pre-wrap; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
  .cc-split { all: unset; cursor: pointer; color: var(--muted); font-size: 11px; margin-left: 6px; padding: 0 2px; }
  .cc-split:hover { color: var(--err); }
  .card-header { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; font-size: 12px; }
  .card-header img.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--hover); }
  .card-header img.listing-thumb { width: 44px; height: 33px; border-radius: 4px; object-fit: cover; background: var(--hover); }
  .card-header .who { font-weight: 600; }
  .card-header a { color: var(--accent); text-decoration: none; }
  .card-header .spacer { flex: 1; }
  .card-header select { width: auto; font-size: 11px; padding: 4px 6px; }
  .compose { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); align-items: flex-end; }
  /* Right side of the composer: send button bottom-aligned with the textarea; chip/error stack above it */
  .compose > div:last-child { display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; gap: 4px; }
  .compose > div:last-child .msg { min-height: 0; }
  /* Accent buttons in the composer keep an accent hover — the generic gray .btn:hover looked broken on them */
  .compose button:hover { background: var(--accent-hover); color: white; }
  /* .compose button paints every compose button accent-blue; the paperclip must stay a quiet
     icon, so this selector deliberately out-specifies it. */
  .compose .attach-btn, .attach-btn { background: none; border: none; font-size: 17px; color: var(--muted); cursor: pointer; padding: 8px 6px; border-radius: 8px; line-height: 1; }
  .compose .attach-btn:hover, .attach-btn:hover { background: var(--hover); color: var(--accent); }
  .compose textarea { flex: 1; resize: vertical; min-height: 64px; max-height: 60vh; line-height: 1.4; }
  @media (max-width: 720px) { .compose textarea { resize: none; } }
  .compose button { align-self: flex-end; background: var(--accent); color: white; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; }
  .fact-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 10px; padding: 0; margin-left: 6px; }
  .fact-btn.flagged { color: var(--ok); }
  .board-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
  .board-tabs .tab { background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 6px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; }
  .board-tabs .tab.active { background: var(--accent); border-color: var(--accent); color: white; }
  /* amoCRM-style board: one compact top bar, stage headers as high as possible, full-height
     columns, no visible scrollbars anywhere, no page-level vertical scroll; the whole area
     (including empty space) is a grab surface for horizontal panning. */
  .page[data-page-content="crmBoard"] { max-width: none; margin-bottom: -24px; }
  .board-topbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
  .board-columns { display: flex; gap: 14px; overflow-x: auto; align-items: stretch; -webkit-overflow-scrolling: touch; height: calc(100vh - 74px); scrollbar-width: none; }
  .board-columns::-webkit-scrollbar { display: none; }
  /* Columns bleed to the very bottom edge — no bottom frame, like amo */
  .board-col { flex: 0 0 260px; background: var(--surface2); border: 1px solid var(--border); border-bottom: none; border-radius: 12px 12px 0 0; display: flex; flex-direction: column; height: 100%; }
  .board-col.locked { opacity: .85; }
  .board-col-header { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; display: flex; justify-content: space-between; font-weight: 600; }
  .board-col-body { padding: 8px; overflow-y: auto; flex: 1; min-height: 60px; scrollbar-width: none; }
  /* Пунктир только у настоящей пустой зоны — подсказка «+ ещё N» под карточками полной
     колонки не должна выглядеть как место для перетаскивания */
  .board-col-body .drop-zone { border: 1px dashed var(--border); border-radius: 8px; margin: 2px; padding: 18px 10px; font-size: 12px; }
  /* Наклейки и малоколоночные воронки: растягиваем на всю ширину; min-width не даёт
     колонкам сжаться в нечитаемые полосы — на узких экранах включается скролл контейнера */
  #labelsColumns .board-col, .board-columns.few-cols .board-col { flex: 1 1 280px; min-width: 240px; }
  .board-col-body::-webkit-scrollbar { display: none; }
  .board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 12px; cursor: grab; box-shadow: var(--shadow); }
  .board-card.sortable-ghost { opacity: .3; }
  /* доски заказов живут в сайдбаре «Заказы», во вкладках «Сделок» их нет */
  #boardTabs [data-board="production"], #boardTabs [data-board="delivery"], #boardTabs [data-board="shipping"], #boardTabs [data-board="pickup"], #boardTabs [data-board="returns"] { display: none !important; }
  /* Кнопка, у которой идёт запрос: полупрозрачная, со спиннером, клики выключены */
  button.busy, .btn.busy { position: relative; pointer-events: none; opacity: .65; }
  button.busy::after, .btn.busy::after { content: ''; position: absolute; right: 6px; top: 50%; width: 10px; height: 10px; margin-top: -6px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
  @media (prefers-reduced-motion: reduce) { button.busy::after, .btn.busy::after { animation-duration: 1.5s; } }
  /* Скелетон загрузки доски: колонки с «карточками»-заглушками, пока данные едут */
  .skel { position: relative; overflow: hidden; background: var(--border-subtle, var(--border)); border-radius: 6px; }
  .skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: skel-shine 1.3s infinite; }
  @keyframes skel-shine { to { transform: translateX(100%); } }
  @media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }
  /* Перенос между стадиями: пока сервер не подтвердил — карточка затенена и мягко пульсирует, клики выключены */
  .board-card.moving { opacity: .45; pointer-events: none; filter: saturate(.5); animation: card-moving 1.1s ease-in-out infinite; }
  .board-card.arrived { animation: card-arrive .6s cubic-bezier(.2,.8,.3,1); }
  @keyframes card-moving { 0%, 100% { opacity: .45; } 50% { opacity: .75; } }
  @keyframes card-arrive { 0% { transform: translateY(-8px) scale(.98); box-shadow: 0 0 0 3px var(--accent); } 100% { transform: none; box-shadow: var(--shadow); } }
  @media (prefers-reduced-motion: reduce) { .board-card.moving, .board-card.arrived { animation: none; } }
  /* Склад: чипы штрихкодов, плитки на мобильном, карточка во весь экран */
  .wh-stock { background: transparent; border: 1px dashed var(--border); border-radius: 6px; padding: 2px 8px; cursor: pointer; font: inherit; color: inherit; }
  .wh-stock:hover { border-color: var(--warn); }
  .card-inline-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
  .board-card.no-wh { border-left: 4px solid var(--danger,#d9534f); background: linear-gradient(100deg, rgba(217,83,79,.20) 0%, rgba(217,83,79,.09) 45%, transparent 90%); }
  .board-card.no-wh:hover { background: linear-gradient(100deg, rgba(217,83,79,.26) 0%, rgba(217,83,79,.12) 45%, transparent 90%); }
  @keyframes boardbar { 0%{background-position:0 0} 100%{background-position:200% 0} }
  .nav-badge { display:inline-block; min-width:18px; padding:0 5px; margin-left:6px; border-radius:999px; background:var(--accent); color:#fff; font-size:11px; line-height:18px; text-align:center }
  .card-inline { font-size: 12px; padding: 4px 6px; min-height: 28px; border: 1px dashed var(--border); background: transparent; }
  .card-inline:focus { border-style: solid; }
  .col-scan { padding: 8px 8px 0; display: flex; gap: 6px; align-items: center; }
  .col-scan input { flex: 1; min-width: 0; font-size: 14px; }
  .col-scan .ic-btn { flex: none; }
  .col-scan-result { padding: 0 8px; }
  @media (max-width: 720px) { .col-scan input { font-size: 16px; min-height: 44px; } }
  /* Панель печати кодов — всегда видна внизу экрана, пока открыта вкладка */
  .lb-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
  .sidebar:not(.collapsed):not(.rail) ~ main .lb-bar { left: 220px; } .sidebar.rail ~ main .lb-bar { left: 64px; }
  #whLabels { padding-bottom: 84px; }
  @media (max-width: 720px) { .lb-bar { left: 0 !important; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); } }
  .wh-cam { min-height: 40px; font-size: 13.5px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; }
  @media (max-width: 720px) { .wh-cam { min-height: 52px; font-size: 16px; flex: 1; } #whScanRow { flex-direction: column; align-items: stretch; } #whScanRow select { max-width: none !important; min-height: 48px; font-size: 16px; border: 2px solid var(--accent); } }
  .tdot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; animation: tdot 1s infinite; display: inline-block; }
  @keyframes tdot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }
  .wh-hl { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--accent-soft, rgba(59,130,246,.12)) !important; }
  tr.wh-hl td { background: var(--accent-soft, rgba(59,130,246,.10)); }
  .wh-code { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 9px; font-size: 12px; background: var(--surface); }
  .wh-code code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
  .wh-code button { border: none; background: transparent; color: var(--muted); cursor: pointer; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; line-height: 22px; padding: 0; }
  .wh-code button:hover { background: var(--danger, #d9534f); color: #fff; }
  .wh-tiles { display: flex; flex-direction: column; gap: 8px; }
  .wh-tile { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
  @media (max-width: 720px) {
    .wh-table { display: none; }
    .wh-tiles { display: flex !important; }
    #whCardOverlay { padding: 0; }
    .wh-card-box { max-width: none !important; width: 100vw; height: 100vh !important; height: 100dvh !important; max-height: none !important; border-radius: 0; border: none; }
    .wh-card-box > div:last-child { padding: 12px 12px 24px !important; }
    .wh-card-box #whVariantsTable th:nth-child(5), .wh-card-box #whVariantsTable td:nth-child(5) { display: none; }
    .wh-card-box .modal-header h2 { font-size: 14px; }
  }
  .board-card .name { font-weight: 600; margin-bottom: 2px; }
  .board-card .listing { color: var(--accent); margin-bottom: 4px; }
  .board-card .badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
  .badge-frozen { background: #eff6ff; color: #2563eb; border-radius: 999px; padding: 1px 7px; font-size: 10px; }
  .badge-snooze { background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 1px 7px; font-size: 10px; cursor: pointer; }
  .card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
  .dtag { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface2, #eee); color: var(--muted); }
  .dtag-ok { background: var(--ok-bg, #e6f6ec); color: var(--ok); }
  .dtag-bad { background: var(--crit-soft, #fde4e4); color: var(--danger, #d9534f); }
  .dtag-warn { background: var(--warn-bg); color: var(--warn); }
  .unanswered-badge { background: var(--danger, #d9534f); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 10px; font-weight: 700; margin-left: 6px; vertical-align: middle; display: inline-flex; align-items: center; gap: 3px; }
  .ic { display: inline-block; vertical-align: -0.15em; flex: 0 0 auto; }
  .ic-btn { display: inline-flex; align-items: center; gap: 6px; }
  .badge-return { background: var(--err-bg); color: var(--err); border-radius: 999px; padding: 1px 7px; font-size: 10px; }
  .badge-ok { background: var(--ok-bg); color: var(--ok); border-radius: 999px; padding: 1px 7px; font-size: 10px; }
  .badge-warn { background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 1px 7px; font-size: 10px; }
  .badge-info { background: #eff6ff; color: #2563eb; border-radius: 999px; padding: 1px 7px; font-size: 10px; }
  .snooze-btn { background: none; border: none; color: var(--muted); font-size: 10px; cursor: pointer; padding: 0; margin-top: 6px; }
  .tab-incoming { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--stop, var(--err)); color: #fff; font-size: 10.5px; font-weight: 700; vertical-align: 1px; }
  .test-card { border: 1.5px dashed var(--warn); background: var(--warn-bg); }
  .test-badge { font-size: 10px; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
  .card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
  .card-actions .snooze-btn { margin-top: 2px; }
  .card-actions .snooze-btn:hover { color: var(--accent); }
  .snooze-pop { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
  .snooze-pop input, .snooze-pop select { font-size: 11px; padding: 4px 6px; }
  .stars-edit .star { cursor: pointer; color: #d1d5db; font-size: 15px; }
  .stars-edit .star.filled { color: #f59e0b; }
  .followups-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
  .followup-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
  .bucket-row { margin-bottom: 12px; }
  .bucket-row .bucket-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
  .bucket-bar-track { background: var(--border-subtle); border-radius: 6px; height: 10px; }
  .bucket-bar-fill { background: var(--accent); height: 100%; border-radius: 6px 4px 4px 6px; min-width: 3px; }
  .bucket-bar-fill[style*="width:0%"] { display: none; }
  .modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
  .modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 640px; height: 80vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(16,24,40,.2); }
  /* amoCRM-style deal card: a drawer sliding in from the right over two thirds of the screen;
     the dimmed board stays visible on the left and clicking it (or ← / Esc) closes the card. */
  .deal-overlay { padding: 0; justify-content: flex-end; align-items: stretch; }
  .modal-box.deal-fullscreen { max-width: none; width: 66vw; min-width: 700px; height: 100vh; border: none; border-left: 1px solid var(--border); border-radius: 0; box-shadow: -14px 0 44px rgba(16,24,40,.18); animation: deal-slide-in .18s ease; }
  @keyframes deal-slide-in { from { transform: translateX(48px); opacity: .5; } to { transform: none; opacity: 1; } }
  @media (max-width: 900px) { .modal-box.deal-fullscreen { width: 100vw; min-width: 0; } }
  /* === КРОССБРАУЗЕРНОСТЬ ===
     - 100dvh не знают старые Safari/Android → сначала 100vh как fallback (каскад возьмёт dvh, где есть).
     - :has() нет в Firefox <121 / старых Safari → full-bleed страницы дублируем классом на <main>
       (ставится из switchPage), чтобы не зависеть от :has().
     - -webkit- префиксы для sticky и плавного скролла на iOS. */
  .modal-box.deal-fullscreen { height: 100vh; height: 100dvh; }
  .deal-fullscreen .compose, .deal-mtabs, .deal-fullscreen .modal-header { position: -webkit-sticky; position: sticky; }
  .board-columns, .dialogs-list, .inbox-thread, .sbx-list, .board-topbar, .filter-tabs, .board-tabs { -webkit-overflow-scrolling: touch; }
  /* Фокус-кольцо повторяет форму кнопки (круглые — круглое), а не прямоугольный outline;
     показываем только при клавиатурной навигации, по клику/тапу — нет */
  button, .btn, a.btn, .tab, .nav-item, .back-btn, .sidebar-close, .sidebar-toggle, .attach-btn, .snooze-btn, .sold-tile, .wh-row, .sbx-row { outline: none; }
  button:focus-visible, .btn:focus-visible, .tab:focus-visible, .nav-item:focus-visible, .back-btn:focus-visible, .attach-btn:focus-visible, .sold-tile:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59,108,255,.35); border-radius: inherit; }
  button:focus:not(:focus-visible), .btn:focus:not(:focus-visible), .tab:focus:not(:focus-visible) { outline: none; box-shadow: none; }
  /* Спиннер загрузки/поиска — единый для приёмки, пикалки, списков */
  .spinner { display: inline-block; width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; flex: none; }
  .spinner.lg { width: 28px; height: 28px; border-width: 3px; }
  .loading-row { display: flex; align-items: center; gap: 10px; padding: 14px; color: var(--muted); font-size: 13px; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.5s; } }
  /* Тонкие стильные скроллбары во внутренних списках (Chrome/Safari через ::-webkit, Firefox через scrollbar-width) */
  .dialogs-list, .inbox-thread, .board-col-body, .inbox-orders, .sidebar, .match-list-col .dialogs-list, .match-pane-col, .deal-side, .sbx-list, #sbxThread, .modal-box > div { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
  .dialogs-list::-webkit-scrollbar, .inbox-thread::-webkit-scrollbar, .board-col-body::-webkit-scrollbar, .inbox-orders::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .match-pane-col::-webkit-scrollbar, .deal-side::-webkit-scrollbar, #sbxThread::-webkit-scrollbar, .modal-box > div::-webkit-scrollbar { width: 6px; height: 6px; }
  .dialogs-list::-webkit-scrollbar-thumb, .inbox-thread::-webkit-scrollbar-thumb, .board-col-body::-webkit-scrollbar-thumb, .inbox-orders::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .match-pane-col::-webkit-scrollbar-thumb, .deal-side::-webkit-scrollbar-thumb, #sbxThread::-webkit-scrollbar-thumb, .modal-box > div::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
  .dialogs-list:hover::-webkit-scrollbar-thumb, .inbox-thread:hover::-webkit-scrollbar-thumb, .board-col-body:hover::-webkit-scrollbar-thumb { background: var(--muted); }
  .dialogs-list::-webkit-scrollbar-track, .inbox-thread::-webkit-scrollbar-track, .board-col-body::-webkit-scrollbar-track { background: transparent; }
  /* Safari (Mac/iOS): нативные стрелки select/поля и зум по фокусу — выравниваем вид; скролл без «резинки»
     за пределы страницы; snap доски с webkit-префиксом; input[type=date/time] не растягиваются */
  select, input, textarea, button { -webkit-appearance: none; appearance: none; font-family: inherit; }
  select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
  input[type="checkbox"], input[type="radio"] { -webkit-appearance: auto; appearance: auto; }
  input[type="datetime-local"], input[type="date"] { min-width: 0; max-width: 100%; }
  html, body { overscroll-behavior-y: none; -webkit-text-size-adjust: 100%; }
  .board-columns { -webkit-scroll-snap-type: x mandatory; }
  main#mainRoot.full-bleed { padding: 10px; overflow-y: hidden; }
  @media (max-width: 720px) { main#mainRoot.full-bleed { padding: 56px 8px 8px; overflow-y: auto; } }
  /* Панель действий по сделке в карточке — над диалогом */
  .deal-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .deal-actions .btn { font-size: 12px; padding: 6px 11px; }
  /* Мобильные табы карточки сделки: на десктопе скрыты (обе панели рядом), на мобильном — переключатель */
  .deal-mtabs { display: none; border-bottom: 1px solid var(--border); background: var(--surface); }
  .deal-mtabs button { flex: 1; padding: 11px 6px; background: none; border: none; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
  .deal-mtabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
  .back-btn { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 6px 14px; border-radius: 8px; flex-shrink: 0; }
  .back-btn:hover { background: var(--hover); color: var(--text); }
  .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .sidebar { transition: width .15s ease, padding .15s ease; }
  /* === Десктоп: логотип без отступа под бургер; rail — свёрнутый сайдбар с иконками и тултипами === */
  @media (min-width: 721px) {
    .sidebar:not(.rail) .sidebar-brand { padding: 0 20px 16px 22px; }
    .sidebar-collapse { margin: 8px 12px 0; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); padding: 7px; cursor: pointer; font-size: 12px; width: calc(100% - 24px); white-space: nowrap; }
    .sidebar:not(.rail) .sidebar-collapse::before { content: '« свернуть меню'; }
    .sidebar.rail { width: 64px; padding: 14px 0; }
    .sidebar.rail .sidebar-brand { padding: 0 0 10px; margin-bottom: 8px; display: flex; justify-content: center; }
    /* В rail показываем только знак логотипа, ровно по центру; текст и кнопка закрытия скрыты */
    .sidebar.rail .sidebar-brand > span { display: inline-flex; align-items: center; justify-content: center; font-size: 0; gap: 0; width: 32px; height: 32px; }
    .sidebar.rail .sidebar-brand > span svg { width: 28px !important; height: 28px !important; display: block; }
    .sidebar.rail .sidebar-brand .sidebar-close { display: none !important; }
    .sidebar.rail .nav-item { padding: 11px 0; display: flex; justify-content: center; position: relative; border-right-width: 3px; }
    .sidebar.rail .nav-item .nav-ic { display: block; }
    .sidebar.rail .nav-item > :not(.nav-ic) { display: none; }
    .sidebar.rail .nav-item { font-size: 0; }
    /* Красивые подсказки: всплывают справа со стрелкой и тенью; сайдбар в rail не режет их overflow'ом */
    .sidebar.rail { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
    .sidebar.rail::-webkit-scrollbar { display: none; }
    #railTip { position: fixed; z-index: 1000; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; padding: 7px 11px; border-radius: 8px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.18); pointer-events: none; opacity: 0; transform: translate(-6px, -50%); transition: opacity .12s, transform .12s; }
    #railTip::before { content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%); border: 6px solid transparent; border-right-color: var(--text); }
    #railTip.show { opacity: 1; transform: translate(0, -50%); }
    #railTip.active { background: var(--accent); color: #fff; }
    #railTip.active::before { border-right-color: var(--accent); }
    .sidebar.rail .nav-item::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(-6px); background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; padding: 7px 11px; border-radius: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.22); }
    .sidebar.rail .nav-item::before { content: ''; position: absolute; left: calc(100% + 4px); top: 50%; transform: translateY(-50%) translateX(-6px); border: 6px solid transparent; border-right-color: var(--text); opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease; z-index: 200; }
    .sidebar.rail .nav-item::after, .sidebar.rail .nav-item::before { display: none; }
    .sidebar.rail .nav-item.active::after { background: var(--accent); color: #fff; }
    .sidebar.rail .nav-item.active::before { border-right-color: var(--accent); }
    /* Логотип-плашка ровно по центру rail (перебиваем базовый padding-left 52px под бургер) */
    .sidebar.rail .sidebar-brand { padding: 0 0 10px !important; margin: 0 0 8px; display: flex !important; justify-content: center !important; align-items: center; border-bottom: 1px solid var(--border); }
    .sidebar.rail .sidebar-footer { padding: 8px 10px 0; }
    .sidebar.rail .sidebar-footer .btn { width: 44px; height: 36px; padding: 0; margin: 6px auto 0; display: flex; align-items: center; justify-content: center; font-size: 0; overflow: hidden; }
    .sidebar.rail .sidebar-footer .btn > * { display: none; }
    .sidebar.rail #themeToggle::before { content: '◐'; font-size: 16px; }
    .sidebar.rail #changePwBtn::before { content: '🔑'; font-size: 14px; }
    .sidebar.rail #logout::before { content: '⏻'; font-size: 15px; }
    .sidebar.rail #changePwBox, .sidebar.rail .impersonating, .sidebar.rail .sidebar-close { display: none !important; }
    .sidebar.rail .sidebar-collapse { width: 44px; margin: 8px auto 0; padding: 7px 0; font-size: 0; }
    .sidebar.rail .sidebar-collapse::before { content: '»'; font-size: 16px; }
  }
  .sidebar.collapsed { width: 0; padding: 18px 0; overflow: hidden; border-right: none; }
  .sidebar-toggle { position: fixed; top: 16px; left: 16px; z-index: 50; background: var(--surface); border: 1px solid var(--border); color: var(--text); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; box-shadow: var(--shadow); }
  /* На десктопе плавающего бургера нет — меню сворачивается кнопкой внутри сайдбара (rail) */
  @media (min-width: 721px) { .sidebar-toggle { display: none !important; } }
  .board-columns { cursor: grab; }
  .board-columns.dragging-scroll { cursor: grabbing; user-select: none; }
  /* Затемнение за выехавшим меню на мобильном — тап по нему закрывает меню */
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 39; }
  .sidebar-backdrop.show { display: block; }
  .sidebar-close { display: none; }
  @media (max-width: 720px) {
    /* Меню на мобильном — выезжающий drawer: ✕ внутри шапки, гамбургер прячется пока открыто
       (раньше бургер перекрывал логотип). */
    .sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; box-shadow: 0 0 40px rgba(0,0,0,.25); transition: transform .2s ease, width 0s; }
    .sidebar:not(.collapsed) { width: min(280px, 84vw); transform: none; }
    .sidebar.collapsed { width: min(280px, 84vw); padding: 18px 0; transform: translateX(-105%); border-right: none; }
    .sidebar-close { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); color: var(--text); font-size: 16px; cursor: pointer; margin-right: 12px; }
    /* Логотип в drawer: в линию с пунктами меню (20px), не прижат к краю */
    .sidebar .sidebar-brand { padding: 0 0 14px 20px !important; }
    body.menu-open .sidebar-toggle { display: none; }
    main#mainRoot { padding: 60px 14px 16px; }
    /* Полноэкранные страницы: оставляем место сверху под кнопку-гамбургер, высота с учётом отступов */
    main#mainRoot:has(.page.active[data-page-content="dialogs"]),
    main#mainRoot:has(.page.active[data-page-content="matching"]) { padding: 56px 8px 8px; overflow-y: auto; }
    .inbox, .match-wrap { grid-template-columns: 1fr; height: auto; }
    .inbox-list, .inbox-thread-wrap, .inbox-orders { border: none; border-bottom: 1px solid var(--border); }
    /* Диалоги на мобильном (22.09.2026): тот же диалог, что на компьютере (карточка, ИИ, оплата, аккаунты), а не
       старое окно магазина. Два экрана: список ↔ переписка (.inbox.m-thread), правая панель — шторка снизу. */
    .m-thread-bar { display: none; }
    .inbox.m-thread .m-thread-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 3; }
    .m-thread-bar .btn { font-size: 13px; padding: 7px 11px; min-height: 36px; border-radius: 10px; white-space: nowrap; }
    .m-thread-bar .m-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .inbox.m-thread .inbox-list { display: none !important; }
    .page[data-page-content="dialogs"] .inbox.m-thread .inbox-thread-wrap { display: flex !important; height: calc(100dvh - 64px); border: none; }
    .inbox.m-thread .card-header { flex-wrap: wrap; gap: 8px 10px; font-size: 12px; padding: 8px 10px; }
    .inbox.m-thread .card-header .avatar { width: 34px; height: 34px; }
    .inbox.m-thread .card-header .listing-thumb, .inbox.m-thread .card-header .hdr-details, .inbox.m-thread .card-header .hdr-listing, .inbox.m-thread .card-header .spacer { display: none; }
    .inbox.m-thread .card-header { padding: 6px 10px; gap: 8px; align-items: center; }
    .inbox.m-thread .card-header .who { font-size: 13px; }
    .inbox.m-thread .card-header .avatar, .inbox.m-thread .card-header .hdr-who { display: none; }
    .inbox.m-thread .card-header { justify-content: flex-end; }
    .inbox.m-thread .card-header select { max-width: 42vw; }
    body.m-thread-open #notifyBar, body.m-thread-open #remindBar { display: none !important; }
    body.m-thread-open main#mainRoot:has(.page.active[data-page-content="dialogs"]) { padding-top: 52px; }
    .page[data-page-content="dialogs"] .inbox.m-thread .inbox-thread-wrap { height: calc(100dvh - 60px); }
    .inbox.m-thread .card-header .spacer { flex-basis: 100%; height: 0; }
    .inbox.m-thread .card-header select, .inbox.m-thread .card-header .btn { min-height: 36px; font-size: 13px; }
    .page[data-page-content="dialogs"] .inbox-orders { display: block !important; position: fixed; left: 0; right: 0; bottom: 0; height: 74dvh; z-index: 120;
      background: var(--surface); border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 36px rgba(0,0,0,.25);
      overflow-y: auto; padding: 14px 14px 28px; transform: translateY(105%); transition: transform .22s ease; }
    .page[data-page-content="dialogs"] .inbox-orders.m-open { transform: none; }
    #mSideClose { display: block; width: 100%; margin: 0 0 10px; font-size: 13px; min-height: 38px; }
    .notify-bar { padding: 6px 10px; gap: 6px; font-size: 12px; }
    .notify-bar .btn { font-size: 11.5px; padding: 4px 8px; min-height: 30px; }
    .notify-bar select { min-height: 30px; font-size: 12px; width: auto; }
    .m-side-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 119; }
    .m-side-backdrop.show { display: block; }
    .reply-bar { padding: 6px 8px; gap: 6px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
    .reply-bar .btn { flex: none; font-size: 12px; padding: 7px 10px; min-height: 34px; border-radius: 9px; }
    /* Кнопки действий на карточках доски были слишком крупные и круглые — обычные компактные */
    .card-actions .snooze-btn { padding: 6px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); min-height: 32px; }
    .notify-bar { font-size: 12.5px; padding: 8px 10px; }
    /* (старое) */
    .page[data-page-content="dialogs"] .inbox-thread-wrap, .page[data-page-content="dialogs"] .inbox-orders { display: none; }
    .page[data-page-content="dialogs"] .inbox-list { max-height: none; }
    .page[data-page-content="dialogs"] .dialogs-list { max-height: calc(100dvh - 200px); overflow-y: auto; }
    .inbox-thread { min-height: 40vh; }
    /* Wide tables (Заказы, Тесты, Сотрудники) scroll inside their card instead of breaking the page */
    .card { overflow-x: auto; }
    .compare-grid, .match-tiles { grid-template-columns: 1fr; }
    .row { flex-direction: column; }
    .bubble { max-width: 90%; }
    /* Табы борда/фильтров и топбары скроллятся вбок, не ломая ширину */
    .board-topbar, .filter-tabs, .board-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .board-topbar > *, .board-tabs > * { flex: none; }
    /* Карточка сделки на весь экран уже есть; списки товаров в диалоге не жмём в узкую колонку */
    .deal-fullscreen .inbox { grid-template-columns: 1fr; }
    /* Тач-таргеты под палец: пункты меню, кнопки, фильтры, поля крупнее (мин. ~40px) */
    .nav-item { padding: 13px 20px; font-size: 15px; }
    .sidebar-footer .btn, .impersonating .btn { min-height: 40px; }
    .filter-tabs .tab, .board-tabs .tab { padding: 8px 13px; white-space: nowrap; }
    .filter-tabs { scrollbar-width: none; }
    .filter-tabs::-webkit-scrollbar { display: none; }
    .board-card { padding: 12px 14px; }
    .dialog-row { padding: 12px 14px; }
    /* 16px на полях — иначе iOS Safari зумит страницу при фокусе */
    input, select, textarea, .stock-search { font-size: 16px; min-height: 40px; }
    .card-header select, .snooze-pop input, .snooze-pop select { min-height: 34px; }
    .attach-btn, #attachBtn, #modalAttachBtn { min-width: 40px; min-height: 40px; }
    #composeSendBtn, #modalComposeSendBtn { min-height: 42px; padding: 0 18px; }

    /* === МОБИЛЬНАЯ КАРТОЧКА СДЕЛКИ: поверх всего, на весь экран, секции переключаются табами
       (Переписка / Товар / Сделка) — вместо трёх колонок стопкой, где переписка тонула. === */
    .deal-overlay { align-items: stretch; }
    .modal-box.deal-fullscreen { width: 100vw; height: 100dvh; display: flex; flex-direction: column; }
    .deal-fullscreen .modal-header { padding: 6px 8px; }
    .deal-fullscreen .card-header { font-size: 12px; gap: 8px; flex-wrap: wrap; }
    .deal-fullscreen .card-header .listing-thumb { width: 34px; height: 34px; }
    .deal-fullscreen .card-header .avatar { width: 30px; height: 30px; }
    /* Карточка сделки на мобильном: переписка всегда на экране; «Товар и клиент» — выезжающая
       снизу шторка (bottom sheet) по кнопке в шапке, закрывается кнопкой/тапом по затемнению */
    .deal-mtabs { display: flex; }
    .deal-mtabs button[data-mtab="chat"] { display: none; }
    .deal-mtabs button[data-mtab="side"] { flex: 1; text-align: left; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; }
    .deal-mtabs button[data-mtab="side"]::after { content: '▾'; font-size: 14px; }
    .deal-mtabs button[data-mtab="side"].active::after { content: '▴'; }
    .deal-body { flex-direction: column; position: relative; }
    .deal-chat { display: flex !important; flex: 1; min-height: 0; }
    .deal-side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: 72vh; height: 72dvh; width: auto !important;
      background: var(--surface); border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
      box-shadow: 0 -12px 36px rgba(0,0,0,.25); z-index: 120; overflow-y: auto; padding: 14px 14px 24px;
      transform: translateY(105%); transition: transform .22s ease; display: block !important; }
    .deal-side.mtab-active { transform: none; }
    .deal-side-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 119; }
    .deal-side-backdrop.show { display: block; }
    .deal-fullscreen .inbox-thread { flex: 1; min-height: 0; }
    /* Compose как в мессенджере: прилипает к низу, поднимается над клавиатурой (visualViewport, JS),
       textarea растёт по тексту (1–5 строк), крупный шрифт, круглая кнопка отправки справа */
    .deal-fullscreen .compose, #composeBox { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); gap: 8px; align-items: flex-end; z-index: 5; will-change: transform; }
    .compose textarea { font-size: 16px; line-height: 1.35; min-height: 40px; max-height: 140px; padding: 9px 12px; border-radius: 20px; background: var(--surface2); border: 1px solid var(--border); }
    .compose > div { display: flex; flex-direction: column; align-items: flex-end; }
    #composeSendBtn, #modalComposeSendBtn { min-width: 44px; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; font-size: 0; display: flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border: none; }
    #composeSendBtn::before, #modalComposeSendBtn::before { content: '➤'; font-size: 18px; line-height: 1; margin-left: 2px; }
    .compose .attach-btn { width: 40px; height: 40px; min-width: 40px; border-radius: 50%; }
    .compose .msg.err { position: absolute; bottom: 100%; left: 10px; right: 10px; background: var(--surface); padding: 4px 8px; }
    /* Песочница: стопкой с рабочей высотой переписки */
    main#mainRoot:has(.page.active[data-page-content="sandbox"]) { padding: 56px 8px 8px; overflow-y: auto; }
    .sbx-pair { grid-template-columns: 1fr; }
    /* Сопоставление на мобильном: стопкой, строго в ширину экрана (вылезало на 13px из-за padding) */
    .match-wrap { grid-template-columns: 1fr; height: auto; width: 100%; max-width: 100%; box-sizing: border-box; }
    .match-list-col, .match-pane-col { min-width: 0; max-width: 100%; }
    .match-list-col .dialogs-list { max-height: 40vh; }
    /* Карточка «поднята» удержанием — видно, что захвачена; во время drag тело не скроллится
       (SortableJS сам ведёт автоскролл), после — всё как было */
    .board-card-lifted { transform: scale(1.03); box-shadow: 0 10px 28px rgba(0,0,0,.28); opacity: .95; outline: 2px solid var(--accent); }
    .board-card-dragging { opacity: .9; }
    /* Подсказка у края при drag: сюда перелистнёт */
    .board-columns { position: relative; }
    .board-columns.edge-left::before, .board-columns.edge-right::after { content: ''; position: fixed; top: 0; bottom: 0; width: 18vw; pointer-events: none; z-index: 4;
      background: linear-gradient(to right, rgba(59,108,255,.28), transparent); animation: edge-pulse .6s ease-in-out infinite alternate; }
    .board-columns.edge-left::before { left: 0; }
    .board-columns.edge-right::after { right: 0; background: linear-gradient(to left, rgba(59,108,255,.28), transparent); }
    @keyframes edge-pulse { from { opacity: .5; } to { opacity: 1; } }
    .board-card { touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; }
    /* Табы воронок на мобиле: скрыть полоску прокрутки (она «висела» сверху), скролл пальцем остаётся */
    .board-topbar, .board-tabs { scrollbar-width: none; }
    .board-topbar::-webkit-scrollbar, .board-tabs::-webkit-scrollbar { display: none; }
    .board-topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 6px 0; margin-bottom: 6px; }
    /* Доски: столбец почти во всю ширину, листаются свайпом (перебиваем few-cols и базовую) */
    .board-columns .board-col, .board-columns.few-cols .board-col, #labelsColumns .board-col { flex: 0 0 86vw; min-width: 0; max-width: 86vw; }
    .board-columns { scroll-snap-type: x mandatory; }
    .board-columns .board-col { scroll-snap-align: start; }
    /* Плитки продаж и карточки демо — в один столбец */
    #soldGrid, #lostGrid, #aiManagersDemo { grid-template-columns: 1fr !important; }
    /* Таблицы склада/заказов: скролл внутри карточки, шрифт чуть меньше */
    table { font-size: 12px; }
    .page-title { font-size: 20px; }
    /* Кнопки действий на карточке доски — крупнее и переносятся */
    .card-actions { flex-wrap: wrap; gap: 6px; }
    .card-actions .snooze-btn { padding: 8px 10px; font-size: 12px; }
  }
  .inbox-thread { display: flex; flex-direction: column; overflow-y: auto; padding: 14px; gap: 8px; flex: 1; }
  .bubble { max-width: 70%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4; }
  .bubble.in { align-self: flex-start; background: var(--hover); }
  .bubble.out { align-self: flex-end; background: var(--accent); color: white; }
  .bubble .meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
  .bubble.out .meta { color: #dbe4ff; }
  .bubble.sys { align-self: center; max-width: 92%; background: var(--warn-bg, #fff7e0); color: var(--text); border: 1px dashed var(--warn, #b8860b); font-size: 12px; font-style: italic; text-align: center; padding: 6px 12px; }
  .bubble.sys .meta { color: var(--muted); text-align: center; }
  .bubble.avito { align-self: center; max-width: 92%; background: var(--surface2, #f1f3f6); color: var(--muted); border: 1px solid var(--border); font-size: 12px; text-align: center; padding: 6px 12px; }
  .bubble.avito .meta { color: var(--muted); text-align: center; }
  .empty { padding: 20px; color: var(--muted); font-size: 13px; text-align: center; }
  .inbox-orders { border-left: 1px solid var(--border); overflow-y: auto; padding: 12px; }
  .inbox-orders h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
  .order-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 12px; }
  .order-card .status { color: var(--ok); font-weight: 600; }
  .order-card .row2 { color: var(--muted); margin-top: 4px; }
  .event-card { flex: 0 0 auto; min-width: 190px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; }
  .event-card.return { border-color: #fde68a; background: var(--warn-bg); }
  .event-card .arrow { color: var(--muted); }
  .event-card .time { color: #6b7280; font-size: 10px; margin-top: 4px; }
  /* Сопоставление */
  .match-wrap { display: grid; grid-template-columns: 360px 1fr; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; height: calc(100vh - 20px); }
  .match-list-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
  .match-list-col .dialogs-list { flex: 1; overflow-y: auto; }
  .match-pane-col { overflow-y: auto; padding: 16px; min-height: 0; min-width: 0; }
  .match-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
  .match-row:hover { background: var(--hover); }
  .match-row.active { background: var(--active-soft); }
  .match-row img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--bg); flex: 0 0 auto; }
  .match-row .t { flex: 1; min-width: 0; }
  .match-row .t .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .match-row .t .sub { color: var(--muted); font-size: 11px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .match-row .linkmark { flex: 0 0 auto; font-size: 12px; }
  .match-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 12px; }
  .match-tile { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 12px; display: flex; flex-direction: column; }
  .match-tile img { width: 100%; height: 130px; object-fit: contain; border-radius: 8px; background: var(--bg); margin-bottom: 8px; }
  .match-tile .name { font-weight: 600; overflow-wrap: anywhere; }
  .match-tile .sub { color: var(--muted); margin-top: 3px; font-size: 11px; }
  .match-tile .actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
  .match-tile .actions .btn { flex: 1; font-size: 12px; }
  @media (max-width: 900px) { .match-wrap { grid-template-columns: 1fr; height: auto; } .match-pane-col { border-top: 1px solid var(--border); } }
