/* =====================================================================
   Baraka EDU CRM
   Базис - дизайн-система основного сайта: Montserrat, зелёный, золото.
   Адаптация под рабочий интерфейс: базовый кегль 14px, отступы примерно
   вдвое меньше сайтовых, никаких анимаций дольше 150мс и никаких
   hover-эффектов, сдвигающих элементы.
   ===================================================================== */

:root {
  /* Палитра сайта */
  --green:       #1A5333;
  --green-dark:  #143F27;
  --green-soft:  #E8F1EC;
  --gold:        #C69A45;
  --gold-soft:   #F7EFE0;
  --beige:       #F5E8D3;

  /* Рабочая нейтраль */
  --text:        #1F2328;
  --text-2:      #5B6572;
  --text-3:      #8B95A1;
  --line:        #E3E7EB;
  --line-strong: #CDD4DB;
  --bg:          #F4F6F8;
  --surface:     #FFFFFF;
  --surface-2:   #FAFBFC;

  /* Статусные цвета */
  --ok:          #15803D;
  --ok-soft:     #E7F5EC;
  --wait:        #B45309;
  --wait-soft:   #FCF2E3;
  --late:        #DC2626;
  --late-soft:   #FDECEC;
  --off:         #6B7280;
  --off-soft:    #F1F2F4;

  /* Цвет этапа воронки - один и тот же везде: список, шапка карточки, фильтры */
  --stage-new:           #64748B;
  --stage-qualified:     #0E8FC4;
  --stage-kev-scheduled: #7C5CD6;
  --stage-kev-done:      #5457D1;
  --stage-offer:         #C69A45;
  --stage-terms:         #D9862B;
  --stage-invoiced:      #E2631B;
  --stage-paid:          #1A5333;
  --stage-rejected:      #DC2626;
  --stage-wait:          #B45309;
  --stage-teal:          #0F766E;

  --radius:    8px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow:    0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);

  --header-h: 52px;
  --sidebar-w: 208px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Montserrat", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); text-decoration: none; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

/* ---------------------------------------------------------------- Каркас */

.app { display: none; min-height: 100vh; }
.app.ready { display: block; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--green); color: #fff; z-index: 40;
}
.topbar .brand { font-weight: 800; letter-spacing: .02em; font-size: 15px; white-space: nowrap;
  display: flex; align-items: center; gap: 9px; }
.topbar .brand-logo { width: 30px; height: 30px; object-fit: contain; flex: none; }
.topbar .brand span { color: var(--gold); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12px; opacity: .9; text-align: right; line-height: 1.3; }
.topbar .who b { display: block; font-size: 13px; opacity: 1; }
.topbar .icon-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  border-radius: var(--radius-sm); padding: 6px 10px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.topbar .icon-btn:hover { background: rgba(255,255,255,.22); }
.burger { display: none; }

.sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 10px 8px; overflow-y: auto; z-index: 30;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2);
  font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--green-soft); color: var(--green); }
.nav-group { font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700; padding: 14px 10px 6px; }
.nav-badge { background: var(--late); color: #fff; border-radius: 10px;
  padding: 1px 6px; font-size: 11px; font-weight: 700; }
.nav-badge.muted { background: var(--off-soft); color: var(--text-2); }

.main { padding: calc(var(--header-h) + 14px) 16px 32px calc(var(--sidebar-w) + 16px); }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.page-title { font-size: 18px; font-weight: 800; }
.page-head .spacer { flex: 1; }

/* --------------------------------------------------------------- Кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s linear, border-color .12s linear;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: #B0873A; }
.btn-danger { background: var(--surface); border-color: var(--late); color: var(--late); }
.btn-danger:hover { background: var(--late-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }

/* ------------------------------------------------------------ Поля ввода */

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 11px; font-weight: 700; color: var(--text-2); letter-spacing: .01em; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 7px 9px; font-size: 13px;
  transition: border-color .12s linear;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--green); outline: none; }
.textarea { resize: vertical; min-height: 62px; line-height: 1.45; }
.input.error, .select.error, .textarea.error { border-color: var(--late); background: var(--late-soft); }
.hint { font-size: 11px; color: var(--text-3); }
.hint.error { color: var(--late); font-weight: 600; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 12px; }
.toolbar .field { min-width: 130px; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* -------------------------------------------------------------- Таблицы */

.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; max-height: calc(100vh - 230px);
}
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; color: var(--text-2);
  padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--text); }
table.grid thead th .dir { color: var(--green); }
table.grid tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:nth-child(even) { background: var(--surface-2); }
table.grid tbody tr:hover { background: var(--green-soft); }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr.row-late td:first-child { box-shadow: inset 3px 0 0 var(--late); }
table.grid tbody tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--wait); }
table.grid.compact tbody td { padding: 4px 10px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }

.pager { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 12px;
  color: var(--text-2); flex-wrap: wrap; }
.pager-nav { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.pager-nav .btn { min-width: 28px; padding: 4px 7px; }

/* Панель массовых действий над отмеченными строками */
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--green-soft); border: 1px solid var(--green); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 10px; }
.bulk-bar .count { font-weight: 800; color: var(--green); white-space: nowrap; }
.bulk-bar .select { width: auto; min-width: 170px; }
table.grid td.check, table.grid th.check { width: 34px; padding-left: 10px; padding-right: 0; }
table.grid tr.picked { background: var(--green-soft) !important; }

/* --------------------------------------------------------------- Бейджи */

.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 20px;
  padding: 2px 9px; font-size: 11px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-stage { background: var(--surface); border-color: currentColor; }
.stage-new           { color: var(--stage-new); }
.stage-qualified     { color: var(--stage-qualified); }
.stage-kev-scheduled { color: var(--stage-kev-scheduled); }
.stage-kev-done      { color: var(--stage-kev-done); }
.stage-offer         { color: var(--stage-offer); }
.stage-terms         { color: var(--stage-terms); }
.stage-invoiced      { color: var(--stage-invoiced); }
.stage-paid          { color: var(--stage-paid); }
.stage-rejected      { color: var(--stage-rejected); }
.stage-wait          { color: var(--stage-wait); }
.stage-teal          { color: var(--stage-teal); }

.badge-ok   { background: var(--ok-soft);   color: var(--ok); }
.badge-wait { background: var(--wait-soft); color: var(--wait); }
.badge-late { background: var(--late-soft); color: var(--late); }
.badge-off  { background: var(--off-soft);  color: var(--off); }

/* ------------------------------------------------------ Состояния экрана */

.state { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 48px 20px; text-align: center; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.state .icon { font-size: 30px; line-height: 1; opacity: .5; }
.state .title { font-weight: 700; color: var(--text); font-size: 15px; }
.state .desc { font-size: 13px; max-width: 420px; }
.state.error .title { color: var(--late); }

.spinner { width: 20px; height: 20px; border: 2px solid var(--line-strong);
  border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, #EEF1F4, #F7F9FA, #EEF1F4);
  border-radius: var(--radius-sm); height: 12px; }

/* --------------------------------------------------------------- Карточки */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card .k { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3); margin-bottom: 4px; }
.card .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.card.accent-late .v { color: var(--late); }
.card.accent-wait .v { color: var(--wait); }
.card.accent-ok   .v { color: var(--ok); }

/* ------------------------------------------------------- Доска по датам */

.board-scroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  align-items: flex-start; }
.board-col { flex: 0 0 250px; width: 250px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 340px); }
.board-col-head { padding: 9px 10px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); position: sticky; top: 0;
  background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.board-col-head .n { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 1px 7px; font-size: 11px; }
.board-col.accent-late .board-col-head { color: var(--late); }
.board-col.accent-wait .board-col-head { color: var(--wait); }
.board-col-body { padding: 9px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto;
  min-height: 60px; transition: background-color .1s linear; }
.board-col-body.drag-over { background: var(--green-soft); outline: 2px dashed var(--green); outline-offset: -2px; }
.board-col-body.drag-blocked.drag-over { background: var(--late-soft); outline-color: var(--late); }
.board-col-empty { padding: 16px 8px; text-align: center; font-size: 12px; color: var(--text-3); }

/* Карточки - самостоятельные прямоугольные плитки (белые на сером фоне
   колонки), а не строки списка: тень и радиус явно отделяют одну от другой. */
.task-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); padding: 9px 10px; cursor: pointer;
  transition: box-shadow .12s linear, transform .12s linear;
}
.task-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.12); transform: translateY(-1px); }
.task-card.late { border-left: 3px solid var(--late); }
.task-card.dragging { opacity: .4; }
.task-card { cursor: grab; }
.task-card .tc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.task-card .tc-name { font-size: 13px; font-weight: 700; }
.task-card .tc-time { font-size: 11px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.task-card.late .tc-time { color: var(--late); }
.task-card .tc-phone { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); margin-top: 1px; }
.task-card .tc-line { font-size: 11px; color: var(--text-3); margin-top: 5px; display: flex;
  flex-wrap: wrap; gap: 3px 6px; }
.task-card .tc-dates { font-size: 10px; color: var(--text-3); margin-top: 6px; border-top: 1px dashed var(--line);
  padding-top: 5px; display: flex; justify-content: space-between; gap: 6px; }
.task-card .tc-actions { margin-top: 7px; }
.task-card .tc-actions .btn { width: 100%; }

/* ------------------------------------------------------- Доска сделок */

.funnel-scroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.funnel-col { flex: 0 0 240px; width: 240px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 300px); }
.funnel-col-head { padding: 9px 10px; border-bottom: 3px solid currentColor; display: flex;
  align-items: center; gap: 6px; font-size: 12px; font-weight: 800; position: sticky; top: 0;
  background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.funnel-col-head .n { margin-left: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 1px 7px; font-size: 11px; color: var(--text-2); }
.funnel-col-body { padding: 9px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto;
  min-height: 60px; transition: background-color .1s linear; }
.funnel-col-body.drag-over { background: var(--green-soft); outline: 2px dashed var(--green); outline-offset: -2px; }
.funnel-col-empty { padding: 16px 8px; text-align: center; font-size: 12px; color: var(--text-3); }
.funnel-col-more { text-align: center; padding: 4px; }

.deal-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); padding: 9px 10px; cursor: pointer; position: relative;
  transition: box-shadow .12s linear, transform .12s linear;
}
.deal-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.12); transform: translateY(-1px); }
.deal-card.late { border-left: 3px solid var(--late); }
.deal-card.dragging { opacity: .4; }
.deal-card { cursor: grab; }
.deal-card.picked { outline: 2px solid var(--green); }
.deal-card .dc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.deal-card .dc-name { font-size: 13px; font-weight: 700; }
.deal-card .dc-amount { font-size: 12px; font-weight: 800; color: var(--green); white-space: nowrap; }
.deal-card .dc-phone { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.deal-card .dc-line { font-size: 11px; color: var(--text-3); margin-top: 5px; }
.deal-card .dc-check { position: absolute; top: 8px; right: 8px; }

.funnel-toggle { display: flex; gap: 6px; margin-bottom: 10px; }

/* ------------------------------------------------------ Очередь менеджера */

.queue-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.queue-count { display: flex; align-items: baseline; gap: 8px; }
.queue-count b { font-size: 40px; font-weight: 900; line-height: 1; color: var(--green); }
.queue-count span { font-size: 13px; color: var(--text-2); font-weight: 600; }

.queue-tiers { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.queue-tier {
  display: flex; align-items: baseline; gap: 6px; border: 1px solid var(--line);
  border-radius: 20px; padding: 4px 12px; font-size: 12px; color: var(--text-2); background: var(--surface-2);
}
.queue-tier b { font-size: 14px; font-weight: 800; color: var(--text); }
.queue-tier.accent-late { border-color: var(--late); background: var(--late-soft); }
.queue-tier.accent-late b { color: var(--late); }
.queue-tier.accent-wait { border-color: var(--wait); background: var(--wait-soft); }
.queue-tier.accent-wait b { color: var(--wait); }

.queue-next {
  font-size: 18px; font-weight: 800; padding: 16px 56px; border-radius: var(--radius);
  letter-spacing: .02em; margin-top: 4px;
}
.queue-box .hint { max-width: 460px; }

/* ---------------------------------------------------------------- Модалка */

.overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .48);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; z-index: 60; overflow: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 900px; max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.modal.narrow { max-width: 520px; }
.modal.wide   { max-width: 1100px; }
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close { border: none; background: transparent; font-size: 22px; line-height: 1;
  color: var(--text-3); cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--text); }

/* --------------------------------------------------- Карточка лида (модалка) */

.lead-head { position: sticky; top: 0; z-index: 5; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: 12px 16px 10px; }
.lead-head-top { display: flex; align-items: flex-start; gap: 10px; }
.lead-name { font-size: 17px; font-weight: 800; line-height: 1.2; }
.lead-id { font-size: 12px; color: var(--text-3); font-weight: 600; }
.lead-phone { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px;
  font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.copy-btn { border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 4px; font-size: 11px; padding: 1px 6px; cursor: pointer; color: var(--text-2); }
.copy-btn:hover { background: var(--surface-2); }
.lead-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.lead-meta b { color: var(--text); font-weight: 700; }
.lead-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.nav-arrows { display: flex; gap: 4px; margin-left: auto; }

.section-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.section-head .t { font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); }
.section-head .line { flex: 1; height: 1px; background: var(--line); }

.progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.progress .bar { flex: 1; max-width: 200px; height: 6px; background: var(--line);
  border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--green); border-radius: 3px;
  transition: width .15s linear; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.field-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .field-grid .span-2 { grid-column: span 1; } }

.f {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 5px 8px 6px; background: var(--surface); min-height: 48px;
  display: flex; flex-direction: column; justify-content: center;
}
.f > .lbl { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 2px; }
.f > .val { font-size: 13px; font-weight: 600; word-break: break-word; cursor: text; min-height: 18px; }
.f.empty { border-style: dashed; border-color: var(--line-strong); background: var(--surface-2); }
.f.empty > .val { color: var(--text-3); font-weight: 500; font-style: italic; }
/* Пустое поле, обязательное для перехода на следующий этап */
.f.required-empty { border-style: dashed; border-color: var(--gold); background: var(--gold-soft); }
.f.required-empty > .lbl { color: #8A6A22; }
.f.required-empty > .val { color: #8A6A22; font-style: normal; font-weight: 600; }
.f.saved { border-color: var(--ok); }
.f .saved-mark { font-size: 10px; color: var(--ok); font-weight: 700; margin-left: 6px; }
.f .input, .f .select, .f .textarea { padding: 3px 5px; font-size: 13px; border-color: var(--green); }
.f.readonly > .val { cursor: default; }

/* Лента событий */
.feed-input { border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 6px 8px; background: var(--surface); margin-bottom: 10px; }
.feed-input textarea { width: 100%; border: none; outline: none; resize: vertical;
  min-height: 44px; font-size: 13px; line-height: 1.45; }
.feed-input .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.feed-input .row .hint { font-size: 11px; }

.feed { display: flex; flex-direction: column; gap: 0; }
.ev { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: none; }
.ev .mark { width: 6px; border-radius: 3px; background: var(--line-strong); flex: none; }
.ev.ev-comment .mark { background: var(--text-3); }
.ev.ev-stage .mark   { background: var(--green); }
.ev.ev-rollback .mark{ background: var(--wait); }
.ev.ev-call .mark    { background: var(--stage-qualified); }
.ev.ev-payment .mark { background: var(--ok); }
.ev.ev-system .mark  { background: var(--line-strong); }
.ev.ev-alert .mark   { background: var(--late); }
.ev .body { flex: 1; min-width: 0; }
.ev .top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.ev .top b { color: var(--text-2); font-weight: 700; }
.ev .txt { font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.ev.ev-stage .txt { font-weight: 700; color: var(--green); }
.ev.ev-rollback .txt { font-weight: 700; color: var(--wait); }
.ev.ev-alert .txt { font-weight: 700; color: var(--late); }

/* Панель смены этапа внутри карточки */
.stage-panel { border: 1px solid var(--gold); background: var(--gold-soft);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.stage-panel h4 { font-size: 13px; font-weight: 800; margin-bottom: 8px; }
.problems { list-style: none; font-size: 12px; color: #8A2020; margin: 6px 0 0; }
.problems li { padding: 2px 0 2px 14px; position: relative; }
.problems li::before { content: "•"; position: absolute; left: 3px; }

/* ------------------------------------------------------ Статус в карточке */

.status-select {
  width: auto; min-width: 190px; font-weight: 700; font-size: 13px;
  border-width: 1.5px; border-color: currentColor; background: var(--surface);
}
.status-select:disabled { opacity: .8; }

/* ------------------------------------------------------- Сделка в карточке */

.deal-box { border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); padding: 10px 12px; margin-bottom: 14px; }
.deal-box.empty { border-style: dashed; }
.deal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.deal-head .t { font-size: 12px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); flex: 1; }
.deal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.deal-cell { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 5px 8px 6px; }
.deal-cell .lbl { font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3); }
.deal-cell .val { font-size: 13px; font-weight: 700; }
.deal-cell .val.ok { color: var(--ok); }
.deal-cell .val.late { color: var(--late); }

.payments { display: flex; flex-direction: column; gap: 4px; }
.payment-row { display: flex; gap: 10px; align-items: baseline; font-size: 12px;
  border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.payment-row b { font-variant-numeric: tabular-nums; }
.payment-reversed b { text-decoration: line-through; opacity: .6; }
.payment-reversal b { color: var(--late); }
.payment-undo { margin-left: auto; }

/* ------------------------------------------------------------ Напоминания */

.reminders { position: fixed; right: 14px; bottom: 14px; z-index: 95;
  display: flex; flex-direction: column-reverse; gap: 8px; max-width: 320px; }
.reminder {
  background: var(--surface); border: 1.5px solid var(--gold); border-left-width: 4px;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 12px;
  animation: reminder-in .15s ease-out;
}
@keyframes reminder-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Задача чужая (тимлид смотрит за командой) - другой акцент, чтобы не путать со своими */
.reminder-team { border-color: var(--stage-qualified); }
.reminder-team .reminder-title { color: var(--stage-qualified); }
.reminder-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reminder-title { font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--gold); }
.reminder-close { border: none; background: none; font-size: 18px; line-height: 1;
  color: var(--text-3); cursor: pointer; padding: 0 2px; }
.reminder-close:hover { color: var(--text); }
.reminder-name { font-size: 15px; font-weight: 800; margin-top: 2px; }
.reminder-phone { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.reminder-meta { font-size: 11px; color: var(--text-3); margin: 4px 0 8px; }
.reminder-actions { display: flex; gap: 6px; }

@media (max-width: 900px) {
  .reminders { left: 10px; right: 10px; bottom: 10px; max-width: none; }
}

/* ---------------------------------------------------------------- Тосты */

.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: var(--text); color: #fff; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); }
.toast.ok    { background: var(--ok); }
.toast.error { background: var(--late); }
.toast.warn  { background: var(--wait); }

/* ----------------------------------------------------------------- Логин */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--green); }
.login-box { background: var(--surface); border-radius: var(--radius-lg); padding: 28px 26px;
  width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); }
.login-logo { display: block; width: 84px; height: 84px; object-fit: contain; margin: 0 auto 12px; }
.login-box .brand { font-size: 20px; font-weight: 900; text-align: center; margin-bottom: 4px; }
.login-box .brand span { color: var(--gold); }
.login-box .sub { text-align: center; font-size: 12px; color: var(--text-3); margin-bottom: 20px; }
.login-box .field { margin-bottom: 12px; }
.login-box .btn { width: 100%; margin-top: 6px; }

/* -------------------------------------------------------------- Аналитика */

.dash-fixed { margin-bottom: 18px; }

.dash-toolbar { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 12px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.dash-toolbar .field > label { margin-bottom: 1px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  overflow: hidden; }
.segmented .btn { border: none; border-radius: 0; background: var(--surface); }
.segmented .btn + .btn { border-left: 1px solid var(--line-strong); }
.segmented .btn.btn-primary { background: var(--green); }

.dash-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.dash-section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dash-section-head .title { font-size: 15px; font-weight: 800; color: var(--text); }
.dash-section-head .sub { font-size: 12px; color: var(--text-3); }
.dash-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }

/* Донат: сплошной conic-gradient снаружи, вырезанный кружок посередине */
.donut-wrap { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.donut { width: 152px; height: 152px; border-radius: 50%; flex: none; position: relative;
  box-shadow: inset 0 0 0 1px var(--line); }
.donut-hole { position: absolute; inset: 22px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-hole b { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.donut-hole span { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }
.donut-legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 190px; }
.donut-legend .row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.donut-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .label { flex: 1; color: var(--text-2); }
.donut-legend .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-legend .pct { color: var(--text-3); font-size: 11px; min-width: 36px; text-align: right; }
.donut-empty { color: var(--text-3); font-size: 13px; padding: 20px 0; }

/* Ряды воронки: название / прогресс-бар / число+процент, всё по сетке */
.stage-rows { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.stage-row { display: grid; grid-template-columns: 168px 1fr 86px; align-items: center; gap: 12px; font-size: 13px; }
.stage-row .name { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.stage-row .name .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.stage-row .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.stage-row .fill { height: 100%; border-radius: 4px; transition: width .2s ease; }
.stage-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.stage-row .num b { font-weight: 800; }

.reject-list { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.reject-list .caption { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); margin-bottom: 10px; }
.reject-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.reject-row .label { flex: 1; color: var(--text-2); }
.reject-row .value { font-weight: 700; color: var(--late); }

/* Столбчатая диаграмма денег по дням */
.money-chart { display: flex; align-items: flex-end; gap: 8px; height: 190px; padding: 24px 4px 0;
  overflow-x: auto; border-bottom: 1px solid var(--line); }
.money-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 6px; flex: 1; min-width: 30px; height: 100%; position: relative; }
.money-col .amount { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-col .bar { width: 100%; max-width: 34px; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  transition: opacity .12s linear; }
.money-col .bar:hover { opacity: .8; }
.money-col.zero .bar { background: var(--line); }
.money-col .date { font-size: 10px; color: var(--text-3); white-space: nowrap; margin-top: 6px; }
.money-empty { color: var(--text-3); font-size: 13px; padding: 30px 0; text-align: center; }

/* ------------------------------------------------------------ План продаж */

.plan-box { border-left: 4px solid var(--gold); }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.plan-title { display: flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 800; }
.plan-title .btn { padding: 2px 8px; font-size: 15px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.plan-cell { padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius); }
.plan-cell .k { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 4px; }
.plan-cell .v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.plan-cell .sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.plan-cell.accent-ok .v { color: var(--ok); }
.plan-cell.accent-late .v { color: var(--late); }
.plan-cell.accent-wait .v { color: var(--wait); }
.plan-bar { position: relative; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: visible; }
.plan-bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--gold), #D9B15F); transition: width .3s ease; }
.plan-bar-fill.done { background: var(--ok); }
.plan-bar-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-2); border-radius: 1px; }
.plan-bar-legend { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; margin-top: 6px; }
.plan-people { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.plan-person { display: grid; grid-template-columns: 160px 1fr auto; align-items: center; gap: 12px; font-size: 13px; }
.plan-person.muted { opacity: .55; }
.plan-person .name { font-weight: 600; }
.plan-person .track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.plan-person .fill { height: 100%; background: var(--gold); border-radius: 4px; }
.plan-person .fill.done { background: var(--ok); }
.plan-person .nums { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.plan-edit-group { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 12px 0 4px; }
.plan-edit-row { display: grid; grid-template-columns: 1fr 160px; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.plan-edit-row .label { font-weight: 600; }
.plan-edit-row .hint { grid-column: 2; }

/* --------------------------------------------------------- Лид-уведомления */

#lead-alerts {
  position: fixed; top: calc(var(--header-h) + 12px); right: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; width: 280px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto;
}
.lead-alert {
  position: relative; background: var(--surface); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--green); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 10px 26px 10px 12px; cursor: pointer; animation: lead-alert-in .18s ease-out;
}
.lead-alert:hover { border-left-color: var(--gold); background: var(--surface-2); }
/* Повторная заявка от уже известного человека - отдельный акцент */
.lead-alert-repeat { border-left-color: var(--gold); }
.lead-alert-repeat .lead-alert-title { color: var(--gold); }
.lead-alert-title { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--green); margin-bottom: 3px; }
.lead-alert-name { font-size: 13px; font-weight: 700; color: var(--text); }
.lead-alert-phone { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.lead-alert-x {
  position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; line-height: 16px;
  border: none; background: transparent; color: var(--text-3); font-size: 16px; cursor: pointer;
  border-radius: 4px; padding: 0;
}
.lead-alert-x:hover { background: var(--surface-2); color: var(--late); }
@keyframes lead-alert-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  #lead-alerts { left: 12px; right: 12px; width: auto; }
}

/* ------------------------------------------------------------- Мобильный */

@media (max-width: 900px) {
  .burger { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .15s linear; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { padding-left: 12px; padding-right: 12px; }
  .overlay { padding: 0; }
  .modal { max-width: none; max-height: 100vh; height: 100vh; border-radius: 0; }
  .table-wrap { max-height: none; }
  .topbar .who { display: none; }
  .stage-row { grid-template-columns: 1fr; row-gap: 4px; }
  .plan-person { grid-template-columns: 1fr; row-gap: 3px; }
  .plan-edit-row { grid-template-columns: 1fr; }
  .plan-edit-row .hint { grid-column: 1; }
  .stage-row .num { text-align: left; }
  .dash-grid-2 { grid-template-columns: 1fr; }
}
