/* Основа интерфейса: токены (светлая и тёмная тема, как в мобильном Битрикс24), каркас и общие
   компоненты. Стили экранов — в css/screens/*.css. */

:root {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --surface-3: #eef1f3;
  --text: #1f2329;
  --text-2: #4b545f;
  --text-3: #7d8691;
  --text-4: #a8adb4;
  --line: #e8eaec;
  --line-2: #d9dde1;
  --link: #2066b0;
  --primary: #2f80ed;
  --primary-press: #236bd0;
  --primary-soft: #e8f1fe;
  --accent: #2fc6f6;
  --accent-soft: #e5f9ff;
  --success: #29ad49;
  --success-soft: #e3f6e8;
  /* Зелёный для текста и для заливки под белым текстом (≥ 4,5:1): --success на белом — 2,9:1. */
  --success-strong: #1e7f36;
  --success-fill: #1e7f36;
  --danger: #ff5752;
  --danger-text: #e4362f;
  --danger-soft: #ffeceb;
  --warning-text: #9f6a00;
  --warning-soft: #fff3d6;
  --green-badge: #7bc72f;
  --chip-on: #3d454f;
  --todo-bg: #fff8e5;
  --overlay: rgba(10, 14, 20, 0.36);
  --sheet-bg: #ffffff;
  --pop-bg: rgba(255, 255, 255, 0.98);
  --chat-bg: #dfe6ec;
  --bubble-in: #ffffff;
  --bubble-out: #d9f2ff;
  --bubble-robot: #e7f5d8;
  --bubble-ai: #eee7ff;
  --bubble-phone: #fff2d4;
  --bubble-note: #fff7d1;
  --tabbar-bg: rgba(255, 255, 255, 0.94);
  --topbar-tint: color-mix(in srgb, var(--brand, #2fc6f6) 16%, #ffffff);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --tabbar-h: 52px;
  /* Нижняя панель ближе к краю: под ней на iPhone остаётся место полоски «домой», но не весь отступ
     безопасной зоны (34 px) — подписи стоят ниже, как в iOS 26. Без «чёлки» снизу — без отступа. */
  /* Сверху safe-area (≈59 px на iPhone с Dynamic Island) включает и пустой зазор под строкой с часами:
     шапку поднимаем на 10 px в этот зазор — часы и значки iOS она не задевает. */
  --topbar-pad: max(calc(var(--safe-top) - 10px), 0px);
  --tabbar-pad: max(calc(var(--safe-bottom) - 20px), 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --sidebar-w: 236px;
  --brand: #2fc6f6;
  /* Старые имена — пока экраны переводятся на новые токены */
  --red: var(--danger);
  --green: #7bd500;
  --green-2: var(--success);
  --bg-2: var(--surface-2);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111214;
    --surface: #1d1e21;
    --surface-2: #232529;
    --surface-3: #2a2d31;
    --text: #f2f3f5;
    --text-2: #c4c8ce;
    --text-3: #8d939b;
    --text-4: #6b7179;
    --line: #2c2f33;
    --line-2: #3a3e43;
    --link: #5aa2f8;
    --primary: #3b8af0;
    --primary-press: #2f77d6;
    --primary-soft: #1b2b42;
    --accent-soft: #15303a;
    --success-soft: #17301f;
    --success-strong: #3ccb64;
    --danger-soft: #3a1b1b;
    --danger-text: #ff7b76;
    --warning-text: #f0b44c;
    --warning-soft: #352a12;
    --chip-on: #d7dbe0;
    --todo-bg: #2f2a18;
    --overlay: rgba(0, 0, 0, 0.55);
    --sheet-bg: #1d1e21;
    --pop-bg: rgba(40, 42, 46, 0.98);
    --chat-bg: #0f1012;
    --bubble-in: #24262a;
    --bubble-out: #193650;
    --bubble-robot: #1f3320;
    --bubble-ai: #2c2346;
    --bubble-phone: #3a2f17;
    --bubble-note: #3a3418;
    --tabbar-bg: rgba(24, 25, 28, 0.94);
    --topbar-tint: color-mix(in srgb, var(--brand, #2fc6f6) 14%, #111214);
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-card: none;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #111214; --surface: #1d1e21; --surface-2: #232529; --surface-3: #2a2d31; --text: #f2f3f5; --text-2: #c4c8ce;
  --text-3: #8d939b; --text-4: #6b7179; --line: #2c2f33; --line-2: #3a3e43; --link: #5aa2f8; --primary: #3b8af0;
  --primary-press: #2f77d6; --primary-soft: #1b2b42; --accent-soft: #15303a; --success-soft: #17301f; --success-strong: #3ccb64; --danger-soft: #3a1b1b;
  --danger-text: #ff7b76; --warning-text: #f0b44c; --warning-soft: #352a12; --chip-on: #d7dbe0; --todo-bg: #2f2a18;
  --overlay: rgba(0, 0, 0, 0.55); --sheet-bg: #1d1e21; --pop-bg: rgba(40, 42, 46, 0.98); --chat-bg: #0f1012;
  --bubble-in: #24262a; --bubble-out: #193650; --bubble-robot: #1f3320; --bubble-ai: #2c2346; --bubble-phone: #3a2f17;
  --bubble-note: #3a3418; --tabbar-bg: rgba(24, 25, 28, 0.94); --topbar-tint: color-mix(in srgb, var(--brand, #2fc6f6) 14%, #111214);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5); --shadow-card: none; color-scheme: dark;
}

* { box-sizing: border-box; }
/* Зума нет нигде — CRM работает как приложение (решение владельца): жесты только прокрутка, без щипка и двойного тапа */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; height: 100%; background: var(--bg); touch-action: pan-x pan-y; }
/* Высота экрана — по реальной видимой области (100% окна), а не 100dvh: dvh не уменьшается под клавиатуру, и в
   iOS 26 низ экрана рисовался под полупрозрачной клавиатурой и просвечивал сквозь неё. То же у шторок ниже. */
body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.35 var(--font); -webkit-font-smoothing: antialiased; }
button, a, [role='button'], .tap { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
a { color: var(--link); text-decoration: none; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Вспомогательное поле primeKeyboard — в видимой области: поле за краем экрана iOS может не принять как цель для клавиатуры. */
#focus-proxy { position: fixed; top: 30%; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; font-size: 16px; caret-color: transparent; pointer-events: none; }

svg.ic { width: 24px; height: 24px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.ic.sm { width: 20px; height: 20px; }
svg.ic.xs { width: 16px; height: 16px; }
svg.ic.xxs { width: 12px; height: 12px; }

.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.hidden { display: none !important; }

/* Приложение с экрана «Домой» на телефоне: размытие iOS 26 снимает закреплённая непрозрачная шапка
   (.topbar/.detail-head — sticky), поэтому шапка стоит сразу под строкой с часами, без лишней пустой полосы.
   Отступ ровно по safe-area: внутрь строки с часами шапку не поднимаем — там она снова попала бы под эффект. */
@media (display-mode: standalone) and (pointer: coarse) {
  :root { --topbar-pad: var(--safe-top); }
}

/* ---------- переключатель-сегмент (как UISegmentedControl в iOS): «Списком | На карте» и подобные ----------
   Надписи по центру своей половины, выбранная — светлая «таблетка», заметная и в тёмной теме. */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(118, 118, 128, 0.14); }
.seg > button { display: flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; font-size: 15px; white-space: nowrap; touch-action: manipulation; -webkit-user-select: none; user-select: none; transition: background 150ms var(--ease-out); }
.seg > button.on { background: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .seg { background: rgba(118, 118, 128, 0.24); }
  :root:not([data-theme='light']) .seg > button.on { background: #636366; box-shadow: none; }
}
:root[data-theme='dark'] .seg { background: rgba(118, 118, 128, 0.24); }
:root[data-theme='dark'] .seg > button.on { background: #636366; box-shadow: none; }

/* ---------- бренд: логотип и переключатель (ui.js BrandLogo, BrandSwitch) ---------- */
.brand-switch { display: inline-flex; align-items: center; gap: 6px; height: 44px; min-width: 0; max-width: 100%; color: var(--text-3); touch-action: manipulation; -webkit-user-select: none; user-select: none; }
/* Стрелка выбора бренда не сжимается: места мало — уменьшается логотип, а не она. */
.brand-switch > svg.ic { flex: none; }
.brand-switch:disabled { opacity: 1; cursor: default; }
.brand-switch:active:not(:disabled) { opacity: 0.6; }
.brand-switch.on-dark { color: rgba(255, 255, 255, 0.7); }
/* Логотип одной «видимой площади» (ui.js LogoBox): ширина = √(площадь × пропорция) в пределах высоты; --r —
   пропорция рисунка без прозрачных полей. Площадь и пределы высоты — у места показа. */
.brand-logo-box { --logo-area: 2600; --logo-h-min: 12px; --logo-h-max: 34px; position: relative; display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; aspect-ratio: var(--r); width: calc(24px * var(--r)); max-width: calc(var(--logo-h-max) * var(--r)); }
@supports (width: calc(sqrt(4) * 1px)) {
  .brand-logo-box { width: clamp(calc(var(--logo-h-min) * var(--r)), calc(sqrt(var(--logo-area) * var(--r)) * 1px), calc(var(--logo-h-max) * var(--r))); }
}
.brand-logo-box > .brand-logo { position: absolute; display: block; max-width: none; height: auto; }
.brand-logo.to-white { filter: brightness(0) invert(1); }
.brand-logo.only-dark { filter: brightness(0); }
.brand-logos { display: flex; min-width: 0; }
.brand-logos .for-dark { display: none; }
.brand-name { font-size: 20px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-switch.on-dark .brand-name { color: #fff; }
.brand-icon { display: block; flex: none; width: 32px; height: 32px; border-radius: 9px; object-fit: cover; outline: 0.5px solid var(--line-2); outline-offset: -0.5px; }
.brand-icon.sm { width: 24px; height: 24px; border-radius: 7px; }
.brand-mark { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 9px; font-size: 15px; font-weight: 600; }
.brand-mark.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 12px; }
/* Значок бренда слева от заголовка (мессенджер, задачи): видно, чьи это данные; тап — сменить бренд. */
.brand-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: 0 2px 0 -6px; border-radius: 12px; touch-action: manipulation; }
.brand-btn:disabled { opacity: 1; cursor: default; }
.brand-btn:active:not(:disabled) { opacity: 0.6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .brand-logos .for-light { display: none; }
  :root:not([data-theme='light']) .brand-logos .for-dark { display: block; }
  :root:not([data-theme='light']) .brand-logo.only-dark { filter: none; }
}
:root[data-theme='dark'] .brand-logos .for-light { display: none; }
:root[data-theme='dark'] .brand-logos .for-dark { display: block; }
:root[data-theme='dark'] .brand-logo.only-dark { filter: none; }

/* ---------- каркас ---------- */
/* Экран закреплён, как карточки и шторки: в iOS 26 закреплённые слои ужимаются над клавиатурой, и экран — вместе
   с ними (раньше один он оставался во всю высоту и просвечивал под полупрозрачной клавиатурой). */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
/* Открыта клавиатура на iPhone (app.js fitKeyboardViewport): body — один слой ровно по видимой области над
   клавиатурой. transform делает его опорой для всех position: fixed внутри (карточки, шторки, меню, затемнение),
   поэтому отдельных правил для них не нужно. Нижняя панель, «+» и капсула связи на это время прячутся. */
:root.kb-open body { position: fixed; left: 0; right: 0; top: 0; height: var(--vvh); min-height: 0; overflow: hidden; transform: translateY(var(--vvt)); }
:root.kb-open .app { inset: 0; }
:root.kb-open .sheet { max-height: calc(var(--vvh) - 12px); padding-bottom: 0; }
:root.kb-open .sheet.tall { height: calc(var(--vvh) - 12px); }
:root.kb-open .sheet-foot { padding-bottom: 10px; }
:root.kb-open .tabbar, :root.kb-open .fab, :root.kb-open .float-comm { display: none; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.topbar { padding: var(--topbar-pad) 16px 0; background: var(--bg); flex: none; }
/* iOS 26 в приложении с экрана «Домой» размывает верх страницы (scroll edge effect, Liquid Glass) — шапка
   с логотипом и кнопками оказывалась под дымкой. WebKit не рисует этот эффект, если у верхнего края стоит
   закреплённый (sticky/fixed) непрозрачный блок во всю ширину без backdrop-filter: его цвет он продлевает
   под строку с часами. Поэтому шапки списков и карточек — sticky с фоном. На раскладку не влияет:
   прокручивается не страница, а список под шапкой. */
.topbar, .detail-head { position: sticky; top: 0; z-index: 4; }
.topbar-row { display: flex; align-items: center; height: 44px; gap: 2px; }
.topbar-title { font-size: 20px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--text-3); position: relative; flex: none; transition: background 120ms, transform 120ms var(--ease-out); }
.icon-btn:active { background: color-mix(in srgb, var(--text) 8%, transparent); transform: scale(0.94); }
.icon-btn.on { color: var(--primary); }
.icon-btn.sm { width: 36px; height: 36px; }

/* Сверху 6 px — под счётчик на чипе (он выступает над чипом, а прокрутка по горизонтали обрезает выступ). */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font-size: 16px; display: inline-flex; align-items: center; gap: 6px; position: relative; transition: transform 100ms var(--ease-out); }
.chip:active { transform: scale(0.97); }
.chip.on { border: 1.5px solid var(--chip-on); color: var(--text); }
/* Цель касания чипа — 44 px, хотя сам чип 36 px */
.chip::before { content: ''; position: absolute; inset: -4px -3px; }
.chip .cnt { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 600; padding: 1px 6px; border: 2px solid var(--bg); line-height: 14px; }
.chip .cnt.gray { background: #9aa3ad; }
.chip.pill { border-radius: 999px; height: 34px; font-size: 15px; }
.chip.pill.solid { background: var(--primary); border-color: var(--primary); color: #fff; }

.tabbar { flex: none; display: flex; background: var(--tabbar-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 0.5px solid var(--line-2); padding-bottom: var(--tabbar-pad); z-index: 20; }
.tabbar a { flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-4); font-size: 11px; position: relative; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg.ic { color: var(--primary); }
.tabbar .tb-badge { position: absolute; top: 4px; left: calc(50% + 4px); background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 600; padding: 1px 6px; border: 1.5px solid var(--surface); line-height: 14px; }

.fab { position: absolute; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 16px; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 38%, transparent); z-index: 15; transition: transform 120ms var(--ease-out); }
.fab:active { transform: scale(0.92); }
/* Телефон: при прокрутке списка вниз строка заголовка («CRM» и кнопки) уезжает, чипсы остаются —
   списку больше места; прокрутка вверх возвращает её (тот же сигнал, что прячет «+», app.js). */
@media (max-width: 1023px) {
  .screen > .topbar > .topbar-row { max-height: 44px; overflow: hidden; transition: max-height 220ms var(--ease-out), opacity 160ms var(--ease-out); }
  body.fab-away .screen > .topbar:has(> .chips) > .topbar-row { max-height: 0; opacity: 0; pointer-events: none; }
}
/* Прокрутка вниз прячет «+», чтобы он не закрывал кнопки связи и цены; прокрутка вверх — возвращает (app.js) */
.fab { transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out); }
body.fab-away .fab { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.fab svg.ic { width: 28px; height: 28px; stroke-width: 2; }

/* ---------- кнопки, поля форм ---------- */
.btn { height: 48px; border-radius: 12px; padding: 0 18px; font-size: 17px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform 100ms var(--ease-out), background 120ms, opacity 120ms; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-press); }
.btn.outline { border: 1.5px solid var(--primary); color: var(--text); background: var(--surface); }
.btn.ghost { color: var(--text-2); background: var(--surface-3); }
.btn.danger { color: #fff; background: var(--danger); }
.btn.sm { height: 38px; font-size: 15px; padding: 0 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.link-btn { color: var(--link); font-size: 16px; padding: 8px 0; }
.dashed { color: var(--text-4); font-size: 14px; border-bottom: 1px dashed currentColor; line-height: 1.15; padding: 10px 0 1px; }

.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.input, .select, .textarea { width: 100%; min-height: 46px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; background: var(--surface); outline: none; }
.textarea { min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.4; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.err { color: var(--danger-text); font-size: 14px; margin: 8px 0; }
.note { font-size: 13px; color: var(--warning-text); background: var(--warning-soft); padding: 8px 10px; border-radius: 8px; margin: 6px 0; line-height: 1.35; }

.toggle { position: relative; width: 51px; height: 31px; flex: none; }
.toggle input { position: absolute; top: -7px; left: -4px; width: calc(100% + 8px); height: calc(100% + 14px); opacity: 0; margin: 0; cursor: pointer; z-index: 1; } /* цель касания 59×45: сам переключатель 51×31 меньше нормы 44 px */
.toggle span { position: absolute; inset: 0; border-radius: 16px; background: var(--line-2); transition: background 160ms; }
.toggle span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 200ms var(--ease-out); }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::after { transform: translateX(20px); }

.checkbox { width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; flex: none; color: #fff; transition: background 120ms; }
.checkbox.on { background: var(--primary); border-color: var(--primary); }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; display: grid; place-items: center; }
.radio.on { border-color: var(--primary); }
.radio.on::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }

/* ---------- шторки ---------- */
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 60; animation: fade-in 200ms var(--ease-out); }
.backdrop.closing { animation: fade-out 200ms var(--ease-out) forwards; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: calc(100% - max(var(--safe-top), var(--topbar-pad)) - 24px); background: var(--sheet-bg); border-radius: 14px 14px 0 0; z-index: 61; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); animation: sheet-in 320ms var(--ease-sheet); }
.sheet.closing { animation: sheet-out 220ms var(--ease-out) forwards; }
/* Верх шторки — ниже размытой полосы iOS (как шапки), см. --topbar-pad. */
.sheet.tall { height: calc(100% - max(var(--safe-top), var(--topbar-pad)) - 24px); }
.sheet-handle { flex: none; height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; }
/* Шапка целиком (ручка + заголовок) — место, за которое шторку тянут вниз на телефоне */
.sheet-grab { flex: none; touch-action: none; }
.sheet-body { overscroll-behavior: contain; }
.sheet-handle::before { content: ''; width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); }
.sheet-head { flex: none; display: grid; grid-template-columns: minmax(64px, auto) 1fr minmax(64px, auto); align-items: center; padding: 0 12px 8px; min-height: 44px; }
.sheet-head .sh-l { justify-self: start; }
.sheet-head .sh-r { justify-self: end; }
/* Шапка без кнопок по бокам (меню оплаты, «Принять оплату») — пустые колонки место не держат, заголовок не режется */
.sheet-head:has(> .sh-l:empty):has(> .sh-r:empty) { grid-template-columns: 0 1fr 0; }
.sheet-title { text-align: center; font-size: 17px; font-weight: 600; padding: 0 4px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.sheet-head.left { grid-template-columns: 1fr auto; padding-left: 16px; }
.sheet-head.left .sheet-title { text-align: left; font-size: 18px; }
.sheet-act { color: var(--link); font-size: 17px; padding: 10px 4px; min-height: 44px; min-width: 44px; }
.sheet-act:disabled { color: var(--text-4); }
.sheet-act.strong { font-weight: 600; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 16px; flex: 1; min-height: 0; }
.sheet-foot { flex: none; padding: 10px 16px calc(10px + var(--safe-bottom)); border-top: 0.5px solid var(--line); background: var(--sheet-bg); }
.sheet-sub { color: var(--text-4); font-size: 16px; margin: 0 0 12px; }

.list-menu .mi { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; font-size: 17px; text-align: left; border-bottom: 0.5px solid var(--line); padding: 6px 0; }
.list-menu .mi:last-child { border-bottom: 0; }
.list-menu .mi:active { opacity: 0.6; }
.list-menu .mi > svg.ic { color: var(--text-2); }
.list-menu .mi .sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.list-menu .mi.hl { background: var(--accent-soft); margin: 0 -16px; padding: 6px 16px; width: calc(100% + 32px); }
.list-menu .mi:disabled { opacity: 0.5; }
.list-menu .mi .chev { color: var(--text-4); }
/* Плиток столько, сколько действий: колонки делятся поровну, пустых мест не остаётся. */
.tiles { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-bottom: 6px solid var(--surface-3); margin: 0 -16px 4px; }
.tiles button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 14px; font-size: 14px; color: var(--text); border-right: 0.5px solid var(--line); }
.tiles button:last-child { border-right: 0; }
.tiles button:active { opacity: 0.6; }

.menu-pop { position: fixed; z-index: 62; min-width: 260px; max-width: calc(100vw - 24px); background: var(--pop-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 14px; box-shadow: var(--shadow-pop); overflow: hidden; animation: pop-in 180ms var(--ease-out); transform-origin: top right; }
.menu-pop .mi { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 48px; width: 100%; font-size: 16px; text-align: left; border-bottom: 0.5px solid var(--line); }
.menu-pop .mi:last-child { border-bottom: 0; }
.menu-pop .mi:active { background: var(--surface-3); }
.menu-pop .mi svg.ic { color: var(--text-2); }
.menu-pop .mi.danger { color: var(--danger-text); }
.menu-pop .mi.danger svg.ic { color: var(--danger-text); }
.menu-pop .mi:disabled { opacity: 0.45; }
.menu-pop .sep { height: 8px; background: var(--surface-3); }
.menu-pop .menu-title { padding: 12px 16px 6px; font-size: 13px; color: var(--text-3); border-bottom: 0.5px solid var(--line); }
.menu-pop .mi .mi-sub { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-pop .mi:has(.mi-sub) { padding-top: 8px; padding-bottom: 8px; }
/* Окно у кнопки (компьютер) — без затемнения, как всплывающее меню */
.backdrop.clear { background: transparent; animation: none; }

/* Поиск и списки выбора */
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--surface-3); border-radius: 10px; padding: 0 10px; height: 40px; margin-bottom: 8px; color: var(--text-3); }
.searchbar input { flex: 1; border: 0; outline: none; background: transparent; height: 38px; min-width: 0; }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 6px 0; border-bottom: 0.5px solid var(--line); text-align: left; font-size: 17px; }
.pick-row:last-child { border-bottom: 0; }
.pick-row .pr-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); color: var(--text-3); display: grid; place-items: center; flex: none; }
.pick-row .sub { font-size: 13px; color: var(--text-3); }
/* Отступ сверху и снизу — для вариантов в 2–3 строки («A — желаемые клиенты, …»): однострочные держит min-height */
.pick-row.opt { min-height: 52px; padding: 10px 2px; }
.pick-row.opt.on { color: var(--link); }
.pick-row .pick-check { color: var(--primary); display: grid; place-items: center; }
/* Отклик касания и выбранный пункт: подложка на всю ширину шторки (за её отступами 16px), галочка «встаёт» на место. */
.pick-row { position: relative; isolation: isolate; }
.pick-row::before { content: ''; position: absolute; inset: 0 -16px; z-index: -1; background: transparent; transition: background-color 200ms ease-out; }
.pick-row:active::before { background: color-mix(in srgb, var(--text) 7%, transparent); transition: none; }
.pick-row.opt.picked::before { background: var(--primary-soft); transition: none; }
.pick-row .pick-check { animation: pick-in 140ms cubic-bezier(0.2, 0.9, 0.3, 1.25); }
@keyframes pick-in { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pick-row .pick-check { animation: none; } }
/* «Создать … «запрос»» под «Ничего не найдено» в выборе записи: иконка 20 px, запрос виден целиком (переносится) */
.btn.pick-create { height: auto; min-height: 48px; padding: 10px 16px; margin-top: -16px; line-height: 1.3; }
.btn.pick-create span { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.pick-chosen { display: flex; gap: 10px; overflow-x: auto; padding: 10px; border: 1px solid var(--line-2); border-radius: 12px; margin-bottom: 10px; min-height: 84px; align-items: center; }
.pick-chosen .pc { position: relative; width: 64px; flex: none; text-align: center; font-size: 12px; }
.pick-chosen .pc .x { position: absolute; top: -4px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
/* Картинка в строке выбора и в плитке выбранного — всегда в рамке, без растягивания на весь экран */
.pick-chosen .pr-ic { width: 40px; height: 40px; display: grid; place-items: center; }
.pick-row .pr-ic img, .pick-chosen .pr-ic img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.group-title { font-size: 13px; color: var(--text-3); margin: 14px 0 4px; }

/* ---------- стадии ---------- */
.stage-ribbon { display: flex; align-items: stretch; height: 38px; margin: 6px -16px 4px; }
.stage-ribbon .tail { width: 16px; flex: none; clip-path: polygon(0 0, 55% 0, 100% 50%, 55% 100%, 0 100%); }
.stage-arrow { position: relative; height: 38px; padding: 0 26px 0 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 500; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 4px 0 0 4px; max-width: 62%; margin-left: 8px; transition: transform 100ms var(--ease-out), filter 120ms; }
.stage-arrow:active { transform: scale(0.98); filter: brightness(0.95); }
.stage-arrow .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-next { flex: 1; min-width: 0; margin-left: 6px; display: block; line-height: 36px; padding: 0 10px; color: var(--text-4); font-size: 16px; background: var(--surface-2); border-bottom: 2px solid var(--next, var(--line-2)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
/* Тап по следующей стадии сразу переводит сделку — отклик на нажатие и плавная перекраска ленты */
.stage-next.quick { transition: background-color 150ms, color 150ms; }
.stage-next.quick:active { background: color-mix(in srgb, var(--next) 22%, var(--surface-2)); color: var(--text-2); }
.stage-arrow { transition: transform 100ms var(--ease-out), filter 120ms, background-color 220ms var(--ease-out); }
.stage-ribbon .tail { transition: background-color 220ms var(--ease-out); }
.stage-pick { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; width: 100%; text-align: left; }
.stage-pick .num { width: 28px; color: var(--text-4); text-align: center; font-size: 15px; flex: none; display: grid; place-items: center; }
.stage-pick .plate { flex: 1; min-width: 0; min-height: 48px; padding: 6px 30px 6px 16px; display: flex; flex-direction: column; justify-content: center; clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); border-radius: 8px 0 0 8px; transition: transform 100ms var(--ease-out); }
.stage-pick:active .plate { transform: scale(0.98); }
.stage-pick .plate .t { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-pick .plate .s { font-size: 14px; opacity: 0.85; }
.stage-pick .plate-o { flex: 1; min-width: 0; display: flex; }
.stage-pick .plate { position: relative; }
/* Обводка текущей стадии: clip-path срезает box-shadow, поэтому — drop-shadow на обёртке */
.stage-pick.current .plate-o { filter: drop-shadow(2px 0 0 var(--primary)) drop-shadow(-2px 0 0 var(--primary)) drop-shadow(0 2px 0 var(--primary)) drop-shadow(0 -2px 0 var(--primary)); }
.stage-pick.current .plate .t { font-weight: 600; }
.stage-pick .cur-mark { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; }
.stage-pick .cur-mark svg { animation: pick-in 140ms cubic-bezier(0.2, 0.9, 0.3, 1.25); }
@media (prefers-reduced-motion: reduce) { .stage-pick .cur-mark svg { animation: none; } }
.stage-pick.current .plate { padding-right: 52px; }
.stage-pick.all .plate { background: var(--surface); border: 1.5px solid var(--line-2); clip-path: none; border-radius: 8px; color: var(--text); }
.stage-pick.all.current .plate-o { filter: none; }
.stage-pick.all.current .plate { border-color: var(--primary); }
.stage-pick .flag-ok { color: #29ad49; }
.stage-pick .flag-fail { color: #ff5752; }

/* ---------- поля карточки (как в Битриксе: пустое — подпись на месте значения) ---------- */
.section { background: var(--surface); border-radius: var(--radius); margin: 10px 8px 0; padding: 0 16px 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-bottom: 0.5px solid var(--line); }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.section-foot { display: flex; gap: 16px; padding: 4px 0 10px; }
.frow { position: relative; display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 10px 0; border-bottom: 0.5px solid var(--line); width: 100%; text-align: left; }
.frow:last-child { border-bottom: 0; }
.frow .fbody { flex: 1; min-width: 0; }
.frow .flabel { font-size: 11px; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.frow .flabel .req { color: var(--danger); }
.frow .fvalue { font-size: 17px; color: var(--text); word-break: break-word; white-space: pre-wrap; }
.frow .fvalue a { color: var(--link); }
.frow .fempty { font-size: 17px; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.frow .fact { color: var(--text-4); flex: none; display: grid; place-items: center; width: 32px; height: 32px; }
.frow.tappable:active { background: color-mix(in srgb, var(--text) 4%, transparent); }
.frow .native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; -webkit-appearance: none; appearance: none; cursor: pointer; z-index: 1; border: 0; }
.frow .native::-webkit-date-and-time-value { text-align: left; }
/* Телефон: прозрачное поле ввода поверх строки (InlineField) — касание попадает прямо в него, клавиатура с первого тапа. */
.frow .finline.ftap { position: absolute; inset: 0; z-index: 1; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; opacity: 0; }
.frow .finline.ftap input, .frow .finline.ftap textarea { width: 100%; height: 100%; padding: 0; resize: none; caret-color: transparent; }
.frow .fvalue a { position: relative; z-index: 2; }
.frow .caret { color: var(--text-3); }
/* Подсказка под адресом: как его понял сайт (тот же разбор, что в корзине) */
.addr-sug { margin: 6px 0 4px; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--surface); }
.addr-sug-row { display: flex; gap: 8px; align-items: flex-start; width: 100%; padding: 10px 12px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.addr-sug-row + .addr-sug-row { border-top: 1px solid var(--line-2); }
.addr-sug-row svg.ic { flex: none; margin-top: 3px; color: var(--text-3); }
.addr-sug-row.on, .addr-sug-row:active { background: var(--primary-soft); }
.addr-sug-v { display: block; font-size: 15px; line-height: 1.3; }
.addr-sug-n { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
@media (hover: hover) and (pointer: fine) { .addr-sug-row:hover { background: var(--surface-2); } .addr-sug-row.on:hover { background: var(--primary-soft); } }
/* Как сайт понял адрес — строка внутри строки поля (FieldRow below): с того же края, что значение, над разделителем.
   Лежит поверх прозрачного поля ввода (.finline.ftap, z-index 1): касание подсказки не открывает правку, кнопки нажимаются. */
.addr-hint { position: relative; z-index: 2; display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; font-size: 13px; line-height: 18px; color: var(--text-2); cursor: default; }
.addr-hint > svg.ic { margin-top: 1px; }
.addr-hint-t { min-width: 0; word-break: break-word; }
.addr-hint b { font-weight: 600; }
.addr-hint.ok > svg.ic { color: var(--success); }
.addr-hint.warn { color: var(--warning-text); }
.addr-hint.bad > svg.ic, .addr-hint.busy { color: var(--text-3); }
.addr-spin { flex: none; width: 14px; height: 14px; margin: 2px 1px 0; border-radius: 50%; border: 1.5px solid var(--line-2); border-top-color: var(--text-3); animation: spin 700ms linear infinite; }
/* Кнопка в строке подсказки: строка 18 px, а цель касания 44 px — невидимым полем вокруг, строка не растёт */
.addr-hint .link-btn { position: relative; padding: 0; font-size: 13px; line-height: 18px; white-space: nowrap; }
.addr-hint .link-btn::after { content: ''; position: absolute; inset: -13px -8px; }
.frow.tappable:has(.addr-hint:active) { background: none; }
/* Выбор даты (DateSheet): быстрые кнопки, месяц, сетка дней Пн–Вс, время */
.ds-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 12px; }
.ds-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 6px; }
.ds-title { font-size: 17px; font-weight: 600; }
.ds-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; padding-bottom: 8px; }
.ds-wd { font-size: 12px; color: var(--text-3); padding: 4px 0; }
.ds-wd.we { color: var(--danger-text); }
.ds-day { height: 44px; border-radius: 12px; font-size: 16px; color: var(--text); transition: background 120ms; }
.ds-day:active { background: var(--surface-3); }
.ds-day.today { color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--primary); }
.ds-day.on { background: var(--primary); color: #fff; box-shadow: none; }
.ds-time { display: flex; align-items: center; gap: 8px; padding: 10px 0 4px; border-top: 0.5px solid var(--line); color: var(--text-2); }
.ds-time span { flex: 1; }
.ds-time .select { width: 76px; min-height: 40px; }
/* Правка поля прямо в строке (компьютер): рамка вокруг ввода и ✕ — очистить */
.frow.editing { min-height: 64px; }
.finline { display: flex; align-items: center; gap: 4px; margin-top: 4px; padding: 0 4px 0 10px; border: 1.5px solid var(--primary); border-radius: 8px; background: var(--surface); }
.finline input, .finline textarea { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 16px; padding: 7px 0; }
.finline textarea { resize: vertical; line-height: 1.4; }
.finline .fclear { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
/* Телефон: правка в строке как в мобильном Битриксе — подпись синяя, значение крупно, синяя линия снизу, без рамки. */
@media (max-width: 1023px) {
  .frow.editing .flabel { color: var(--primary); }
  .frow.editing { border-bottom-color: transparent; }
  .frow.editing .finline { margin-top: 2px; padding: 0 0 2px; border: 0; border-bottom: 2px solid var(--primary); border-radius: 0; background: none; }
  .frow.editing .finline input, .frow.editing .finline textarea { font-size: 17px; padding: 4px 0 6px; }
  .frow.editing .finline textarea { resize: none; }
  .finline .fclear { width: 36px; height: 36px; }
}
/* Свой вариант в списке с галочками (причина провала) */
.pick-own { display: flex; align-items: center; gap: 10px; padding: 8px 0 10px; border-bottom: 0.5px solid var(--line); }
.pick-own .pr-ic { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); color: var(--text-3); display: grid; place-items: center; flex: none; }
.pick-own input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 10px; background: var(--surface); outline: none; font-size: 16px; }
.pick-own input:focus { border-color: var(--primary); }
.box { border: 1px solid var(--line-2); border-radius: 12px; padding: 12px; margin: 10px 0; }

/* ---------- общие блоки экранов: страница, список карточек, панель ---------- */
.page { padding: 0 12px calc(var(--tabbar-h) + var(--safe-bottom) + 40px); }
.list { padding: 0 0 calc(var(--tabbar-h) + var(--safe-bottom) + 90px); }
.card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 10px; position: relative; box-shadow: var(--shadow-card); }
.card-title { font-size: 17px; font-weight: 700; line-height: 1.25; padding-right: 34px; word-break: break-word; }
.card-sub { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.card-more { position: absolute; top: 4px; right: 4px; }
.kv { margin-top: 10px; }
.kv-label { font-size: 11px; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-3); }
.kv-value { font-size: 16px; color: var(--text); margin-top: 2px; word-break: break-word; }
.kv-value.big { font-size: 20px; }
.kv-value .link { color: var(--link); }
.list-block { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 17px; }
.table-list .tr { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 0; border-bottom: 0.5px solid var(--line); }
.table-list .tr:last-child { border-bottom: 0; }
.group-h { padding: 12px 16px 6px; color: var(--text-3); font-size: 15px; }
.deadline { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 2px 8px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.deadline.over { background: var(--danger-soft); color: var(--danger-text); }
.deadline.today { background: var(--warning-soft); color: var(--warning-text); }
.sandbox-note { font-size: 13px; color: var(--warning-text); background: var(--warning-soft); padding: 8px 10px; border-radius: 8px; margin: 6px 0; line-height: 1.35; }
/* Заглушка списка «дышит» прозрачностью, как .sk карточки: бегущий блик тянул взгляд и перерисовывался каждый кадр. */
.skeleton { background: var(--surface-2); border-radius: 8px; animation: sk-breathe 1.1s ease-in-out infinite alternate; }
/* Заглушка первой загрузки карточки (ui.js Skeleton): серые строки на местах полей или пузыри чата. Появляется
   через 150 мс (быстрый ответ её не покажет) и мягко «дышит» прозрачностью — без перерисовки каждого кадра. */
.sk { padding: 6px 16px; animation: sk-in 200ms 150ms var(--ease-out) both, sk-breathe 1.1s 350ms ease-in-out infinite alternate; }
.sk-row { padding: 12px 0 13px; border-bottom: 0.5px solid var(--line); }
.sk-l, .sk-v, .sk-bubble, .sk-stage, .sk-tab { display: block; border-radius: 6px; background: color-mix(in srgb, var(--text) 9%, transparent); }
.sk-l { width: 26%; height: 9px; margin-bottom: 9px; }
.sk-v { height: 14px; }
.sk-chat { display: flex; flex-direction: column; gap: 10px; padding: 16px 12px; }
.sk-bubble { height: 44px; border-radius: 16px; }
.sk-bubble.out { align-self: flex-end; }
/* Компьютер: сделка — полоса стадий и вкладки на белом, ниже поля слева и лента справа (как .dc-desk-top и .dc-cols);
   контакт — те же две колонки без стадий. */
.sk.sk-desk { padding: 0; }
.sk-top { background: var(--surface); padding: 8px 20px 12px; margin-bottom: 14px; border-bottom: 0.5px solid var(--line); }
.sk-stages { display: flex; gap: 3px; height: 30px; }
.sk-stage { flex: 1; border-radius: 4px; }
.sk-stage:first-child { flex: 0 0 120px; }
.sk-tabs { display: flex; gap: 8px; margin-top: 12px; }
.sk-tab { width: 96px; height: 36px; border-radius: 18px; }
.sk-cols { display: grid; grid-template-columns: minmax(380px, 470px) minmax(0, 1fr); gap: 16px; padding: 0 16px; align-items: start; }
.sk-desk .sk-cols { padding-top: 14px; }
.sk-desk .sk-top + .sk-cols { padding-top: 0; }
.sk-box { display: block; background: var(--surface); border-radius: var(--radius); padding: 2px 16px; }
.sk-box .sk-row:last-child { border-bottom: 0; }
.sk-feed { display: flex; flex-direction: column; gap: 12px; }
.sk-feed .sk-box { height: 132px; }
.sk-feed .sk-box:first-child { height: 280px; }
@keyframes sk-in { from { opacity: 0; } }
@keyframes sk-breathe { to { opacity: 0.55; } }

/* ---------- карточка сущности поверх списка (сделка, контакт, товар, задача, чат) ---------- */
.detail { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; animation: detail-in 340ms var(--ease-sheet); }
.detail.closing { animation: detail-out 220ms var(--ease-out) forwards; }
.detail-head { flex: none; padding: var(--topbar-pad) 8px 0; background: var(--surface); }
.detail-head .hrow { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.ent-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.ent-title { font-size: 18px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ent-sub { font-size: 13px; color: var(--text-3); }
.detail-tabs { display: flex; gap: 8px; padding: 6px 8px 10px; overflow-x: auto; scrollbar-width: none; }
.detail-tabs::-webkit-scrollbar { display: none; }
.detail-tabs .tcnt { margin-left: 6px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-3); color: var(--text-3); font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.detail-tabs .tcnt.red { background: var(--danger); color: #fff; }
.detail-head { touch-action: pan-x; }
.detail-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--safe-bottom) + 96px); }
.float-comm { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 22px); z-index: 10; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); border-radius: 26px; }
.detail .fab { bottom: calc(var(--safe-bottom) + 16px); }
.detail-backdrop { display: none; }
/* Карточки стопкой (app.js): обёртка без своей коробки. Карточка, на которую вернулись «назад», появляется на месте,
   а не выезжает снизу заново; у нижней карточки на компьютере своё затемнение прозрачное — фон не темнеет дважды. */
.dstack { display: contents; }
.dstack[data-instant] > :is(.detail, .detail-backdrop):not(.closing) { animation: none; }
.dstack[inert] > .detail-backdrop { background: transparent; }
/* На компьютере нижняя карточка видна слева от верхней — притенена: щелчок по ней проходит к затемнению верхней
   и закрывает её (inert не принимает касаний). */
@media (min-width: 1024px) { .dstack[inert] > .detail::after { content: ''; position: absolute; inset: 0; z-index: 20; border-radius: inherit; background: var(--overlay); } }
.dot-badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }

/* Капсула связи ☎ ✉ 💬: вертикальная в карточке списка, горизонтальная внизу карточки сущности */
.comm-pill { display: inline-flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 22px; background: var(--accent-soft); }
.comm-pill button { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 50%; }
.comm-pill button .disc { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; transition: transform 100ms var(--ease-out); }
.comm-pill button:active .disc { transform: scale(0.9); }
.comm-pill button.off .disc { background: var(--line-2); color: var(--surface); }
.comm-pill.h { flex-direction: row; background: var(--surface); padding: 4px 6px; gap: 4px; }
.comm-pill.h button { color: var(--accent); }
.comm-pill.h button:active { background: var(--accent-soft); }
.comm-pill.h button.off { color: var(--text-4); }

/* ---------- прочее ---------- */
.av { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 12px; font-weight: 600; flex: none; }
.av.lg { width: 52px; height: 52px; font-size: 19px; }
.av.md { width: 40px; height: 40px; font-size: 15px; }
.ch-ic { position: absolute; right: -2px; bottom: -2px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--surface); color: #fff; }
.counter { min-width: 22px; height: 22px; border-radius: 11px; background: var(--surface-3); color: var(--text-3); font-size: 12px; display: grid; place-items: center; padding: 0 6px; flex: none; }
.counter.on { background: var(--green-badge); color: #fff; }
.counter.red { background: var(--danger); color: #fff; }
.badge-outline { display: inline-block; font-size: 11px; border: 1px solid #55d0e0; color: var(--text-2); border-radius: 9px; padding: 0 7px; margin-left: 6px; vertical-align: 2px; line-height: 16px; }
.status-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-3); white-space: nowrap; }
.status-badge.paid { background: var(--success-soft); color: var(--success); }
.status-badge.viewed { background: var(--primary-soft); color: var(--link); }
.status-badge.unpaid { background: var(--danger-soft); color: var(--danger-text); }
/* В открытой карточке нижней панели нет, а внизу плавает капсула связи — тост встаёт над ней. Класс ставит
   ui.js Toast при показе: правило body:has(.detail) заставляло WebKit перепроверять стили на каждое изменение страницы. */
@media (max-width: 1023px) { .toast.over-detail { bottom: calc(var(--safe-bottom) + 96px); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--tabbar-pad) + 20px); transform: translateX(-50%); background: rgba(31, 35, 41, 0.94); color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 100; font-size: 15px; width: max-content; max-width: calc(100vw - 32px); outline: 1px solid color-mix(in srgb, var(--text) 14%, transparent); animation: toast-in 220ms var(--ease-out); text-align: center; pointer-events: none; }
.empty { text-align: center; color: var(--text-3); padding: 40px 24px; }
/* Только крупная иконка пустого экрана, а не иконки в его кнопках. */
.empty > svg.ic { width: 44px; height: 44px; color: var(--text-4); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--primary); animation: spin 700ms linear infinite; margin: 30px auto; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.94); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.97) translateY(8px); } }
@keyframes detail-in { from { transform: translateY(100%); } }
@keyframes detail-out { to { transform: translateY(100%); } }
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes slide-out { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; } }

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text-2); }
  .chip:hover { border-color: var(--text-4); }
  .menu-pop .mi:hover, .list-menu .mi:hover, .pick-row:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
  .btn.primary:hover { background: var(--primary-press); }
  .frow.tappable:hover { background: color-mix(in srgb, var(--text) 3%, transparent); cursor: pointer; }
  .ds-day:hover:not(.on) { background: var(--surface-3); }
  .stage-next.quick:hover { background: color-mix(in srgb, var(--next) 12%, var(--surface-2)); color: var(--text-2); }
  .dashed:hover { color: var(--text-2); }
  .finline .fclear:hover { background: var(--surface-3); color: var(--text); }
}

/* ======================= ДЕСКТОП ======================= */
.sidebar { display: none; }
.desk-only { display: none !important; }
@media (min-width: 1024px) {
  body { background: var(--bg); }
  .app { flex-direction: row; }
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; width: var(--sidebar-w); flex: none; background: linear-gradient(180deg, #2b2a7a 0%, #3b3196 55%, color-mix(in srgb, var(--brand, #2fc6f6) 45%, #3b3196) 100%); color: #fff; padding: 14px 10px; gap: 2px; }
  .sidebar .logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 700; font-size: 18px; }
  .sidebar .logo .mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; background: rgba(255, 255, 255, 0.18); transition: background 120ms, transform 120ms var(--ease-out); }
  .sidebar .logo .mark:hover { background: rgba(255, 255, 255, 0.3); }
  .sidebar .logo .mark:active { transform: scale(0.94); }
  /* Значок бренда в кнопке сворачивания: картинка во всю кнопку. */
  .sidebar .logo .mark .brand-icon, .sidebar .logo .mark .brand-mark { width: 34px; height: 34px; border-radius: 10px; outline: none; }
  .sidebar .logo .brand-switch { height: 34px; }
  /* Строка логотипа одной высоты у любого бренда (без запаса под строку текста) — пункты не прыгают. */
  .sidebar .logo .sb-label { display: flex; align-items: center; }
  .sidebar .brand-switch:focus-visible { outline-offset: -2px; }
  .sidebar .logo .brand-logo-box { --logo-h-max: 30px; }
  /* Свёрнутое меню — узкая полоса со значками; подписи плавно гаснут, счётчики — бейджами на значках */
  .sidebar { transition: width 220ms var(--ease-out); overflow: hidden; }
  .sidebar .sb-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 160ms; }
  .sidebar a { position: relative; }
  .sidebar.collapsed { width: 68px; }
  .sidebar.collapsed .sb-label { opacity: 0; pointer-events: none; }
  /* Невидимый переключатель бренда в свёрнутой панели не должен ловить Tab. */
  .sidebar.collapsed .logo .sb-label { visibility: hidden; }
  .sidebar.collapsed .logo { padding-left: 7px; }
  .sidebar.collapsed a { padding: 0 14px; }
  .sidebar.collapsed .sb-badge { position: absolute; top: 3px; left: 28px; margin: 0; padding: 0 5px; font-size: 10px; line-height: 16px; min-width: 16px; text-align: center; }
  .sidebar.collapsed .sb-sep { margin: 10px 4px; }
  .sidebar a { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 10px; color: rgba(255, 255, 255, 0.9); font-size: 15px; }
  .sidebar a:hover { background: rgba(255, 255, 255, 0.1); }
  .sidebar a.on { background: rgba(255, 255, 255, 0.22); color: #fff; }
  .sidebar a .sb-badge { margin-left: auto; background: var(--danger); border-radius: 9px; font-size: 11px; font-weight: 600; padding: 1px 6px; }
  .sidebar .sb-sep { height: 1px; background: rgba(255, 255, 255, 0.15); margin: 10px 8px; }
  .topbar { padding: 14px 24px 4px; background: transparent; }
  .topbar-title { font-size: 26px; }
  .fab { display: none; }
  .desk-only { display: inline-flex !important; }

  /* Шторки на компьютере — окно по центру. Без transform: перетаскивание на десктопе выключено. */
  .sheet { left: 0; right: 0; margin: 0 auto; width: 540px; max-width: calc(100vw - 48px); bottom: auto; top: 8vh; border-radius: 16px; max-height: 84vh; padding-bottom: 0; animation: dialog-in 200ms var(--ease-out); }
  .sheet.tall { height: 84vh; }
  /* Окно над окном (выбор из фильтра) — ниже на 32 px и с тенью: видно, что это второй слой (ui.js Portal). */
  .sheet { top: calc(8vh + var(--layer-depth, 0) * 32px); box-shadow: var(--shadow-pop); }
  .sheet.closing { animation: fade-out 160ms forwards; }
  .sheet-handle { display: none; }
  /* Окно выбора/действия у кнопки, на которую нажали (ui.js anchoredBox), а не по центру большого экрана */
  .sheet.anchored { margin: 0; border-radius: 14px; box-shadow: var(--shadow-pop); border: 0.5px solid var(--line-2); animation: pop-in 160ms var(--ease-out); }
  .sheet.anchored.closing { animation: fade-out 120ms forwards; }
  .sheet.anchored .sheet-head { padding-top: 6px; min-height: 42px; }
  .sheet.anchored .sheet-title { font-size: 15px; }
  .sheet-head { padding-top: 10px; }
  .toast { bottom: 24px; }
  .screen { overflow: hidden; }
  .page { padding: 0 24px 40px; max-width: 1100px; }
  .list { padding: 0 0 40px; }

  /* Карточка сущности — слайдер справа, как в Битриксе */
  .detail { left: auto; width: min(1180px, calc(100vw - 120px)); border-radius: 16px 0 0 16px; box-shadow: -16px 0 40px rgba(0, 0, 0, 0.18); animation: slide-in 320ms var(--ease-sheet); }
  .detail.closing { animation: slide-out 220ms var(--ease-out) forwards; }
  .detail-backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 39; animation: fade-in 200ms; }
  .detail-head { padding: 14px 20px 0; border-radius: 16px 0 0 0; }
  .ent-title { font-size: 24px; }
  .detail-body { padding-bottom: 40px; }
  .float-comm { display: none; }
}

/* Текст только для экранного диктора (VoiceOver): «не прочитано» у точки и т. п. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
