/* Оформление в стиле «Фабрики» (presale-server, Mantine v7): маджента #E60077 точечно,
   нейтральные серые Mantine в светлой теме, тёплая тёмная палитра, Inter, плотно и тонко. */
:root {
  --paper: #fafaf9;          /* фон body, off-white */
  --surface: #ffffff;        /* карточки, шапка, меню */
  --surface-2: #f8f9fa;      /* шапки таблиц, наведение (gray-0) */
  --surface-3: #f1f3f5;      /* дорожки графиков (gray-1) */
  --border: #dee2e6;         /* default-border (gray-3) */
  --input-border: #ced4da;   /* рамка полей (gray-4) */
  --ink: #212529;
  --ink-soft: #495057;
  --ink-faint: #868e96;      /* dimmed */
  --accent: #e60077;         /* brand-6 */
  --accent-hover: #cc0468;   /* brand-7 */
  --accent-soft: rgba(230,0,119,.1);
  --accent-ink: #e60077;     /* текст на светлой заливке акцента */
  --good: #2b8a3e;
  --good-soft: #ebfbee;
  --bad: #e03131;
  --bad-soft: #fff5f5;
  --neutral: #495057;
  --neutral-soft: #f1f3f5;
  --scrim: rgba(0,0,0,.45);
  --shadow: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.05), rgba(0,0,0,.05) 0 10px 15px -5px, rgba(0,0,0,.04) 0 7px 7px -5px;
  --shadow-lg: 0 1px 3px rgba(0,0,0,.05), rgba(0,0,0,.05) 0 28px 23px -7px, rgba(0,0,0,.04) 0 12px 12px -7px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --nav-w: 240px;
  --brand-ink: #22222a;
  --brand-caption: #8a8a90;
  --brand-divider: #d9d9de;
  color-scheme: light;
}
/* Тёмная тема Фабрики: body ≈ dark[7], карточки ≈ dark[6] — маджента на этом фоне «горит» */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1920; --surface: #232028; --surface-2: #2e2a36; --surface-3: #413d4b;
    --border: #413d4b; --input-border: #413d4b;
    --ink: #d3d0d9; --ink-soft: #a9a5b3; --ink-faint: #807b8c;
    --accent: #ee2286; --accent-hover: #e60077; --accent-soft: rgba(230,0,119,.15); --accent-ink: #f34c97;
    --good: #69db7c; --good-soft: rgba(47,158,68,.15);
    --bad: #ff8787; --bad-soft: rgba(224,49,49,.15);
    --neutral: #a9a5b3; --neutral-soft: #2e2a36;
    --scrim: rgba(0,0,0,.6);
    --shadow: 0 1px 3px rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.3);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.2), rgba(0,0,0,.3) 0 10px 15px -5px;
    --shadow-lg: 0 1px 3px rgba(0,0,0,.3), rgba(0,0,0,.45) 0 28px 23px -7px;
    --brand-ink: #ffffff; --brand-caption: rgba(255,255,255,.55); --brand-divider: rgba(255,255,255,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1920; --surface: #232028; --surface-2: #2e2a36; --surface-3: #413d4b;
  --border: #413d4b; --input-border: #413d4b;
  --ink: #d3d0d9; --ink-soft: #a9a5b3; --ink-faint: #807b8c;
  --accent: #ee2286; --accent-hover: #e60077; --accent-soft: rgba(230,0,119,.15); --accent-ink: #f34c97;
  --good: #69db7c; --good-soft: rgba(47,158,68,.15);
  --bad: #ff8787; --bad-soft: rgba(224,49,49,.15);
  --neutral: #a9a5b3; --neutral-soft: #2e2a36;
  --scrim: rgba(0,0,0,.6);
  --shadow: 0 1px 3px rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2), rgba(0,0,0,.3) 0 10px 15px -5px;
  --shadow-lg: 0 1px 3px rgba(0,0,0,.3), rgba(0,0,0,.45) 0 28px 23px -7px;
  --brand-ink: #ffffff; --brand-caption: rgba(255,255,255,.55); --brand-divider: rgba(255,255,255,.3);
  color-scheme: dark;
}
:root[data-collapsed] { --nav-w: 64px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--ink);
  font-family: 'Inter','Segoe UI',Arial,sans-serif; font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: inherit; font-weight: 600; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
button, select, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.mono { font-family: 'JetBrains Mono', monospace; }
::selection { background: var(--accent-soft); }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---- shell: шапка 72px + боковое меню 240px (свёрнутое — 64px) ---- */
.app {
  display: grid; grid-template-columns: var(--nav-w) minmax(0,1fr); grid-template-rows: 72px minmax(0,1fr);
  height: 100vh; transition: grid-template-columns .15s ease;
}

.header {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); z-index: 5;
}
.header .spacer { flex: 1; }

/* логотип «Первый БИТ»: чёрный на светлой теме, белый (розовый квадрат остаётся) — на тёмной */
.brand-lockup { display: flex; align-items: center; gap: 16px; user-select: none; }
.brand-logo { height: 44px; width: auto; display: block; -webkit-user-drag: none; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}
.brand-divider { width: 1px; align-self: stretch; margin: 2px 0; background: var(--brand-divider); }
.brand-product {
  display: flex; flex-direction: column; font-family: Arial,'Liberation Sans',Helvetica,sans-serif;
  font-size: 17px; line-height: 1.2; color: var(--brand-ink); white-space: nowrap;
}
.brand-product span { font-size: 12px; color: var(--brand-caption); }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: none; background: transparent;
  color: var(--ink-soft); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

.navbar {
  position: relative; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 4;
}
.nav-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .4px;
  padding: 6px 12px; white-space: nowrap;
}
.nav-sep { height: 8px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font-size: 14px; text-align: left; cursor: pointer; white-space: nowrap;
}
.nav-link svg { width: 18px; height: 18px; }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.nav-foot {
  padding: 10px 20px 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--ink-faint); line-height: 1.35;
}
.sidebar-handle {
  position: absolute; top: 18px; right: -12px; z-index: 6; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0; box-shadow: var(--shadow);
}
.sidebar-handle:hover { color: var(--accent-ink); border-color: var(--accent); }
.sidebar-handle svg { width: 14px; height: 14px; stroke-width: 1.8; }
.sidebar-handle .i-right { display: none; }
/* свёрнутое меню — полоса иконок 40×40 по центру, подписи в подсказках */
:root[data-collapsed] .sidebar-handle .i-left { display: none; }
:root[data-collapsed] .sidebar-handle .i-right { display: block; }
:root[data-collapsed] .nav-section, :root[data-collapsed] .nav-foot, :root[data-collapsed] .nav-link span { display: none; }
:root[data-collapsed] .nav-sep { height: 1px; margin: 6px 10px; background: var(--border); }
:root[data-collapsed] .nav-scroll { gap: 4px; }
:root[data-collapsed] .nav-link { width: 40px; height: 40px; margin: 0 auto; padding: 0; justify-content: center; }
:root[data-collapsed] .nav-link svg { width: 20px; height: 20px; }

/* ---- main ---- */
.main { min-width: 0; overflow-y: auto; display: flex; flex-direction: column; }
.page-head { padding: 20px 24px 14px; }
.page-head h2 { font-size: 22px; line-height: 1.25; }
.page-sub { font-size: 14px; color: var(--ink-faint); margin-top: 4px; }
.view { padding: 0 24px 24px; display: flex; flex-direction: column; }
.view[hidden] { display: none; }

/* ---- filters bar (отбор) ---- */
.filters-bar {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; flex: none;
  margin: 0 24px 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
}
.filters-bar[hidden] { display: none; }
.filter-item { display: flex; flex-direction: column; gap: 4px; width: 240px; min-width: 0; }
.filter-item select.field { text-overflow: ellipsis; }
.filter-item label, .field-label, .field-item label {
  font-size: 13px; font-weight: 500; color: var(--ink); text-transform: none; letter-spacing: 0;
}
.filter-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); height: 36px; white-space: nowrap; cursor: pointer; }
.filter-check input { cursor: pointer; }

.summary-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.summary-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 3px; min-width: 150px; flex: 1 1 150px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.summary-tile .num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.summary-tile .lbl { font-size: 13px; color: var(--ink-soft); }
.summary-tile .pct { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

/* ---- кнопки и поля (Mantine size sm: 36px, радиус 4px) ---- */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.sel-count { font-size: 13px; color: var(--ink-soft); }
.hint { font-size: 13px; color: var(--ink-faint); }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--ink-faint); pointer-events: none; }
.search {
  height: 36px; border: 1px solid var(--input-border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 0 12px 0 34px; font-size: 14px; min-width: 260px; color: var(--ink);
}
.search::placeholder, .field::placeholder { color: var(--ink-faint); }
.search:focus, .field:focus { outline: none; border-color: var(--accent); }
.btn {
  height: 36px; border: 1px solid var(--input-border); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm);
  padding: 0 16px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 1.8; margin-left: -2px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled, .btn:disabled:hover { opacity: .5; cursor: not-allowed; background: var(--surface-2); color: var(--ink-faint); border-color: var(--border); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }

select.field, input.field, textarea.field, input[type=date].field {
  height: 36px; border: 1px solid var(--input-border); background: var(--surface); color: var(--ink); border-radius: var(--radius-sm);
  padding: 0 10px; font-size: 14px; width: 100%;
}
textarea.field { height: auto; padding: 8px 10px; resize: vertical; min-height: 60px; line-height: 1.45; }

/* ---- table (Mantine Table: тонкие линии, наведение gray-1) ---- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow-x: auto; }
table.grid { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 14px; }
table.grid thead th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  background: var(--surface); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grid tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr.row:hover { background: var(--surface-2); cursor: pointer; }
.comment-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); display: block; }
.k7-cell { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink-soft); }
.k7-cell.copyable, .val.copyable { cursor: pointer; }
.k7-cell.copyable:hover, .val.copyable:hover { color: var(--accent-ink); }
.copy-hint { opacity: 0; font-size: 10px; margin-left: 5px; }
.k7-cell.copyable:hover .copy-hint, .val.copyable:hover .copy-hint { opacity: .75; }
.company-name { font-weight: 600; }
.company-inn { color: var(--ink-faint); font-size: 12px; font-family: 'JetBrains Mono',monospace; }
.company-inn.copyable { cursor: pointer; }
.company-inn.copyable:hover { color: var(--accent-ink); }
.company-inn.copyable:hover .copy-hint { opacity: .75; }

/* статусы — как Badge variant="light" в Фабрике, но без капса: длинные результаты звонка читаются */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.neutral { background: var(--neutral-soft); color: var(--neutral); }
/* «Пришёл» — спокойная светло-зелёная плашка, чуть заметнее обычной */
.chip.good.solid { background: #d3f9d8; color: #237032; }
:root[data-theme="dark"] .chip.good.solid { background: rgba(64,192,87,.22); color: #8ce99a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.good.solid { background: rgba(64,192,87,.22); color: #8ce99a; } }
.dup-tag {
  display: inline-block; vertical-align: 1px; margin-left: 4px; padding: 0 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent-ink);
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.webinar-mini { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }

/* ---- окна (карточка компании, сделки и т. п.) ---- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; animation: fade-in .15s ease both; }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.drawer-head h3 { font-size: 18px; }
.drawer-head .sub { color: var(--ink-faint); font-size: 13px; margin-top: 3px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 20px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field-item label { display: block; margin-bottom: 4px; }
.field-item .val { font-size: 14px; }
.field-item .val.empty { color: var(--ink-faint); font-style: italic; }
.field-copy { display: flex; gap: 6px; align-items: stretch; }
.field-copy input.field { flex: 1; min-width: 0; }
.field-copy-btn {
  flex: none; border: 1px solid var(--input-border); background: var(--surface); color: var(--ink-soft);
  border-radius: var(--radius-sm); width: 36px; font-size: 13px; cursor: pointer;
}
.field-copy-btn:hover { background: var(--surface-2); color: var(--accent-ink); border-color: var(--accent); }

.journal { display: flex; flex-direction: column; gap: 10px; }
.journal h4 { font-size: 14px; color: var(--ink); }
.call-row { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); }
.call-row .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-faint); }
.call-row .result { font-weight: 600; font-size: 14px; }
.call-row .comment { font-size: 13px; color: var(--ink-soft); }
.call-row .callback { font-size: 12px; color: var(--accent-ink); font-weight: 600; }
.empty-journal { font-size: 13px; color: var(--ink-faint); font-style: italic; padding: 6px 0; }

.add-call-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; }
.add-call-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.close-btn {
  margin-left: auto; border: none; background: transparent; width: 28px; height: 28px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--ink-faint); font-size: 15px; flex: none;
}
.close-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---- quick call popup ---- */
.quickcall {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 31;
  width: 660px; max-width: 92vw; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); /* окно результата звонка — на 50% шире прежних 440px */
  display: flex; flex-direction: column; max-height: 86vh; animation: pop-in .16s ease both;
}
.quickcall-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.quickcall-head h3 { font-size: 17px; }
.quickcall-head .sub { font-size: 13px; color: var(--ink-faint); margin-top: 3px; }
.quickcall-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.prior-calls { display: flex; flex-direction: column; gap: 6px; }
.prior-calls .lbl { font-size: 13px; font-weight: 500; color: var(--ink); }
.prior-call-mini { font-size: 13px; color: var(--ink-soft); display: flex; gap: 8px; }
.prior-call-mini .d { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--ink-faint); flex: none; }
.quickcall-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.quickcall-foot .spacer { flex: 1; }
.field-label { margin-bottom: 4px; display: block; }

/* ---- funnel ---- */
.funnel-wrap { display: flex; flex-direction: column; gap: 24px; }
.funnel-section { display: flex; flex-direction: column; gap: 12px; }
.funnel-manager {
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  overflow: hidden; transition: box-shadow .12s ease, transform .12s ease, border-color .12s ease;
}
.funnel-manager-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.mgr-badge {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
}
.funnel-manager-head .name { font-weight: 600; font-size: 14px; flex: 1; }
.funnel-manager-head .total { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.funnel-rows { padding: 6px 16px 4px; }
.funnel-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.funnel-row:last-child { border-bottom: none; }
.funnel-row .rlabel { flex: 0 0 172px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-row .bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.funnel-row .bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }
.funnel-row .bar-fill.good { background: var(--good); }
.funnel-row .bar-fill.bad { background: var(--bad); }
.funnel-row .rcount { flex: 0 0 44px; text-align: right; }
.funnel-row .rcount .n { font-variant-numeric: tabular-nums; font-weight: 600; display: block; }
.funnel-row .rcount .p { font-variant-numeric: tabular-nums; font-size: 11px; color: var(--ink-faint); display: block; }
.funnel-row.clickable, .summary-tile.clickable, .funnel-manager-head.clickable { cursor: pointer; }
.funnel-row.clickable:hover { background: var(--surface-2); border-radius: var(--radius-sm); margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.funnel-row.clickable:hover .rlabel { color: var(--accent-ink); }
.summary-tile.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.summary-tile.clickable:hover .num { color: var(--accent-ink); }
.funnel-manager-head.clickable:hover { background: var(--surface-2); }
.funnel-manager-head.clickable:hover .name { color: var(--accent-ink); }
.manager-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.section-title { font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .4px; }
.section-title .cnt { font-weight: 500; color: var(--ink-faint); text-transform: none; letter-spacing: 0; }

/* ---- compact funnel stat strip ---- */
.stat-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px 2px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.stat-chip { display: inline-flex; align-items: baseline; gap: 5px; padding: 5px 8px; border-radius: var(--radius-sm); font-size: 13px; color: var(--ink-soft); }
.stat-chip b { font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-chip i { font-style: normal; color: var(--ink-faint); font-size: 11.5px; }
.stat-chip.clickable { cursor: pointer; }
.stat-chip.clickable:hover { background: var(--surface-2); }
.stat-chip.clickable:hover b { color: var(--accent-ink); }
.stat-sep { color: var(--border); font-size: 13px; }

/* ---- compact result breakdown: labeled column chart ---- */
.colchart-wrap { overflow-x: auto; padding-bottom: 2px; }
.colchart { display: flex; gap: 20px; align-items: flex-start; }
.colchart-col { display: flex; flex-direction: column; align-items: center; width: 88px; flex: none; border-radius: var(--radius-sm); padding: 6px 4px; margin: -6px -4px; }
.colchart-col.clickable { cursor: pointer; }
.colchart-col.clickable:hover { background: var(--surface-2); }
.colchart-col.clickable:hover .colchart-label { color: var(--accent-ink); }
.colchart-barwrap { height: 132px; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-bottom: 1px solid var(--border); }
.colchart-val { font-weight: 600; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; margin-bottom: 5px; white-space: nowrap; }
.colchart-val .p { font-weight: 500; font-size: 11px; color: var(--ink-faint); margin-left: 3px; }
.colchart-bar { width: 24px; border-radius: 4px 4px 0 0; }
.colchart-bar.good { background: var(--good); }
.colchart-bar.bad { background: var(--bad); }
.colchart-bar.neutral { background: var(--accent); }
.colchart-label { margin-top: 8px; font-size: 11.5px; color: var(--ink-soft); text-align: center; line-height: 1.25; max-width: 88px; }

/* ---- drilldown ---- */
.drilldown {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 31;
  width: 660px; max-width: 94vw; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: 82vh; animation: pop-in .16s ease both;
}
.drilldown-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.drilldown-head h3 { font-size: 17px; }
.drilldown-head .sub { font-size: 13px; color: var(--ink-faint); margin-top: 3px; }
.drilldown-body { overflow: auto; flex: 1; }
.drilldown-body table.grid { min-width: 560px; }
.drilldown-body table.grid tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.drilldown-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- отчёт-картинка (рисуется за экраном, всегда светлая, снимается в PNG) ---- */
.share-card-host { position: fixed; left: -10000px; top: 0; width: 640px; }
.share-card {
  width: 640px; background: #ffffff; font-family: 'Inter', sans-serif; color: #212529; padding: 28px 30px 24px;
}
.share-card .sc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid #dee2e6; padding-bottom: 16px; margin-bottom: 18px; }
.share-card .sc-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: #212529; }
.share-card .sc-sub { font-size: 13px; color: #868e96; margin-top: 5px; }
.share-card .sc-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  background: #ffe8f3; color: #e60077; border-radius: 999px; padding: 4px 10px; white-space: nowrap; flex: none;
}
.share-card .sc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.share-card .sc-tile { border: 1px solid #dee2e6; border-radius: 8px; padding: 12px 14px; }
.share-card .sc-tile .n { font-size: 22px; font-weight: 600; color: #212529; line-height: 1.15; }
.share-card .sc-tile .l { font-size: 12px; color: #868e96; margin-top: 4px; }
.share-card .sc-section-title { font-size: 12px; font-weight: 600; color: #868e96; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 10px; }
.share-card table { width: 100%; border-collapse: collapse; font-size: 13px; }
.share-card table th { text-align: left; font-size: 12px; color: #868e96; padding: 0 0 8px; font-weight: 600; }
.share-card table th:last-child, .share-card table td:last-child { text-align: right; }
.share-card table td { padding: 7px 0; border-top: 1px solid #f1f3f5; color: #212529; }
.share-card .sc-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid #dee2e6; font-size: 11px; color: #adb5bd; display: flex; justify-content: space-between; }

/* ---- excel import ---- */
.import-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 31;
  width: 880px; max-width: 95vw; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: 90vh; animation: pop-in .16s ease both;
}
.import-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.import-head h3 { font-size: 17px; }
.import-head .sub { font-size: 13px; color: var(--ink-faint); margin-top: 3px; }
.import-body { padding: 18px 22px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }

.import-new-base { display: grid; grid-template-columns: 160px 170px 150px minmax(0,1fr); gap: 10px; }
.import-new-base > [hidden] { display: none; }
.import-new-base:has(> #importBaseDateBox[hidden]) { grid-template-columns: 160px 150px minmax(0,1fr); }
.import-new-base[hidden] { display: none; }
.grid-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
/* зона для файла: перетащить или выбрать */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 36px 24px; border: 2px dashed var(--input-border); border-radius: var(--radius-md); background: var(--surface-2);
  transition: border-color .12s ease, background .12s ease;
}
.dropzone svg { width: 40px; height: 40px; color: var(--accent-ink); stroke-width: 1.4; margin-bottom: 4px; }
.dz-title { font-size: 16px; font-weight: 600; }
.dz-sub { font-size: 14px; color: var(--ink-soft); }
.dz-hint { font-size: 12.5px; color: var(--ink-faint); max-width: 440px; margin-top: 6px; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent-ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.import-modal.drag-over .dropzone { border-color: var(--accent); background: var(--accent-soft); }
.import-modal.drag-over .file-chip { border-color: var(--accent); background: var(--accent-soft); }

.file-chip {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
}
.file-chip > svg { width: 28px; height: 28px; color: var(--good); stroke-width: 1.4; }
.fc-main { flex: 1; min-width: 0; }
.fc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-sub { font-size: 12.5px; color: var(--ink-faint); }

.map-block { display: flex; flex-direction: column; gap: 8px; }
.block-title { font-size: 14px; font-weight: 600; }
table.import-compare.map-table { min-width: 0; }
table.map-table td { vertical-align: middle; }
table.map-table select.field { height: 32px; font-size: 13px; }
table.map-table tr.unmapped td:first-child b, table.map-table tr.unmapped .map-samples { color: var(--ink-faint); }
.map-how { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.map-samples { font-size: 12.5px; color: var(--ink-soft); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-scroll { max-height: 320px; overflow: auto; }
.preview-scroll .import-preview-head { position: sticky; left: 0; }
.warn-text { color: var(--bad); }
.dup-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.dup-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.dup-row select.field { width: 280px; }
.fill-swatch { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex: none; }
.dup-note { font-size: 13px; color: var(--ink-soft); }
.import-badge.dup { background: var(--accent-soft); color: var(--accent-ink); }
.import-warn {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--bad); background: var(--bad-soft); color: var(--bad); font-size: 13px;
}

.import-preview-head { padding: 9px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--ink-soft); }
.import-preview-head b { color: var(--ink); }
table.import-compare { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 13px; }
table.import-compare th {
  background: var(--surface-2); color: var(--ink-soft); font-weight: 600; text-align: left;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.import-compare td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.import-compare tr:last-child td { border-bottom: none; }
.import-badge { flex: none; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.import-badge.isnew { background: var(--good-soft); color: var(--good); }
.import-badge.update { background: var(--accent-soft); color: var(--accent-ink); }
table.import-compare .old { color: var(--ink-faint); text-decoration: line-through; font-size: 12px; }
table.import-compare .next { color: var(--ink); font-weight: 600; }

.import-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.import-foot .spacer { flex: 1; }

/* ---- presale board: вертикальное дерево статусов (аккордеон) ---- */
.presale-board { display: flex; flex-direction: column; gap: 10px; }
.ptree-stage { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
/* шапка статуса: цвет статуса — полоской слева и точкой, а не сплошной заливкой (цвет приходит из style="background:…") */
.ptree-head {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 11px 16px 11px 18px;
  cursor: pointer; user-select: none; color: var(--ink); background: var(--surface) !important;
}
.ptree-head::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stage-color, var(--accent)); }
.ptree-head:hover { background: var(--surface-2) !important; }
.ptree-head.dragover { outline: 2px dashed var(--accent); outline-offset: -4px; }
.ptree-chevron { font-size: 11px; flex: none; color: var(--ink-faint); width: 10px; }
.ptree-name { font-weight: 600; font-size: 14px; flex: 1; }
.ptree-dealcount {
  font-size: 12px; font-weight: 600; color: var(--ink-soft); background: var(--surface-3);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap; flex: none;
}
.ptree-count { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.ptree-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border); }
.ptree-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pcol-add {
  align-self: flex-start; border: 1px dashed var(--input-border); background: transparent; color: var(--ink-soft);
  border-radius: var(--radius-sm); padding: 5px 10px; font-size: 13px; cursor: pointer;
}
.pcol-add:hover { color: var(--accent-ink); border-color: var(--accent); }
.pcol-add:disabled { opacity: .4; cursor: not-allowed; }
.pcol-add:disabled:hover { color: var(--ink-soft); border-color: var(--input-border); }
.deal-empty { font-size: 13px; color: var(--ink-faint); font-style: italic; padding: 4px 2px; }

.deal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px;
  cursor: grab; display: flex; flex-direction: column; gap: 5px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.deal-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.deal-card:active { cursor: grabbing; }
.deal-card.dragging { opacity: .4; }
.deal-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.deal-inn { font-size: 11.5px; color: var(--ink-faint); }
.deal-amount { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.deal-meta { display: flex; align-items: center; gap: 8px; }
.deal-date { font-size: 11.5px; color: var(--ink-faint); }
.deal-owner { font-size: 11.5px; color: var(--ink-faint); }
.deal-foot { display: flex; gap: 8px; margin-top: 2px; }
.deal-owner, .deal-chip { display: inline-flex; align-items: center; gap: 4px; }
.deal-owner svg, .deal-chip svg { width: 13px; height: 13px; }
.deal-chip { font-size: 11.5px; color: var(--ink-soft); background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px 7px; }
.chip.sm { height: 20px; padding: 0 8px; font-size: 11px; }

/* ---- centered card modal (карточка компании и карточка сделки) ---- */
.center-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 31;
  width: 660px; max-width: 94vw; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: 88vh; animation: pop-in .16s ease both;
}

/* ---- deal drawer: comments/tasks ---- */
.task-row {
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 12px; display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-2);
}
.task-row.done { opacity: .55; }
.task-row.done .task-text { text-decoration: line-through; }
.task-row input[type=checkbox] { margin-top: 2px; flex: none; }
.task-body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.task-text { font-size: 14px; font-weight: 500; }
.task-meta { font-size: 12px; color: var(--ink-faint); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-stage-tag { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; color: #fff; font-weight: 700; white-space: nowrap; }
.add-task-form, .add-comment-form { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 16px; }
.add-task-form .row3 { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(0); z-index: 40;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---- анимации (как в Фабрике: короткие, без резких движений) ---- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } to { opacity: 1; transform: translate(-50%,-50%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 860px) {
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-item { min-width: 0; }
  .field-grid { grid-template-columns: 1fr; }
  .brand-divider, .brand-product { display: none; }
}

/* ---- ширина колонок таблицы компаний ---- */
table.grid thead th { position: relative; }
.col-resizer { position: absolute; top: 0; right: -4px; width: 9px; height: 100%; cursor: col-resize; z-index: 2; }
.col-resizer::after { content: ''; position: absolute; top: 20%; bottom: 20%; left: 4px; width: 1px; background: var(--border); }
.col-resizer:hover::after, .col-resizer.active::after { top: 0; bottom: 0; width: 2px; left: 3px; background: var(--accent); }
table.grid.fixed-cols { table-layout: fixed; min-width: 0; }
table.grid.fixed-cols td { overflow: hidden; text-overflow: ellipsis; }
table.grid.fixed-cols thead th { overflow: hidden; text-overflow: ellipsis; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none; }

/* ---- сравнение при загрузке файла ---- */
.import-info {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--ink); font-size: 13px;
}
.cmp-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.cmp-chip { display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 13px; background: var(--surface-2); color: var(--ink-soft); }
.cmp-chip b { font-size: 14px; color: var(--ink); }
.cmp-chip.isnew { background: var(--good-soft); color: var(--good); }
.cmp-chip.isnew b { color: var(--good); }
.cmp-chip.update { background: var(--accent-soft); color: var(--accent-ink); }
.cmp-chip.update b { color: var(--accent-ink); }
.new-mgr-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
td.cell-changed { background: var(--accent-soft); }

/* ---- справочник баз (дерево папок) ---- */
table.dir-table { min-width: 720px; }
table.dir-table tbody td { padding: 7px 12px; }
.dir-row { cursor: default; }
.dir-row:hover { background: var(--surface-2); }
.dir-row.dragging { opacity: .4; }
.dir-row.drop-target td { background: var(--accent-soft); box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.dir-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; width: 100%; }
.dir-name > * { vertical-align: middle; }
.dir-caret {
  width: 18px; height: 18px; margin-right: 4px; border: none; background: none; padding: 0; cursor: pointer;
  color: var(--ink-faint); font-size: 11px; line-height: 18px; border-radius: 3px;
}
.dir-caret:hover { background: var(--surface-3); color: var(--ink); }
.dir-icon { display: inline-flex; margin-right: 8px; color: var(--ink-faint); }
.dir-icon svg { width: 17px; height: 17px; }
.dir-icon.folder { color: #e8a317; }
.dir-icon.folder svg { fill: rgba(232,163,23,.18); }
.dir-group .dir-title { font-weight: 600; }
.dir-num { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.dir-actions { text-align: right; white-space: nowrap; }
.dir-actions .icon-btn { opacity: 0; }
.dir-row:hover .dir-actions .icon-btn, .dir-actions .icon-btn:focus-visible { opacity: 1; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.dir-root-zone {
  margin-bottom: 10px; padding: 12px; text-align: center; font-size: 13px; color: var(--ink-soft);
  border: 2px dashed var(--input-border); border-radius: var(--radius-md); background: var(--surface-2);
}
.dir-root-zone[hidden] { display: none; }
.dir-root-zone.drop-target { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.dir-modal { width: 560px; }
.dir-modal .drawer-body { gap: 14px; }

/* ---- меню «Столбцы» ---- */
.col-menu-wrap { position: relative; }
.col-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 15; width: 290px; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px;
}
.col-menu[hidden] { display: none; }
.cm-head { font-weight: 600; padding: 6px 8px 8px; }
.cm-head span { font-weight: 400; color: var(--ink-faint); font-size: 12.5px; }
.cm-item { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: var(--radius-sm); }
.cm-item:hover { background: var(--surface-2); }
.cm-item label, .cm-item.fixed { flex: 1; display: flex; align-items: center; gap: 8px; padding: 5px 4px; cursor: pointer; font-size: 13.5px; }
.cm-item.fixed { color: var(--ink-faint); cursor: default; }
.cm-move { border: none; background: none; width: 24px; height: 24px; border-radius: var(--radius-sm); color: var(--ink-faint); cursor: pointer; font-size: 9px; }
.cm-move:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.cm-move:disabled { opacity: .3; cursor: default; }
.cm-foot { border-top: 1px solid var(--border); margin-top: 6px; padding: 8px 8px 4px; }
th.check-col { width: 40px; }
td.num-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.multi-cell { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
table.grid.fixed-cols .multi-cell, table.grid.fixed-cols .comment-cell { max-width: none; }

.field-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.field-grid > [hidden] { display: none; }
.cold-tag { display: inline-block; vertical-align: 1px; margin-left: 6px; padding: 0 7px; border-radius: 999px; font-size: 10.5px; font-weight: 600; background: rgba(34,139,230,.12); color: #1c7ed6; }

.assign-group { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
td.nowrap { white-space: nowrap; }

/* ---- нумерация и выделение строк ---- */
th.num-col { width: 48px; text-align: right; }
td.num-cell-row { text-align: right; color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 12.5px; cursor: pointer; user-select: none; }
td.check-cell { cursor: pointer; user-select: none; }
td.num-cell-row:hover, td.check-cell:hover { background: var(--surface-3); }
table.grid tbody tr.row.selected { background: var(--accent-soft); }
table.grid tbody tr.row.selected:hover { background: var(--accent-soft); }
body.row-selecting, body.row-selecting * { cursor: ns-resize !important; user-select: none; }
.sel-range { width: 150px; }
.sel-count b { color: var(--ink); }

/* ---- пресейл: горизонтальный канбан — колонка на этап, листается вбок (из прототипа v31) ---- */
.presale-board { display: flex; flex-direction: row; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 10px; }
.kanban-col {
  flex: 0 0 280px; width: 280px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  display: flex; flex-direction: column; max-height: calc(100vh - 280px); min-height: 160px;
}
.kanban-col.dragover { outline: 2px dashed var(--accent); outline-offset: -3px; }
.kanban-col-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex: none;
  background: var(--surface); border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-top: 3px solid var(--stage-color, var(--accent)); border-bottom: 1px solid var(--border);
}
.kanban-col-name { font-weight: 600; font-size: 13.5px; flex: 1; line-height: 1.25; }
.kanban-col-count { font-size: 12px; font-weight: 600; color: var(--ink-soft); background: var(--surface-3); border-radius: 999px; padding: 1px 9px; flex: none; }
.kanban-col-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 50px; }
.kanban-col-add { margin: 0 10px 10px; align-self: stretch; text-align: center; }
.deal-card { cursor: pointer; }

/* ---- карточка сделки почти на весь экран, как в Bitrix: данные и задачи слева, лента справа ---- */
.center-modal.wide { width: 96vw; max-width: 1500px; height: 92vh; max-height: 92vh; }
.drawer-body.split { flex-direction: row; padding: 0; gap: 0; overflow: hidden; }
.deal-col-left, .deal-col-right { overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.deal-col-left { flex: 1 1 56%; border-right: 1px solid var(--border); }
.deal-col-right { flex: 1 1 44%; }
@media (max-width: 860px) {
  .drawer-body.split { flex-direction: column; overflow-y: auto; }
  .deal-col-left { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---- «Сегодня перезвонить» и уведомления «пора перезвонить» ---- */
.today-badge { cursor: pointer; height: 36px; padding: 0 12px; font-size: 13px; }
.today-badge:hover { background: var(--accent-soft); color: var(--accent-ink); }
.notify-stack { position: fixed; top: 84px; right: 18px; z-index: 50; display: flex; flex-direction: column; gap: 10px; width: 320px; max-width: 92vw; }
.notify-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; animation: notifySlide .2s ease-out;
}
@keyframes notifySlide { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.notify-head { display: flex; align-items: center; gap: 8px; color: var(--accent-ink); }
.notify-head svg { width: 18px; height: 18px; }
.notify-title { font-weight: 600; font-size: 14px; flex: 1; color: var(--ink); }
.notify-close { border: none; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 16px; flex: none; line-height: 1; }
.notify-close:hover { color: var(--ink); }
.notify-body { font-size: 13px; color: var(--ink-soft); }
.notify-foot { display: flex; gap: 8px; margin-top: 2px; }

/* окно результата звонка: «Когда перезвонить» и «Кто звонил» в одну строку, комментарий повыше */
.quickcall .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quickcall textarea.field { min-height: 90px; }

/* ---- крупные окна: карточка компании и результат звонка ---- */
.company-card { width: 96vw; max-width: 1400px; height: 90vh; max-height: 90vh; }
.company-card .deal-col-left { flex: 1 1 55%; }
.company-card .deal-col-right { flex: 1 1 45%; background: var(--surface-2); }
.company-card .field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
.company-card .field-item .val { font-size: 15px; }
.company-card .drawer-head h3 { font-size: 22px; }
.company-card .add-call-form .row2 { gap: 12px; }
.company-card .call-row { background: var(--surface); }

.quickcall { width: 900px; max-width: 94vw; max-height: 92vh; }
.quickcall-head { padding: 20px 24px; }
.quickcall-head h3 { font-size: 22px; }
.quickcall-head .sub { font-size: 14px; }
.quickcall-body { padding: 20px 24px; gap: 16px; font-size: 15px; }
.quickcall-foot { padding: 16px 24px; }
.quickcall .field-label { font-size: 14px; }
.quickcall select.field, .quickcall input.field { height: 42px; font-size: 15px; }
.quickcall textarea.field { min-height: 130px; font-size: 15px; }
.quickcall .prior-call-mini { font-size: 14px; }
.quickcall .btn { height: 40px; font-size: 15px; }

@media (max-width: 1100px) {
  .company-card .field-grid { grid-template-columns: 1fr 1fr; }
}
/* форма звонка в карточке — такого же размера, как окно результата (подписи в разметке заданы инлайн, поэтому !important) */
.company-card .add-call-form { gap: 14px; font-size: 15px; }
.company-card .add-call-form h4 { font-size: 16px !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--ink) !important; }
.company-card .add-call-form label { font-size: 14px !important; color: var(--ink) !important; font-weight: 500; display: block; margin-bottom: 4px; }
.company-card .add-call-form select.field, .company-card .add-call-form input.field { height: 42px; font-size: 15px; }
.company-card .add-call-form textarea.field { min-height: 120px; font-size: 15px; }
.company-card .add-call-form .btn { height: 40px; font-size: 15px; }
.company-card .journal h4 { font-size: 16px; }
.company-card .call-row .result { font-size: 15px; }
.company-card .call-row .comment { font-size: 14px; }

/* название компании в таблице — ссылка на карточку */
.company-link { cursor: pointer; }
.company-link:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

/* перетаскивание колонок за заголовок */
table.grid thead th[draggable="true"] { cursor: grab; }
table.grid thead th.col-dragging { opacity: .45; }
table.grid thead th.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
table.grid thead th.drop-after { box-shadow: inset -3px 0 0 var(--accent); }

/* меню «Столбцы»: строки перетаскиваются, текст при этом не выделяется */
.col-menu { user-select: none; }
.cm-item[draggable="true"] { cursor: grab; position: relative; }
.cm-grip { color: var(--ink-faint); font-size: 12px; letter-spacing: -2px; width: 12px; flex: none; }
.cm-item:hover .cm-grip { color: var(--ink-soft); }
.cm-item.cm-dragging { opacity: .4; }
.cm-item.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.cm-item.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }
.cm-item.fixed { padding-left: 20px; }

.fix-line { font-size: 13px; color: var(--ink-soft); }
.fix-line b { color: var(--ink); }

/* ---- вход и роли ---- */
.role-manager .admin-only { display: none !important; }
.role-manager th.check-col, .role-manager td.check-cell { display: none; }
.user-box { display: flex; align-items: center; gap: 4px; }
.user-box:empty { display: none; }
.user-name { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; font-weight: 500; line-height: 1.2; }
.user-name span { font-size: 12px; font-weight: 400; color: var(--ink-faint); }
.login-screen {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: var(--paper);
}
.login-card {
  width: 380px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 6px;
}
.login-card .brand-logo { height: 48px; align-self: flex-start; margin-bottom: 12px; }
.login-card h2 { font-size: 22px; }
.login-sub { font-size: 14px; color: var(--ink-faint); margin-bottom: 14px; }
.login-card .field-label { margin-top: 8px; }
.login-card .field { height: 40px; font-size: 15px; }
.login-card .btn { height: 40px; margin-top: 16px; justify-content: center; font-size: 15px; }
.login-hint { font-size: 13px; color: var(--ink-faint); min-height: 18px; margin-top: 6px; }
.login-hint.error { color: var(--bad); }
.login-card [hidden] { display: none; }

/* ---- веб-версия: страница входа с двухфакторной аутентификацией и кнопки, которых нет в настольной ---- */
html:not(.web) .web-only { display: none !important; }
.login-card[hidden] { display: none; }
/* страница входа на невысоком экране (телефон, QR-код) — прокрутка вместо обрезанного верха */
.login-screen { overflow-y: auto; align-items: flex-start; padding: 16px 0; }
.login-screen > .login-card { margin: auto; }
.login-card .btn.ghost { margin-top: 4px; }
.enroll-steps { margin: 0 0 8px 18px; padding: 0; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.enroll-qr { display: block; width: 200px; height: 200px; margin: 6px auto; image-rendering: pixelated; border-radius: 8px; background: #fff; }
.enroll-secret { font-size: 12px; color: var(--ink-faint); text-align: center; line-height: 1.5; }
.enroll-secret code { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--ink); user-select: all; }
.code-field { font-family: 'JetBrains Mono', monospace; letter-spacing: 4px; text-align: center; }
