/* BingX Scout — дизайн-система (23.10, навык ui-ux-pro-max): Minimalism & Swiss Style, плотный дашборд.
   Шрифт IBM Plex Sans (финансы, кириллица). Цвета — только через токены ниже. */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  /* поверхности и текст */
  --bg: #f5f7fb; --panel: #ffffff; --panel-2: #f8fafc; --ink: #0f172a; --ink-2: #334155; --muted: #64748b;
  --line: #e2e8f0; --line-2: #cbd5e1;
  /* бренд */
  --navy: #0b1530; --navy-2: #13213f; --navy-line: rgba(255,255,255,.08); --navy-text: #a9b6cf;
  --accent: #2354e6; --accent-hover: #1d47c5; --accent-soft: #eaf0ff; --accent-ink: #1a3fb0;
  /* состояния */
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fef3e2; --bad: #b91c1c; --bad-soft: #fdecec;
  --info: #0369a1; --info-soft: #e6f3fb;
  /* тиры лидов (как цвета строк в Google-таблице, мягче) */
  --tier-a: #effaf2; --tier-b: #fffaeb; --tier-c: #f6f7f9; --tier-a-mark: #22c55e; --tier-b-mark: #f59e0b; --tier-c-mark: #94a3b8;
  --bx: #2354e6;
  /* площадки */
  --tg: #229ed9; --yt: #e62117;
  /* форма */
  --r: 10px; --r-sm: 7px; --shadow-sm: 0 1px 2px rgba(15,23,42,.06); --shadow: 0 8px 28px rgba(15,23,42,.12);
  --ease: cubic-bezier(.2,.7,.2,1); --t: 160ms;
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); display: flex;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button, summary, [data-i], .conv, .mode, label:has(input) { cursor: pointer; }
button { font: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ------------------------------------------------------------------ боковое меню */
.side { width: 240px; flex: none; background: var(--navy); color: var(--navy-text); display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0; border-right: 1px solid #060d20; }
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px 18px; color: #fff; }
.brand b { font-weight: 600; letter-spacing: -.01em; }
.brand small { display: block; color: #7f8db0; font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
nav { flex: 1; overflow: auto; padding: 6px 10px; }
nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px; color: var(--navy-text);
  font-weight: 500; transition: background var(--t) var(--ease), color var(--t) var(--ease); margin-bottom: 1px; }
nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
nav a.on { background: rgba(35,84,230,.22); color: #fff; box-shadow: inset 2px 0 0 #6b8cff; }
nav a .ic { display: flex; }
nav a .cnt { margin-left: auto; font-size: 11px; font-weight: 600; background: #ef4444; color: #fff; border-radius: 10px;
  padding: 1px 7px; line-height: 16px; }
nav .sep { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #5d6b8c; padding: 18px 11px 6px; }
.side-foot { font-size: 12px; color: #6d7b9c; padding: 14px 18px; border-top: 1px solid var(--navy-line); line-height: 1.45; }

/* переключатель площадки */
.plat-sw { display: grid; grid-template-columns: 1fr 1fr; margin: 0 14px 12px; background: var(--navy-2); border-radius: 9px; padding: 3px;
  border: 1px solid var(--navy-line); }
.plat-sw button { border: 0; background: none; color: var(--navy-text); padding: 7px 0; border-radius: 7px; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 6px; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.plat-sw button:hover { color: #fff; }
.plat-sw button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow-sm); }
.plat-sw button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tg); }
.plat-sw button[data-k="yt"]::before { background: var(--yt); }

/* ------------------------------------------------------------------ шапка и контент */
main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  min-height: 64px; }
.top h1 { font-size: 19px; font-weight: 600; letter-spacing: -.015em; margin: 0; display: flex; align-items: center; gap: 10px; }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.burger { display: none; border: 0; background: none; padding: 6px; color: var(--ink); }
#view { flex: 1; overflow: auto; padding: 22px 28px 48px; }

/* ------------------------------------------------------------------ базовые компоненты */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 12px; font-weight: 600; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; }

.btn { border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: var(--r-sm); padding: 7px 13px;
  font-weight: 500; display: inline-flex; align-items: center; gap: 6px; min-height: 34px;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.btn:hover { border-color: #94a3b8; background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(35,84,230,.3); }
.btn.pri:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.bad { color: var(--bad); }
.btn.bad:hover { background: var(--bad-soft); border-color: #f3b4b4; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; min-height: 28px; }
.btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

input, select, textarea { font: inherit; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 10px; min-height: 34px;
  background: #fff; color: var(--ink); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,84,230,.15); }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--accent); width: 15px; height: 15px; }
textarea { width: 100%; resize: vertical; }
::placeholder { color: #94a3b8; }

.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 500; line-height: 18px;
  background: #eef1f6; color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.blue { background: var(--accent-soft); color: var(--accent-ink); }
.mock { font-size: 11.5px; font-weight: 500; background: var(--panel-2); color: var(--muted); border: 1px dashed var(--line-2);
  border-radius: 6px; padding: 2px 8px; }

.kpi b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; display: block; line-height: 1.2; }
.kpi span { color: var(--muted); font-size: 12.5px; }
a.card.kpi { color: var(--ink); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
a.card.kpi:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,84,230,.08); }

.plat { font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 6px; color: #fff; }
.plat.tg, .plat-tag.tg { background: var(--tg); } .plat.yt, .plat-tag.yt { background: var(--yt); }
.plat-tag { font-size: 11px; font-weight: 600; border-radius: 5px; padding: 2px 8px; color: #fff; letter-spacing: .01em; }

/* вкладки разделов (в «Сообщениях») */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500;
  white-space: nowrap; margin-bottom: -1px; transition: color var(--t) var(--ease), border-color var(--t) var(--ease); }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { font-size: 11px; color: var(--muted); margin-left: 5px; }

/* переключатель из двух вариантов (Отправка / Поиск) */
.seg-sw { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(130px, 1fr); background: #e9edf4; border-radius: 9px; padding: 3px; }
.seg-sw button { border: 0; background: none; color: var(--ink-2); padding: 7px 16px; border-radius: 7px; font-weight: 600;
  transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.seg-sw button:hover { color: var(--ink); }
.seg-sw button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-sw .n { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }

/* ------------------------------------------------------------------ выпадающие списки (все фильтры) */
.dd { position: relative; }
.dd summary { list-style: none; }
.dd summary::-webkit-details-marker { display: none; }
.dd summary.btn { gap: 6px; }
.dd[open] summary.btn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(35,84,230,.12); }
.dd summary.on { border-color: #b8c8f8; background: var(--accent-soft); color: var(--accent-ink); }
.dd-in { position: absolute; z-index: 6; top: calc(100% + 6px); left: 0; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px; min-width: 230px; max-height: 380px; overflow: auto; box-shadow: var(--shadow);
  display: grid; gap: 1px; animation: dd-in 140ms var(--ease); }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } }
.dd-in .row { padding: 4px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dd-in label { display: flex; gap: 9px; align-items: center; padding: 6px 8px; border-radius: 6px; transition: background var(--t); }
.dd-in label:hover { background: var(--panel-2); }
.dd-in label .small { margin-left: auto; font-feature-settings: "tnum" 1; }

/* ------------------------------------------------------------------ таблицы */
.tbl-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; box-shadow: var(--shadow-sm); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; z-index: 1; border-bottom: 1px solid var(--line-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-feature-settings: "tnum" 1; }
tbody tr[data-i], tbody tr[data-id], tbody tr[data-b] { transition: background var(--t) var(--ease); }
tbody tr[data-i]:hover td { background-image: linear-gradient(rgba(15,23,42,.035), rgba(15,23,42,.035)); }
/* тир: мягкая заливка строки и цветная метка слева */
tr.tA td { background-color: var(--tier-a); } tr.tB td { background-color: var(--tier-b); } tr.tC td { background-color: var(--tier-c); }
tr.tA td:first-child { box-shadow: inset 3px 0 0 var(--tier-a-mark); }
tr.tB td:first-child { box-shadow: inset 3px 0 0 var(--tier-b-mark); }
tr.tC td:first-child { box-shadow: inset 3px 0 0 var(--tier-c-mark); }
tr.bx td:first-child { box-shadow: inset 3px 0 0 var(--bx); }
td b { font-weight: 600; }
td.why { white-space: normal; min-width: 180px; max-width: 420px; font-size: 12.5px; color: var(--ink-2); }
.more { text-align: center; padding: 14px; border-top: 1px solid var(--line); }
.leads td:nth-child(1) { white-space: normal; min-width: 210px; max-width: 340px; }
.leads td:nth-child(2) { white-space: normal; min-width: 110px; max-width: 170px; color: var(--ink-2); }
.leads td:nth-child(3) { white-space: normal; max-width: 220px; }
.leads td.ctc { white-space: normal; min-width: 170px; max-width: 250px; }

/* ------------------------------------------------------------------ карточка лида и модальные окна */
.drawer { position: fixed; inset: 0; background: rgba(11,21,48,.38); display: none; z-index: 20; backdrop-filter: blur(1px); }
.drawer.on { display: block; animation: fade 160ms var(--ease); }
.drawer-in { position: absolute; right: 0; top: 0; bottom: 0; width: min(580px, 100%); background: var(--panel); overflow: auto;
  padding: 24px 26px 32px; box-shadow: -18px 0 40px rgba(11,21,48,.18); animation: slide 220ms var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer-in h2 { font-size: 20px; letter-spacing: -.015em; margin: 14px 0 4px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 6px; }
.kv div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.kv b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.kv span { font-size: 12px; color: var(--muted); }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }

.modal { position: fixed; inset: 0; background: rgba(11,21,48,.45); display: none; z-index: 30; place-items: center; backdrop-filter: blur(2px); }
.modal.on { display: grid; animation: fade 160ms var(--ease); }
.modal-in { background: var(--panel); border-radius: 14px; padding: 24px; width: min(660px, 94vw); max-height: 88vh; overflow: auto;
  box-shadow: 0 24px 60px rgba(11,21,48,.28); animation: pop 200ms var(--ease); }
.modal-in > h2:first-child { font-size: 18px; margin-bottom: 16px; }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }

/* ------------------------------------------------------------------ воронка */
/* колонки в один ряд; при прокрутке вбок колонка встаёт к краю целиком, название не обрезается */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 12px; overflow-x: auto;
  padding-bottom: 10px; scroll-snap-type: x mandatory; scroll-padding: 0; }
.kanban .col { scroll-snap-align: start; }
.col { background: #eef1f6; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 140px; }
.col h4 { margin: 2px 4px 6px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; color: var(--ink); }
.col h4 .muted { font-weight: 600; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; font-size: 12.5px;
  box-shadow: var(--shadow-sm); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.chip:hover { border-color: var(--line-2); box-shadow: 0 3px 10px rgba(15,23,42,.07); }
.chip b { font-weight: 600; font-size: 13px; }
.chip.flag { border-color: #f3b4b4; background: #fff7f7; }

/* ------------------------------------------------------------------ входящие */
.inbox { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100vh - 170px); min-height: 460px; }
.list { overflow: auto; }
.conv { padding: 12px 14px; border-bottom: 1px solid var(--line); transition: background var(--t) var(--ease); }
.conv:hover { background: var(--panel-2); }
.conv.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.conv .t { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.chat { display: flex; flex-direction: column; }
.msgs { flex: 1; overflow: auto; padding: 12px 2px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; padding: 9px 13px; border-radius: 14px 14px 14px 4px; background: #f1f4f9; border: 1px solid var(--line); line-height: 1.5; }
.msg.me { align-self: flex-end; background: var(--accent-soft); border-color: #d6e0fd; border-radius: 14px 14px 4px 14px; }
.msg small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; }

/* ------------------------------------------------------------------ фильтры и настройки */
.rule { display: grid; grid-template-columns: 1fr 130px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.card .rule:last-of-type { border-bottom: 0; }
.rule input { width: 100%; text-align: right; }
.rule .d { font-size: 12.5px; color: var(--muted); }
.rule.changed input { border-color: var(--accent); background: var(--accent-soft); }
.words { display: flex; flex-wrap: wrap; gap: 5px; }
.words span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 12.5px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch i { position: absolute; inset: 0; background: #cbd5e1; border-radius: 11px; transition: background var(--t) var(--ease); pointer-events: none; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,.25); transition: left var(--t) var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 18px; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode { border: 1.5px solid var(--line); border-radius: var(--r); padding: 16px; background: var(--panel); }
.mode.on { border-color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------------ аналитика */
.bar { height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.funnel div { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.funnel span { width: 160px; font-size: 13px; color: var(--ink-2); }
.funnel .bar { flex: 1; height: 24px; }
.funnel b { width: 64px; text-align: right; font-weight: 600; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; font-weight: 500;
  padding: 11px 18px; border-radius: 10px; display: none; z-index: 40; box-shadow: var(--shadow); }
.toast.on { display: block; animation: toast 200ms var(--ease); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ------------------------------------------------------------------ телефон и планшет */
.tabbar, .side-back, .only-m { display: none; }
.logout { display: block; margin-top: 10px; background: none; border: 1px solid var(--navy-line); color: var(--navy-text);
  border-radius: 7px; padding: 6px 12px; font-size: 12.5px; }
.logout[hidden] { display: none; }
.logout:hover { color: #fff; border-color: rgba(255,255,255,.25); }
.lead-cards { display: grid; gap: 10px; }
.lead-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px;
  box-shadow: var(--shadow-sm); border-left: 4px solid var(--line-2); }
.lead-card.tA { border-left-color: var(--tier-a-mark); } .lead-card.tB { border-left-color: var(--tier-b-mark); }
.lead-card.tC { border-left-color: var(--tier-c-mark); } .lead-card.bx { border-left-color: var(--bx); }
.lead-card:active { background: var(--panel-2); }
.lc-top { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.lc-name b { font-size: 15px; line-height: 1.3; }
.lc-score { text-align: center; min-width: 44px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; }
.lc-score b { display: block; font-size: 16px; line-height: 1.2; } .lc-score span { font-size: 11px; color: var(--muted); }
.lc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lc-foot { display: flex; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; }
.lc-foot .ctc { min-width: 0; font-size: 13px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 820px) {
  body { display: block; }
  .side { position: fixed; left: -260px; z-index: 35; transition: left 220ms var(--ease); box-shadow: var(--shadow); padding-top: env(safe-area-inset-top); }
  .side.on { left: 0; }
  .side-back { display: block; position: fixed; inset: 0; z-index: 34; background: rgba(11,21,48,.45); opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); }
  .side-back.on { opacity: 1; pointer-events: auto; }
  .burger { display: flex; }
  main { height: auto; min-height: 100vh; }
  .top { position: sticky; top: 0; z-index: 15; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; min-height: 56px; }
  .top h1 { font-size: 17px; }
  .top-right .lbl { display: none; }
  .top-right .btn { min-width: 40px; justify-content: center; padding: 7px 10px; }
  .top-right .mock { display: none; }
  #view { padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); overflow: visible; }
  .g2, .g3, .g4, .modes { grid-template-columns: 1fr; }
  .kv { grid-template-columns: repeat(2, 1fr); }
  .btn, input, select { min-height: 42px; }
  input, select, textarea { font-size: 16px; }  /* iOS не увеличивает страницу при вводе */
  .only-m { display: inline-flex; }

  /* нижнее меню */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255,255,255,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; color: var(--muted);
    font-size: 11px; font-weight: 500; min-height: 48px; justify-content: center; border-radius: 8px; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a:active { background: var(--panel-2); }
  .tabbar .ic { position: relative; display: flex; }
  .tabbar .cnt { position: absolute; top: -4px; right: -10px; font-size: 10px; font-weight: 600; background: #ef4444; color: #fff;
    border-radius: 9px; padding: 0 5px; line-height: 16px; }

  /* лиды: фильтры свёрнуты под кнопку */
  .filters { gap: 8px; }
  .filters .dd[data-f], .filters #sortDD, .filters .f-extra { display: none; }
  .filters.open .dd[data-f], .filters.open #sortDD, .filters.open .f-extra { display: block; }
  .filters.open #q { width: 100%; order: 5; }
  .filters .dd { flex: 1 1 auto; }
  .filters .dd summary.btn { width: 100%; justify-content: space-between; }
  .dd-in { position: fixed; left: 12px !important; right: 12px !important; top: auto !important; bottom: calc(76px + env(safe-area-inset-bottom));
    max-height: 60vh; min-width: 0; z-index: 40; box-shadow: 0 -8px 40px rgba(11,21,48,.25); }
  .dd-in label { padding: 10px 8px; font-size: 15px; }

  /* входящие: два экрана */
  .inbox { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .inbox.m-list .chat { display: none; }
  .inbox.m-chat .list { display: none; }
  .inbox.m-chat .chat { min-height: calc(100vh - 220px); }
  .msg { max-width: 88%; }

  /* счётчики в ряд, а не столбиком */
  .grid.g3:has(> .kpi) { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
  .grid.g3:has(> .kpi) .card { padding: 12px; }
  .grid.g3:has(> .kpi) .kpi b, .kpi b { font-size: 20px; }
  .grid.g3:has(> .kpi) .kpi span { font-size: 11.5px; }
  /* воронка: колонка почти на всю ширину, листается вбок */
  .kanban { grid-auto-columns: 82vw; }

  /* карточка лида и окна — на весь экран */
  .drawer { z-index: 36; } .modal { z-index: 38; } .toast { z-index: 45; }
  .drawer-in { width: 100%; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .modal { place-items: end center; }
  .modal-in { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
