/* Дизайн-система CRM. Тёмная база #060706 и изумруд — как на сайте
   Nomad Solutions; светлая тема переключателем для дневной работы.
   Всё на переменных: цвет меняется в одном месте. */

:root {
  color-scheme: dark;
  --bg: #060706;
  --bg-soft: #0d0f0e;
  --panel: #111413;
  --panel-2: #161a18;
  --line: #232826;
  --line-soft: #1a1e1c;
  --text: #eef2f0;
  --text-dim: #9aa5a0;
  --text-mute: #6b7671;
  --brand: #17b26a;
  --brand-soft: rgba(23, 178, 106, .12);
  --brand-line: rgba(23, 178, 106, .35);
  --accent: #ff3b49;
  --accent-soft: rgba(255, 59, 73, .12);
  --warn: #f6b73c;
  --warn-soft: rgba(246, 183, 60, .12);
  --info: #4c9aff;
  --info-soft: rgba(76, 154, 255, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 232px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8f7;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f2f4f3;
  --line: #e2e6e4;
  --line-soft: #edf0ee;
  --text: #121614;
  --text-dim: #5c6763;
  --text-mute: #8b948f;
  --brand: #0f9457;
  --brand-soft: rgba(15, 148, 87, .1);
  --brand-line: rgba(15, 148, 87, .3);
  --accent: #e02a38;
  --accent-soft: rgba(224, 42, 56, .1);
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 8px 24px rgba(16, 24, 20, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ------------------------------------------------------------- каркас */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Имя системы — во всю ширину боковой панели: это заголовок окна, а не
   подпись мелким шрифтом. */
.brand {
  display: flex; align-items: center; gap: 8px; color: inherit;
  text-decoration: none;
  padding: 2px 0 18px;
  font-weight: 700; letter-spacing: -.03em;
}
.brand svg.logo { width: 32px; height: 32px; flex: 0 0 32px; color: var(--brand);
  filter: drop-shadow(0 0 6px rgba(23, 178, 106, .75))
          drop-shadow(0 0 16px rgba(23, 178, 106, .4)); }
.brand-name { flex: 1; min-width: 0; font-size: 25px; white-space: nowrap; }
/* «CRM» светится тем же зелёным, что и лупа: это одна вывеска. */
.brand-crm { color: var(--brand); font-weight: 700;
  text-shadow: 0 0 10px rgba(23, 178, 106, .75), 0 0 26px rgba(23, 178, 106, .45); }
.brand-big { font-size: 16px; }
:root[data-theme="light"] .brand svg.logo,
:root[data-theme="light"] .brand-crm { filter: none;
  text-shadow: 0 0 8px rgba(23, 178, 106, .45); }
.brand-big svg.logo { width: 30px; height: 30px; flex: 0 0 30px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; }
.nav-badge {
  margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 20px;
  background: var(--panel-2); color: var(--text-dim);
}
.nav-item.active .nav-badge { background: var(--brand); color: #04150d; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }

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

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }

.content { padding: 22px; max-width: 1500px; width: 100%; }

/* --------------------------------------------------------- элементы */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .sub { color: var(--text-mute); font-size: 12px; }
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

.stat { padding: 16px; }
.stat .label { color: var(--text-mute); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; }
.stat .value { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-top: 6px;
  font-family: "JetBrains Mono", ui-monospace, monospace; }
.stat .delta { font-size: 12px; margin-top: 4px; color: var(--text-mute); }
.delta.up { color: var(--brand); }
.delta.down { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); cursor: pointer; font-weight: 500; font-size: 13px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--line-soft); border-color: var(--text-mute); color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #04150d; }
.btn-primary:hover { background: #14a061; border-color: #14a061; color: #04150d; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-danger { color: var(--accent); border-color: var(--accent-soft); }

.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder { color: var(--text-mute); }
textarea.input { resize: vertical; min-height: 76px; }
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }

.search { position: relative; flex: 0 1 380px; }
.search input { padding-left: 34px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-mute); }

/* --------------------------------------------------------- бейджи */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; }
.badge-new { background: var(--info-soft); color: var(--info); }
.badge-in_work { background: var(--warn-soft); color: var(--warn); }
.badge-qualified { background: var(--brand-soft); color: var(--brand); }
.badge-sent { background: var(--brand-soft); color: var(--brand); }
.badge-paid { background: var(--brand); color: #04150d; }
.badge-paid::before { background: #04150d; }
.badge-lost { background: var(--accent-soft); color: var(--accent); }
.badge-plain { background: var(--panel-2); color: var(--text-dim); border-color: var(--line); }
.badge-plain::before { display: none; }
.badge-repeat { background: var(--warn-soft); color: var(--warn); }
.badge-repeat::before { display: none; }

.filters { display: flex; flex-direction: column; gap: 9px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.chips .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.chip.reset { color: var(--text-mute); border-style: dashed; }
.select-inline {
  width: auto; padding: 5px 10px; border-radius: 20px; font-size: 12.5px;
  background: var(--panel); color: var(--text-dim); cursor: pointer;
}
.select-inline:hover { border-color: var(--text-mute); color: var(--text); }

/* Заголовки-сортировщики: стрелка видна всегда, у активной колонки ярче. */
.table th.sortable { padding: 0; }
.table th.sortable a {
  display: flex; align-items: center; gap: 5px; padding: 10px 14px;
  color: inherit; white-space: nowrap;
}
.table th.sortable a:hover { color: var(--text); background: var(--panel-2); }
.table th.sortable .arrow { font-size: 10px; opacity: .35; }
.table th.sorted a { color: var(--brand); }
.table th.sorted .arrow { opacity: 1; }
.table th.sortable[style*="right"] a { justify-content: flex-end; }
.chip {
  padding: 5px 11px; border-radius: 20px; font-size: 12.5px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-dim);
}
.chip:hover { border-color: var(--text-mute); color: var(--text); }
.chip.active { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }

/* --------------------------------------------------------- таблица */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-mute); padding: 10px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tbody tr:hover { background: var(--panel-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .who { font-weight: 550; }
.table .muted { color: var(--text-mute); font-size: 12.5px; }
.snippet {
  color: var(--text-dim); font-size: 13px; max-width: 460px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.empty { padding: 46px 20px; text-align: center; color: var(--text-mute); }
.empty svg { width: 34px; height: 34px; opacity: .5; margin-bottom: 10px; }

/* --------------------------------------------------------- доска */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.column { flex: 0 0 292px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft); font-weight: 600; font-size: 13px; }
.column-head .count { margin-left: auto; color: var(--text-mute); font-size: 12px; }
.column-body { padding: 10px; display: flex; flex-direction: column; gap: 9px;
  max-height: calc(100vh - 220px); overflow-y: auto; }
.mini {
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 11px 12px;
}
.mini:hover { border-color: var(--brand-line); }
.mini .who { font-weight: 550; font-size: 13px; }
.mini .text { color: var(--text-dim); font-size: 12.5px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mini .foot { display: flex; align-items: center; gap: 8px; margin-top: 8px;
  color: var(--text-mute); font-size: 11.5px; }

/* --------------------------------------------------------- карточка */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.split-right { min-width: 0; }
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--text-mute); }
.kv dd { margin: 0; word-break: break-word; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before {
  content: ""; position: absolute; left: -18px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--panel); border: 2px solid var(--line);
}
.tl-item.lead::before { border-color: var(--brand); }
.tl-item.status::before { border-color: var(--warn); }
.tl-item.merge::before { border-color: var(--info); }
.tl-item .meta { color: var(--text-mute); font-size: 11.5px; margin-top: 2px; }

.lead-block { border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; background: var(--panel); }
.lead-block.target { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.lead-block .head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.lead-block .body { margin-top: 9px; white-space: pre-wrap; font-size: 13.5px;
  color: var(--text-dim); }
.lead-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px;
  padding-top: 11px; border-top: 1px solid var(--line-soft); }

/* --------------------------------------------------------- график */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars .bar { flex: 1; background: var(--brand-soft); border-radius: 3px 3px 0 0;
  min-height: 2px; position: relative; border-bottom: 2px solid var(--brand); }
.bars .bar:hover { background: var(--brand-line); }
.bars .bar span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--text-mute); opacity: 0; transition: opacity .1s;
  white-space: nowrap; }
.bars .bar:hover span { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 11px; color: var(--text-mute); }

.meter { height: 6px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.rows { display: flex; flex-direction: column; gap: 12px; }
.row-line { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.row-line .name { flex: 0 0 128px; color: var(--text-dim); }
.row-line .meter { flex: 1; }
.row-line .num { flex: 0 0 46px; text-align: right;
  font-family: "JetBrains Mono", monospace; font-size: 12.5px; }

/* ------------------------------------------------------ вспомогательное */
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.dim { color: var(--text-dim); } .mute { color: var(--text-mute); }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.copy { cursor: pointer; border-bottom: 1px dashed var(--line); }
.copy:hover { color: var(--brand); border-color: var(--brand-line); }

dialog {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: var(--radius); padding: 0; box-shadow: var(--shadow); max-width: 520px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
dialog .card-body { max-height: 70vh; overflow-y: auto; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 366px; }

/* --------------------------------------------------------- мобильное */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2-1, .split { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: sticky; bottom: 0; top: auto;
    order: 2; flex-direction: row; overflow-x: auto; padding: 8px;
    border-right: none; border-top: 1px solid var(--line); z-index: 30;
  }
  .brand, .sidebar-foot { display: none; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 11px; padding: 7px 12px; }
  .nav-badge { display: none; }
  .main { order: 1; }
  .content { padding: 14px; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: 3; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}

/* --- контакты человека: телефоны, почты, ники ------------------------ */
.idents { margin-top: 18px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.idents-head { display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-mute); }
.ident-list { list-style: none; margin: 8px 0 0; padding: 0; }
.ident-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px dashed var(--line-soft); font-size: 14px; }
.ident-list li:last-child { border-bottom: none; }
.ident-kind { min-width: 74px; color: var(--text-mute); font-size: 12px; }
.ident-list form { margin: 0; }
.ident-wa { font-size: 11px; color: var(--brand); border: 1px solid var(--brand);
  border-radius: 5px; padding: 1px 5px; text-decoration: none; }
.ident-wa:hover { background: var(--brand); color: #04150c; }
.ident-add { margin-top: 10px; }
.ident-add summary { cursor: pointer; }
.ident-form { display: grid; grid-template-columns: 1fr 1.4fr 1.4fr auto; gap: 8px;
  margin-top: 10px; }
@media (max-width: 720px) { .ident-form { grid-template-columns: 1fr; } }
.notice { border: 1px solid var(--brand-line); border-radius: 10px; padding: 10px 14px;
  background: var(--brand-soft); font-size: 14px; }

/* --- партнёры -------------------------------------------------------- */
.partner-card { display: block; text-decoration: none; color: inherit; }
.partner-card:hover { border-color: var(--brand-line); }
.partner-card .unit { font-size: 13px; font-weight: 400; color: var(--text-mute); }
.meter { height: 6px; border-radius: 3px; background: var(--panel-2); margin: 10px 0 6px;
  overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.badge-partner { background: var(--info-soft); color: var(--info);
  border: 1px solid rgba(76, 154, 255, .35); }

/* Бейдж-ссылка: фильтр в один клик, но выглядит как обычный бейдж. */
a.badge { text-decoration: none; cursor: pointer; }
a.badge:hover { filter: brightness(1.25); }

/* Сводка направлений человека: по одному отказ, по другому оплата. */
.deal-lines { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.deal-line { display: flex; align-items: center; gap: 8px; padding: 6px 10px;
             border-radius: 8px; text-decoration: none; color: inherit; }
.deal-line:hover { background: var(--bg-hover, rgba(127,127,127,.12)); }
.deal-line .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
                   white-space: nowrap; font-size: 13px; }
.deal-line .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-new { background: var(--info); }
.dot-in_work { background: var(--warn); }
.dot-sent { background: var(--brand-soft); }
.dot-paid { background: var(--brand); }
.dot-lost { background: var(--accent); }
.input-sm { padding: 2px 8px; font-size: 12px; max-width: 240px; }

/* ------------------------------------------------------------- аналитика */
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Выбор периода: кнопки на частые отрезки и календарь на всё остальное. */
.periods { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.periods-title { font-size: 13px; font-weight: 600; margin-right: 4px; }
.periods-form { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.periods-form .input { width: 140px; }

/* Оплаты внутри столбика заявок: видно, какая часть дня дошла до денег. */
.bars .bar .bar-won { position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--brand); border-radius: 3px 3px 0 0; }

/* Часы суток: когда люди пишут. */
.hours { display: flex; align-items: flex-end; gap: 2px; height: 64px; }
.hours .hour { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.hours .hour i { display: block; width: 100%; min-height: 2px; border-radius: 2px;
  background: var(--brand-soft); border-bottom: 2px solid var(--brand); }
.hours .hour:hover i { background: var(--brand-line); }

.meter-inline { display: inline-block; width: 54px; vertical-align: middle;
  margin-right: 6px; }
.ml-8 { margin-left: 8px; }

/* Расход месяца поверх дохода: видно, сколько от столбика осталось. */
.bars .bar .bar-cost { position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--accent-soft); border-bottom: 2px solid var(--accent);
  border-radius: 3px 3px 0 0; }
tr.dim td { opacity: .55; }

/* ------------------------------------------------------------- графики */
/* Геометрию считает crm/charts.py, ось подписывается обычным текстом
   поверх картинки: так подписи не растягиваются вместе с SVG. */
.chart { position: relative; }
.chart-plot { position: relative; }
.chart-svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-cursor { stroke: var(--text-mute); stroke-width: 1; stroke-dasharray: 3 3; }

.chart-brand { stroke: var(--brand); fill: var(--brand); }
.chart-info { stroke: var(--info); fill: var(--info); }
.chart-warn { stroke: var(--warn); fill: var(--warn); }
.chart-accent { stroke: var(--accent); fill: var(--accent); }
rect.chart-bar { stroke: none; opacity: .85; }
rect.chart-bar:hover { opacity: 1; }

.chart-y { position: absolute; inset: 0; pointer-events: none; }
.chart-y span { position: absolute; left: 0; transform: translateY(-50%);
  font-size: 10.5px; color: var(--text-mute); background: var(--panel);
  padding: 0 4px; font-family: "JetBrains Mono", monospace; }
.chart-x { position: relative; height: 16px; margin-top: 2px; }
.chart-x span { position: absolute; transform: translateX(-50%); font-size: 10.5px;
  color: var(--text-mute); white-space: nowrap; }
/* Крайние подписи прижимаем к краям, иначе они вылезают за карточку. */
.chart-x span:first-child { transform: none; }
.chart-x span:last-child { transform: translateX(-100%); }

.chart-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 10px; font-size: 11.5px; color: var(--text-dim); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-dot { width: 9px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-note { color: var(--text-mute); }

.chart-tip { position: absolute; z-index: 5; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 11.5px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); transform: translate(-50%, -120%); }
.chart-tip b { display: block; font-size: 12px; margin-bottom: 2px; }

/* Воронка: ступени в долях от первой. */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-step { display: flex; align-items: center; gap: 10px; text-decoration: none;
  color: inherit; font-size: 13px; }
.funnel-title { flex: 0 0 84px; color: var(--text-dim); }
.funnel-bar { flex: 1; position: relative; height: 26px; border-radius: 7px;
  background: var(--panel-2); display: flex; align-items: center; }
.funnel-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px;
  background: var(--brand-soft); border-right: 2px solid var(--brand); }
.funnel-bar b { position: relative; padding: 0 9px;
  font-family: "JetBrains Mono", monospace; font-size: 12px; }
.funnel-new .funnel-fill, .funnel-fill.funnel-new { background: var(--info-soft); border-color: var(--info); }
.funnel-fill.funnel-in_work { background: var(--warn-soft); border-color: var(--warn); }
.funnel-fill.funnel-paid { background: rgba(23, 178, 106, .3); border-color: var(--brand); }
.funnel-fill.funnel-lost { background: var(--accent-soft); border-color: var(--accent); }
.funnel-share { flex: 0 0 128px; text-align: right; font-size: 11.5px;
  color: var(--text-dim); }

/* Рейтинг: источники, партнёры, направления. */
.rank { display: flex; flex-direction: column; gap: 9px; }
.rank-row { display: flex; align-items: center; gap: 10px; font-size: 13px;
  text-decoration: none; color: inherit; }
.rank-row:hover .rank-title { color: var(--text); }
.rank-title { flex: 0 0 132px; color: var(--text-dim); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--panel-2);
  overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.rank-num { flex: 0 0 44px; text-align: right; font-family: "JetBrains Mono", monospace;
  font-size: 12.5px; }
.rank-extra { flex: 0 0 66px; text-align: right; font-size: 11.5px; color: var(--text-mute); }

/* Добавление ещё одного запроса тому же человеку. */
.add-lead > summary { padding: 12px 16px; cursor: pointer; font-weight: 600;
  font-size: 13.5px; list-style: none; color: var(--text-dim); }
.add-lead > summary::-webkit-details-marker { display: none; }
.add-lead > summary:hover { color: var(--text); }
.add-lead[open] > summary { border-bottom: 1px solid var(--line); color: var(--text); }
.add-lead-form { display: grid; gap: 10px 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.add-lead-form .field { margin-bottom: 0; }
.add-lead-form .field.wide { grid-column: 1 / -1; }
.add-lead-form button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 900px) {
  .add-lead-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Деньги сделки в заявке: два коротких поля рядом со статусами. */
.money-form { gap: 6px; }
.money-input { width: 88px; }
.badge-money { background: rgba(23, 178, 106, .18); color: var(--brand);
  border: 1px solid var(--brand-line); }
