/* CRM-тема Кельвики v2 — «уровень Linear/Stripe/Attio» (02.07.2026).
   Источники значений: исследование crm/rynok-2026-07 + дизайн-воркфлоу
   (Radix Gray — реальные hex; тени Tailwind v4; spacing Stripe; приёмы shadcn:
   карточка светлее фона в тёмной теме, альфа-бордеры, focus-кольцо 3px/50%).
   Бренд: жёлтый #FECE15 ТОЛЬКО фоном с тёмным текстом (чёрный на жёлтом ≈14:1 AAA;
   жёлтый текст на белом ≈1.5:1 — запрещён). Шрифт: Inter self-hosted (tabular-nums
   подтверждён — деньги в таблицах не пляшут). */

/* ───────── Inter (self-hosted, кириллица+латиница) ───────── */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; /* impeccable-disable-line overused-font — Inter выбран Николаем 02.09 (эталон v2) */
  src: url("../fonts/inter/inter-cyrillic-400.74a70a8b71d0.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; /* impeccable-disable-line overused-font — Inter выбран Николаем 02.09 (эталон v2) */
  src: url("../fonts/inter/inter-cyrillic-500.0f5211cce140.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; /* impeccable-disable-line overused-font — Inter выбран Николаем 02.09 (эталон v2) */
  src: url("../fonts/inter/inter-cyrillic-600.40727edfba55.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; /* impeccable-disable-line overused-font — Inter выбран Николаем 02.09 (эталон v2) */
  src: url("../fonts/inter/inter-cyrillic-700.fc4bfa8e4204.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; /* impeccable-disable-line overused-font — Inter выбран Николаем 02.09 (эталон v2) */
  src: url("../fonts/inter/inter-latin-400.da03732a27e1.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/inter/inter-latin-500.51205681a1ba.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; /* impeccable-disable-line overused-font — Inter выбран Николаем 02.09 (эталон v2) */
  src: url("../fonts/inter/inter-latin-600.2ede57db1a3a.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/inter/inter-latin-700.8ca0a5155296.woff2") format("woff2"); }

:root {
  /* ── Нейтрали: Radix Gray light (роль по ступени: 1-2 фон, 3-5 компонент,
       6-8 бордеры, 9-10 solid, 11-12 текст) ── */
  --gray-1: #FCFCFC; --gray-2: #F9F9F9; --gray-3: #F0F0F0; --gray-4: #E8E8E8;
  --gray-5: #E0E0E0; --gray-6: #D9D9D9; --gray-7: #CECECE; --gray-8: #BBBBBB;
  --gray-9: #8D8D8D; --gray-10: #838383; --gray-11: #646464; --gray-12: #202020;

  /* ── Акцент: жёлтая шкала, ступень 9 = бренд #FECE15 (Pantone 109C) ── */
  --yellow-1: #FEFDFA; --yellow-2: #FEFBE9; --yellow-3: #FFF8BF; --yellow-4: #FFF099;
  --yellow-5: #FCE674; --yellow-6: #F3D66E; --yellow-7: #E7C364; --yellow-8: #DDA737;
  --yellow-9: #FECE15; --yellow-10: #F3C50A; --yellow-11: #8A6416; --yellow-12: #4C3721;

  /* ── Статусы: пастель-фон + тёмный текст (палитра тегов Notion) ── */
  --ok-bg: #EEF3ED;  --ok-text: #44714E;
  --hot-bg: #FAECEC; --hot-text: #B3382F;

  /* ── Бренд-легаси (старые имена продолжают работать) ── */
  --kp-yellow: var(--yellow-9);
  --kp-ink: #141517;              /* сайдбар/шапка — тёплый почти-чёрный, не #000 */
  --kp-ink-2: var(--gray-11);
  --kp-ink-3: #7C7C7C;
  --kp-line: var(--gray-4);
  --kp-fog: var(--gray-2);
  --kp-eco: #46A758;              /* Radix green 9 — точки/акценты */
  --kp-hot: #E5484D;              /* Radix red 9 */
  --kp-ok: #2F7C43;

  --step-overdue: #E5484D;
  --step-today: var(--yellow-9);  /* «сегодня» = тот же бренд-жёлтый, второго оттенка нет */
  --step-none: #C7C7C7;

  --kp-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Радиусы: инпут/кнопка меньше карточки — вложенность читается «дорого» */
  --kp-r-sm: 8px; --kp-r: 12px; --kp-r-lg: 16px; --kp-r-pill: 999px;

  /* Тени Tailwind v4 — еле заметные, намёк на объём, не декорация */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .07), 0 1px 2px -1px rgb(0 0 0 / .07);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .08), 0 2px 4px -2px rgb(0 0 0 / .08);
  --kp-shadow-card: var(--shadow-md);

  /* Движение: быстро и незаметно (Linear: hover 100-150мс) */
  --t-fast: 120ms ease-out;
  --t-med: 200ms ease-out;

  /* Семантические алиасы (компоненты работают через них) */
  --bg: var(--gray-1);
  --surface: #FFFFFF;
  --surface-2: var(--gray-2);
  --surface-3: var(--gray-3);
  --text: var(--gray-12);
  --text-muted: var(--gray-11);
  --text-faint: #6B6B6B;
  --line: var(--gray-4);
  --line-strong: var(--gray-7);   /* бордер инпутов (Radix роль 7) */
  --accent: var(--yellow-9);
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--gray-12);
  --white: #fff; --black: #000;  /* литерал один раз, дальше токен */

  /* Каналы связи на рельсе карточки (редизайн 27.08, hex сверены по первичным
     источникам: telegram.org SVG · брендбук go.max.ru/brandbook · vk.com/brand ·
     официальный логотип Авито 2022; WhatsApp — устоявшийся плоский #25D366;
     почта — нейтральный slate, бренда нет) */
  --ch-whatsapp: #25D366;
  --ch-telegram: #229ED9;
  --ch-max: #471AFF;
  --ch-email: #64748B;
  --ch-avito: #00AAFF;
  --ch-vk: #0077FF;
  /* Подцвета глифа Авито (4 круга): red/purple/green для _ch_icon.html */
  --ch-avito-red: #F86060;
  --ch-avito-purple: #A068F0;
  --ch-avito-green: #90C820;
}

/* Тёмная тема — НЕ инверсия: отдельная калибровка (Radix Gray dark),
   карточка СВЕТЛЕЕ фона (элевация цветом), бордеры — альфа-оверлей. */
[data-theme="dark"] {
  --gray-1: #111111; --gray-2: #191919; --gray-3: #222222; --gray-4: #2A2A2A;
  --gray-5: #313131; --gray-6: #3A3A3A; --gray-7: #484848; --gray-8: #606060;
  --gray-9: #6E6E6E; --gray-10: #7B7B7B; --gray-11: #B4B4B4; --gray-12: #EEEEEE;

  --ok-bg: #242B26;  --ok-text: #6CBD82;
  --hot-bg: #332523; --hot-text: #E06C60;

  --kp-ink: #0B0C0D;
  --kp-ink-2: var(--gray-11);
  --kp-ink-3: #8F8F8F;
  --kp-line: rgb(255 255 255 / .10);
  --kp-fog: var(--gray-2);

  --bg: var(--gray-1);
  --surface: var(--gray-2);        /* светлее фона — приём shadcn/Geist */
  --surface-2: var(--gray-3);
  --surface-3: var(--gray-4);
  --text: var(--gray-12);
  --text-muted: var(--gray-11);
  --text-faint: #8F8F8F;
  --line: rgb(255 255 255 / .10);
  --line-strong: rgb(255 255 255 / .16);
  --kp-shadow-card: 0 8px 24px rgb(0 0 0 / .45);
  --shadow-xs: none; --shadow-sm: none; --shadow-md: none; /* глубина цветом, не тенью */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--kp-font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  background: var(--bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;   /* деньги в таблицах не пляшут */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { letter-spacing: -0.014em; font-weight: 600; }

a { color: var(--text); text-decoration-color: var(--accent); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }

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

/* Шапка-приложение (гостевые страницы) */
.app-header {
  display: flex; align-items: center; gap: 14px;
  background: var(--kp-ink); color: var(--white);
  padding: 10px 20px;
}
[data-theme="dark"] .app-header { background: var(--black); }
.app-header .brand-k {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 3px 6px; box-sizing: border-box;
  background: var(--accent); border-radius: 7px; flex: 0 0 32px;
}
.app-header .brand-k img { width: 100%; height: 100%; object-fit: contain; display: block; }
.app-header a { color: var(--white); }
.app-header nav { display: flex; gap: 18px; margin-left: 20px; }
.app-header nav a { text-transform: uppercase; font-size: 12px; letter-spacing: .08em; opacity: .85; }
.app-header nav a:hover, .app-header nav a.active { opacity: 1; }
.app-header .spacer { flex: 1; }

main.app-main { padding: 24px; max-width: 1240px; margin: 0 auto; }

/* ───────── Сайдбар: приглушённый, навигация уходит на второй план (Linear) ───────── */
.app { display: flex; align-items: stretch; min-height: 100vh; }
.sidebar {
  flex: 0 0 216px; width: 216px; background: var(--kp-ink); color: var(--white);
  display: flex; flex-direction: column; gap: 3px; padding: 14px 10px;
  position: sticky; top: 0; height: 100vh;
  transition: flex-basis var(--t-med), width var(--t-med); /* impeccable-disable-line layout-transition — сворачивание сайдбара, одиночный элемент вне горячего пути */
}
.side-brand-row { display: flex; align-items: center; gap: 4px; padding: 0 2px 10px; }
.side-brand { display: flex; align-items: center; gap: 10px; color: var(--white);
  text-decoration: none; padding: 2px 6px; font-weight: 600; font-size: 15px;
  letter-spacing: -0.01em; flex: 1; min-width: 0; }
.side-brand .brand-k {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 3px 6px; box-sizing: border-box;
  background: var(--accent); border-radius: 7px; flex: 0 0 32px;
}
.side-brand .brand-k img { width: 100%; height: 100%; object-fit: contain; display: block; }
.side-toggle {
  flex: 0 0 auto; width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid rgb(255 255 255 / .18);
  border-radius: 8px; color: #C9CCCE; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.side-toggle:hover { background: rgb(255 255 255 / .08); color: var(--white); border-color: rgb(255 255 255 / .28); }
.side-toggle .ic { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-new { width: 100%; justify-content: center; margin-bottom: 10px;
  /* А4: в сайдбаре «+ Сделка» тихая контурная — жёлтый на экране один,
     и это главное действие контента, а не каркаса (канон, правило 2). */
  background: transparent; border-color: rgb(255 255 255 / .18);
  color: rgb(255 255 255 / .78); box-shadow: none; }
.side-new:hover { background: rgb(255 255 255 / .07); color: var(--white); }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 7px; color: #9BA1A6; text-decoration: none; font-size: 13px;
  font-weight: 500; transition: background var(--t-fast), color var(--t-fast); }
.side-link:hover { background: rgb(255 255 255 / .06); color: #E6E7E8; }
.side-link.active { background: rgb(255 255 255 / .09); color: var(--white); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--kp-yellow); }
.side-link .ic { width: 18px; height: 18px; flex: 0 0 18px; fill: none;
  stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-unread { margin-left: auto; }
.side-logout-form { margin: 0; }

/* Свёрнутая рейка: одна ширина 56px, все ячейки 40×40 по центру */
.app.sidebar-collapsed .sidebar {
  flex: 0 0 56px;
  width: 56px;
  padding: 10px 8px;
  gap: 2px;
  overflow: hidden;
  align-items: center;
}
.app.sidebar-collapsed .side-brand-row,
.app.sidebar-collapsed .side-nav,
.app.sidebar-collapsed .side-bottom,
.app.sidebar-collapsed .side-logout-form {
  width: 40px;
  align-items: center;
}
.app.sidebar-collapsed .side-brand-row {
  flex-direction: column;
  gap: 4px;
  padding: 0 0 6px;
}
.app.sidebar-collapsed .side-brand {
  width: 40px; height: 40px; padding: 0;
  justify-content: center; flex: none;
}
.app.sidebar-collapsed .side-brand-txt { display: none; }
.app.sidebar-collapsed .side-brand .brand-k {
  width: 32px; height: 32px; padding: 3px 6px;
  border-radius: 8px;
}
.app.sidebar-collapsed .side-toggle { width: 40px; height: 40px; }
.app.sidebar-collapsed .side-new {
  width: 40px; height: 40px; min-width: 40px; max-width: 40px;
  padding: 0; margin: 0 0 6px; gap: 0;
  justify-content: center; border-radius: 8px;
  box-shadow: none;
}
.app.sidebar-collapsed .side-new-txt { display: none; }
.app.sidebar-collapsed .side-new-ico { font-size: 20px; font-weight: 700; line-height: 1; }
.app.sidebar-collapsed .side-link {
  width: 40px; height: 40px; padding: 0; gap: 0;
  justify-content: center; position: relative;
}
.app.sidebar-collapsed .side-link.active { box-shadow: none; }
.app.sidebar-collapsed .side-link > span:not(.badge) { display: none; }
.app.sidebar-collapsed .side-unread {
  position: absolute; top: 3px; right: 2px; margin: 0;
  min-width: 16px; height: 16px; padding: 0 3px;
  font-size: 9px; line-height: 16px; text-align: center;
}
.app.sidebar-collapsed .side-user { display: none; }
.app.sidebar-collapsed .side-logout {
  width: 40px; height: 40px; padding: 0; gap: 0;
  justify-content: center; border: 0; box-shadow: none;
}
.app.sidebar-collapsed .side-logout-txt { display: none; }

.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; }
.side-user { padding: 4px 10px; line-height: 1.3; }
.side-user-name { display: block; font-size: 13px; color: #D5D7D9; }
.side-user-role { display: block; font-size: 11px; color: #7E8388; }
.side-logout { width: 100%; background: transparent; border: 1px solid rgb(255 255 255 / .18);
  color: #C9CCCE; padding: 6px 10px; border-radius: 7px; cursor: pointer; font: inherit;
  font-size: 13px; transition: background var(--t-fast), color var(--t-fast); }
.side-logout { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-logout .ic { width: 18px; height: 18px; flex: 0 0 18px; fill: none;
  stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-logout:hover { background: rgb(255 255 255 / .07); color: var(--white); }

.content { flex: 1 1 auto; min-width: 0; padding: 22px 28px; max-width: 1280px; }
.content.wide { max-width: none; }
.flash { background: var(--yellow-2); color: var(--yellow-11);
  border: 1px solid var(--yellow-4);
  border-radius: 10px; padding: 9px 14px; margin-bottom: 14px; font-size: 13.5px; }
[data-theme="dark"] .flash { background: #2B2416; color: #E0B54B; border-color: #4A3D1C; }
.content-foot { margin-top: 34px; font-size: 12px; color: var(--text-faint); }
.content-foot a { color: var(--text-faint); }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .app.app-board { height: auto; overflow: visible; }
  .sidebar { flex: none; width: auto; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 10px; }
  .side-brand-row { padding: 0; }
  .side-brand { padding: 4px 6px; } .side-brand-txt { display: none; }
  .side-toggle { width: 34px; height: 34px; }
  .side-new { width: auto; margin: 0; }
  .side-nav { flex-direction: row; flex: 1 1 auto; overflow-x: auto; }
  .side-link span { display: none; } .side-link { padding: 9px; }
  .side-link.active { box-shadow: inset 0 -3px 0 var(--kp-yellow); }
  .side-bottom { margin: 0; flex-direction: row; align-items: center; padding: 0; gap: 6px; }
  .side-user { display: none; } .side-logout { width: auto; padding: 7px 12px; }
  .content { padding: 14px; max-width: none; }
}

/* ───────── Кнопки ───────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: var(--kp-r-sm); font-weight: 500;
  font-size: 13.5px; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0.5px); box-shadow: none; }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn-primary { background: var(--yellow-9); color: var(--kp-ink); border-color: transparent;
  font-weight: 600; }
.btn-primary:hover { background: var(--yellow-10); }

/* ───────── Бейджи состояний: пастель-фон + тёмный текст (Notion-пары) ───────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--kp-r-pill);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0; white-space: nowrap; }
.badge-paid { background: var(--ok-bg); color: var(--ok-text); }
.badge-debt { background: var(--hot-bg); color: var(--hot-text); }
.badge-seg-large { background: var(--yellow-9); color: #201800; }
.badge-seg-medium { background: var(--yellow-2); color: var(--yellow-11);
  border: 1px solid var(--yellow-4); }
[data-theme="dark"] .badge-seg-medium { background: #2B2416; color: #E0B54B; border-color: #4A3D1C; }
.badge-seg-small { background: var(--surface-3); color: var(--text-muted); }

/* ───────── Карточки и таблицы ───────── */
.card { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--kp-r); padding: 16px; box-shadow: var(--shadow-xs); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--gray-3); }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-9); font-weight: 600; border-bottom-color: var(--line); }
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--surface-2); }

/* Карточка сделки: факты как highlights-панель (4 колонки), не простыня */
.deal-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px; align-items: start; }
.deal-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 16px; margin: 0 0 14px; padding: 0 0 12px; border-bottom: 1px solid var(--line); }
.deal-fact-label { display: block; font-size: 12px;
  color: var(--text-muted); font-weight: 500; margin-bottom: 3px; }
.deal-fact-value { font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
/* Волна 1 (03.09): консоль «Деньги: доход → расход → маржа» — три строки
   по согласованному макету; заменяет прежние раздельные блоки счёта и денег */
.mc-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 0;
  border-bottom: 1px dashed var(--gray-5); flex-wrap: wrap; }
.mc-row:last-of-type { border-bottom: 0; }
.mc-lbl { flex: 0 0 68px; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-muted); }
.mc-val { font-size: 17px; font-weight: 700; }
.mc-rest { margin-left: auto; display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap; justify-content: flex-end; }
.mc-row--margin .mc-val strong { color: var(--text); }
.mc-inv-file { flex-basis: 100%; margin-top: 2px; }
.mc-inv-file > summary { cursor: pointer; color: var(--text-muted);
  font-size: 12.5px; }
.mc-inv-file[open] > summary { margin-bottom: 6px; }
.deal-invoice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); }
.deal-invoice-sum { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.deal-invoice-file { grid-column: 1 / -1; }
.inv-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  text-decoration: none; color: var(--text); max-width: 100%; }
.inv-file:hover { background: var(--yellow-1); }
[data-theme="dark"] .inv-file:hover { background: var(--surface-3); }
.inv-file-ico { flex: 0 0 auto; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 4px 6px; border-radius: 4px; background: var(--kp-hot); color: var(--white); }
.inv-file-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-file-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.inv-file-form .field { width: auto; max-width: 12em; padding: 6px 8px; }
.inv-file-form input[type="file"] { font-size: 12.5px; min-width: 0; flex: 1 1 160px; }
@media (max-width: 640px) {
  .deal-invoice { grid-template-columns: 1fr 1fr; }
}
.deal-facts-channels { grid-column: 1 / -1; }
.ch-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ch-chip { display: inline-flex; align-items: stretch; max-width: 100%; }
.ch-chip-link { display: inline-block; padding: 3px 8px; border: 1px solid var(--line-strong);
  border-right: 0; border-radius: var(--kp-r-pill) 0 0 var(--kp-r-pill);
  background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 13px;
  max-width: 22em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.ch-chip-link:hover { background: var(--yellow-1); }
[data-theme="dark"] a.ch-chip-link:hover { background: var(--surface-3); }
.ch-chip-del { border: 1px solid var(--line-strong); border-left: 0; margin: 0;
  border-radius: 0 var(--kp-r-pill) var(--kp-r-pill) 0; background: var(--surface);
  color: var(--text-faint); cursor: pointer; padding: 0 8px; font: inherit; font-size: 15px;
  line-height: 1; }
.ch-chip-del:hover { color: var(--kp-hot); background: var(--surface-2); }
.ch-add { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.ch-add select.field { width: auto; padding: 4px 6px; font-size: 13px; }
.ch-add input.field { width: 14em; max-width: 42vw; padding: 4px 8px; font-size: 13px; }
.ch-error { color: var(--kp-hot); font-size: 12.5px; margin: 4px 0 0; }

/* Клиент-блок: человек на лице + каналы-иконки (макет 08.09,
   kritika-blok-klient P0–P2). Клик по имени — сменить контакт. */
.deal-client-person { margin: 0 0 2px; display: flex; flex-wrap: wrap;
  align-items: baseline; gap: 2px 12px; }
.deal-contact-name { font-size: 15px; font-weight: 700; }
.deal-client-mail { margin: 0 0 2px; font-size: 13.5px; }
.deal-channels { display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 10px; margin-top: 8px; }
.ch-ic-wrap { display: inline-flex; align-items: center; gap: 1px; }
.ch-ic { display: inline-flex; width: 20px; height: 20px;
  align-items: center; justify-content: center; }
.ch-ic svg { width: 20px; height: 20px; display: block; }
.ch-ic.ch-whatsapp { color: var(--ch-whatsapp); }
.ch-ic.ch-telegram { color: var(--ch-telegram); }
.ch-ic.ch-max { color: var(--ch-max); }
.ch-ic.ch-vk { color: var(--ch-vk); }
.ch-ic.ch-avito { color: var(--ch-avito); }
a.ch-ic:hover { opacity: .8; }
.ch-ic-x { border: 0; background: none; padding: 0 2px; margin: 0;
  color: var(--text-faint); cursor: pointer; font: inherit; font-size: 13px;
  line-height: 1; }
.ch-ic-x:hover { color: var(--kp-hot); }
.ch-add-fold summary { display: inline-block; border: 0; background: none;
  color: var(--text-muted); font: 500 13px inherit; cursor: pointer;
  padding: 0; list-style: none; }
.ch-add-fold summary::-webkit-details-marker { display: none; }
.ch-add-fold summary:hover { color: var(--text); }
.ch-add-fold[open] summary { color: var(--text); }
@media (max-width: 900px) {
  .deal-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .ch-add { flex-wrap: wrap; }
}

/* Маркер следующего шага */
.step-dot { width: 9px; height: 9px; min-width: 9px; min-height: 9px;
  flex: 0 0 9px; border-radius: 50%; aspect-ratio: 1; display: block; }
.step-overdue { background: var(--step-overdue); }
.step-today { background: var(--step-today); }
.step-none { background: var(--step-none); }
.step-inbox { background: var(--gray-8); }
.step-ok { background: var(--kp-eco); }

/* Канбан на весь экран: горизонтальный скролл у низа вьюпорта (как Битрикс24) */
.app.app-board { height: 100vh; overflow: hidden; }
.content.board {
  display: flex; flex-direction: column;
  min-height: 0; height: 100%;
  padding-bottom: 0; overflow: hidden;
}
.content.board .board-toolbar { flex: 0 0 auto; }
.content.board .content-foot { display: none; }
.content.board .kanban {
  flex: 1 1 auto; min-height: 0;
  overflow-x: auto; overflow-y: hidden;
  align-items: stretch; padding-bottom: 0;
}
.content.board .kanban-col {
  display: flex; flex-direction: column;
  max-height: 100%; min-height: 0;
}
.content.board .kanban-drop {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
}
.content.board .kanban-terminals { max-height: 100%; min-height: 0; overflow-y: auto; }

/* ───────── Канбан ───────── */
/* Эталон v2: карточка встаёт в колонку ВПЛОТНУЮ по бокам — боковых серых
   полей нет (жалоба Н «отступ справа»), воздух только сверху/снизу и между
   карточками. Карточка 256 в колонке 256 — ширина эталонной карточки. */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
/* Навигация доски как в Битрикс24: обёртка держит круглые стрелки по краям */
.kanban-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.kb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 6;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--gray-6); color: var(--text);
  box-shadow: var(--shadow-md); cursor: pointer;
  display: none; align-items: center; justify-content: center;
  transition: border-color var(--t-fast), transform var(--t-fast); }
.kb-nav.on { display: flex; }
.kb-nav:hover { border-color: var(--gray-8); transform: translateY(-50%) scale(1.06); }
.kb-nav:active { transform: translateY(-50%) scale(.98); }
.kb-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.kb-nav--l { left: 14px; }
.kb-nav--r { right: 14px; }
@media (hover: none), (max-width: 760px) { .kb-nav { display: none !important; } }
.kanban-col { flex: 0 0 256px; width: 256px; min-width: 256px; max-width: 256px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--gray-3); border: 0; border-radius: 8px; padding: 8px; }
/* Скроллбар колонки скрыт полностью: классическая полоса съедала ширину,
   карточка прижималась влево и справа оставалась серая пустота (жалоба Н).
   Скролл остаётся колесом/тачем/перетаскиванием. */
.kanban-drop { scrollbar-width: none; -ms-overflow-style: none; }
.kanban-drop::-webkit-scrollbar { display: none; }
[data-theme="dark"] .kanban-col { background: var(--gray-4); }
/* Шапка колонки нейтральна (канан канбана Attio/Linear): цвет стадии = точка
   слева; полоса стадии живёт на карточках. */
.kanban-col-head { font-weight: 600; font-size: 12px; line-height: 16px;
  color: var(--text); height: 24px;
  padding: 0 4px; margin: 0;
  display: flex; gap: 8px; align-items: center; position: relative; }
.kanban-col-dot { width: 8px; height: 8px; min-width: 8px; border-radius: 50%;
  flex: 0 0 auto; background: var(--stage-color, var(--gray-9));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .10); }
.kanban-col-name { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.kanban-count { flex: 0 0 auto; color: var(--text-muted); font-weight: 500;
  font-size: 11px; line-height: 16px; padding: 0 6px;
  background: var(--surface); border: 1px solid var(--gray-5); border-radius: 999px;
  font-variant-numeric: tabular-nums; }
.kanban-sum { margin: 0; padding: 0 4px; color: var(--text-muted);
  font-size: 11px; line-height: 16px; font-weight: 500; white-space: nowrap; }
.kanban-drop { min-height: 40px; display: flex; flex-direction: column; gap: 8px; }
.kanban-drop > .deal-card { flex-shrink: 0; }
.kanban-terminals { flex: 0 0 256px; display: flex; flex-direction: column; gap: 12px; }
.kanban-terminal { background: var(--gray-4); border: 0;
  border-radius: var(--kp-r); padding: 12px 0; position: relative; }
.kanban-terminal summary { cursor: pointer; font-weight: 600; font-size: 13px;
  color: var(--text); padding: 7px 28px 7px 8px; border-radius: 6px;
  list-style: none; display: flex; gap: 7px; align-items: center; }
.kanban-terminal summary::before { content: ''; width: 10px; height: 10px;
  min-width: 10px; border-radius: 50%; flex: 0 0 auto;
  background: var(--stage-color, var(--gray-9)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); }
.kanban-terminal summary::-webkit-details-marker { display: none; }
.kanban-terminal > .stage-paint { position: absolute; top: 14px; right: 16px; z-index: 2; }

/* ── Futura PT (бренд-пак k-promo: book=400, medium=500, demi=600, bold=700).
   На канбан-карточке НЕ используется: дисплейная гарнитура, в 12px не читается
   (решение Н 02.09 вечером — карточка на Inter, как в эталоне). Файлы под
   задачи брендирования (заголовки КП, лендинги). ── */
@font-face { font-family: "Futura PT"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/futura/futurapt-book.65f1bab1d35a.woff2") format("woff2"); }
@font-face { font-family: "Futura PT"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/futura/futurapt-medium.160ca77a8a8f.woff2") format("woff2"); }
@font-face { font-family: "Futura PT"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/futura/futurapt-demi.c8b95088c288.woff2") format("woff2"); }
@font-face { font-family: "Futura PT"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/futura/futurapt-bold.7a71d276c9be.woff2") format("woff2"); }

/* ── Карточка v2 «Attio» (порт эталона 02.09): белый прямоугольник без рамки,
   двойная тень, паддинг 16, вертикальный ритм 12. База шрифта карточки —
   12/16 с normal-трекингом; шрифт — фирменная Futura PT. ── */
.deal-card { display: flex; flex-direction: column; flex-shrink: 0; min-width: 0;
  overflow-x: clip; overflow-y: visible; background: var(--surface);
  border: 1px solid var(--gray-6); border-radius: 8px;
  box-shadow: var(--shadow-xs);
  text-decoration: none; color: var(--text); position: relative;
  font-family: var(--kp-font);
  font-size: 12px; line-height: 16px; letter-spacing: normal; font-weight: 400;
  transition: border-color var(--t-fast); }
.deal-card:hover { border-color: var(--gray-8); }
[data-theme="dark"] .deal-card { box-shadow: 0 8px 24px rgb(0 0 0 / .45); }
.deal-card::before { display: none; }
.deal-card-main { display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 12px; text-decoration: none; color: inherit; cursor: grab; }

/* Шапка: суть ≤2 строк + сумма слева, аватар ответственного справа */
.dc-top { display: flex; gap: 8px; align-items: flex-start; }
.dc-hd { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.dc-nm { margin: 0; font-size: 13px; line-height: 20px; font-weight: 600;
  letter-spacing: -0.01em; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dc-sum { margin: 0; font-size: 13px; line-height: 16px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; }
.dc-owner { flex: none; margin-top: 2px; width: 16px; height: 16px; border-radius: 99px;
  background: var(--yellow-9); color: var(--kp-ink); font-size: 9px; line-height: 16px;
  font-weight: 600; display: flex; align-items: center; justify-content: center; }

/* Контакт: имя + юрлицо, справа живые каналы; телефон строкой ниже */
.dc-id { display: flex; flex-direction: column; gap: 4px; min-width: 0;
  font-size: 12px; line-height: 16px; }
.dc-who-row { display: flex; gap: 8px; align-items: flex-start; }
.dc-who { flex: 1; min-width: 0; color: var(--text-muted); overflow-wrap: anywhere; }
.dc-who b { font-weight: 500; color: var(--text); }
.dc-chs { flex: none; display: flex; gap: 4px; align-items: center; }
.dc-ch { width: 16px; height: 16px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform var(--t-fast); }
.dc-ch svg { width: 16px; height: 16px; display: block; }
.dc-ch--link { cursor: pointer; }
.dc-ch--link:hover { transform: scale(1.18); }
.dc-ch--whatsapp { color: var(--ch-whatsapp); }
.dc-ch--telegram { color: var(--ch-telegram); }
.dc-ch--vk { color: var(--ch-vk); }
.dc-ch--max { color: var(--ch-max); }
.dc-ch--avito { color: var(--ch-avito); }
.dc-ch--mute { opacity: .38; filter: saturate(.25); }
.dc-ch--email { width: 16px; height: 16px; border-radius: 99px;
  background: var(--ch-email); color: var(--white); }
.dc-ch--email svg { width: 10px; height: 10px; }
.dc-tel { color: var(--text-muted); display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Сниппет последнего сообщения — тихий, ≤2 строк */
.dc-snip { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Флаги: пилюли заливкой (v2), не контуром */
.dc-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: var(--kp-r-pill);
  background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.tag-paid { background: var(--ok-bg); color: var(--ok-text); }
.tag-debt { background: var(--hot-bg); color: var(--hot-text); }
.deal-card .tag { border: 1px solid var(--gray-6); background: transparent; color: var(--text);
  padding: 1px 8px; font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap;
  border-radius: 999px; }
.deal-card .tag-debt { background: var(--hot-bg); border-color: transparent; color: var(--hot-text); }
[data-theme="dark"] .deal-card .tag { background: transparent; }
.dc-pill { display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--gray-6); background: transparent; color: var(--text-muted);
  padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 16px; font-weight: 500; }
[data-theme="dark"] .dc-pill { background: transparent; }
.dc-pill svg { width: 12px; height: 12px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Следующий шаг: слева суть, справа дата; просрочен — красный */
.dc-next { display: flex; align-items: baseline; gap: 8px; margin: 0;
  font-size: 12px; line-height: 16px; color: var(--text-muted); }
.dc-next b { font-weight: 500; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.dc-next .step-dot { align-self: center; }
.dc-when { margin-left: auto; font-weight: 600; color: var(--text); white-space: nowrap; }
.dc-next--late, .dc-next--late b, .dc-next--late .dc-when { color: var(--kp-hot); }

/* Подвал по эталону v2: компактный чип по контенту слева, старт сделки
   справа (это и есть пара «деньги | время»). Чип неоплаченного прячет кнопки
   Нал/Безнал в hover-раскрытие — в покое карточка чистая, как на эталоне. */
.deal-card-pay { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pay-chip { display: inline-flex; align-items: center; gap: 6px;
  min-width: 50%; white-space: nowrap;
  font-size: 11px; line-height: 16px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px; position: relative;
  font-variant-numeric: tabular-nums; }
.pay-chip--ok { background: var(--ok-bg); color: var(--ok-text); }
.pay-chip--hot { background: var(--hot-bg); color: var(--hot-text); }
.pay-chip--partial { background: color-mix(in srgb, var(--yellow-9) 18%, var(--surface));
  color: var(--yellow-11); }
/* Чип оплаты — цикл не оплачен → частично → оплачен (клик с канбана
   и со слайдера). Без счёта ghost-чип снесён (решение Н 02.09). */
button.pay-chip { border: 0; cursor: pointer; font-family: inherit;
  transition: filter var(--t-fast); }
button.pay-chip:hover { filter: brightness(.96); }
.pay-ok-ic { width: 12px; height: 12px; stroke: currentColor; fill: none;
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.deal-since { flex: none; margin-left: auto; font-size: 11px; line-height: 16px;
  color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deal-card-phone { font-variant-numeric: tabular-nums; }
.drag-ghost { opacity: .4; }

.kanban-col-head > .stage-paint { flex: 0 0 auto; }
.stage-paint { position: relative; flex: 0 0 auto; }
.stage-paint-dot { list-style: none; width: 14px; height: 14px; min-width: 14px;
  flex: 0 0 14px; aspect-ratio: 1; border-radius: 50%;
  padding: 0; background: var(--stage-color, var(--gray-9)); border: 2px solid var(--surface-2);
  cursor: pointer; display: block; box-sizing: border-box;
  transition: transform var(--t-fast); }
.stage-paint-dot:hover { transform: scale(1.15); }
.stage-paint-dot::-webkit-details-marker { display: none; }
.stage-paint-dot:focus { box-shadow: none; }
.stage-paint-dot:focus-visible { outline: 2px solid var(--gray-8); outline-offset: 1px; }
.stage-paint-pop { position: absolute; top: 22px; right: 0; z-index: 30; width: 168px;
  padding: 8px; background: var(--surface); color: var(--text);
  border: 1px solid var(--gray-6); border-radius: 8px;
  display: flex; flex-wrap: wrap; gap: 6px; }
.stage-swatch { width: 22px; height: 22px; border-radius: 50%; padding: 0;
  border: 1px solid rgb(0 0 0 / .18); cursor: pointer; }
.stage-paint-form { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-swatch-on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--yellow-9); }
.deal-inv-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 0; font-size: 14px; }
.deal-inv-pay { display: flex; gap: 6px; flex-wrap: wrap; }
.deal-inv-row .deal-inv-pay { margin-left: auto; }
.deal-invoice .deal-inv-pay { margin-top: 6px; }
.deal-inv-pay .btn { padding: 3px 10px; font-size: 12px; }
.deal-inv-pay .btn.is-on { background: var(--ok-bg); color: var(--ok-text);
  border-color: transparent; font-weight: 600; }

/* Мобильный список по стадиям */
.kanban-mobile { display: none; }
.mobile-stage { background: var(--surface-3); border-radius: var(--kp-r); padding: 8px; margin-bottom: 10px; }
.mobile-stage summary { cursor: pointer; font-weight: 600; font-size: 13.5px;
  display: flex; justify-content: space-between; align-items: center; gap: 7px;
  color: var(--text); border-radius: 6px; padding: 6px 8px; }
.mobile-stage summary::before { content: ''; width: 10px; height: 10px; min-width: 10px;
  border-radius: 50%; flex: 0 0 auto; order: -1;
  background: var(--stage-color, var(--gray-9)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); }
.mobile-stage .kanban-count { color: var(--text-faint); }
.mobile-stage .deal-card { margin-top: 8px; cursor: pointer; }

/* ───────── Формы ───────── */
.form-grid { display: grid; gap: 14px; max-width: 560px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row > label { font-size: 12px;
  color: var(--text-muted); font-weight: 500; }
.field {
  width: 100%; padding: 8px 11px; font: inherit; letter-spacing: inherit;
  border: 1px solid var(--line-strong); border-radius: var(--kp-r-sm);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field:focus { outline: none; border-color: var(--yellow-8); box-shadow: var(--focus-ring); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-cols { grid-template-columns: 1fr; } }

/* Inline-редактирование (клик по значению → форма на месте) */
.editable { cursor: pointer; border-bottom: 1px dashed var(--gray-6); }
.editable:hover { background: var(--surface-2); }
.inline-edit { display: flex; gap: 6px; align-items: center; }
.inline-edit .field { padding: 5px 8px; }
.inline-field { transition: background var(--t-fast); border-radius: 4px; }
.inline-field:hover { background: var(--yellow-1); }
[data-theme="dark"] .inline-field:hover { background: var(--surface-3); }

@media (max-width: 760px) {
  .kanban { display: none; }
  .kanban-mobile { display: block; }
  main.app-main { padding: 14px; }
  .app.app-board { height: auto; overflow: visible; }
  .content.board { height: auto; overflow: visible; display: block; padding-bottom: 14px; }
  .content.board .content-foot { display: block; }
}

/* Вход и 2FA */
.auth-card { max-width: 380px; margin: 6vh auto 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--kp-r-lg);
  box-shadow: var(--kp-shadow-card); padding: 28px 26px; text-align: center; }
.auth-card h1 { font-size: 22px; margin: 0 0 10px; }
.auth-card .muted { color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.qr-box { margin: 18px auto; width: 200px; height: 200px; }
.qr-box svg { width: 100%; height: 100%; }
.manual-key { margin: 4px 0 16px; font-size: 13px; }
.manual-key summary { cursor: pointer; color: var(--text-faint); }
.secret { display: inline-block; margin-top: 8px; padding: 6px 10px;
  background: var(--surface-2); border-radius: var(--kp-r-sm);
  font-family: ui-monospace, monospace; letter-spacing: .12em; word-break: break-all; }
.otp-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.otp-form input { font-size: 28px; text-align: center; letter-spacing: .35em;
  padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--kp-r);
  background: var(--surface); color: var(--text); }
.btn-link { background: none; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 13px; text-decoration: underline; }

.muted { color: var(--text-muted); }

/* Редактор стадий воронки */
.stages-edit input, .stages-edit select { padding: 6px 8px; border: 1px solid var(--line-strong);
  border-radius: var(--kp-r-sm); background: var(--surface); color: var(--text); font: inherit; }
.stages-edit .stage-new { background: var(--surface-2); }

/* Чек-лист стадии */
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.check-done { color: var(--text-faint); text-decoration: line-through; }

/* База знаний — markdown */
.wiki-body { line-height: 1.6; font-size: 14.5px; max-width: 72ch; }
.wiki-body h2 { font-size: 19px; margin: 18px 0 8px; }
.wiki-body h3 { font-size: 16px; margin: 16px 0 6px; }
.wiki-body h4 { font-size: 14px; margin: 14px 0 6px; }
.wiki-body p { margin: 8px 0; }
.wiki-body ul { margin: 8px 0; padding-left: 22px; }
.wiki-body li { margin: 3px 0; }
.wiki-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px;
  font-family: ui-monospace, monospace; font-size: .92em; }
.wiki-body a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); }

/* Конструктор КП */
.quote-item { margin-bottom: 12px; }
.tiers { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tier-pair { display: inline-flex; gap: 4px; }
.tier-pair .field { width: 80px; padding: 5px 7px; }

/* Планёрка — метрики */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--kp-r);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-xs); }
.metric-num { font-size: 22px; font-weight: 650; line-height: 1.1; letter-spacing: -0.02em; }
.metric-cap { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600; }
.metric-debt .metric-num { color: var(--kp-hot); }

/* Карточка сделки: компактный правый столбец */
.deal-aside { display: flex; flex-direction: column; gap: 10px; }
.deal-aside .card { padding: 13px 15px; }
.deal-aside .card h3 { font-size: 14px; letter-spacing: -0.01em; margin-bottom: 8px; }
.fold { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--kp-r); padding: 11px 15px; box-shadow: var(--shadow-xs); }
.fold > summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none;
  display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--text-faint); font-size: 11px; width: 10px; }
.fold[open] > summary::before { content: "▾"; }
.fold > summary .cnt { margin-left: auto; color: var(--text-faint); font-weight: 400; font-size: 12.5px; }
.fold > *:not(summary) { margin-top: 10px; }

/* ───────── Переписка: тред как в почтовике ───────── */
.msg { display: flex; gap: 10px; margin: 0 0 14px; }
.msg-out { flex-direction: row-reverse; }
.msg-avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: var(--white); background: var(--gray-9); }
.msg-out .msg-avatar { background: var(--yellow-9); color: var(--kp-ink); }
.msg-bubble { max-width: 80%; min-width: 240px; padding: 10px 13px;
  border-radius: var(--kp-r); border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-xs); }
.msg-out .msg-bubble { background: var(--yellow-2); border-color: var(--yellow-4);
  --text: #1B1B1B; --text-faint: #6F684A; color: var(--text); }
.msg-head { font-size: 12px; color: var(--text-faint); margin-bottom: 6px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.msg-head strong { color: var(--text); font-weight: 600; }
.msg-time { white-space: nowrap; }
.msg-body { white-space: pre-wrap; font-size: 14px; line-height: 1.55; word-break: break-word; }
.msg-atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.att-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
  font-size: 12.5px; text-decoration: none; color: var(--text); max-width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast); }
.att-chip:hover { border-color: var(--yellow-8); background: var(--surface); }
.att-chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.att-ico { font-size: 17px; }
.att-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500; }
.att-size { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; }
.qfold { margin-top: 8px; }
.qfold > summary { cursor: pointer; font-size: 12px; color: var(--text-faint);
  user-select: none; list-style: none; transition: color var(--t-fast); }
.qfold > summary::-webkit-details-marker { display: none; }
.qfold > summary::before { content: "▸ "; font-size: 10px; }
.qfold[open] > summary::before { content: "▾ "; }
.qfold[open] > summary { color: var(--text); }
.msg-quoted { white-space: pre-wrap; font-size: 13px; line-height: 1.45;
  color: var(--text-faint); border-left: 3px solid var(--gray-4); /* impeccable-disable-line side-tab — цитата письма, почтовая конвенция (как Gmail/Apple Mail) */
  padding-left: 10px; margin-top: 6px; word-break: break-word; }

/* ───────── Модалка быстрого создания ───────── */
.modal-overlay { position: fixed; inset: 0; background: rgb(20 21 23 / .40);
  backdrop-filter: blur(2px);
  z-index: 200; display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px; }
.modal-box { background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-md), 0 16px 40px rgb(0 0 0 / .12);
  padding: 18px 20px; width: 600px; max-width: 100%; max-height: 86vh; overflow: auto;
  animation: modal-in 150ms ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(4px) scale(.985); }
  to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x { background: none; border: 0; cursor: pointer; font-size: 15px;
  color: var(--text-faint); padding: 4px 8px; border-radius: 7px;
  transition: background var(--t-fast), color var(--t-fast); }
.modal-x:hover { background: var(--surface-2); color: var(--text); }

/* Входящие: вся строка кликабельна */
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--surface-2); }

/* Дисциплина потока: чипы-фильтры */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--kp-r-pill);
  font-size: 12.5px; font-weight: 500; text-decoration: none; color: var(--text);
  background: var(--surface); box-shadow: var(--shadow-xs);
  transition: background var(--t-fast), border-color var(--t-fast); }
.chip:hover { background: var(--surface-2); }
.chip-hot { color: var(--hot-text); border-color: #EBC8C4; background: var(--hot-bg); }
.chip-active { background: var(--kp-ink); color: var(--white); border-color: var(--kp-ink); }
.chip-hot.chip-active { background: var(--kp-hot); color: var(--white); border-color: var(--kp-hot); }

/* Undo-тосты (батч 9) */
#toast-root { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 14px; background: var(--kp-ink);
  color: var(--white); border-radius: 10px; padding: 10px 16px; font-size: 14px;
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.25)); }
.toast-btn { border: 0; background: none; color: var(--yellow-9); font: inherit; font-weight: 700;
  cursor: pointer; padding: 2px 4px; }

/* «★ сохранить вид»: первый клик раскрывает поле названия, Enter/повторный клик сохраняет */
.sv-save { display: inline-flex; align-items: center; }
.sv-save input.field { display: none; width: 150px; margin-right: -1px;
  padding: 2px 8px; font-size: 12px; border-radius: var(--kp-r-pill) 0 0 var(--kp-r-pill); }
.sv-save.open input.field { display: inline-block; }
.sv-save.open button.chip { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Двухфазное подтверждение ([data-confirm] + ui-confirm.js):
   взведённая кнопка — красная, второй клик выполняет, 4 с бездействия снимает.
   Тёмные селекторы дублированы с [data-theme], чтобы перебить тему (специфичность). */
.chip.confirm-arm, .btn.confirm-arm, button.confirm-arm,
[data-theme="dark"] .chip.confirm-arm, [data-theme="dark"] .btn.confirm-arm,
[data-theme="dark"] button.confirm-arm {
  background: var(--kp-hot); color: var(--white); border-color: transparent; }

/* Вкладки-сегменты (Входящие): активная — жёлтая планка, единый язык с полосой стадии */
.seg-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 14px;
  border-bottom: 1px solid var(--line); }
.seg-tab { position: relative; padding: 6px 12px 7px; font-size: 13.5px; font-weight: 500;
  color: var(--text-muted); text-decoration: none; border-radius: 8px 8px 0 0;
  transition: background var(--t-fast), color var(--t-fast); }
.seg-tab:hover { background: var(--surface-2); color: var(--text); }
.seg-tab-on { color: var(--text); font-weight: 650; }
.seg-tab-on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 3px; border-radius: 2px 2px 0 0; background: var(--yellow-9); }

/* Палитра Ctrl+K (батч 9) */
#palette-overlay { position: fixed; inset: 0; background: rgba(15,15,15,.45); z-index: 300; }
#palette-box { width: min(580px, 92vw); margin: 12vh auto 0; background: var(--surface, var(--white));
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.3); }
#palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--line);
  padding: 14px 16px; font: inherit; font-size: 15px; background: var(--surface);
  color: var(--text); outline: none; box-sizing: border-box; }
#palette-results { max-height: 52vh; overflow-y: auto; padding: 6px 0; }
.pal-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); padding: 8px 16px 3px; }
.pal-item { display: flex; justify-content: space-between; gap: 12px; padding: 7px 16px;
  font-size: 14px; color: var(--text); text-decoration: none; }
.pal-item:hover, .pal-item.active { background: var(--surface-2); }
.pal-meta { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.pal-empty { padding: 16px; color: var(--text-faint); font-size: 14px; }
#palette-hint { border-top: 1px solid var(--line); padding: 7px 16px; font-size: 11.5px;
  color: var(--text-faint); }
.chip-x { border: 0; background: none; cursor: pointer; color: inherit; font-size: 11px;
  padding: 0 0 0 2px; opacity: .55; }
.chip-x:hover { opacity: 1; }

/* ───────── Лента стадий в шапке карточки (волна Г + F1 UX-ускорение) ─────────
   Плашки: пройденные (fog) / текущая (#FECE15 + чёрный текст) / будущие (контур);
   терминалы — зелёная/красная, отделены. Клик = move_stage. На ≤760px лента
   скроллится горизонтально (не прячем). */
.stage-strip { display: flex; flex-wrap: nowrap; align-items: center; gap: 0;
  margin: 0 0 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch; touch-action: pan-x; overscroll-behavior-x: contain;
  padding: 2px 0; }
#deal-main[data-dropzone] { position: relative; }
.stage-pill { font: inherit; font-size: 12px; font-weight: 500; padding: 5px 16px 5px 18px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-faint);
  cursor: pointer; white-space: nowrap; flex: 0 0 auto;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
  margin-left: -6px; transition: background var(--t-fast), color var(--t-fast); }
.stage-strip .stage-pill:first-of-type { margin-left: 0;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
  padding-left: 12px; }
.stage-pill:hover { background: var(--surface-2); color: var(--text); }
.stage-pill:disabled { cursor: default; }
.stage-passed { background: var(--kp-fog); border-color: transparent; color: var(--text-muted); }
.stage-passed:hover { background: var(--gray-5); }
.stage-current, .stage-current:hover { background: var(--kp-ink); border-color: transparent;
  color: var(--white); font-weight: 600; }
.stage-won, .stage-won:hover { background: var(--ok-bg); border-color: transparent; color: var(--ok-text);
  clip-path: none; border-radius: var(--kp-r-pill); margin-left: 0; padding: 4px 12px; }
.stage-lost, .stage-lost:hover { background: var(--hot-bg); border-color: transparent; color: var(--hot-text);
  clip-path: none; border-radius: var(--kp-r-pill); margin-left: 0; padding: 4px 12px; }
.stage-won.stage-current { background: var(--kp-eco); color: var(--white); }
.stage-lost.stage-current { background: var(--kp-hot); color: var(--white); }
.stage-strip-sep { width: 1px; align-self: stretch; background: var(--line-strong); margin: 2px 10px;
  flex: 0 0 1px; }
.stage-badge-mobile { display: none; }
.loss-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -8px 0 16px; }
.loss-picker[hidden] { display: none; }
.drop-overlay { position: absolute; inset: 0; z-index: 20; background: rgb(20 21 23 / .45);
  color: var(--white); display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; pointer-events: none; text-align: center;
  padding: 16px; }
.drop-overlay[hidden] { display: none; }
#deal-main.drop-active { outline: 2px dashed var(--gray-8); outline-offset: -4px; }
.paste-preview { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.paste-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 8px; font-size: 12px; background: var(--surface-2); }
.paste-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.today-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.today-sec { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); margin: 18px 0 8px; }
.today-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: var(--surface); }
.today-row.kb-focus, .kb-row.kb-focus { outline: 2px solid var(--kp-ink); outline-offset: 1px; }
.today-row-main { flex: 1; min-width: 0; }
.today-row-sub { font-size: 13px; color: var(--text-faint); }
.today-row-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.today-act { padding: 4px 8px; font-size: 13px; }
.today-empty { text-align: center; padding: 48px 16px; color: var(--text); }
.shift-menu { display: flex; gap: 6px; align-items: center; margin-left: 8px; }
.help-overlay { position: fixed; inset: 0; z-index: 300; background: rgb(20 21 23 / .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px; }
.help-overlay[hidden] { display: none; }
.help-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; width: 480px; max-width: 100%; box-shadow: var(--shadow-md); }
.help-box h2 { margin: 0 0 12px; font-size: 18px; }
.help-box td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
@media (max-width: 760px) {
  .stage-strip { display: flex; }
  .stage-badge-mobile { display: none; }
}

/* Спецификация (батч 10): плотная таблица с инлайн-инпутами */
.spec-table td { padding: 3px 4px; }
.spec-table input.field { padding: 4px 6px; font-size: 13px; width: 100%; box-sizing: border-box; }
.spec-table input[name="qty"] { min-width: 76px; } /* 5-значный тираж виден целиком */
.spec-del { border: 0; background: none; color: var(--text-faint); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.spec-del:hover { color: var(--kp-hot); background: var(--surface-2); }

/* Мультивыбор категорий: чипы-чекбоксы, не выпадайка */
.cat-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-picker-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cat-picker label.chip { cursor: pointer; user-select: none; position: relative; margin: 0; }
.cat-picker-cb { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.cat-picker label.chip:has(.cat-picker-cb:focus-visible) { outline: 2px solid var(--kp-ink); outline-offset: 2px; }
.cat-picker label.chip:has(.cat-picker-cb:checked) {
  background: var(--kp-ink); color: var(--white); border-color: var(--kp-ink);
}
.cat-picker-new { border-style: dashed; gap: 4px; cursor: text; }
.cat-picker-new:has(.cat-picker-new-input:focus) { border-style: solid; border-color: var(--kp-ink); }
.cat-picker-new-input { border: 0; background: transparent; font: inherit; font-size: 12.5px;
  width: 6.5em; outline: none; color: inherit; padding: 0; min-width: 0; }
.cat-picker-new-input::placeholder { color: var(--text-faint); }
.cat-picker-implicit { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); border: 0; padding: 0; margin: -1px; }
.cat-chip { display: inline-flex; align-items: stretch; }
.cat-chip .chip { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cat-chip-del { border: 1px solid var(--line-strong); border-left: 0; margin: 0;
  border-radius: 0 var(--kp-r-pill) var(--kp-r-pill) 0; background: var(--surface);
  color: var(--text-faint); cursor: pointer; padding: 0 8px; font: inherit; font-size: 15px;
  line-height: 1; }
.cat-chip:has(.cat-picker-cb:checked) .cat-chip-del {
  background: var(--kp-ink); color: var(--white); border-color: var(--kp-ink); }
.cat-chip-del:hover { color: var(--kp-hot); background: var(--surface-2); }
.cat-chip:has(.cat-picker-cb:checked) .cat-chip-del:hover { color: var(--white); background: #3a3a3a; }

/* F5 peek + F6 hover-кнопки на канбане */
.peek-trig, .card-hover-acts { display: none; }
.peek-trig { position: absolute; top: 6px; right: 36px; z-index: 3;
  width: 28px; height: 28px; align-items: center; justify-content: center;
  border: 1px solid var(--gray-6); border-radius: 6px; background: var(--surface);
  color: var(--text); cursor: pointer; padding: 0; }
.peek-trig:hover { border-color: var(--gray-8); }
.card-hover-acts { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  justify-content: flex-end; gap: 4px; padding: 6px 8px;
  background: linear-gradient(transparent, var(--surface) 40%);
  pointer-events: none; }
.card-hover-acts .card-act { pointer-events: auto; }
.card-act { display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 28px; padding: 0 8px; border: 1px solid var(--gray-6);
  border-radius: 6px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 12px; font-weight: 650; text-decoration: none; cursor: pointer; }
.card-act:hover { border-color: var(--gray-8); }
@media (hover: hover) and (pointer: fine) {
  .deal-card:hover .peek-trig,
  .deal-card:focus-within .peek-trig { display: flex; }
  .deal-card:hover .card-hover-acts,
  .deal-card:focus-within .card-hover-acts { display: flex; }
}
.peek-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100vw);
  z-index: 50; display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--gray-6); box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.deal-dim { position: fixed; inset: 0; background: rgb(20 21 23 / .38); z-index: 49; cursor: default; }
.peek-panel.deal-slider { top: 56px; right: auto; bottom: 28px; left: 50%;
  width: min(1000px, calc(100vw - 120px)); transform: translateX(-50%);
  border-left: 0; border: 1px solid var(--gray-6); border-radius: 14px;
  background: var(--gray-2); box-shadow: 0 24px 64px rgb(0 0 0 / .28); }
.deal-slider-head { display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; color: var(--text-muted); font-size: 12.5px; flex: none; }
.deal-slider-head-actions { display: flex; align-items: center; gap: 12px; }
.deal-slider-head .peek-close { width: 28px; height: 28px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.deal-slider-head .peek-close:hover { color: var(--text); background: var(--surface-2); }
.deal-sheet { flex: 1; overflow: auto; padding: 4px 20px 22px; }

/* Слайдер — вид утверждённого макета 08.09 (kartochki-otkrytie):
   шапка «организация / имя клиента / чип / сумма / даты», две колонки.
   Скоуп под .deal-slider — полная страница живёт прежними классами. */
.deal-slider .deal-head-title { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.deal-slider .deal-head-title a { text-decoration: none; }
.deal-slider .deal-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.deal-slider .deal-head-k { margin: 0 0 2px; font-size: 11px; color: var(--text-muted);
  letter-spacing: .04em; text-transform: uppercase; }
.deal-slider .deal-head-sum { margin: 4px 0 0; font-size: 17px; font-weight: 650; }
.deal-slider .deal-dates { margin: 8px 0 10px; font-size: 13px; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 4px 14px; }
.deal-slider .deal-dates b { color: var(--text); font-weight: 600; }
.deal-slider .deal-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 12px; align-items: start; margin-top: 12px; }
.deal-slider .deal-cols > div > .card,
.deal-slider .deal-cols > div > details.fold,
.deal-slider .deal-cols > div > .deal-client { margin: 0 0 12px; }
.deal-slider .deal-cols .card > h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: -.01em; }
/* h3 секции уже называет блок — служебный h4 партиала внутри прячем */
.deal-slider .deal-cols .card h4:first-child { display: none; }
.deal-slider .stage-strip { margin: 0 0 4px; }
.deal-slider .stage-pill { font-size: 11.5px; padding: 4px 13px 4px 15px; }
.deal-slider .owner-chip { border: 1px solid var(--line-strong); background: var(--surface); }
.deal-slider .owner-pick .owner-menu { left: auto; right: 0; }
.deal-slider .src-inline { border: 0; background: transparent; font: inherit;
  font-weight: 600; color: var(--text); cursor: pointer; padding: 0 2px; }
.deal-slider .inline-field { border-bottom: 0 !important; }

/* Деньги — консоль макета, не волна 1 «Доход/Расход/Маржа» */
.deal-slider .money { padding-bottom: 4px; }
.deal-slider .money h3 { margin-bottom: 8px; }
.deal-slider .money-top { display: flex; align-items: center; justify-content: space-between;
  gap: 8px 12px; flex-wrap: wrap; }
.deal-slider .money-sum { font-size: 20px; font-weight: 700; letter-spacing: -.03em; flex: none; }
.deal-slider .money-tools { display: flex; align-items: center; gap: 6px;
  flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; margin-left: auto;
  min-width: 0; max-width: 100%; }
.deal-slider .money-inv { font-size: 13px; font-weight: 600; white-space: nowrap; }
.deal-slider .money-inv-btn { border: 0; background: none; font: inherit;
  font-weight: 600; color: inherit; cursor: pointer; padding: 0; }
.deal-slider .money-inv-btn:hover { text-decoration: underline; }
.deal-slider .money-bot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px;
  font-size: 13px; color: var(--text-muted); }
.deal-slider .money-bot b { color: var(--text); font-weight: 650; font-size: 14px; }
.deal-slider .money-pct { font-weight: 600; }
.deal-slider .pay-chip { min-width: 0; font-size: 12px; }
.deal-slider .money-pdf { position: relative; }
.deal-slider .money-pdf[open] { flex: 1 1 100%; max-width: 100%; }
.deal-slider .money-pdf > summary { list-style: none; cursor: pointer; }
.deal-slider .money-pdf > summary::-webkit-details-marker { display: none; }
.deal-slider .money-pdf .deal-invoice-file { margin-top: 8px; max-width: 100%; }
.deal-slider .money-pdf .inv-file-form { max-width: 100%; }
.deal-slider .money-pdf .inv-file-form input[type="file"] { max-width: 100%; }

.deal-slider .spec-row-sub { display: none; }
.deal-slider .spec-mini, .deal-slider .spec-unit { display: none; }
.deal-slider #spec-block > h4 { display: none; }
.deal-slider .spec-row--line { flex-wrap: nowrap; }
.deal-slider .spec-add { margin-top: 2px; }
.deal-slider .spec-add-input { margin-top: 2px; border: 0; background: none;
  color: var(--text-muted); font: 500 13px inherit; padding: 0; }
.deal-slider .spec-add-input:hover { color: var(--text); }
.deal-slider .quiet-add { margin-top: 2px; border: 0; background: none; color: var(--text-muted);
  font: 500 13px inherit; cursor: pointer; padding: 0; text-decoration: none; display: inline; }
.deal-slider .quiet-add:hover { color: var(--text); }
.deal-slider .fld { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 10px; font: inherit; background: var(--surface); box-sizing: border-box; }
.deal-slider .sup { display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 8px 3px 11px;
  font-size: 13px; margin: 0 6px 6px 0; background: var(--kp-ink); color: var(--gray-1); }
.deal-slider .sup button { border: 0; background: none; color: inherit; cursor: pointer;
  padding: 0 2px; opacity: .7; }
.deal-slider .sup button:hover { opacity: 1; }
.deal-slider .pick { position: relative; margin-top: 4px; }

.deal-slider .who { margin: 0 0 4px; }
.deal-slider .who-top { display: flex; justify-content: space-between; align-items: stretch; gap: 8px; }
.deal-slider .who-name, .deal-slider .tel, .deal-slider .mail {
  display: block; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; background: var(--surface); min-height: 1.2em; flex: 1;
  text-decoration: none; color: inherit; }
.deal-slider .who-name { font-size: 15px; font-weight: 700; }
.deal-slider .tel, .deal-slider .mail { color: var(--text-muted); }
.deal-slider .tel { font-variant-numeric: tabular-nums; }
.deal-slider .tel-row, .deal-slider .mail-row { display: flex; gap: 6px; align-items: stretch; margin-top: 6px; }
.deal-slider .copy-btn { width: 36px; height: auto; }
.deal-slider .who-links { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; }
.deal-slider .who-links .quiet-add { margin-top: 0; }
.deal-slider .deal-channels { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.deal-slider .ch-empty { display: none; }
.deal-slider .ch-ic-wrap { display: none; }
.deal-slider .ch-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.deal-slider .ch-tog { width: 32px; height: 32px; border: 0; background: none; padding: 0;
  border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  color: inherit; text-decoration: none; cursor: pointer; }
.deal-slider .ch-tog svg { width: 20px; height: 20px; display: block; }
.deal-slider .ch-tog.ch-whatsapp { color: var(--ch-whatsapp); }
.deal-slider .ch-tog.ch-telegram { color: var(--ch-telegram); }
.deal-slider .ch-tog.ch-max { color: var(--ch-max); }
.deal-slider .ch-tog.ch-vk { color: var(--ch-vk); }
.deal-slider .ch-tog.ch-email { color: var(--ch-email); }
.deal-slider .ch-tog.ch-avito { color: var(--ch-avito); }
.deal-slider .ch-tog.ch-email.on { background: var(--ch-email); color: #fff;
  border-radius: 99px; }
.deal-slider .ch-tog.ch-email.on svg { width: 14px; height: 14px; }
.deal-slider .ch-tog:hover { background: var(--surface-2); }
.deal-slider .ch-tog.ch-email.on:hover { background: var(--ch-email); color: #fff; }
.deal-slider .ch-tog:not(.on) { opacity: .38; filter: saturate(.25); }
.deal-slider .ch-edit { margin-top: 8px; }
.deal-slider .composer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.deal-slider .composer-bar .quiet-add { margin-top: 0; }
.deal-slider .file-chip { display: inline-flex; align-items: center; gap: 4px; margin: 0 6px 6px 0;
  padding: 3px 8px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; }
.deal-slider .file-chip a { color: inherit; text-decoration: none; }
.deal-slider .composer, .deal-slider .deal-reply { margin: 0 0 8px; }
.deal-slider .deal-reply-none { display: none; }
.deal-slider .deal-reply-body { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; min-height: 52px; resize: vertical; background: var(--surface); box-sizing: border-box; }
.deal-slider .slider-more { margin-top: 8px; }

/* Спецификация и закуп — строки-боксы (макет 08.09), поля все на месте */
.spec-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  padding: 7px 10px; margin: 0 0 6px; }
.spec-row .spec-name { flex: 1; min-width: 12em; border: 0; background: transparent;
  padding: 2px 4px; font-weight: 500; }
.spec-row .spec-mini { width: 5.5em; border: 0; background: transparent; padding: 2px 4px; }
.spec-row .spec-unit { width: 3.5em; }
.spec-del { border: 0; background: none; color: var(--text-faint); cursor: pointer;
  font-size: 14px; padding: 0 2px; }
.spec-del:hover { color: var(--kp-hot); }
.spec-row-sub { display: flex; flex: 1 1 100%; gap: 6px; }
.spec-row-sub .spec-sub { flex: 1; min-width: 6em; border: 0; background: var(--surface-2);
  border-radius: 6px; padding: 3px 8px; font-size: 12.5px; color: var(--text-muted); }
.spec-row-sub .spec-sub:focus { color: var(--text); }
.spec-add-input { margin-top: 2px; border-style: dashed; font-size: 13px; }
.pur-row { display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  padding: 7px 10px; margin: 0 0 6px; }
.pur-main { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.pur-sup { flex: 1; min-width: 10em; border: 0; background: transparent; padding: 2px 4px; font-weight: 600; }
.pur-money { width: 7.5em; border: 0; background: transparent; padding: 2px 4px;
  font-variant-numeric: tabular-nums; }
.pur-vat { font-size: 12px; }
.pur-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pur-cell { flex: 1; min-width: 8em; border: 0; background: var(--surface-2);
  border-radius: 6px; padding: 3px 8px; font-size: 12.5px; }
.pur-mini { width: auto; max-width: 11em; border: 0; background: var(--surface-2);
  border-radius: 6px; padding: 3px 8px; font-size: 12.5px; }
input[type="date"].pur-mini { width: 9.5em; color: var(--text-muted); }
.pur-empty { font-size: 13px; margin: 0 0 6px; }
.pur-add { margin: 2px 0 6px; }
.pur-add summary { display: inline-block; border: 0; background: none;
  color: var(--text-muted); font: 500 13px inherit; cursor: pointer; padding: 0;
  list-style: none; }
.pur-add summary::-webkit-details-marker { display: none; }
.pur-add summary:hover { color: var(--text); }
.pur-add-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pur-add-grid .field { font-size: 13px; }
.pur-totals { margin: 4px 0 0; font-size: 13px; }
.copy-btn { width: 28px; height: 28px; flex: none; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); cursor: pointer;
  color: var(--text-muted); display: inline-flex; align-items: center;
  justify-content: center; font-size: 14px; }
.copy-btn:hover { color: var(--text); background: var(--surface-2); }
@media (max-width: 900px) {
  .deal-slider .deal-cols { grid-template-columns: 1fr; }
  .deal-slider .money-top { flex-wrap: wrap; }
}
.peek-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 16px 10px;
  border-bottom: 1px solid var(--gray-5); }
.peek-num { font-size: 12px; color: var(--text-faint); }
.peek-close { border: 0; background: transparent; font-size: 18px; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: 4px; }
.peek-body { padding: 14px 16px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.peek-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.peek-msg { padding-top: 8px; border-top: 1px solid var(--gray-5); }
.peek-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin: 6px 0 0; font-size: 14px; line-height: 1.4; }
.peek-acts { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--gray-5); }
.peek-skel { padding-top: 20px; }
.peek-skel .peek-bar { height: 12px; margin: 14px 16px; border-radius: 4px;
  background: var(--gray-5); animation: peekPulse 1s ease infinite; }
.peek-skel .peek-bar.short { width: 40%; }
@keyframes peekPulse { 50% { opacity: .4; } }

@media (max-width: 760px) {
  .peek-panel { top: auto; left: 0; width: 100%; max-height: 70vh;
    border-left: 0; border-top: 1px solid var(--gray-6);
    border-radius: 12px 12px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,.12); }
  .peek-panel.deal-slider { top: 8px; bottom: 8px; left: 8px; right: 8px;
    width: auto; max-height: none; transform: none; border-radius: 12px; }
}

/* F7 свайпы inbox: только pan-y, горизонталь ловит JS */
.kb-row { touch-action: pan-y; }
.kb-row.swipe-right { background: color-mix(in srgb, var(--kp-eco) 16%, var(--surface)); }
.kb-row.swipe-left { background: color-mix(in srgb, var(--gray-6) 55%, var(--surface)); }
.kb-row.swipe-spam { background: color-mix(in srgb, var(--kp-hot) 16%, var(--surface)); }

/* F8 индикатор HTMX на кнопках */
.btn.htmx-request, button.htmx-request { opacity: .55; pointer-events: none; }
.feed-item { padding: 7px 0; border-bottom: 1px solid var(--line); }
.feed-meta { font-size: 12px; color: var(--text-faint); }
.feed-body { font-size: 13px; line-height: 1.4; }

/* F10 bulk — только «Сегодня», на канбане выбора карточек нет */
.bulk-bar { position: sticky; bottom: 12px; z-index: 20; display: flex; flex-wrap: wrap;
  align-items: center; gap: 8px; padding: 10px 12px; margin: 12px 0;
  background: var(--surface); border: 1px solid var(--gray-6); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.bulk-bar[hidden] { display: none !important; }
.bulk-check { display: none; position: absolute; top: 6px; right: 8px; z-index: 3;
  background: var(--surface); border-radius: 4px; padding: 2px; }
.bulk-check-row { position: static; display: inline-flex; }

/* F11 нижняя панель карточки */
.deal-mobile-bar, .stage-sheet { display: none; }
@media (max-width: 760px) {
  #deal-main { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .deal-mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border-top: 1px solid var(--gray-6); }
  .deal-mobile-bar .btn { flex: 1; text-align: center; font-size: 13px; padding: 10px 6px; }
  .deal-mobile-off { opacity: .45; pointer-events: none; }
  .stage-sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    max-height: 70vh; overflow: auto; padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border-top: 1px solid var(--gray-6);
    border-radius: 12px 12px 0 0; }
  .stage-sheet[hidden] { display: none !important; }
  .stage-sheet-list { display: flex; flex-direction: column; gap: 6px; }
}

.purchase-grid .grid-cell { width: 100%; font-size: 13px; padding: 3px 6px; box-sizing: border-box; }
.pal-hint { font-size: 12px; color: var(--text-faint); padding: 8px 4px 4px; }
.pal-hint code { font-size: 11px; }

/* Карточка клиента: кликабельные каналы контакта (эталон Б24) */
.contact-id-links { display: inline-flex; gap: 6px; align-items: center; }
.contact-id-links a { font-size: 12px; font-weight: 600; text-decoration: none;
  padding: 1px 7px; border-radius: var(--kp-r-pill, 999px);
  background: var(--surface-3, #eee); color: var(--text, inherit); }
.contact-id-links a:hover { background: var(--yellow-9, #FECE15); color: #201800; }
.copy-link { border: 0; background: none; padding: 0; cursor: pointer;
  color: inherit; font: inherit; border-bottom: 1px dashed var(--line); }


/* ───────── Гигиена интерфейса (UI-QA 05.10, crm/issledovanie-2026-10-05/01-ui-qa.md) ───────── */
/* №5: форм-контролы не наследовали шрифт — .btn рисовался Arial */
button, input, select, textarea { font: inherit; letter-spacing: inherit; }
/* №4: широкая таблица прокручивается внутри карточки, а не всей страницей (телефон/планшет) */
.card:has(> table.data), .card:has(> .table-scroll) { overflow-x: auto; }
/* №2: «Выиграна/Проиграна» прилипают к правому краю полосы и не прячутся за скроллом */
.stage-strip-end { position: sticky; right: 0; margin-left: auto; display: inline-flex; align-items: center;
  gap: 6px; padding-left: 6px; background: var(--surface); box-shadow: -10px 0 8px -4px var(--surface); }
/* №16: длинная строка без пробелов не вылезает из ленты */
.feed-body, .feed-item, .msg-body { overflow-wrap: anywhere; }
/* №15: заметное кольцо фокуса у раскрывающихся фильтров */
summary.chip:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.table-scroll { overflow-x: auto; max-width: 100%; }
