:root {
  --accent: #5b2ce8;
  --accent-hover: #4a20cc;
  --accent-soft: #f0eafe;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --line: #e9e9ec;
  --line-strong: #d9d9de;
  --text: #16151a;
  --muted: #8b8b93;
  --chip: #f2f2f4;
  --chip-hover: #e8e8ec;
  --green: #16a34a;
  --green-bg: #e7f7ed;
  --orange: #e08a2e;
  --orange-bg: #fdf2e3;
  --blue: #2f6fed;
  --blue-bg: #e9f0fd;
  --red: #e0483d;
  --red-bg: #fdecea;
  --radius: 12px;
  /* Ширину сайдбара держим здесь: по ней же выравнивается панель отмеченных,
     а она приклеена к окну и до разметки страницы дотянуться не может. */
  --sidebar: 56px;
  --sidebar-expanded: 248px;
  --surface: #ffffff;
  --border: #ddd;
  --field-span: 6;
  --deal-stage-progress: 0%;
  --deal-stage-color: var(--accent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  -webkit-font-smoothing: antialiased;
}

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

.layout { display: flex; min-height: 100vh; padding-left: var(--sidebar); }
.layout[hidden] { display: none; }

/* --- сайдбар --- */
.sidebar {
  width: var(--sidebar);
  background: var(--bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: fixed; left: 0; top: 0;
  height: 100vh; height: 100dvh; z-index: 25; overflow: hidden;
  transition: width .18s ease, box-shadow .18s ease;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; }
/* Шапка кликабельна только у админа — остальным настройки закрыты сервером. */
.brand.clickable { cursor: pointer; border-radius: 10px; margin: 0 8px; padding: 18px 10px 14px; }
.brand.clickable:hover { background: var(--chip); }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.brand-title { font-weight: 600; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 12px; }

.nav { padding: 6px 6px 28px 10px; flex: 1 1 auto; min-height: 0; overflow-y: auto;
  overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: #c6c7cf transparent;
  display: flex; flex-direction: column; }
.nav::-webkit-scrollbar { width: 7px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: #c6c7cf; border-radius: 10px; border: 2px solid var(--bg); }
.nav::-webkit-scrollbar-thumb:hover { background: #a9abb5; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; margin-bottom: 2px; border: 0; border-radius: 10px;
  background: transparent; font: inherit; color: var(--text); cursor: pointer; text-align: left;
}
.nav > button { flex: 0 0 auto; }
.nav button:hover { background: var(--chip-hover); }
.nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav button.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; display: inline-flex; justify-content: center; color: var(--muted); }
.nav .nav-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.nav button.active .nav-count { color: var(--accent); }
.nav .nav-count.alert { background: var(--red); color: #fff; border-radius: 8px; padding: 1px 7px; }
.nav button.nav-rules { margin-top: auto; }
.nav button.nav-funnel-add {
  width: calc(100% + 20px); min-height: 40px; margin: 2px -10px 0; padding: 6px 12px 6px 22px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0;
  color: var(--text); font: inherit; cursor: pointer;
}
.nav button.nav-funnel-add:hover { background: var(--panel); color: var(--text); }
.nav button.nav-custom-funnel { padding-left: 12px; }
.nav-funnel-row { display: flex; align-items: center; gap: 2px; width: 100%; }
.nav .nav-funnel-row > button.nav-funnel-main {
  flex: 1 1 auto; min-width: 0; width: auto;
}
.nav .nav-funnel-row > button.nav-funnel-edit {
  flex: 0 0 34px; width: 34px; height: 34px; padding: 8px; margin: 0 0 2px;
  justify-content: center; color: var(--muted);
}
.nav .nav-funnel-row > button.nav-funnel-edit:hover { color: var(--accent); }
.nav-config-section { width: 100%; position: relative; min-height: 8px; margin-bottom: 7px;
  flex: 0 0 auto;
  padding: 0 0 3px; border-radius: 10px; }
.nav-config-entry { position: relative; min-height: 40px; border-radius: 10px;
  transition: opacity .12s, background .12s; }
.nav-config-entry:hover { background: rgba(91,44,232,.035); }
.nav-config-handle { flex: 0 0 18px; width: 18px; height: 28px; display: inline-flex;
  align-items: center; justify-content: center; color: #a7a8b2; cursor: grab;
  font-size: 17px; line-height: 1; text-align: center; overflow: hidden; user-select: none; }
.nav-config-handle:active { cursor: grabbing; color: var(--accent); }
.nav-config-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 5px; }
.nav-config-handle-spacer { flex: 0 0 20px; width: 20px; }
.nav-config-entry > .nav-config-handle { margin-left: 2px; }
.nav .nav-config-entry > button.nav-funnel-main { padding-left: 5px; }
.nav .nav-config-entry > button.nav-config-main { flex: 1 1 auto; min-width: 0; width: auto; }
.nav-config-group { display: flex; align-items: center; gap: 5px; min-height: 36px;
  margin-top: 4px; padding: 7px 2px 4px 3px; position: relative; box-sizing: border-box; }
.nav-config-group-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; line-height: 18px; }
.nav button.nav-group-action { flex: 0 0 28px; width: 28px; height: 28px; margin: -5px 0;
  padding: 5px; border-radius: 7px; justify-content: center; color: var(--muted); }
.nav button.nav-group-action:hover { color: var(--accent); background: var(--accent-soft); }
.nav button.nav-group-action .icon, .nav button.nav-group-action svg { width: 15px; height: 15px; }
.nav button.nav-section-add { margin-top: 0; border-top: 0; }
.nav-config-empty { margin: 2px 4px 5px 22px; padding: 7px 8px; border: 1px dashed var(--line-strong);
  border-radius: 8px; color: var(--muted); font-size: 11px; line-height: 1.25; }
.nav-dragging { opacity: .38; }
.nav-drop-before::before, .nav-drop-after::after { content: ''; position: absolute; z-index: 3;
  left: 5px; right: 5px; height: 3px; border-radius: 3px; background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft); pointer-events: none; }
.nav-drop-before::before { top: -2px; }
.nav-drop-after::after { bottom: -2px; }
.nav-config-section.nav-drop-section { background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent); }
.nav-funnel-plus {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  flex: 0 0 24px; border: 1px solid #dbe1ea; border-radius: 6px; background: var(--panel);
  color: var(--muted); font-size: 18px; font-weight: 300; line-height: 1;
}
.nav-group { padding: 14px 12px 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.sidebar-footer { flex: 0 0 auto; padding: 12px 18px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--line); position: relative; }

/* Узкая полоса остаётся на месте; подписи раскрываются поверх страницы. */
.sidebar:is(:hover, :has(:focus-visible), .nav-editing) {
  width: var(--sidebar-expanded); box-shadow: 8px 0 24px rgba(22,21,26,.09);
}
.sidebar .brand { flex: 0 0 56px; padding: 12px 13px; gap: 9px; white-space: nowrap;
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.sidebar .brand.clickable { margin: 0 6px; padding: 12px 7px; }
.sidebar .brand.clickable:hover { background: var(--chip); }
.sidebar .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sidebar .brand-logo { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
.sidebar .brand-copy { min-width: 0; }
.sidebar .brand-title { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.sidebar .brand-sub { display: block; font-size: 11px; }
.sidebar .nav { padding: 2px 6px 6px; scrollbar-gutter: auto; font-size: 13px; }
.sidebar .nav button:has(.nav-icon) { position: relative; min-height: 32px; padding: 7px 12px; gap: 10px; border-radius: 8px; }
.sidebar .nav-icon { flex: 0 0 18px; width: 18px; height: 18px; align-items: center; }
.sidebar .nav-icon .icon, .sidebar .nav-icon svg { width: 18px; height: 18px; }
.sidebar .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .nav-count { flex: none; font-size: 11px; white-space: nowrap; }
.sidebar .nav-config-section { margin-bottom: 3px; padding-bottom: 0; }
.sidebar .nav-group { position: relative; height: 20px; padding: 4px 12px 2px; font-size: 10px; line-height: 14px; white-space: nowrap; }
.sidebar .nav-group::after { content: ''; position: absolute; left: 11px; top: 10px; width: 20px; border-top: 1px solid var(--line-strong); }
.sidebar .nav-config-group { height: 28px; min-height: 28px; padding-left: 3px; }
.sidebar .nav-config-entry { min-height: 34px; }
.sidebar .nav .nav-funnel-row > button.nav-funnel-edit { width: 28px; height: 28px; flex-basis: 28px; padding: 5px; }
.sidebar .nav-config-entry > button:has(.nav-icon) { padding-left: 5px; }
.sidebar .nav-funnel-add { width: 100%; min-height: 34px; margin-left: 0; margin-right: 0; padding-left: 11px; }
.sidebar .sidebar-footer { padding: 8px 10px; min-height: 86px; }
.sidebar .account { min-width: 34px; min-height: 34px; padding: 4px; margin: 0; gap: 8px; }
.sidebar .account-avatar { width: 26px; height: 26px; font-size: 12px; }
.sidebar .account-name { font-size: 12px; line-height: 16px; }
.sidebar .account-role { font-size: 10px; line-height: 12px; }
.sidebar .footer-db { margin-top: 5px; font-size: 10px; line-height: 13px; white-space: nowrap; }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) :is(.brand-copy, .nav-label, .nav-group-label,
  .nav-config-group-title, .account-who, .account-chevrons, .footer-db) { visibility: hidden; }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) .nav-count:not(.alert) { display: none; }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) .nav-count.alert {
  position: absolute; top: 5px; right: 6px; width: 7px; height: 7px;
  padding: 0; font-size: 0; border-radius: 50%;
}
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) :is(.nav-config-handle, .nav-config-handle-spacer,
  .nav-funnel-edit, .nav-group-action, .nav-config-empty) { display: none; }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) .nav-config-entry > button:has(.nav-icon) { padding-left: 12px; }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) .nav { scrollbar-width: none; }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) .nav::-webkit-scrollbar { width: 0; }
.sidebar:is(:hover, :has(:focus-visible), .nav-editing) .nav-group::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* --- контент --- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 22px 32px 14px;
  position: sticky; top: 0; background: var(--panel); z-index: 8;
}
.topbar h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -.5px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.page { padding: 4px 32px 60px; }

/* --- кнопки --- */
/* Высота задана явно: кнопки бывают и <button>, и <a> (выгрузка CSV), а у них
   разные отступы по умолчанию — в ряду они получались разной высоты. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: var(--chip); color: var(--text);
  border-radius: 10px; height: 40px; padding: 0 16px; font: inherit; letter-spacing: .2px;
  cursor: pointer; white-space: nowrap; text-decoration: none; box-sizing: border-box;
}
.btn:hover { background: var(--chip-hover); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-telegram { background: #229ed9; color: #fff; font-weight: 500; }
.btn-telegram:hover { background: #1b8fc7; }
.publish-icons { display: inline-flex; align-items: center; gap: 4px; }
.publish-icons .icon { width: 17px; height: 17px; flex-basis: 17px; }
.max-brand-icon { display: block; width: 18px; height: 18px; object-fit: contain; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-outline { background: var(--panel); border: 1px solid var(--line-strong); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fbdcd9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
.icon { width: 18px; height: 18px; display: block; flex: 0 0 18px; }

/* --- правила работы --- */
.rules-page { max-width: 1180px; padding-bottom: 30px; }
.rules-intro { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr);
  gap: 24px; align-items: center; padding: 26px 28px; border: 1px solid #ddd5fa;
  border-radius: 16px; background: linear-gradient(135deg, #f7f3ff, #fff); }
.rules-kicker { color: var(--accent); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; }
.rules-intro h2, .rules-flow h2, .rules-danger h2 { margin: 7px 0 8px; font-size: 21px; }
.rules-intro p { max-width: 760px; margin: 0; color: #5f5d67; line-height: 1.6; }
.rules-tip { padding: 18px; border-radius: 13px; background: var(--panel); box-shadow: 0 5px 20px rgba(61,36,125,.08); }
.rules-tip strong, .rules-tip span { display: block; }
.rules-tip span { margin-top: 7px; color: var(--muted); line-height: 1.5; }
.rules-flow { margin-top: 22px; padding: 24px 26px; border: 1px solid var(--line); border-radius: 16px; }
.rule-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.rule-step { display: flex; gap: 12px; padding: 14px; border-radius: 12px; background: var(--bg); }
.rule-step-number { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center;
  border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; }
.rule-step strong { display: block; margin: 3px 0 5px; }
.rule-step p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.rule-section { display: flex; flex-direction: column; align-items: flex-start; padding: 22px;
  border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.rule-section h2 { margin: 0 0 6px; font-size: 18px; }
.rule-section-lead { margin: 0; color: var(--muted); line-height: 1.5; }
.rule-section ul, .rules-danger ul { margin: 15px 0 18px; padding-left: 19px; line-height: 1.55; }
.rule-section li + li, .rules-danger li + li { margin-top: 8px; }
.rule-section .btn { margin-top: auto; }
.rules-danger { margin-top: 14px; padding: 22px 24px; border: 1px solid #f2c9c5;
  border-radius: 15px; background: var(--red-bg); }
.rules-danger ul { margin-bottom: 0; }

@media (max-width: 900px) {
  .rules-intro, .rules-grid { grid-template-columns: 1fr; }
  .rule-steps { grid-template-columns: 1fr; }
}

/* --- панель фильтров --- */
/* Выравниваем по низу: у полей с подписью («с», «по») сверху есть строка текста,
   и при центрировании сами поля оказывались ниже поиска. */
.bar { display: flex; align-items: flex-end; gap: 12px; margin: 6px 0 16px; flex-wrap: wrap; }
/* Всё, что без подписи, — кнопки, чипы, переключатели — держим на высоте поиска. */
.bar > .btn, .bar > .chip, .bar > button, .bar > .right { align-self: center; }
.search {
  display: flex; align-items: center; gap: 12px; flex: 0 1 460px; min-width: 240px;
  border: 1px solid #e6e6ea; border-radius: 12px; padding: 0 16px; height: 48px; background: var(--panel);
}
.search:focus-within { border-color: #c9c9d1; }
/* Вес селектора должен перебивать общий input[type="text"] ниже по файлу:
   при равном весе побеждал он и рисовал вторую рамку внутри поиска. */
.search input[type="text"], .search input {
  border: 0; outline: 0; box-shadow: none; border-radius: 0;
  flex: 1; background: transparent; padding: 0;
  font-family: inherit; font-size: 15px; color: var(--text);
}
.search input[type="text"]:focus { box-shadow: none; }
.search input::placeholder { color: #b3b3bb; }
.search .icon { color: #9a9aa3; }
.bar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bar select, .bar input[type="date"] { height: 48px; border-radius: 12px; }
.bar label.field { gap: 3px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
/* Второй ряд фильтров с подписью: сразу видно, что это другой разрез, а не
   продолжение первого ряда. */
.chips-row { display: flex; align-items: flex-start; gap: 12px; margin: -6px 0 16px; }
.chips-row .chips { margin-bottom: 0; }
.shift-filter-row { display: flex; align-items: flex-start; gap: 20px; width: 100%; flex-wrap: wrap; }
.chips-label { color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .6px; padding-top: 8px; flex: 0 0 auto; }
.chip {
  border: 1px dashed var(--line-strong); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 6px 12px; font: inherit; font-size: 13px;
  cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--muted); }
.chip.active { border: 1px solid var(--accent); color: var(--accent); }
.chip .count { color: var(--muted); margin-left: 6px; font-size: 11px; }
.chip.active .count { color: var(--accent); opacity: .7; }

.list-summary { display: flex; align-items: center; gap: 16px; margin: 0 0 12px; flex-wrap: wrap; }
.list-summary-text { font-size: 17px; font-weight: 600; letter-spacing: -.3px; }
.list-summary .metric { color: var(--muted); }
.list-summary .metric b { color: var(--text); font-variant-numeric: tabular-nums; }
.list-summary .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.list-toolbar { display: flex; align-items: center; gap: 18px; min-height: 42px;
  margin: 2px 0 12px; flex-wrap: wrap; }
.list-total { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.list-toolbar .metric { color: var(--muted); }
.list-toolbar .metric b { color: var(--text); font-variant-numeric: tabular-nums; }
.list-toolbar-right { margin-left: auto; }
.list-toolbar select { min-width: 116px; height: 38px; padding: 0 34px 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background-color: var(--panel);
  color: var(--text); font: inherit; cursor: pointer; }

.pager { display: flex; align-items: center; gap: 4px; justify-content: flex-start;
  margin: 18px 0 0; color: var(--muted); }
.page-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px;
  height: 36px; padding: 0 9px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.page-btn:hover:not(:disabled) { background: var(--bg); }
.page-btn.active { border-color: #b896ff; color: var(--accent); background: var(--panel); }
.page-btn:disabled { color: #c8c8ce; cursor: default; }
.page-arrow { font-size: 23px; font-weight: 300; }
.page-ellipsis { min-width: 30px; text-align: center; color: var(--muted); }

/* --- таблицы --- */
/* Как на образце: все выбранные 10/25/50/100 строк идут одним списком и листаются
   вместе со страницей. Внутреннюю прокрутку оставляем только по горизонтали для узких экранов. */
.table-wrap { overflow-x: auto; max-height: none; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
.table-wrap > table { min-width: 1050px; }
th {
  text-align: left; font-weight: 500; color: #97979f; font-size: 12.5px;
  padding: 13px 14px; white-space: nowrap; background: #fcfcfd;
  /* Линия тенью не сдвигает таблицу на пиксель. */
  box-shadow: inset 0 -1px 0 var(--line);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.active { color: var(--text); font-weight: 500; }
/* Бледный двойной шеврон — подсказка «по колонке можно сортировать».
   У активной колонки подсвечивается та половина, куда идёт сортировка. */
.sort-mark { display: inline-flex; vertical-align: middle; margin-left: 6px; color: #cfcfd6; }
.sort-mark .icon { width: 13px; height: 13px; flex: 0 0 13px; }
th.sortable:hover .sort-mark { color: var(--muted); }
.sort-mark.active { color: var(--line-strong); }
.sort-mark.active.asc svg path:first-child,
.sort-mark.active.desc svg path:last-child { stroke: var(--accent); }
td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaff; }
.table-wrap .pill { border-radius: 8px; padding: 4px 10px; font-weight: 500; }
.table-wrap .pill::before { display: none; }
tr.clickable { cursor: pointer; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.name { font-weight: 500; }
.wrap { max-width: 320px; white-space: normal; line-height: 1.35; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.empty { padding: 48px; text-align: center; color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* --- метки статусов --- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 20px; font-size: 12px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-orange { background: var(--orange-bg); color: var(--orange); }
.pill-gray { background: var(--chip); color: var(--muted); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-red { background: var(--red-bg); color: var(--red); }
.tag { display: inline-block; padding: 3px 9px; border-radius: 8px; font-size: 12px; background: var(--chip); color: var(--muted); margin-right: 4px; }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.tag-warn { background: var(--orange-bg); color: #8a5a1e; }
.tag-red { background: var(--red-bg); color: var(--red); }
/* Мессенджер чата: у бота их два, и по цвету видно, куда уйдёт сообщение. */
/* Плашки состояний: плотный прямоугольник с заливкой — три подряд читаются
   столбиками, в отличие от «пилюль» с точкой, которые дробят строку. */
/* Поиск человека с подсказками: список раскрывается прямо под полем формы. */
.picker { position: relative; }
.picker-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(20, 18, 40, .14); padding: 4px; max-height: 260px; overflow-y: auto; }
.picker-item { display: block; width: 100%; text-align: left; border: 0; background: none;
  font: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker-item:hover { background: var(--chip); }
.picker-empty { padding: 12px; color: var(--muted); text-align: center; }

/* --- поле периода и календарь --- */
/* Поле периода стоит в одном ряду с кнопками — высота у них общая. */
.range-field { display: inline-flex; align-items: center; gap: 4px; height: 40px;
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 6px 0 12px;
  background: var(--panel); }
.range-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.range-field input[type="text"] { border: 0; outline: 0; box-shadow: none; padding: 0;
  width: 96px; font: inherit; background: transparent; text-align: center; }
.range-field input::placeholder { color: #b3b3bb; }
.range-arrow { color: var(--muted); }
.range-cal { border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; padding: 6px; border-radius: 8px; }
.range-cal:hover { background: var(--chip); color: var(--text); }

/* Календарь одной даты — уже, чем период на два месяца. */
.dp-single { padding: 14px 16px 8px; }
.dp-single .dp-grid { width: 240px; }
.dp-hint { color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0 4px;
  border-top: 1px solid var(--line); margin-top: 8px; }
/* Строка выбора времени под сеткой месяца. */
.dp-time { display: flex; align-items: center; gap: 6px; padding: 12px 0 6px; margin-top: 10px;
  border-top: 1px solid var(--line); }
.dp-time > span:first-child { color: var(--muted); font-size: 12px; margin-right: 4px; }
/* Ширины хватает и на две цифры, и на стрелку списка: при 32 px они наезжали
   друг на друга и текст выглядел смазанным. */
.dp-time select { height: 34px; width: 64px; padding: 0 20px 0 10px; }
.dp-time .btn { margin-left: auto; }
.dt-field { width: 100%; }
.dt-field input[type="text"] { width: 100%; text-align: left; }

.dp { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 14px 40px rgba(20, 18, 40, .16); padding: 16px 18px 10px; }
.dp-head { display: flex; align-items: flex-start; gap: 10px; }
.dp-months { display: flex; gap: 26px; }
.dp-month { width: 232px; }
.dp-title { text-align: center; font-weight: 600; margin-bottom: 12px; }
.dp-nav { width: 32px; height: 32px; border: 0; border-radius: 10px; background: var(--chip);
  color: var(--text); font-size: 17px; line-height: 1; cursor: pointer; flex: 0 0 32px; }
.dp-nav:hover { background: var(--chip-hover); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd { text-align: center; color: var(--muted); font-size: 12px; padding-bottom: 6px; }
.dp-day { border: 0; background: transparent; font: inherit; cursor: pointer; height: 30px;
  border-radius: 8px; color: var(--text); }
.dp-day:hover { background: var(--chip); }
.dp-day.out { color: #c9c9d1; }
/* Сегодняшний день — только рамкой: заливка занята выбранным диапазоном. */
.dp-day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.dp-day.in { background: var(--accent-soft); border-radius: 0; }
.dp-day.sel { background: var(--accent); color: #fff; }
.dp-day.start { border-radius: 8px 0 0 8px; }
.dp-day.end { border-radius: 0 8px 8px 0; }
.dp-reset { display: block; width: 100%; border: 0; background: transparent; font: inherit;
  color: var(--muted); padding: 12px 0 6px; margin-top: 8px; border-top: 1px solid var(--line);
  cursor: pointer; }
.dp-reset:hover { color: var(--accent); }

/* Переключатель вида «Столбцы | Список». */
.switch { display: inline-flex; background: var(--chip); border-radius: 11px; padding: 3px; gap: 2px;
  align-self: center; }
.switch button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent;
  font: inherit; color: var(--muted); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.switch button:hover { color: var(--text); }
.switch button.active { background: var(--panel); color: var(--text); font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,.07); }
.switch .icon { width: 16px; height: 16px; flex: 0 0 16px; }
/* У выбранного вида иконка цветная — как на образце: активные столбцы синим,
   неактивный список серым. */
.switch button.active .icon { color: var(--accent); }

/* Доска: колонки прокручиваются вбок, карточки внутри — вниз. Высоту считаем от
   экрана, чтобы шапка страницы оставалась на месте, а листалась только доска. */
/* Колонки тянутся на всю высоту доски, даже если карточек в них одна: пустое место
   под ними — тоже зона броска. Иначе короткую колонку не во что «попасть» мышью. */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: stretch;
  height: calc(100vh - 210px); min-height: 360px; }
.board-col { --stage-color: var(--line-strong); flex: 0 0 300px; background: var(--bg);
  border-radius: 14px; padding: 12px; display: flex; flex-direction: column; }
.board-green { --stage-color: var(--green); }
.board-orange { --stage-color: var(--orange); }
.board-blue { --stage-color: var(--blue); }
.board-red { --stage-color: var(--red); }
.board-gray { --stage-color: var(--line-strong); }
/* Шапка держится на месте, пока карточки внутри колонки прокручиваются: при переносе
   всегда видно, куда именно кладёшь. */
.board-head { margin: 0 -12px 10px; padding: 4px 16px 12px;
  border-bottom: 3px solid var(--stage-color); position: sticky; top: 0;
  background: var(--bg); z-index: 1; }
.board-title { font-weight: 600; font-size: 14px; }
.board-meta { display: flex; justify-content: space-between; align-items: baseline; margin-top: 3px;
  color: var(--muted); font-size: 12.5px; }
.board-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.board-cards { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 2px;
  flex: 1; }
.board-more { color: var(--muted); font-size: 12.5px; text-align: center; padding: 8px; }
/* Подсказка в пустой колонке: она остаётся на доске как место для переноса. */
.board-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 18px 8px;
  border: 1px dashed var(--line-strong); border-radius: 12px; }

/* Колонка под курсором с карточкой. */
.board-col.board-drop { background: var(--accent-soft); outline: 2px dashed var(--accent);
  outline-offset: -2px; }

/* Карточка поручения. */
.kcard { display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; }
.kcard:hover { border-color: var(--accent); }
.kcard[draggable="true"] { cursor: grab; }
.kcard-dragging { opacity: .4; cursor: grabbing; }
.kcard-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.kcard-name { font-weight: 600; line-height: 1.25; }
.kcard-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.kcard-line { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.kcard-note { background: var(--bg); border-radius: 8px; padding: 7px 9px; margin-top: 8px;
  font-size: 12.5px; line-height: 1.3; }
.kcard-sum { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 9px; }
.kcard-sum b { font-size: 17px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kcard-meta { color: var(--muted); font-size: 12.5px; }
.kcard-tags { margin-top: 8px; }
.kcard-foot { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 9px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.kcard-foot .neg { font-weight: 600; }
.kcard-foot a { display: inline-flex; align-items: center; color: var(--accent); }
.kcard-foot a .icon { width: 13px; height: 13px; margin-left: 4px; }

/* Карточки настраиваемых досок. Две колонки экономят высоту, длинные значения
   (адрес, получатель) сами занимают всю ширину благодаря минимальной ширине. */
.config-card-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 12px; margin-top: 8px; }
.config-card-field { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.config-card-label { color: var(--muted); font-size: 11px; line-height: 1.2; }
.config-card-value { color: var(--text); font-size: 13px; line-height: 1.3;
  overflow-wrap: anywhere; }
.config-card-value strong { font-size: 14px; }
.config-card-value .tag + .tag { margin-left: 5px; }
.sales-card .config-card-fields { margin-top: 4px; }
.shift-kcard .config-card-fields { margin-top: 0; }
.shift-kcard.bulk-selecting { cursor: pointer; }
.shift-kcard.bulk-selecting.selected { border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft); }

/* В выплатах полей больше всего, поэтому карточка плотнее остальных. ФИО остаются
   читаемыми в две строки, а телефоны и номера не раздувают её по высоте. */
.payment-kcard { padding: 9px 10px; }
.payment-kcard .config-card-fields { gap: 6px 10px; margin-top: 0; }
.payment-kcard .config-card-field { gap: 1px; }
.payment-kcard .config-card-label { font-size: 9.5px; line-height: 1.15; }
.payment-kcard .config-card-value { font-size: 12px; line-height: 1.2; }
.payment-kcard .config-card-value strong { font-size: 13px; }
.payment-kcard .config-card-field-employer .config-card-value,
.payment-kcard .config-card-field-recipient .config-card-value {
  display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.payment-kcard .config-card-field-contact .config-card-value,
.payment-kcard .config-card-field-order .config-card-value {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.payment-kcard .config-card-field-amount .config-card-value strong { font-size: 15px; }
.payment-kcard .tag { padding: 2px 7px; border-radius: 7px; font-size: 10.5px; }

/* Конструктор воронок: горизонтальные этапы как на рабочей доске, но с
   редактируемыми заголовками, подсказками и точками добавления между ними. */
.funnel-builder { min-width: 0; }
.funnel-builder-toolbar { display: flex; align-items: center; justify-content: space-between;
  gap: 18px; margin-bottom: 14px; }
.funnel-builder-toolbar strong { display: block; font-size: 15px; }
.funnel-builder-toolbar .sub { margin-top: 3px; }
.funnel-builder-scroll { overflow-x: auto; border: 1px solid var(--line);
  border-radius: 14px; background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.funnel-builder > [hidden] { display: none; }
.funnel-fields-pane { margin-top: 16px; }
.funnel-fields-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.funnel-fields-toolbar h3 { margin-bottom: 6px; }
.funnel-fields-pane .bar input { flex: 1; min-width: 180px; }
.funnel-field-row { display: grid; grid-template-columns: 30px minmax(180px, 1fr) 160px 90px; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.funnel-field-row.is-hidden { background: var(--bg); }
.funnel-field-row .check { margin: 0; }
.funnel-field-name input { width: 100%; }
.funnel-field-name .sub { margin-top: 5px; }
.funnel-field-order { display: flex; gap: 4px; }
@media (max-width: 760px) {
  .funnel-fields-toolbar { align-items: stretch; flex-direction: column; }
  .funnel-field-row { grid-template-columns: 26px minmax(120px, 1fr) 80px; gap: 10px; }
  .funnel-field-row > label:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .funnel-field-order { grid-column: 3; grid-row: 1; }
  .funnel-fields-toolbar .board-settings-actions { flex-wrap: wrap; }
}
.funnel-builder-track { display: flex; align-items: stretch; width: max-content; min-width: 100%;
  min-height: 430px; padding: 0 14px 18px; }
.funnel-builder-column { --stage-color: var(--line-strong); position: relative; flex: 0 0 300px;
  min-height: 410px; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  background-color: var(--panel); background-image:
        linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 128px; transition: background-color .15s, outline-color .15s; }
.funnel-builder-column.drop { background-color: var(--accent-soft); outline: 2px dashed var(--accent);
  outline-offset: -2px; }
.funnel-builder-green { --stage-color: #2fb66d; }
.funnel-builder-yellow { --stage-color: #e0b724; }
.funnel-builder-orange-dark { --stage-color: #c96e22; }
.funnel-builder-orange { --stage-color: #e7923b; }
.funnel-builder-blue { --stage-color: #4285e6; }
.funnel-builder-teal { --stage-color: #21a5a3; }
.funnel-builder-green-light { --stage-color: #77ba55; }
.funnel-builder-red { --stage-color: var(--red); }
.funnel-builder-gray { --stage-color: var(--line-strong); }
.funnel-stage-header { display: grid; grid-template-columns: 38px minmax(0, 1fr) 20px 24px;
  align-items: center; gap: 3px; height: 29px; padding: 0 6px 0 8px; background: var(--bg); }
.funnel-stage-drag { display: inline-flex; align-items: center; justify-content: flex-start; gap: 3px;
  width: 36px; height: 26px; padding: 0; border: 0; background: transparent;
  color: #b8bbc1; cursor: grab; }
.funnel-stage-drag:active { cursor: grabbing; }
.funnel-stage-drag .icon { width: 17px; height: 17px; }
.funnel-stage-drag .icon svg { width: 17px; height: 17px; }
.funnel-drag-dots { color: #b8bbc1; font-size: 16px; line-height: 1; letter-spacing: -5px; }
.funnel-stage-title { min-width: 0; width: 100%; border: 0; border-bottom: 1px solid transparent;
  border-radius: 0; padding: 5px 2px; background: transparent; color: var(--text);
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-align: center;
  text-transform: uppercase; }
.funnel-stage-title:focus { outline: 0; border-bottom-color: var(--accent); }
.funnel-stage-remove { display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 24px; padding: 0; border: 0; background: transparent;
  color: #ff615f; cursor: pointer; }
.funnel-stage-remove:hover { color: var(--red); }
.funnel-stage-remove .icon { width: 14px; height: 14px; }
.funnel-stage-color-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.funnel-stage-color-dot { width: 15px; height: 15px; padding: 0;
  border: 0; border-radius: 50%; background: var(--stage-color, #65adf9); cursor: pointer; }
.funnel-stage-color-dot:hover { box-shadow: 0 0 0 4px var(--accent-soft); }
.funnel-color-palette { position: absolute; top: 21px; right: -80px; z-index: 35;
  display: grid; grid-template-columns: repeat(6, 15px); gap: 6px; width: 132px; padding: 8px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--panel);
  box-shadow: 0 10px 34px rgba(0,0,0,.16); }
.funnel-color-option { width: 15px; height: 15px;
  padding: 0; border: 0; border-radius: 50%;
  background: var(--stage-color, var(--line-strong)); cursor: pointer; }
.funnel-color-option:hover { transform: scale(1.08); }
.funnel-color-option.active { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--line-strong); }
.funnel-stage-color { height: 3px; background: var(--stage-color); }
.funnel-stage-hint-row { display: flex; align-items: center; justify-content: center;
  min-height: 45px; border-bottom: 1px solid var(--line); background: var(--bg); }
.funnel-stage-hint { width: calc(100% - 34px); border: 0; border-bottom: 1px solid transparent;
  border-radius: 0; padding: 5px 2px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; text-align: center; text-decoration: underline;
  text-underline-offset: 2px; }
.funnel-stage-hint::placeholder { color: var(--muted); opacity: 1; }
.funnel-stage-hint:focus { outline: 0; border-bottom-color: var(--accent); text-decoration: none; }
.funnel-stage-workspace { min-height: 280px; padding: 16px; }
.funnel-integration-add { display: block; width: 36px; height: 36px; margin: 12px auto;
  border: 1px dashed var(--accent); border-radius: 50%; color: var(--accent);
  background: var(--panel); font-size: 24px; cursor: pointer; }
.funnel-integration-add:hover { background: var(--bg); }
.funnel-integration-card { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); font-size: 14px; }
.funnel-add-stage { position: relative; z-index: 4; flex: 0 0 28px; }
.funnel-add-stage-button { position: sticky; top: 31px; display: flex; align-items: center;
  justify-content: center; width: 26px; height: 26px; margin: 17px 1px 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--panel);
  color: var(--muted); font: inherit; font-size: 18px; font-weight: 300; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.funnel-add-stage-button:hover { border-color: var(--accent); color: var(--accent); }
.funnel-add-menu { position: absolute; top: 64px; left: 0; z-index: 30; width: 240px;
  padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  box-shadow: 0 10px 34px rgba(0,0,0,.16); }
.funnel-add-menu strong { display: block; padding: 7px 9px; font-size: 12px; }
.funnel-restore-stages button { display: block; width: 100%; padding: 9px; border: 0;
  border-radius: 8px; background: transparent; color: var(--text); font: inherit;
  font-size: 13px; text-align: left; cursor: pointer; }
.funnel-restore-stages button:hover { background: var(--chip); }
.funnel-add-form { display: grid; gap: 8px; padding: 4px; }
.funnel-add-form input, .funnel-add-form select { width: 100%; min-width: 0; height: 38px;
  padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px; }
.funnel-add-form input:focus, .funnel-add-form select:focus { outline: 2px solid var(--accent-soft);
  border-color: var(--accent); }
.funnel-add-form .btn { display: inline-flex; }
.funnel-restore-stages { margin-top: 8px; padding: 8px 4px 2px; border-top: 1px solid var(--line); }
.funnel-restore-stages > span { display: block; padding: 4px 5px 6px; color: var(--muted);
  font-size: 11px; }
.board-settings-fields { margin-top: 18px; }
.funnel-links-pane .info-box p { margin: 8px 0 0; }
.funnel-links-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.funnel-link-row { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel); }
.funnel-link-controls { display: grid; grid-template-columns: minmax(130px,.8fr) minmax(240px,1.3fr) minmax(170px,1fr) minmax(180px,1fr); gap: 12px; align-items: end; }
.funnel-link-controls > strong { align-self: center; font-size: 13px; }
.funnel-link-controls .field { margin: 0; min-width: 0; gap: 4px; }
.funnel-link-controls .field > span { font-size: 11px; }
.funnel-link-controls select { width: 100%; min-width: 0; height: 36px; padding: 0 28px 0 10px; font-size: 12px; }
.funnel-link-hint { display: grid; margin-top: 8px; font-size: 12px; }
.funnel-link-hint > span { grid-area: 1 / 1; visibility: hidden; }
.funnel-link-hint > span.is-active { visibility: visible; }
@media (max-width: 1050px) {
  .funnel-link-controls { grid-template-columns: 1fr 1fr; }
  .funnel-link-controls > strong { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .funnel-link-controls { grid-template-columns: 1fr; }
}
.board-settings-fields-head { display: flex; align-items: end; justify-content: space-between;
  gap: 18px; margin-bottom: 14px; }
.board-settings-fields-head h3 { margin-bottom: 3px; }
.board-settings-add { display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px; min-width: min(440px, 100%); }
.board-settings-add-select { min-width: 0; width: 100%; height: 36px; padding: 0 34px 0 10px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel);
  color: var(--text); font: inherit; font-size: 13px; }
.board-settings-list { display: flex; flex-direction: column; gap: 8px; }
.board-settings-row { display: grid; grid-template-columns: 20px minmax(150px, 1fr) auto auto;
  align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); }
.board-settings-row input[type="text"], .board-settings-row input:not([type]) {
  min-width: 0; width: 100%; border: 0; border-bottom: 1px solid transparent;
  border-radius: 0; padding: 6px 4px; background: transparent; }
.board-settings-row input[type="text"]:focus, .board-settings-row input:not([type]):focus {
  outline: 0; border-bottom-color: var(--accent); }
.board-settings-handle { color: var(--muted); letter-spacing: -3px; cursor: default; }
.board-settings-move { display: flex; gap: 4px; }
.board-settings-move .btn { min-width: 34px; padding-left: 8px; padding-right: 8px; }
.board-settings-remove { white-space: nowrap; }
.board-settings-actions { display: flex; gap: 10px; }
.drawer-danger-zone { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .funnel-builder-toolbar, .board-settings-fields-head { align-items: stretch; flex-direction: column; }
  .board-settings-add { width: 100%; }
}
@media (max-width: 620px) {
  .config-card-fields { grid-template-columns: 1fr; }
  .funnel-builder-column { flex-basis: 260px; }
  .funnel-builder-toolbar .board-settings-actions { width: 100%; }
  .funnel-builder-toolbar .board-settings-actions .btn { flex: 1; }
  .board-settings-row { grid-template-columns: 16px minmax(120px, 1fr) auto; }
  .board-settings-move { grid-column: 3; grid-row: 1; }
  .board-settings-remove { grid-column: 2 / 4; justify-content: center; }
  .board-settings-add { grid-template-columns: 1fr; }
}

/* Карточка смены в столбцах: только четыре рабочих строки из макета — адрес,
   потребность/время, движение людей и ответственные. */
.shift-kcard-address { text-align: center; font-weight: 600; line-height: 1.3; }
.shift-kcard-facts { margin-top: 9px; color: var(--muted); font-size: 12.5px;
  line-height: 1.35; }
.shift-kcard-stages { margin-top: 13px; font-size: 12.5px; line-height: 1.4; }
.shift-kcard-owners { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.shift-kcard-owners > div:last-child { text-align: right; }
.shift-kcard-owner-label { display: block; margin-bottom: 3px; color: var(--muted);
  font-size: 11px; line-height: 1.25; }
.shift-kcard-owners strong { display: block; overflow: hidden; color: var(--text);
  font-size: 12.5px; font-weight: 500; line-height: 1.3; text-overflow: ellipsis; }

/* Воронка карточками: ступени слева направо, у активной — рамка акцентом.
   Цветная полоса сверху повторяет цвет стадии, чтобы проблемные ступени
   (не прошёл, нет ответа) отличались от нормального хода. */
.funnel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px; margin: 4px 0 18px; }
.fcard { text-align: left; font: inherit; cursor: pointer; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 13px;
  border-top: 3px solid var(--line-strong); }
.fcard:hover { border-color: var(--line-strong); background: #fcfcfd; }
.fcard.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fcard-title { color: var(--muted); font-size: 12.5px; line-height: 1.25; min-height: 32px; }
.fcard-count { font-size: 23px; font-weight: 600; letter-spacing: -.4px;
  font-variant-numeric: tabular-nums; margin-top: 2px; }
.fcard-sum { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.fcard-green { border-top-color: var(--green); }
.fcard-orange { border-top-color: var(--orange); }
.fcard-blue { border-top-color: var(--blue); }
.fcard-red { border-top-color: var(--red); }
.fcard-gray { border-top-color: var(--line-strong); }

/* Колонка выбора: узкая, галочка в цвете акцента, как в остальных элементах формы. */
td.cell-check, th.cell-check { width: 34px; padding-right: 0; padding-left: 12px; }
.cell-check input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent);
  margin: 0; cursor: pointer; }

/* Панель действий над отмеченным. */
/* Панель отмеченных приклеена к нижнему краю окна и не двигается вовсе: галочки
   ставят по всему списку, и кнопки должны быть на одном месте, куда бы ни увели
   прокрутку. Строки уходят под неё — это нормально, панель живёт ровно столько,
   сколько держится выбор.
   Позиция fixed, а не sticky: sticky ограничен своим контейнером и у конца
   страницы отпускал панель вверх, к последним строкам.
   Слева отступаем на сайдбар, справа и снизу — на поля страницы, чтобы полоса
   встала по ширине таблицы. Обёртка при этом схлопывается в ноль и места в
   потоке не занимает. */
.bulk-bar { position: fixed; z-index: 9; flex-wrap: wrap;
  left: calc(var(--sidebar) + 32px); right: 32px; bottom: 16px;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 28px rgba(16, 14, 32, .14); }
/* Счётчик и крестик — одной «таблеткой»: снять выделение хочется там же, где
   видно его размер, а не искать отдельную кнопку на другом краю полосы. */
.bulk-count { display: inline-flex; align-items: center; gap: 6px; height: 32px;
  padding: 0 6px 0 12px; border-radius: 8px; background: var(--chip);
  font-weight: 600; white-space: nowrap; }
.bulk-clear { display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; }
.bulk-clear:hover { background: var(--chip-hover); color: var(--text); }
.bulk-clear .icon, .bulk-clear svg { width: 14px; height: 14px; flex: 0 0 14px; }
.bulk-bar .right { margin-left: auto; }
/* Внутри белой полосы обводка кнопок сливается с фоном — берём заливку. */
.bulk-bar .btn-outline { background: var(--chip); border-color: transparent; }
.bulk-bar .btn-outline:hover { background: var(--chip-hover); }
/* Список статусов в панели — под рост маленьких кнопок рядом, иначе полоса
   раздувается и спорит с таблицей. */
.bulk-bar select { height: 32px; padding: 0 30px 0 10px; font-size: 13px; border-radius: 8px;
  background-color: var(--chip); border-color: transparent; }

.state { display: inline-flex; align-items: center; padding: 5px 11px; border-radius: 8px;
  font-size: 13px; font-weight: 500; white-space: nowrap; }
.state-green { background: #dcf5e3; color: #157f3c; }
.state-orange { background: #fdeed8; color: #a4620f; }
.state-red { background: #fbe0dd; color: #b3352b; }
.state-gray { background: var(--chip); color: var(--muted); }
.state-blue { background: var(--blue-bg); color: var(--blue); }
.state-cell { display: flex; align-items: center; gap: 8px; }
.state-cell a { display: inline-flex; color: var(--muted); }
.state-cell a:hover { color: var(--accent); }
.state-cell a .icon { margin-left: 0; }

.tag-tg { background: var(--blue-bg); color: var(--blue); }
/* Иконка внешней ссылки внутри текста: по умолчанию .icon блочная и переносила
   стрелку под название. */
a .icon { display: inline-block; vertical-align: -3px; width: 14px; height: 14px; margin-left: 4px; }
a .icon svg { width: 14px; height: 14px; }
.sub .tag { margin-left: 6px; }
.tag-max { background: #efe7fd; color: #6b34d6; }

/* Удалённые чаты из списка не убираем — их видно, но вполсилы. */
tr.row-dim td { opacity: .55; }
tr.row-dim:hover td { opacity: 1; }

/* --- карточки метрик --- */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--panel); }
.card.clickable:hover { border-color: var(--accent); }
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card .value { font-size: 25px; font-weight: 600; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.card .value.long { font-size: 19px; }
.card .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.card.alert { border-color: #f3c9c4; background: #fffbfa; }
.card.alert .value { color: var(--red); }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 22px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.panel h3 .muted { font-weight: 400; font-size: 13px; }
.panel table { margin: -4px 0; }
.panel table th { padding: 6px 8px; }
.panel table td { padding: 9px 8px; }
.panel table tr:last-child td { border-bottom: 0; }

/* воронка */
.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel-row { display: grid; grid-template-columns: 170px 1fr 52px; gap: 12px; align-items: center; }
.funnel-row .t { color: var(--muted); font-size: 13px; }
.funnel-row .track { background: var(--chip); border-radius: 6px; height: 10px; overflow: hidden; }
/* display:block обязателен — у строчного элемента ширина и высота не применяются */
.funnel-row .fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.funnel-row .fill.green { background: var(--green); }
.funnel-row .fill.orange { background: var(--orange); }
.funnel-row .fill.red { background: var(--red); }
.funnel-row .fill.blue { background: var(--blue); }
.funnel-row .fill.gray { background: var(--line-strong); }
.funnel-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* столбики по дням */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin-top: 6px; }
/* height:100% нужен, чтобы проценты у столбиков считались от высоты графика, а не от нуля */
.bars .bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 4px; }
.bars .b1 { background: var(--accent-soft); border-radius: 3px 3px 0 0; }
.bars .b2 { background: var(--accent); border-radius: 3px 3px 0 0; }
/* Активные по дням: цвета мессенджеров те же, что у меток в списке чатов. */
.bars .b-max { background: var(--accent); border-radius: 3px 3px 0 0; }
.bars .b-tg { background: var(--blue); }
/* Скругление верха достаётся тому, кто в столбце сверху: в дни без MAX это
   Telegram, и иначе его полоска выглядела бы обрезанной. */
.bars .b-max[style*="height:0%"] + .b-tg { border-radius: 3px 3px 0 0; }
/* Подсказка графика. Висит над столбиками, курсор сквозь неё проходит — иначе
   она перекрывала бы столбец, с которого её и вызвали, и мигала бы. */
.bars-wrap { position: relative; }
.bar-tip {
  position: absolute; top: -6px; transform: translateX(-50%); z-index: 5;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  background: var(--chip); color: var(--text); font-size: 12px;
  box-shadow: 0 4px 14px rgba(16, 14, 32, .12);
  opacity: 0; transition: opacity .08s;
}
.bar-tip.on { opacity: 1; }
/* Курсор-стрелка на столбце: подсказка появляется, а нажимать нечего. */
.bars .bar-col { cursor: default; }

.bars-legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; margin-top: 10px; }
.bars-legend .right { margin-left: auto; }
.bars-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* прогресс укомплектованности */
.progress { background: var(--chip); border-radius: 6px; height: 8px; overflow: hidden; min-width: 70px; }
.progress i { display: block; height: 100%; background: var(--accent); }
.progress i.full { background: var(--green); }
.progress i.low { background: var(--orange); }

/* --- страница-карточка --- */
.back-link {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none;
  font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; padding: 4px 8px 4px 0;
}
.back-link:hover { color: var(--accent); }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
@media (max-width: 1150px) { .detail { grid-template-columns: 1fr; } }

.block { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; }
.block > h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.block > h3 .right { margin-left: auto; font-weight: 400; }
.side-card { background: #f6f6f8; border-radius: 14px; padding: 18px 20px; margin-bottom: 18px; }
.side-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.side-total { font-size: 24px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }

.props { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; font-size: 14px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-word; }

.steps { display: flex; flex-direction: column; gap: 13px; }
.steps .step { display: flex; align-items: center; gap: 11px; color: var(--muted); }
.steps .step .mark {
  width: 24px; height: 24px; border-radius: 50%; background: #e3e3e7; color: #fff;
  display: flex; align-items: center; justify-content: center; flex: 0 0 24px;
}
.steps .step.done { color: var(--text); }
.steps .step.done .mark { background: var(--accent); }
.steps .step .icon { width: 14px; height: 14px; flex: 0 0 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  border: 0; background: none; font: inherit; padding: 11px 16px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tabs .count { font-size: 12px; opacity: .7; margin-left: 5px; }

.note { white-space: pre-wrap; line-height: 1.45; background: var(--bg); border-radius: 10px; padding: 14px 16px; }
.warn-box { background: var(--orange-bg); color: #8a5a1e; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }
.err-box { background: var(--red-bg); color: #a3372e; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }
.info-box { background: var(--blue-bg); color: #24519f; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }

/* --- поля и формы --- */
input[type="date"], input[type="text"], input[type="tel"], input[type="number"], input[type="time"],
input[type="datetime-local"], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; font: inherit;
  background: var(--panel); color: var(--text); max-width: 100%;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b8b93" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m8 9 4-4 4 4"/><path d="m16 15-4 4-4-4"/></svg>');
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px 15px;
}
select::-ms-expand { display: none; }

/* У поля даты родной значок браузера выбивается из набора — гасим его и кладём свой.
   Сам значок оставляем кликабельным: он и открывает календарь. */
input[type="date"] {
  padding-right: 34px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b8b93" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="16" rx="3"/><path d="M3 10h18M8 3v4M16 3v4"/></svg>');
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px 16px;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0; cursor: pointer; margin: 0; padding: 0; width: 20px;
}
/* Стрелки-крутилки у числовых полей убраны: по ним всё равно не попасть с первого
   раза, а значение набирается быстрее руками. Подсказки-списки остаются. */
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
/* min-width: 0 и ширина 100% — иначе поля тянутся по своему «естественному» размеру
   (у textarea он около 600px) и распирают панель шире экрана: левый край уезжал за
   границу окна вместе с заголовком. */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted);
  min-width: 0; }
label.field input, label.field select, label.field textarea { width: 100%; box-sizing: border-box; }
.field-autocomplete { position: relative; width: 100%; }
.field-inline-hint { position: relative; width: 100%; }
.field-inline-hint input { padding-right: 38px; }
.field-hint-button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: help; }
.field-hint-button:hover, .field-hint-button:focus-visible { color: var(--accent); background: var(--accent-soft); }
.field-hint-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-suggestions { position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  max-height: 240px; overflow-y: auto; background: white; border: 1px solid var(--border, #ddd);
  border-radius: 10px; box-shadow: 0 8px 24px #0002; margin-top: 4px; padding: 4px; }
.field-suggestions[hidden] { display: none; }
.field-suggestions button { display: block; width: 100%; text-align: left; border: 0;
  background: transparent; color: var(--text); padding: 10px 12px; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.field-suggestions button:hover, .field-suggestions button[aria-selected="true"] { background: #f1edff; }
label.field > span { font-size: 12px; }
label.field.required > span:first-child::after { content: ' *'; color: var(--red); font-weight: 600; }
label.field input, label.field select, label.field textarea { color: var(--text); font-size: 14px; }
label.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; padding: 7px 0; }
label.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
/* minmax(0, 1fr), а не 1fr: колонка не должна раздуваться под содержимое. */
/* Матрица доступов: роли строками, разделы столбцами, галочки на пересечениях.
   Первый столбец закреплён — при боковой прокрутке видно, чья это строка. */
/* Матрица прокручивается внутри себя: только так шапка с ролями остаётся видна.
   Высота меньше обычной таблицы — сверху ещё вкладки и пояснение. */
.access-matrix { max-height: calc(100vh - 330px); min-height: 320px; }
.access-matrix th.access-role, .access-matrix td.access-role {
  position: sticky; left: 0; background: var(--panel); z-index: 3; min-width: 200px; }
/* Угловая ячейка перекрывает и строку, и столбец, поэтому лежит выше обеих. */
.access-matrix th.access-role { z-index: 5; }
.access-matrix th { box-shadow: inset 0 -1px 0 var(--line); }
.access-matrix th { text-align: center; }
.access-matrix th.access-role { text-align: left; }
.access-matrix td { text-align: center; padding: 8px 10px; }
.access-matrix td.access-role { text-align: left; }
/* Уровень доступа в ячейке — светофором: зелёный «полный», жёлтый «только просмотр»,
   красный «скрыто». Цвет читается быстрее текста, а закрытые разделы должны бросаться
   в глаза, поэтому у них красный, а не серый. */
/* Светофор: три кружка в вертикальной рамке, горит выбранный. */
.tl { display: inline-flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px 5px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel); }
.tl-dot { width: 13px; height: 13px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--panel); }
.tl-dot:hover { border-color: var(--muted); }
/* Столбец администратора не меняется: показываем это блёклостью, а не пряча светофор —
   так видно, что доступ полный. */
.tl-locked { opacity: .55; background: var(--bg); }
.tl-locked .tl-dot { cursor: default; }
.tl-locked .tl-dot:hover { border-color: var(--line-strong); }
.tl-dot.active.tl-none { background: var(--red); border-color: var(--red); }
.tl-dot.active.tl-view { background: var(--orange); border-color: var(--orange); }
.tl-dot.active.tl-full { background: var(--green); border-color: var(--green); }
.access-matrix tbody tr:hover td { background: #fbfaff; }

/* Подзаголовок внутри формы: отделяет данные CRM от полей бота. */
.form-title { font-weight: 600; font-size: 14px; margin: 4px 0 12px; }
/* Пояснение под полем — мельче подписи и приглушённое: это справка,
   а не часть названия. */
.field-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.register-row { display: flex; gap: 10px; align-items: end; grid-column: 1 / -1; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
  margin: 4px 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.form-grid-configured { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
.form-grid.form-grid-configured > .field, .form-grid.form-grid-configured > .check,
.form-grid.form-grid-configured > .card-layout-field { grid-column: span var(--field-span, 6); }
.bot-message-grid textarea { min-height: 112px; resize: vertical; line-height: 1.45; }
.bot-message-grid .field-hint { min-height: 34px; }
@media (max-width: 640px) {
  .form-grid, .form-grid.form-grid-configured { grid-template-columns: 1fr; }
  .form-grid.form-grid-configured > .field, .form-grid.form-grid-configured > .check,
  .form-grid.form-grid-configured > .card-layout-field { grid-column: 1 / -1; }
}

/* --- боковая панель редактирования --- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(16, 14, 32, .3); z-index: 30; display: flex; justify-content: flex-end; }
.drawer {
  width: 520px; max-width: 100%; background: var(--panel); height: 100%;
  overflow-y: auto; padding: 22px 26px 32px; box-shadow: -8px 0 30px rgba(0,0,0,.1);
}
.drawer h2 { margin: 0 0 2px; font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.drawer:not(.drawer-layout-editing) > .form-grid { gap: 8px 10px; }
.drawer:not(.drawer-layout-editing) > .form-grid > label.field { gap: 3px; }
.drawer:not(.drawer-layout-editing) > .form-grid > label.field > .sub { margin-top: 0; line-height: 1.35; }
.drawer:not(.drawer-layout-editing) > .form-grid > .field > :is(input, select, textarea),
.drawer:not(.drawer-layout-editing) > .form-grid .field-inline-hint > input,
.drawer:not(.drawer-layout-editing) > .form-grid .field-autocomplete > :is(input, textarea) { padding-top: 7px; padding-bottom: 7px; }
.drawer:not(.drawer-layout-editing) > .form-grid .dt-field { height: 36px; }
.drawer textarea { resize: none; }
.drawer .close { float: right; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.drawer-field-tools { display: flex; justify-content: flex-end; margin: 10px 0 16px; }
.drawer-actions { display: flex; gap: 10px; padding-top: 6px; position: sticky; bottom: -32px; background: var(--panel); padding-bottom: 4px; }
.drawer-actions .right { margin-left: auto; }
.drawer-layout-editing { width: 660px; }
.card-layout-tools { margin: 16px 0; padding: 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); }
.card-layout-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-layout-tools p { margin: 10px 0 0; line-height: 1.5; }
.card-layout-grid { gap: 12px; }
.card-layout-field { min-width: 0; border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px; background: var(--panel); position: relative; }
.card-layout-field-head { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }
.card-layout-field .card-layout-title { min-width: 0; flex: 1; font-size: 13px; font-weight: 600; padding: 6px; border-color: transparent; background: transparent; }
.card-layout-field .card-layout-title:hover, .card-layout-field .card-layout-title:focus { border-color: var(--accent); background: var(--panel); }
.card-layout-grip { flex: none; border: 0; border-radius: 6px; padding: 2px 5px; font-size: 23px; line-height: 1; background: transparent; color: var(--muted); cursor: grab; touch-action: none; user-select: none; }
.card-layout-grip:hover, .card-layout-grip:focus-visible { color: var(--accent); background: var(--bg); outline: 2px solid var(--accent); }
.card-layout-preview { margin: 0; }
.card-layout-preview-box { position: relative; min-width: 0; }
.card-layout-resize { position: absolute; bottom: 1px; right: 1px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center; border: 0; border-radius: 4px;
  padding: 0; background: transparent; color: var(--muted); cursor: nwse-resize; touch-action: none; }
.card-layout-resize:hover, .card-layout-resize:focus-visible { color: var(--accent); background: var(--accent-soft); outline: 2px solid var(--accent); }
.card-layout-field.is-resizing { border-color: var(--accent); user-select: none; }
.card-layout-preview .card-sized-control { resize: none; }
.card-field-control.card-sized-control > input { height: 100%; }
.card-layout-preview.field > span:first-child { display: none; }
.card-layout-preview .field-hint-button { display: none; }
.card-layout-preview input:disabled, .card-layout-preview select:disabled, .card-layout-preview textarea:disabled { opacity: .75; color: var(--text); background: var(--bg); }
.card-layout-preview textarea { min-height: 72px; max-height: 110px; resize: none; }
.card-layout-field-options { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.card-layout-field-options .check { font-size: 11px; gap: 5px; }
.card-layout-field-options input[type=checkbox] { width: 14px; height: 14px; }
.card-layout-field-options select { width: auto; font-size: 11px; padding: 5px 6px; }
.card-layout-field.is-dragging { opacity: .5; border-style: dashed; }
.card-layout-field.is-dragging .card-layout-grip { cursor: grabbing; }
.card-layout-field.drop-before::before, .card-layout-field.drop-after::after { content: ''; position: absolute; left: -2px; right: -2px; height: 4px; background: var(--accent); border-radius: 4px; pointer-events: none; }
.card-layout-field.drop-before::before { top: -8px; }
.card-layout-field.drop-after::after { bottom: -8px; }
.card-field-picker { margin-top: 14px; border-top: 1px solid var(--line-strong); padding-top: 12px; }
.card-field-picker [hidden], .card-field-picker[hidden] { display: none !important; }
.card-field-picker .chips { margin-bottom: 12px; }
.card-field-picker-results { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; margin-top: 10px; }
.card-field-picker-item { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 12px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 12px; color: var(--text); background: var(--panel); cursor: pointer; }
.card-field-picker-item:hover { border-color: var(--accent); }
.card-field-picker-item strong, .card-field-picker-item .sub { display: block; }
.card-field-picker-item strong { font-size: 13px; font-weight: 500; }
.card-field-picker-item svg { flex: none; width: 16px; height: 16px; }
.card-field-create { display: grid; gap: 12px; }
.card-layout-error { color: var(--red); font-size: 12px; }
.card-layout-actions { z-index: 2; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line-strong); }
@media (max-width: 640px) {
  .card-layout-toolbar { align-items: stretch; flex-direction: column; }
}

/* Шапка сделки: ключевой контекст виден до полей — название, воронка и этап. */
.drawer-has-hero { padding-top: 0; }
.deal-drawer-hero {
  margin: 0 -26px 18px; padding: 16px 26px 14px; color: #fff;
  background: var(--accent); border-bottom: 1px solid var(--accent-hover);
}
.deal-drawer-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.deal-drawer-hero-actions { display: flex; align-items: center; gap: 6px; flex: none; margin-top: -5px; }
.deal-drawer-settings { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  padding: 0; border: 0; border-radius: 8px; background: transparent; color: rgba(255,255,255,.8); cursor: pointer; }
.deal-drawer-settings:hover, .deal-drawer-settings[aria-pressed="true"] { color: #fff; background: rgba(255,255,255,.15); }
.deal-drawer-settings:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.deal-drawer-hero h2 { margin: 0; color: #fff; font-size: 18px; line-height: 1.25; }
.deal-drawer-hero .deal-drawer-title-input {
  min-width: 0; width: 100%; margin: 0; padding: 0 0 2px; border: 0;
  border-bottom: 1px solid transparent; border-radius: 0; outline: 0;
  background: transparent; color: #fff; font: inherit; font-size: 18px;
  font-weight: 700; line-height: 1.2; letter-spacing: -.3px; cursor: text;
}
.deal-drawer-hero .deal-drawer-title-input:hover,
.deal-drawer-hero .deal-drawer-title-input:focus { border-bottom-color: rgba(255,255,255,.75); }
.deal-drawer-hero .deal-drawer-title-input:read-only { cursor: pointer; }
.deal-drawer-hero .close { flex: none; float: none; margin-top: -1px; color: rgba(255,255,255,.72); }
.deal-drawer-hero .close:hover { color: #fff; }
.deal-drawer-hero-meta { display: flex; align-items: center; gap: 8px; min-height: 24px;
  margin-top: 8px; color: rgba(255,255,255,.67); font-size: 12px; }
.deal-drawer-customer { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 7px; border: 1px solid rgba(255,255,255,.38); border-radius: 6px;
  background: rgba(255,255,255,.1); }
.deal-drawer-context { margin-top: 8px; color: rgba(255,255,255,.65); font-size: 12px; }
.deal-drawer-stage { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin-top: 3px; }
.deal-drawer-stage strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; text-transform: uppercase; }
.deal-drawer-stage span { flex: none; color: rgba(255,255,255,.65); font-size: 12px; }
.deal-drawer-stage .deal-drawer-stage-select { min-width: 0; width: auto; max-width: 100%; flex: 0 1 auto;
  padding: 5px 32px 5px 8px; border: 1px solid rgba(255,255,255,.4); border-radius: 6px;
  color: #fff; background-color: rgba(255,255,255,.08); font-size: 14px; font-weight: 700; cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="m7 10 5 5 5-5"/></svg>'); }
.deal-drawer-stage-select:hover, .deal-drawer-stage-select:focus { border-color: #fff; }
.deal-drawer-stage-select option { color: var(--text); background: var(--panel); font-weight: 400; }
.deal-drawer-stage-select:disabled { cursor: default; }
.deal-drawer-stage { flex-wrap: wrap; }
.deal-drawer-progress { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 99px;
  background: rgba(32,15,85,.42); }
.deal-drawer-progress i { display: block; width: var(--deal-stage-progress); height: 100%;
  border-radius: inherit; background: var(--deal-stage-color); }

@media (max-width: 640px) {
  .deal-drawer-hero { margin-right: -26px; margin-left: -26px; }
  .deal-drawer-hero h2,
  .deal-drawer-hero .deal-drawer-title-input { font-size: 17px; }
}

/* Окно «уверены?»: строго по центру экрана, поверх всего. */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 14, 32, .35); z-index: 70;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--panel); border-radius: 16px; padding: 24px 26px 20px; width: 400px;
  max-width: 100%; box-shadow: 0 20px 50px rgba(20, 18, 40, .25); }
.modal h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.modal-text { margin: 0 0 20px; color: var(--muted); line-height: 1.45; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #16151a; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.22); max-width: 80vw;
}
.toast.error { background: var(--red); }

.loading { padding: 60px; text-align: center; color: var(--muted); }

/* --------------------------------------------------------------- вход и аккаунт */

.auth-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 24px; z-index: 50;
}
.auth-box {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.startup-box { min-height: 146px; justify-content: center; }
.startup-status { color: var(--muted); font-size: 14px; padding-top: 8px; }
.startup-error { color: var(--red); line-height: 1.45; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-title { font-size: 22px; font-weight: 600; margin-top: 6px; }
.auth-hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-input {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel);
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-code { letter-spacing: 8px; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
/* Форма разложена с шагом 14px, а сообщение об ошибке относится к полю над ним —
   поэтому подтягиваем его вплотную отрицательным отступом, а не общим gap. */
.auth-err { color: var(--red); font-size: 12px; line-height: 1.35; margin-top: -8px; }
.auth-submit { justify-content: center; padding: 12px; font-size: 15px; }
.auth-back { justify-content: center; color: var(--muted); font-size: 13px; }
/* Повторная отправка: пока идёт отсчёт — серая и неактивная, как подпись;
   стала доступна — подсвечивается, чтобы её было видно сразу после «код истёк». */
.auth-resend { justify-content: center; font-size: 13px; color: var(--muted); }
.auth-resend:disabled { opacity: 1; cursor: default; }
.auth-resend.ready { color: var(--accent); font-weight: 500; }
.auth-resend.ready:hover { background: var(--chip); }

.account {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; padding: 6px; margin: -6px;
  border-radius: 10px; font: inherit; color: inherit;
}
.account:hover { background: var(--chip); }
.account-chevrons { flex: none; display: flex; color: var(--muted); }

/* Выпадает вбок от сайдбара: снизу места нет, карточка и так прижата к краю окна. */
.account-menu {
  position: fixed; z-index: 100; width: 268px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .14); overflow: hidden;
}
.account-menu-head {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  border-bottom: 1px solid var(--line);
}
.account-menu-head .account-name { font-size: 15px; font-weight: 600; }
.account-avatar.big { width: 42px; height: 42px; font-size: 15px; }
.account-menu-list { padding: 6px; }
.account-menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 10px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--text); border-radius: 8px;
}
.account-menu-item:hover { background: var(--chip); }
.account-menu-icon { display: flex; color: var(--muted); flex: none; }
.account-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.account-who { min-width: 0; flex: 1; }
.account-name { color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-role { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-db { margin-top: 10px; font-size: 11px; opacity: .8; }


/* --- кнопка «Фильтры» с выпадающей панелью дат --- */
.filter-wrap { position: relative; }
.bar > .filter-wrap { align-self: center; }
/* Ровняем по поиску: у него высота 48 и скругление 12, кнопка должна совпасть. */
.bar .filter-wrap > .btn { height: 48px; border-radius: 12px; padding: 0 18px; }
.btn.btn-active { border-color: var(--accent); color: var(--accent); }
.btn .count {
  background: var(--accent); color: #fff; border-radius: 10px;
  padding: 1px 7px; font-size: 11px; font-variant-numeric: tabular-nums;
}
.filter-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; width: 360px; max-width: calc(100vw - 48px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .14); padding: 16px;
  display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
}
.filter-menu-row { display: flex; gap: 12px; width: 100%; }
/* min-width: 0 обязателен: иначе поле даты не сжимается ниже своей родной ширины
   и вылезает за край панели. */
.filter-menu-row label.field { flex: 1 1 0; min-width: 0; }
.filter-menu-row input[type="date"] {
  width: 100%; min-width: 0; height: 42px; border-radius: 10px;
}

.filter-menu-block { width: 100%; }
/* Поиск и списки, вложенные в панель фильтров, приходят из общей строки над
   таблицей — там они рассчитаны на всю ширину и рост 48px. Внутри панели их
   надо ужать, иначе поиск растягивает её по своей flex-basis. */
.filter-menu .search { width: 100%; flex: none; min-width: 0; height: 42px; padding: 0 12px; }
.filter-menu .search input { font-size: 14px; }
.filter-menu select { width: 100%; height: 42px; border-radius: 10px; }
.filter-menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.filter-menu-block .chips { margin-bottom: 0; max-height: 168px; overflow-y: auto; }

/* Общий вид всех воронок со столбцами. */
.sales-page {
  margin: 0; padding: 0; min-height: 0; background: transparent;
}
.funnel-board {
  gap: 12px; padding: 0 6px 12px; background: #e9ebee;
}
.funnel-board > .board-col { flex: 0 0 calc((100% - 48px) / 5); min-width: 0;
  border-radius: 0; padding: 0; background: transparent; }
.funnel-board > .board-col.board-drop { background: var(--accent-soft); }
.funnel-board .board-head { flex: none; margin: 0 0 8px; padding: 16px 8px 11px;
  text-align: center; background: transparent; }
.funnel-board .board-title { text-transform: uppercase; font-size: 12px; line-height: 1.3;
  font-weight: 600; letter-spacing: .5px; }
.funnel-board .board-meta { display: block; margin-top: 5px; font-size: 12px; line-height: 1.4;
  font-weight: 400; letter-spacing: normal; }
.funnel-board .board-meta b { color: inherit; font-size: inherit; font-weight: inherit; }
.funnel-board .board-meta > span + b::before { content: ': '; }
.funnel-board .sales-selectable-head { position: relative; padding-left: 27px; padding-right: 27px; }
.sales-column-select { position: absolute; top: 17px; left: 4px; width: 16px; height: 16px;
  margin: 0; accent-color: var(--accent); cursor: pointer; }
.sales-column-select:disabled { cursor: default; opacity: 1; }
.funnel-board .board-cards { min-height: 0; padding: 8px 2px 2px; }
.funnel-board .board-empty { border: 0; border-radius: 0; padding: 9px 8px;
  font-size: 14px; line-height: 1.4; font-weight: 400; letter-spacing: normal; }
@media (min-width: 1001px) and (max-width: 1400px) {
  .funnel-board .board-head { height: 82px; display: flex; flex-direction: column; justify-content: center; }
}
@media (max-width: 1000px) {
  .funnel-board > .board-col { flex-basis: 230px; }
}
@media (max-width: 640px) {
  .funnel-board > .board-col { flex-basis: 84vw; }
}
.sales-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.funnel-page-toolbar {
  display: grid;
  grid-template-columns: max-content minmax(280px, 1fr) minmax(160px, 220px) max-content;
  align-items: center;
  gap: 8px; width: 100%; margin: 0 0 10px;
}
.funnel-page-toolbar.funnel-toolbar-three {
  grid-template-columns: max-content minmax(280px, 1fr) minmax(180px, 240px);
}
.funnel-page-toolbar.funnel-toolbar-three > .filter-wrap,
.funnel-page-toolbar.funnel-toolbar-three > select { justify-self: stretch; width: 100%; }
.funnel-page-toolbar .search {
  width: 100%; max-width: none; min-width: 0; flex: none; height: 40px;
  padding: 0 13px; gap: 9px; border-radius: 10px;
}
.funnel-page-toolbar .search input { font-size: 14px; }
.funnel-page-toolbar > select {
  width: 100%; min-width: 0; height: 40px; padding-left: 12px;
  border-radius: 10px; font-size: 14px;
}
.funnel-page-toolbar > .filter-wrap { justify-self: end; }
.shift-toolbar-actions { display: flex; align-items: center; justify-self: end; gap: 7px; }
.shift-toolbar-actions > .filter-wrap { position: relative; }
.shift-bulk-trigger { width: 36px; height: 40px; padding: 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--accent); }
.shift-bulk-trigger:hover, .shift-bulk-trigger.active { background: var(--accent-soft); color: var(--accent); }
.sales-menu { margin-bottom: 0; }
.sales-toolbar .switch { flex: none; }
.sales-toolbar .filter-wrap { position: relative; }
.sales-toolbar .filter-wrap > .btn {
  height: 40px; border-radius: 10px; padding: 0 14px; font-size: 14px; white-space: nowrap;
}
.sales-toolbar .filter-menu { left: auto; right: 0; }
.sales-toolbar.funnel-toolbar-compact { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.funnel-toolbar-compact > .switch { height: 34px; padding: 2px; border-radius: 8px; }
.funnel-toolbar-compact > .switch button { height: 30px; padding: 0 10px; gap: 6px; border-radius: 6px; font-size: 13px; }
.funnel-toolbar-compact > .search { flex: 1 1 260px; width: auto; min-width: 220px; max-width: 340px;
  height: 34px; padding: 0 10px; gap: 6px; border-radius: 8px; }
.funnel-toolbar-compact > .search input { font-size: 13px; }
.funnel-toolbar-compact > .search .icon { width: 16px; height: 16px; flex: 0 0 16px; }
.funnel-toolbar-compact > select { flex: 0 0 160px; width: 160px; min-width: 0; height: 34px;
  padding: 0 30px 0 10px; border-radius: 8px; font-size: 13px; }
.funnel-toolbar-compact > .filter-wrap > .btn { height: 34px; padding: 0 10px; gap: 6px; border-radius: 8px; font-size: 13px; }
.funnel-toolbar-compact > .filter-wrap > .btn .icon { width: 16px; height: 16px; }
.funnel-toolbar-compact .shift-toolbar-actions { gap: 8px; }
.funnel-toolbar-compact .shift-toolbar-actions .filter-wrap > .btn {
  height: 34px; padding: 0 10px; gap: 6px; border-radius: 8px; font-size: 13px; }
.funnel-toolbar-compact .shift-bulk-trigger { width: 30px; height: 34px; border-radius: 8px; }
.funnel-toolbar-compact.funnel-toolbar-three > .filter-wrap { width: auto; }
@media (max-width: 640px) {
  .funnel-toolbar-compact > .search { flex-basis: 100%; min-width: 0; max-width: 100%; }
}
.sales-filter-menu input[type="date"] {
  width: 100%; height: 42px; border-radius: 10px; border: 1px solid var(--line-strong);
  padding: 0 11px; color: var(--text); background: var(--panel); font: inherit;
}
.sales-day-row { align-items: center; gap: 8px; margin: -2px 0 4px; }
.sales-day-row .chips { gap: 6px; }
.sales-day-row .chips-label { padding-top: 0; font-size: 11px; }
.sales-day-row .chip { padding: 5px 10px; border-radius: 10px; font-size: 12px; }
.shift-filter-row {
  align-items: center; gap: 14px; margin: -2px 0 4px;
}
.shift-filter-row .chips-row { align-items: center; gap: 8px; margin: 0; }
.shift-filter-row .chips { gap: 6px; }
.shift-filter-row .chips-label { padding-top: 0; font-size: 11px; }
.shift-filter-row .chip { padding: 5px 10px; border-radius: 10px; font-size: 12px; }
.shift-filter-row + .list-toolbar { min-height: 30px; margin: 2px 0 8px; }
@media (max-width: 1100px) {
  .funnel-page-toolbar { grid-template-columns: max-content minmax(260px, 1fr) max-content; }
  .funnel-page-toolbar > select { grid-column: 2; grid-row: 2; }
  .funnel-page-toolbar > .filter-wrap { grid-column: 3; grid-row: 1 / span 2; }
  .funnel-page-toolbar > .shift-toolbar-actions { grid-column: 3; grid-row: 1 / span 2; }
  .funnel-page-toolbar.funnel-toolbar-three {
    grid-template-columns: max-content minmax(240px, 1fr) minmax(170px, 220px);
  }
  .funnel-page-toolbar.funnel-toolbar-three > select,
  .funnel-page-toolbar.funnel-toolbar-three > .filter-wrap { grid-column: auto; grid-row: auto; }
}
.sales-views {
  display: inline-flex; align-items: center; padding: 2px; border-radius: 10px;
  background: #e8e9ed; white-space: nowrap;
}
.sales-view {
  height: 34px; padding: 0 11px; display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 13px;
}
.sales-view.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.09); }
.sales-search-wrap {
  min-width: 280px; flex: 1 1 360px; height: 48px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px;
}
.sales-search { width: 100%; border: 0; outline: 0; background: transparent; font: inherit; }
.sales-select {
  height: 48px; min-width: 160px; max-width: 220px; padding: 0 38px 0 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel);
  color: var(--text); font: inherit;
}
.sales-board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr);
  gap: 14px; overflow-x: auto; padding: 2px 0 24px; scrollbar-color: var(--line-strong) transparent;
}
.sales-column { --stage-color: var(--blue); min-height: 460px; transition: background .15s; }
.sales-column.drop { background: rgba(91,44,232,.06); }
.sales-column-head { padding: 13px 8px 11px; border-bottom: 3px solid var(--stage-color);
  text-align: center; text-transform: uppercase; }
.sales-column-head strong { display: block; font-size: 12px; letter-spacing: .5px; }
.sales-column-head span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; text-transform: none; }
.sales-green { --stage-color: #2fb66d; }
.sales-yellow { --stage-color: #e0b724; }
.sales-orange-dark { --stage-color: #c96e22; }
.sales-orange { --stage-color: #e7923b; }
.sales-blue { --stage-color: #4285e6; }
.sales-teal { --stage-color: #21a5a3; }
.sales-green-light { --stage-color: #77ba55; }
.sales-red { --stage-color: var(--red); }
.sales-cards { display: flex; flex-direction: column; gap: 9px; min-height: 120px; padding-top: 8px; }
.sales-empty { padding: 17px; text-align: center; color: var(--muted); }
.sales-card {
  padding: 12px; border: 1px solid #d0d0d6; border-radius: 10px; background: var(--panel); color: #111114;
  box-shadow: 0 1px 3px rgba(0,0,0,.04); cursor: pointer;
}
.funnel-board .kcard { padding: 12px; border: 1px solid #d0d0d6; border-radius: 10px;
  background: var(--panel); color: #111114; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.funnel-board .kcard:hover { border-color: #cfcfd6; box-shadow: 0 4px 14px rgba(0,0,0,.07); }
.funnel-board .config-card-fields { display: flex; flex-direction: column; gap: 6px; margin-top: 0; }
.funnel-board .config-card-field { gap: 2px; }
.funnel-board .config-card-label { font-size: 10.5px; line-height: 1.2; }
.funnel-board .config-card-value, .funnel-board .config-card-value strong {
  font-size: 12px; line-height: 1.2; }
.funnel-board .config-card-field-employer .config-card-label,
.funnel-board .config-card-field-address .config-card-label,
.funnel-board .config-card-field-shift .config-card-label { display: none; }
.funnel-board .config-card-field-employer .config-card-value,
.funnel-board .kcard-name { font-size: 13px; line-height: 1.2; font-weight: 600; text-transform: uppercase; }
.funnel-board .config-card-field-employer .config-card-value a { color: inherit; }
.funnel-board .kcard-top { gap: 6px; margin-bottom: 6px; }
.funnel-board .config-card-field-address .config-card-value { font-size: 12px; }
.funnel-board .config-card-field-progress { padding: 8px; border-radius: 8px;
  background: #f4f1f9; color: #4f485d; }
.funnel-board .config-card-field-progress .config-card-value { color: inherit; }
.funnel-board .shift-kcard .config-card-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.funnel-board .shift-kcard .config-card-field { grid-column: 1 / -1; }
.funnel-board .shift-kcard .config-card-field-account,
.funnel-board .shift-kcard .config-card-field-logist { grid-column: auto; }
.funnel-board .shift-kcard .config-card-field-schedule .config-card-label { display: none; }
.funnel-card-schedule { display: flex; flex-direction: column; gap: 6px; }
.page:has(.bulk-bar) .shift-board { height: calc(100vh - 320px); }
.funnel-board .payment-kcard .config-card-field-employer .config-card-value,
.funnel-board .payment-kcard .config-card-field-recipient .config-card-value {
  display: block; -webkit-line-clamp: unset; overflow: visible; }
.funnel-board .payment-kcard .config-card-field-contact .config-card-value,
.funnel-board .payment-kcard .config-card-field-order .config-card-value { white-space: normal; overflow: visible; }
.sales-card > * + * { margin-top: 6px; }
.sales-card-name { font-size: 13px; font-weight: 600; line-height: 1.2; text-transform: uppercase;
  overflow-wrap: anywhere; }
.sales-card-address, .sales-card-date { font-size: 12px; line-height: 1.2; }
.sales-card-address { white-space: nowrap; }
.sales-card-address > span { display: inline-block; vertical-align: top; }
.sales-card-task { padding: 8px; border-radius: 8px; background: #f4f1f9; color: #4f485d;
  font-size: 12px; line-height: 1.2; white-space: pre-wrap; overflow-wrap: anywhere; }
.sales-card-bottom { display: flex; align-items: baseline; justify-content: space-between;
  gap: 6px; color: #787881; font-size: 11.5px; line-height: 1.3; }
.sales-card-people { flex: none; }
.sales-card-manager { margin-left: auto; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.sales-card-total { font-size: 12px; font-weight: 600; }
.sales-card:hover { border-color: #cfcfd6; box-shadow: 0 4px 14px rgba(0,0,0,.07); }
.sales-card.dragging { opacity: .45; }
.sales-card.bulk-selecting:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sales-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.sales-bulk-trigger { width: 30px; height: 34px; padding: 0; flex: none; color: var(--accent); }
.sales-bulk-trigger.active { background: var(--accent-soft); }
.sales-bulk-panel .bulk-bar { flex-wrap: wrap; }
.sales-bulk-picker { position: relative; }
.sales-bulk-picker > summary { list-style: none; }
.sales-bulk-picker > summary::-webkit-details-marker { display: none; }
.sales-bulk-picker > summary[aria-disabled="true"] { opacity: .45; cursor: default; }
.sales-bulk-picker > summary .icon:last-child { width: 13px; height: 13px; }
.sales-bulk-menu { position: absolute; z-index: 1; left: 0; bottom: calc(100% + 12px);
  width: max-content; min-width: 220px; max-width: min(320px, calc(100vw - 48px));
  max-height: min(360px, 55vh); overflow-y: auto; padding: 6px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); box-shadow: 0 6px 24px rgba(16, 14, 32, .14); }
.sales-bulk-choice { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.sales-bulk-choice:hover, .sales-bulk-choice:focus-visible { background: var(--accent-soft); color: var(--accent); }
.sales-bulk-choice:disabled { opacity: .5; cursor: default; }
@media (max-width: 900px) {
  .sales-bulk-panel .bulk-bar { left: 12px; right: 12px; gap: 6px; }
}
.sales-page:has(.sales-bulk-panel .bulk-bar) .sales-funnel-board { height: calc(100vh - 280px); }
.sales-card-top, .sales-card-foot, .sales-card-meta { display: flex; align-items: center; gap: 8px; }
.sales-card-top, .sales-card-foot { justify-content: space-between; }
.sales-card-top strong { min-width: 0; }
.sales-card-line { margin-top: 7px; font-size: 13px; color: #55545b; }
.sales-card-meta { margin-top: 10px; color: var(--muted); font-size: 12px; }
.sales-card-foot { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.sales-age { margin-left: auto; padding: 2px 6px; border-radius: 7px; background: var(--chip); }
.sales-age.hot { background: var(--red-bg); color: var(--red); }
.sales-list { border-left: 0; border-right: 0; border-radius: 0; }
.sales-list > table { min-width: 1480px; }
.sales-list th { padding: 12px 10px; background: var(--panel); }
.sales-list td { padding: 12px 10px; vertical-align: top; line-height: 1.4; }
.sales-list tbody tr { background: #fcfaff; }
.sales-list tbody tr:hover { background: #f5f1fc; }
.sales-list .sub { margin-top: 3px; line-height: 1.35; }
.sales-list-order { min-width: 200px; max-width: 280px; overflow-wrap: anywhere; }
.sales-list-address { min-width: 200px; max-width: 260px; overflow-wrap: anywhere; }
.sales-list .pill { border-radius: 20px; padding: 3px 10px; font-weight: 400; }
.sales-list .pill::before { display: block; }
.sales-list .cell-check { width: 36px; min-width: 36px; }
.sales-activity-wrap { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.sales-activity-toggle { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; list-style: none; font-size: 15px; font-weight: 700; cursor: pointer; }
.sales-activity-toggle::-webkit-details-marker { display: none; }
.sales-activity-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.sales-activity-chevron { display: flex; color: var(--muted); }
.sales-history[open] > .sales-activity-toggle .sales-activity-chevron { transform: rotate(180deg); }
.sales-history[open] > .sales-activity { margin-top: 10px; }
.sales-tasks { margin-top: 18px; }
.sales-tasks h3 { margin: 0; font-size: 15px; }
.sales-event { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.45; }
.sales-task-form { display: grid; grid-template-columns: 1fr 180px; gap: 8px; margin-top: 14px; }
.sales-task-form textarea { grid-column: 1 / -1; }
.sales-task-form textarea, .sales-task-form input, .sales-task-form select {
  min-width: 0; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--panel); color: var(--text); font: inherit;
}
.sales-task-form .btn { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .sales-page { margin-left: -18px; margin-right: -18px; padding-left: 18px; padding-right: 18px; }
  .sales-board { grid-auto-columns: minmax(260px, 84vw); }
  .sales-select { flex: 1 1 150px; max-width: none; }
}

/* Общие колонки основного и ручного состава смены. */
.table-wrap > .shift-roster-table { table-layout: fixed; width: 100%; min-width: 0; }
.shift-roster-table th, .shift-roster-table td { padding-left: 8px; padding-right: 8px; white-space: normal; overflow-wrap: anywhere; }
.shift-roster-table .nowrap { white-space: normal; }
.shift-roster-table .btn { max-width: 100%; padding: 7px 6px; white-space: normal; font-size: 12px; }
.shift-roster-table .sub { white-space: normal; }
.shift-roster-table .cell-check { width: auto; padding-left: 6px; padding-right: 6px; }
.shift-roster-table td.wrap { overflow-wrap: anywhere; }
.shift-roster-table .pill { max-width: 100%; white-space: normal; }
.shift-person-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.shift-roster-table td.shift-comment-above { border-bottom: 0; padding-bottom: 4px; }
.shift-roster-comment td { padding-top: 4px; white-space: normal; overflow-wrap: anywhere; }

.shift-roster-table th, .shift-roster-table .btn, .shift-roster-table .pill { white-space: nowrap; overflow-wrap: normal; }
@media (max-width: 850px) { .table-wrap > .shift-roster-table { min-width: 1050px; } }

/* Компактные условия и состав; сводка в обычной правой колонке. */
.shift-detail .block { padding: 14px 16px; margin-bottom: 12px; }
.shift-detail .block > h3 { margin-bottom: 10px; flex-wrap: wrap; }
.shift-detail .shift-roster-table td { padding-top: 10px; padding-bottom: 10px; }
.shift-detail .shift-roster-table th { padding-top: 10px; padding-bottom: 10px; }
.shift-detail .shift-roster-comment td { padding-top: 0; padding-bottom: 8px; }
.shift-roster-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shift-roster-tools .muted { margin-right: 0 !important; }
@media (max-width: 650px) {
  .shift-roster-tools { margin-left: 0 !important; }
}

.shift-detail .shift-conditions { padding: 18px 20px; margin-bottom: 18px; }
.shift-detail .shift-conditions > h3 { margin-bottom: 14px; }

.drawer-field-tools.drawer-stage-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.drawer-stage-tools .drawer-top-stage { flex: 1; min-width: 0; max-width: 300px; margin: 0; }
.drawer-stage-tools > .btn { flex-shrink: 0; }
@media (max-width: 550px) { .drawer-field-tools.drawer-stage-tools { flex-wrap: wrap; } }

/* Настройки меню справа от «Правила». */
.nav-rules-row { display: flex; align-items: center; gap: 4px; margin-top: auto; flex-shrink: 0; }
.nav .nav-rules-row > button.nav-rules { flex: 1; min-width: 0; width: auto; margin: 0; }
.nav .nav-rules-row > button.nav-menu-settings { width: 32px; height: 32px; flex: 0 0 32px;
  padding: 7px; margin: 0; justify-content: center; color: var(--muted); border-radius: 8px; }
.nav .nav-rules-row > button.nav-menu-settings:hover,
.nav .nav-rules-row > button.nav-menu-settings[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.sidebar:not(:hover):not(:has(:focus-visible)):not(.nav-editing) .nav-menu-settings { display: none; }

.address-list { display: flex; flex-direction: column; gap: 8px; }
.address-list-rows { display: flex; flex-direction: column; gap: 8px; }
.address-list-row { display: flex; align-items: center; gap: 8px; }
.address-list-row input { min-width: 0; flex: 1; }
.address-list-row .address-remove { flex: 0 0 32px; height: 32px; padding: 6px;
  display: flex; align-items: center; justify-content: center; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer; }
.address-list-row .address-remove:hover { color: var(--red); background: var(--chip); }
.address-list .address-add { align-self: flex-start; }
.address-list.card-sized-control { height: auto; max-height: none; }
.sales-list-address { white-space: pre-line; }

.company-filter { position: relative; }
.company-filter > summary { list-style: none; max-width: 280px; cursor: pointer; }
.company-filter > summary::-webkit-details-marker { display: none; }
.company-filter[open] { z-index: 30; }
.company-filter-panel { position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; max-width: calc(100vw - 32px); padding: 14px; display: flex; flex-direction: column;
  gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.15); }
.company-filter-actions { display: flex; gap: 6px; }
.company-filter-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.company-filter-list .check { white-space: normal; overflow-wrap: anywhere; }

.company-filter-embedded > summary { width: 100%; max-width: none; justify-content: space-between; }
.company-filter-embedded .company-filter-panel { position: static; width: 100%; max-width: none;
  box-sizing: border-box; margin-top: 8px; padding: 10px; box-shadow: none; }
.company-filter-embedded .company-filter-list { max-height: 180px; }
.sales-filter-menu:has(.company-filter-embedded) { max-height: min(80vh, 700px); overflow-y: auto; }

.drawer.company-order-history { width: min(1100px, 100vw); max-width: 100vw; }
.company-order-history-content { display: flex; flex-direction: column; gap: 16px; }
.company-history-pages { display: flex; gap: 12px; align-items: center; justify-content: flex-end; }

.company-contact-actions .btn { padding: 5px 9px; min-height: 28px; font-size: 12px; gap: 5px; }
.company-contact-actions .btn svg { width: 14px; height: 14px; }

/* Calendar application report: fixed period column, horizontal metric scroll. */
.application-report { display: grid; gap: 18px; min-width: 0; }
.application-report-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.application-report-toolbar label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.application-report-toolbar select { padding: 9px 12px; border: 1px solid #dbe0e6; border-radius: 8px; background: white; max-width: 300px; }
.application-report-scroll { overflow: auto; max-height: 70vh; border: 1px solid #dbe0e6; border-radius: 12px; }
.application-report-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.application-report-table th, .application-report-table td { padding: 10px 12px; border-right: 1px solid #e2e6e9; border-bottom: 1px solid #e2e6e9; text-align: right; min-width: 115px; white-space: nowrap; }
.application-report-table thead th { position: sticky; top: 0; z-index: 2; background: #edf1f5; white-space: normal; text-align: center; height: 64px; }
.application-report-table tr > :first-child { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 160px; background: #fff; }
.application-report-table thead tr > :first-child { z-index: 3; background: #edf1f5; }
.application-report-table .report-year > * { background: #dcebe4; font-weight: 750; }
.application-report-table .report-month > * { background: #edf5ef; font-weight: 650; }
.application-report-table .report-weekend > * { background: #fff8e5; }
.application-report-table .report-paid, .application-report-table .report-paid_hour { color: #2463bf; }
.application-report-table .report-negative { color: #bd3541; }
.application-report-table td.report-logist_name { min-width: 220px; max-width: 300px; white-space: normal; text-align: left; overflow-wrap: anywhere; }
.report-month-button { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-transform: capitalize; cursor: pointer; width: 100%; text-align: left; }
.report-month-button:focus-visible { outline: 2px solid #2463bf; outline-offset: 4px; }
.application-report-note { padding: 16px 20px; border: 1px solid #e2e6e9; border-radius: 12px; font-size: 13px; line-height: 1.6; background: #fafbfc; }
.application-report-note p { margin: 7px 0 0; color: #67717d; }

.report-company-filter > summary { max-width: 340px; overflow-wrap: anywhere; white-space: normal; }
.report-company-filter .company-filter-panel { left: 0; right: auto; width: min(360px, calc(100vw - 100px)); }
.report-company-filter .company-filter-panel select { width: 100%; max-width: none; }
.report-company-filter input[type="search"] { width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; color: var(--text); background: var(--panel); }

.report-order-info { width: 235px; white-space: normal; padding-left: 12px; }
.report-order-button { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.report-order-button:hover { text-decoration: underline; }
.application-report-table .report-order > * { background: #fafaff; font-weight: 400; }
.application-report-table .report-empty-day td { text-align: left; white-space: normal; color: var(--muted); padding: 16px; }

/* Payroll payment calendar: coloured staff columns and Tuesday–Monday totals. */
.payroll-payment-toolbar input[type="date"] { padding: 9px 12px; border: 1px solid #dbe0e6; border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
.payroll-payment-scroll { border-radius: 8px; }
.payroll-payment-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; font-size: 14px; font-variant-numeric: tabular-nums; }
.payroll-payment-table th, .payroll-payment-table td { padding: 8px 14px; height: 36px; border-right: 1px solid #d6dce2; border-bottom: 1px solid #d6dce2; text-align: center; white-space: nowrap; font-size: inherit; }
.payroll-payment-table thead th { position: sticky; top: 0; z-index: 2; background: #f5f6f8; color: #20242a; font-weight: 750; height: 64px; white-space: normal; line-height: 1.35; }
.payroll-payment-table tr > :first-child { position: sticky; left: 0; z-index: 1; width: 154px; min-width: 154px; border-right: 3px solid #c4cbd2; background: #fff; }
.payroll-payment-table thead tr > :first-child { z-index: 3; background: #f5f6f8; }
.payroll-payment-table tbody th { color: #20242a; font-weight: 450; }
.payroll-payment-table tbody td { min-width: 155px; }
.payroll-payment-table thead .payroll-payment-department { background: #d0d0d0; }
.payroll-payment-table thead .payroll-payment-alterman { background: #e99c9f; }
.payroll-payment-table thead .payroll-payment-saradzhyan { background: #b4d6a3; }
.payroll-payment-table thead .payroll-payment-buslaeva { background: #fff2cb; }
.payroll-payment-table thead .payroll-payment-afanasyeva { background: #ccdff4; }
.payroll-payment-table .payroll-payment-department { font-weight: 750; }
.payroll-payment-table tbody .payroll-payment-week > * { background: #cfe3f2; font-weight: 750; border-bottom-color: #adc7db; }
.payroll-payment-table tbody .payroll-payment-unfilled { color: #858c94; }
.payroll-payment-table .payroll-payment-week .payroll-payment-unfilled { color: #5f7487; }
.payroll-payment-table tr > :last-child { border-right: 0; }
.payroll-payment-table tbody tr:last-child > * { border-bottom: 0; }
.payroll-payment-hint { font-size: 12px; }
.payroll-payment-partial { margin-left: 3px; color: var(--muted); }
.payroll-payment-debt { margin-top: 8px; font-size: 12px; font-weight: 600; }
.payroll-payment-deduction { margin-top: 4px; font-size: 10px; line-height: 1.4; color: var(--muted); font-weight: 400; }
.payroll-payment-table tfoot th, .payroll-payment-table tfoot td { background: #f1eefb; font-weight: 600; }
.payroll-payment-table tfoot th { white-space: normal; font-size: 12px; }
.payroll-payment-table tfoot tr:last-child > * { background: #e5def9; font-weight: 750; }
.payroll-payout-history { margin-top: 22px; }
.payroll-payout-history > summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; }
.payroll-payout-voided td { color: var(--muted); }
.payroll-settings { max-width: 1050px; }
.payroll-settings > p { line-height: 1.6; margin: 0 0 20px; }
.payroll-settings .table-wrap > table { min-width: 540px; }
.payroll-settings th:last-child { width: 190px; }
.payroll-percent-input { display: inline-flex; align-items: center; gap: 10px; }
.payroll-percent-input input { width: 100px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
.payroll-percent-input input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.payroll-percent-input input:disabled { opacity: .65; }
.payroll-settings-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-top: 20px; }
.access-hint { max-width: 260px; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.45; white-space: normal; }
