/* RedMint CRM — светлая тема, плотный рабочий интерфейс */

:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --line: #e4e5e7;
  --line-strong: #c8cacd;
  --ink: #1c1e20;
  --ink-2: #5f6367;
  --ink-3: #8d9195;
  /* Фирменный красный из логотипа — акцентом, не фоном */
  --accent: #cf272b;
  --accent-ink: #a81f22;
  --accent-wash: #fbebeb;
  /* Деньги и успех остаются зелёными: красным их красить нельзя, читается как минус */
  --won: #1f7a55;
  --won-wash: #eaf4ef;
  --lost: #8f1b16;
  --warn: #a8600a;
  --warn-wash: #fdf3e4;
  --focus: #52565b;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(20, 22, 25, .06), 0 2px 8px rgba(20, 22, 25, .04);
  --shadow-2: 0 2px 4px rgba(20, 22, 25, .08), 0 8px 24px rgba(20, 22, 25, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать любой display у классов —
   иначе скрытые блоки остаются на экране */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-wash); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid var(--bg);
  border-radius: 6px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

a { color: var(--accent-ink); text-decoration-color: rgba(207, 39, 43, .35); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ——— Каркас ——— */

.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  padding: 17px 18px 15px;
  border-bottom: 1px solid var(--line);
  line-height: 0;
}
.logo img { height: 22px; width: auto; display: block; }
.logo a { display: block; line-height: 0; }

.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-wash); color: var(--accent-ink); }
.nav svg { width: 16px; height: 16px; flex: none; stroke-width: 1.7; }

.me {
  border-top: 1px solid var(--line); padding: 12px;
  display: flex; align-items: center; gap: 10px;
}
.me .avatar { width: 30px; height: 30px; }
.me-name { font-weight: 500; font-size: 13px; line-height: 1.3; }
.me-role { color: var(--ink-3); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar .grow { flex: 1; }

.content { padding: 20px; flex: 1; min-width: 0; }

/* ——— Элементы ——— */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 500; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; stroke-width: 1.8; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { color: var(--lost); border-color: transparent; background: transparent; }
.btn-danger:hover { background: #fbebeb; border-color: #edc6c5; }

.btn-sm { padding: 4px 9px; font-size: 13px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg a {
  padding: 6px 12px; text-decoration: none; color: var(--ink-2);
  font-weight: 500; background: var(--surface);
}
.seg a + a { border-left: 1px solid var(--line); }
.seg a:hover { background: var(--surface-2); color: var(--ink); }
.seg a[aria-current="page"] { background: var(--accent-wash); color: var(--accent-ink); }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=number], input[type=search], input[type=datetime-local],
select, textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit;
  caret-color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(28, 30, 32, .12);
}
::placeholder { color: var(--ink-3); }
textarea { min-height: 76px; resize: vertical; line-height: 1.55; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 8l3-3.5' fill='none' stroke='%235c6a64' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

label { display: block; font-weight: 500; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }

.field { margin-bottom: 14px; }
.row { display: grid; gap: 14px; }
.row > .field { min-width: 0; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.check label { margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card-body { padding: 16px; }

.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 16px; align-items: start; }

/* ——— Таблица ——— */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; font-size: 12px; letter-spacing: .02em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }

/* ——— Канбан ——— */

.board { display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }

.column {
  flex: 0 0 268px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  max-height: calc(100vh - 150px);
}

/* Заголовок залит цветом этапа, текст белый */
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: var(--stage-color, var(--ink-3));
  color: #fff;
}
.column-head .name {
  font-weight: 600; font-size: 13px; line-height: 1.3;
  border-radius: 4px; padding: 1px 4px; margin-left: -4px;
  transition: background .12s ease;
}
.column-head .name[contenteditable]:hover { background: rgba(255, 255, 255, .16); }
.column-head .name[contenteditable]:focus {
  outline: none; background: rgba(255, 255, 255, .22);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .5);
}
.column-head .name.saved { background: rgba(255, 255, 255, .3); }
.column-head .count {
  font-size: 12px; color: #fff; background: rgba(255, 255, 255, .22);
  padding: 1px 7px; border-radius: 10px; margin-left: auto;
}
.column-head[draggable="true"] { cursor: grab; }
.column-head[draggable="true"]:active { cursor: grabbing; }

.column-sum {
  padding: 7px 12px; font-weight: 600; font-size: 13px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.column.col-dragging { opacity: .5; }
.column.col-target { outline: 2px dashed var(--accent); outline-offset: -2px; }

.column-body {
  padding: 8px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; flex: 1; min-height: 44px;
}
.column-body.over { background: var(--accent-wash); }

.deal-card {
  display: block; padding: 10px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; color: inherit; cursor: grab;
  box-shadow: var(--shadow-1);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s cubic-bezier(.2,.8,.3,1);
}
.deal-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.deal-card.dragging { opacity: .45; cursor: grabbing; }
.deal-card .who { font-weight: 600; margin-bottom: 3px; }
.deal-card .meta { color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.deal-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.deal-card .amount { font-weight: 600; color: var(--won); margin-top: 6px; }

/* Быстрая сделка внизу колонки */
.quick { border-top: 1px solid var(--line); padding: 8px; }
.quick-open {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 7px 9px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); font: inherit; font-size: 13px;
  cursor: pointer; transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.quick-open:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-wash); }
.quick-open svg { width: 14px; height: 14px; stroke-width: 2; }
.quick-fields { display: flex; flex-direction: column; gap: 7px; }
.quick-fields input { font-size: 13px; padding: 6px 9px; }
.quick-actions { display: flex; gap: 6px; }

/* ——— Мелочи ——— */

.avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  background: var(--surface-2); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; flex: none; border: 1px solid var(--line);
}

.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.tag-accent { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
/* Успех, деньги, «подключено» — зелёным: красный тут читался бы как проблема */
.tag-won { background: var(--won-wash); border-color: transparent; color: var(--won); }
.tag-warn { background: var(--warn-wash); border-color: transparent; color: var(--warn); }
.tag-lost { background: #fbebeb; border-color: transparent; color: var(--lost); }

/* Долг перед партнёром — тёплым, а не красным: это задача, а не авария */
.due-money { color: var(--warn); }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }

.flash {
  padding: 9px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
  background: var(--accent-wash); color: var(--accent-ink); font-weight: 500;
}

/* Уведомление сверху: что мешает сохранить */
.notice {
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.notice li { margin: 2px 0; }
.notice-error { background: #fbebeb; border-color: #f0c9c6; color: var(--lost); }
.notice-error strong { color: var(--lost); }

/* Кнопка сохранения в правом нижнем углу: видна на любой длине карточки */
.savebar {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: 0 6px 20px rgba(24, 33, 30, .14);
}
.savebar-note { color: var(--warn); font-size: 13px; font-weight: 500; }

/* Поле, из-за которого сделка не сохранилась */
input.bad, select.bad, textarea.bad {
  border-color: var(--lost); background: #fdf7f7;
}

.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.empty h2 { margin-bottom: 6px; color: var(--ink); }

.feed { display: flex; flex-direction: column; gap: 0; }
.feed-item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: none; }
.feed-meta { color: var(--ink-3); font-size: 12px; margin-bottom: 3px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 150px; }

.task-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: none; }
.task-row.overdue .due { color: var(--lost); font-weight: 500; }
.task-row.done .title { color: var(--ink-3); text-decoration: line-through; }

/* ——— Вход ——— */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 368px; }
.auth-logo { margin-bottom: 10px; line-height: 0; }
.auth-logo img { height: 28px; width: auto; }
.auth-sub { color: var(--ink-2); margin: 0 0 22px; }
.auth-error {
  background: #fbebeb; color: var(--lost); padding: 9px 12px;
  border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px;
}

@media (max-width: 900px) {
  /* Одна колонка: шапка по содержимому, остальное — контенту.
     Без grid-template-rows строки делят высоту поровну и шапка растягивается. */
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side {
    position: sticky; top: 0; z-index: 30;
    height: auto; min-height: 0;
    flex-direction: row; align-items: center; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .logo { border-bottom: none; border-right: 1px solid var(--line); white-space: nowrap; }
  .nav { flex-direction: row; flex: 1; }
  .nav a span { display: none; }
  .me { border-top: none; border-left: 1px solid var(--line); margin-left: auto; }
  .me-name, .me-role { display: none; }
  .logo { padding: 12px 14px; }
  .nav { padding: 8px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; top: 55px; }
  .topbar h1 { font-size: 18px; }
  .content { padding: 14px; }
  .column { flex-basis: 84vw; max-height: none; }
  .filters .field { min-width: 0; flex: 1 1 140px; }
  .grid-2 { grid-template-columns: 1fr; }
  .savebar { right: 12px; bottom: 12px; left: 12px; justify-content: flex-end; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

/* ——— Цвет этапа, правка названия, палитра ——— */

.swatch-btn {
  width: 15px; height: 15px; border-radius: 50%; padding: 0; flex: none;
  border: 1px solid rgba(255, 255, 255, .55); background: transparent;
  cursor: pointer; opacity: 0; transition: opacity .12s ease, transform .12s ease;
}
.column:hover .swatch-btn, .swatch-btn:focus-visible { opacity: 1; }
.swatch-btn:hover { transform: scale(1.15); background: rgba(255, 255, 255, .25); }

.palette {
  position: absolute; z-index: 50; display: flex; gap: 6px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
}

.swatch {
  width: 20px; height: 20px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 1px solid rgba(0, 0, 0, .12);
  transition: transform .1s ease;
}
.swatch:hover { transform: scale(1.15); }
.swatch-reset {
  background: var(--surface);
  background-image: linear-gradient(45deg, transparent 44%, var(--lost) 44%, var(--lost) 56%, transparent 56%);
}

.dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  border: 1px solid rgba(0, 0, 0, .12);
}

/* ——— Карточка: свойства сверху вниз, метка слева ——— */

.props { display: flex; flex-direction: column; }

.prop {
  display: grid; grid-template-columns: 160px minmax(0, 1fr);
  align-items: center; gap: 14px;
  padding: 7px 0;
}
.prop > label {
  margin: 0; text-align: left; color: var(--ink-2);
  font-weight: 400; font-size: 13px; line-height: 1.35;
}
.prop .check { min-height: 34px; }
.prop .check label { font-size: 14px; }

.prop-static { color: var(--ink-2); font-size: 13px; }

.prop-sep { height: 1px; background: var(--line); margin: 11px 0; }

.prop-wide { align-items: start; }
.prop-wide > label { padding-top: 8px; }

/* Обязательное поле: без пары «имя или компания» и «телефон или почта» не сохранить */
.prop-req > label::after { content: ' *'; color: var(--accent); }
.props-note { margin: 14px 0 0; max-width: 60ch; }

@media (max-width: 720px) {
  .prop { grid-template-columns: 1fr; gap: 5px; padding: 8px 0; }
  .prop > label { font-size: 12px; }
}

/* Формы внутри ячеек таблицы не должны ломать строку */
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select, .inline-form input { font-size: 13px; padding: 5px 8px; }
td.overdue-cell input { border-color: var(--lost); color: var(--lost); }

/* ——— Задача в карточке сделки ——— */

.task-item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: none; }
.task-item.done .title { color: var(--ink-3); text-decoration: line-through; }
.task-line { display: flex; align-items: center; gap: 10px; }
.task-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  color: var(--ink-3); font-size: 12px; margin-top: 3px;
}
.task-meta .overdue { color: var(--lost); font-weight: 500; }

/* ——— Настройки воронок ——— */

.funnel-next { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }

.funnel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.funnel-name { width: 260px; font-weight: 600; font-size: 15px; }

.stages { display: flex; flex-direction: column; }

.stage-row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) 170px 74px auto;
  align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.stage-row:last-child { border-bottom: none; }
.stage-kind { font-size: 12px; }
.stage-actions { display: flex; gap: 2px; justify-content: flex-end; }

.funnel-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}

.stage-add { display: flex; gap: 8px; margin-top: 12px; }
.stage-add input { width: 260px; }

@media (max-width: 720px) {
  .stage-row { grid-template-columns: 12px 1fr; row-gap: 6px; }
  .stage-row select, .stage-kind, .stage-actions { grid-column: 2; justify-content: flex-start; }
  .funnel-name, .stage-add input { width: 100%; }
  .stage-add { flex-direction: column; }
}

/* ——— Интеграции ——— */

.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); margin: 22px 0 10px; }
.group-title:first-child { margin-top: 0; }

.integrations { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.integration .card-head h3 { font-size: 15px; }

.hook {
  display: inline-block; max-width: 100%; overflow-x: auto; white-space: nowrap;
  padding: 6px 9px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink);
  cursor: pointer;
}
.hook:hover { border-color: var(--accent); }
.hook.copied { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-ink); }

@media (max-width: 900px) { .integrations { grid-template-columns: 1fr; } }

.utm { display: flex; gap: 6px; flex-wrap: wrap; }

.check-result {
  padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px;
  font-size: 13px; line-height: 1.5;
}
.check-result.ok   { background: var(--won-wash); color: var(--won); }
.check-result.bad  { background: #fbebeb; color: var(--lost); }
.check-result.info { background: var(--warn-wash); color: var(--warn); }

/* ——— Интеграции: выбор направления ——— */

.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.group-card { text-decoration: none; color: inherit; transition: border-color .12s ease, box-shadow .12s ease, transform .12s cubic-bezier(.2,.8,.3,1); }
.group-card:hover { border-color: var(--accent); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.group-head { display: flex; align-items: center; gap: 10px; }
.group-head h2 { font-size: 16px; }
.group-names { margin: 0; font-size: 13px; color: var(--ink-2); }

.provider-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; transition: background .1s ease;
}
.provider-row:last-child { border-bottom: none; }
.provider-row:hover { background: var(--surface-2); }
.provider-name { font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }

/* ——— Настройки: разделы ——— */

.stage-dots { display: flex; gap: 3px; flex-shrink: 0; }
.stage-dots .dot { width: 8px; height: 8px; }

/* Строка справочника: название правится на месте */
.dict-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.dict-row:last-child { border-bottom: none; }
.dict-row input[type="text"] { flex: 1; min-width: 0; }
.dict-row .muted { white-space: nowrap; }

.partner-card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.partner-card:first-child { padding-top: 0; }
.partner-card:last-child { border-bottom: none; padding-bottom: 0; }
.partner-card.off { opacity: .6; }
.partner-card .partner-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.partner-card .field { margin-bottom: 10px; }

code {
  padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink);
}
pre.code {
  margin: 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink);
  overflow-x: auto;
}
pre.code code { padding: 0; border: 0; background: none; }

/* ——— Задачи: цвет статуса ——— */

.tasks-table tbody tr td:first-child { position: relative; padding-left: 16px; }
.tasks-table tbody tr td:first-child::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 2px;
}
.tasks-table tr.row-red    td:first-child::before { background: var(--lost); }
.tasks-table tr.row-yellow td:first-child::before { background: var(--warn); }
.tasks-table tr.row-green  td:first-child::before { background: var(--won); }
.tasks-table tr.row-red    { background: #fdf6f5; }
.tasks-table tr.row-green  { background: #f7fbf9; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lamp { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lamp-red { background: var(--lost); }
.lamp-yellow { background: var(--warn); }
.lamp-green { background: var(--won); }

.seg a.seg-danger { color: var(--lost); }
.seg a.seg-danger[aria-current="page"] { background: #fbebeb; color: var(--lost); }

.date-pick { display: flex; align-items: center; gap: 8px; }

@media (max-width: 900px) {
  .legend { display: none; }
  .date-pick { width: 100%; }
}

/* ——— База знаний ——— */

.kb-search { display: flex; gap: 8px; margin-bottom: 18px; }
.kb-search input { flex: 1; padding: 10px 14px; font-size: 15px; }

.kb-found { padding: 12px 0; border-bottom: 1px solid var(--line); }
.kb-found:last-child { border-bottom: none; }
.kb-found-title { font-weight: 600; margin-right: 8px; }
.kb-snippet { margin: 6px 0 0; font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.kb-snippet b { background: var(--warn-wash); color: var(--ink); font-weight: 600; padding: 0 2px; border-radius: 3px; }

.kb-list { display: grid; gap: 12px; }
.kb-item { text-decoration: none; color: inherit; transition: border-color .12s ease, box-shadow .12s ease; }
.kb-item:hover { border-color: var(--accent); box-shadow: var(--shadow-2); }
.kb-item-head { display: flex; align-items: center; gap: 10px; }
.kb-item-head h2 { font-size: 15px; }
.kb-other { display: flex; flex-wrap: wrap; gap: 8px; }

/* Статья: колонка текста ограничена по ширине, читать длинные строки тяжело */
.kb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.kb-article .card-body { padding: 24px 28px 28px; }
.kb-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }
.kb-meta .tag { text-decoration: none; }
.kb-summary { margin: 0 0 18px; font-size: 15px; line-height: 1.65; color: var(--ink-2); padding-left: 12px; border-left: 3px solid var(--accent); }

.kb-body { max-width: 78ch; font-size: 15px; line-height: 1.7; }
.kb-body h2 { font-size: 19px; margin: 28px 0 10px; }
.kb-body h3 { font-size: 16px; margin: 24px 0 8px; }
.kb-body h4 {
  font-size: 16px; color: var(--ink); margin: 26px 0 10px;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.kb-body h3 + h4, .kb-body > h4:first-child { padding-top: 0; border-top: 0; margin-top: 8px; }
.kb-body h3 + p, .kb-body h4 + p { margin-top: 0; }
.kb-body p { margin: 0 0 12px; }
.kb-body ul, .kb-body ol { margin: 0 0 14px; padding-left: 22px; }
.kb-body li { margin-bottom: 5px; }
.kb-body blockquote {
  margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.kb-body hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.kb-body strong { font-weight: 600; }
.kb-table { overflow-x: auto; margin: 0 0 16px; }
.kb-table table { min-width: 420px; }
.kb-table th, .kb-table td { padding: 8px 10px; vertical-align: top; font-size: 13px; line-height: 1.55; }
.kb-table td { border-bottom: 1px solid var(--line); }

.kb-aside .task-row a { text-decoration: none; }

@media (max-width: 1000px) { .kb-layout { grid-template-columns: 1fr; } }

/* ——— Календарь встреч ——— */
.cal-week { font-weight: 600; white-space: nowrap; }
.cal { overflow: hidden; }
.cal-head, .cal-body { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal-dayhead { padding: 8px 6px; text-align: center; border-left: 1px solid var(--line); color: var(--ink-2); font-size: 12px; }
.cal-dayhead b { display: block; font-size: 18px; line-height: 1.2; color: var(--ink); font-weight: 600; }
.cal-dayhead.is-today b { color: var(--accent); }
.cal-dayhead.is-weekend, .cal-day.is-weekend { background-color: var(--surface-2); }
.cal-body { max-height: calc(100vh - 210px); overflow-y: auto; }
.cal-times div { height: var(--hour); padding: 0 8px 0 0; text-align: right; font-size: 11px; color: var(--ink-3); transform: translateY(-7px); }
.cal-times div:first-child { transform: none; }
.cal-day {
  position: relative; height: calc(var(--hour) * var(--hours)); border-left: 1px solid var(--line); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour));
}
.cal-day.is-today { background-color: #fff8f8; }
.cal-ev {
  position: absolute; overflow: hidden; padding: 3px 6px; border-radius: 6px; font-size: 12px; line-height: 1.3;
  color: var(--ink); text-decoration: none; cursor: pointer;
  background: #eef2f8; border-left: 3px solid #6b7772; box-shadow: 0 1px 2px rgba(20, 22, 25, .08);
}
.cal-ev:hover { box-shadow: var(--shadow-2); z-index: 2; }
.cal-ev span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-time { color: var(--ink-2); font-size: 11px; }
.cal-ev-title { font-weight: 600; }
.cal-ev-sub { color: var(--ink-2); }
.kind-meet_first { background: #e8f0fb; border-left-color: #2f6fc4; }
.kind-meet_kp { background: #f0ebfa; border-left-color: #6b46b8; }
.kind-call { background: #e7f4f5; border-left-color: #0d7a88; }
.kind-send_kp, .kind-prep_kp { background: #fdf3e4; border-left-color: #94690a; }
.kind-invoice { background: #eaf4ef; border-left-color: #1f7a55; }
.cal-ev.is-done, .cal-agenda-ev.is-done { opacity: .5; }
.cal-ev.is-done .cal-ev-title { text-decoration: line-through; }
.cal-ev.is-overdue { outline: 1.5px solid var(--lost); }
.cal-agenda { display: none; }
.cal-agenda-day { margin-bottom: 12px; }
.cal-agenda-day.is-today .card-head h2 { color: var(--accent); }
.cal-agenda-ev { display: flex; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); border-left: 3px solid #6b7772; color: var(--ink); text-decoration: none; }
.cal-agenda-ev b { min-width: 44px; }
.cal-dialog { border: none; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-2); }
.cal-dialog::backdrop { background: rgba(20, 22, 25, .35); }
.cal-dialog .card-head { display: flex; align-items: center; justify-content: space-between; }
@media (max-width: 760px) {
  .cal { display: none; }
  .cal-agenda { display: block; }
  .cal-week { display: none; }
}
