/* Interactive sales / Avito / chat-quality dashboard.
   Каркас, фильтры, таблицы и графики унаследованы от демо застройщика
   (instrumenty/dashbordy/dashbord-zastroyshchika/dashboard.css) — одинаковые компоненты
   ведут себя одинаково на обоих стендах. Ниже — компоненты этого отчёта. */
@font-face {
  font-family: Onest;
  src: url('/site5/fonts/onest-cyrillic.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f2f4f7;
  --blue: #3975e8;
  --blue-soft: #eaf1ff;
  --red: #bf3651;
  --green: #2f8f4e;
  --amber: #d88a1e;
  --purple: #8c5ac2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 28px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Onest, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, select, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ========================================================================== */
/* Шапка                                                                      */
/* ========================================================================== */
.demo-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px clamp(18px, 3vw, 48px);
  color: #fff;
  background: #0c2340;
}

.demo-logo {
  flex: none;
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.demo-logo span { color: #f5a623; }

.demo-header-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.demo-header-copy strong { font-size: 15px; }
.demo-header-copy span { color: #aebbd0; font-size: 13px; }

.demo-back {
  margin-left: auto;
  padding: 10px 14px;
  color: #fff;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .2s, background .2s;
}

.demo-back:hover { border-color: #fff; background: rgba(255,255,255,.08); }

/* ========================================================================== */
/* Каркас                                                                     */
/* ========================================================================== */
.dashboard-shell { padding: 28px clamp(12px, 2.5vw, 40px) 56px; }

.dashboard { max-width: 1540px; margin: 0 auto; }

.dashboard-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(27px, 3vw, 42px);
  letter-spacing: -.045em;
  line-height: 1.08;
}

.demo-notice {
  max-width: 490px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  color: #465166;
  background: #fff9e9;
  border: 1px solid #f1dfaa;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.notice-dot {
  width: 8px;
  height: 8px;
  flex: none;
  margin-top: 5px;
  background: var(--amber);
  border-radius: 50%;
}

.dashboard-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid #d8dde6;
}

.dashboard-tabs button {
  position: relative;
  flex: none;
  padding: 13px 17px 14px;
  color: #667085;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 15px;
  white-space: nowrap;
}

.dashboard-tabs button::after {
  content: '';
  position: absolute;
  right: 14px;
  bottom: -1px;
  left: 14px;
  height: 2px;
  background: transparent;
}

.dashboard-tabs button:hover { color: var(--ink); }
.dashboard-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 650; }
.dashboard-tabs button[aria-selected="true"]::after { background: var(--blue); }

/* ========================================================================== */
/* Фильтры                                                                    */
/* ========================================================================== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 0 10px;
}

.filter-control {
  position: relative;
  min-width: 186px;
  padding: 8px 10px 9px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 11px;
  box-shadow: var(--shadow);
}

.filter-control > span {
  display: block;
  margin: 0 2px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.filter-control select {
  width: 100%;
  min-height: 28px;
  padding: 0 26px 0 2px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.filter-control:focus-within { border-color: #9bbcf8; }

/* Мультиселект */
.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  padding: 0 2px;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

.ms-trigger em { overflow: hidden; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.ms-trigger::after { content: '⌄'; flex: none; margin-top: -6px; color: #8a93a5; font-size: 15px; }
.ms[data-open="true"] .ms-trigger::after { transform: rotate(180deg); margin-top: 4px; }

.ms-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid #dfe4ec;
  border-radius: 11px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
}

.ms-option:hover { background: #f4f7fd; }
.ms-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--blue); }


/* Пресеты периода */
.preset-group { display: flex; align-self: stretch; align-items: stretch; gap: 0; }
.preset-group button {
  padding: 0 13px;
  color: #475467;
  background: #fff;
  border: 1px solid #dfe4ec;
  border-left-width: 0;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.preset-group button:first-child { border-left-width: 1px; border-radius: 11px 0 0 11px; }
.preset-group button:last-child { border-radius: 0 11px 11px 0; }
.preset-group button:hover { color: var(--blue); background: var(--blue-soft); }
.preset-group button[aria-pressed="true"] { color: #fff; background: var(--blue); border-color: var(--blue); font-weight: 650; }

.reset-filters {
  align-self: stretch;
  padding: 0 17px;
  color: #475467;
  background: transparent;
  border: 1px solid #cfd5df;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13px;
}

.reset-filters:hover { color: var(--blue); border-color: var(--blue); }

.filter-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 30px;
  padding-bottom: 12px;
}

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 11px;
  color: #1c3d7a;
  background: var(--blue-soft);
  border: 1px solid #cadcfd;
  border-radius: 999px;
  font-size: 12.5px;
}

.chip b { font-weight: 650; }
.chip button {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  padding: 0;
  color: #2f5fae;
  background: rgba(57, 117, 232, .14);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.chip button:hover { color: #fff; background: var(--blue); }

.updated-stamp { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.updated-stamp::before { content: ''; width: 7px; height: 7px; background: #35b06a; border-radius: 50%; }

/* ========================================================================== */
/* Секции и панели                                                            */
/* ========================================================================== */
.dashboard-content { min-height: 620px; }

.section-head { margin: 4px 0 14px; }

.section-head h2 {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  letter-spacing: -.035em;
}

.section-head p {
  max-width: 640px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.kpi-card, .panel {
  background: var(--surface);
  border: 1px solid #edf0f4;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { min-width: 0; padding: 16px 16px 14px; }
.panel + .panel, .panel + .grid-2, .grid-2 + .panel, .kpi-grid + .panel { margin-top: 10px; }

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-title h3 { margin: 0; font-size: 15px; }
.panel-title .panel-sub { color: var(--muted); font-size: 13px; }
.panel-head-left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.panel-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.panel-actions button {
  padding: 5px 10px;
  color: #55637a;
  background: #f5f7fa;
  border: 1px solid #e6eaf0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.panel-actions button:hover { color: var(--blue); background: var(--blue-soft); border-color: #cadcfd; }
.panel-actions button[aria-pressed="true"] { color: #fff; background: var(--blue); border-color: var(--blue); }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(400px, 1fr);
  align-items: start;
  gap: 10px;
  margin-top: 10px;
}

.grid-equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ========================================================================== */
/* KPI                                                                        */
/* ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.kpi-card { display: flex; flex-direction: column; min-height: 132px; padding: 16px 17px 14px; }
.kpi-card .kpi-label { min-height: 34px; display: block; color: #475467; font-size: 13px; line-height: 1.32; }

.kpi-card strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: clamp(26px, 2.1vw, 34px);
  letter-spacing: -.045em;
  line-height: 1.05;
}

/* Текстовые значения (названия источников, месяцев) не должны спорить с числами */
.kpi-card strong.is-text { font-size: 20px; letter-spacing: -.02em; line-height: 1.2; }

.kpi-card small { display: block; margin-top: auto; padding-top: 8px; color: #667085; font-size: 12.5px; line-height: 1.4; }

/* ========================================================================== */
/* Графики                                                                    */
/* ========================================================================== */
.chart-block { position: relative; }
.chart-host { width: 100%; }
.chart-host svg { display: block; width: 100%; }
.chart-overlay { fill: transparent; }
.chart-overlay.is-clickable { cursor: pointer; }
.chart-empty { display: grid; place-items: center; height: 100%; min-height: 200px; color: var(--muted); font-size: 14px; }


.chart-tip {
  position: fixed;
  z-index: 90;
  max-width: 280px;
  padding: 9px 11px;
  color: #f2f5fa;
  background: rgba(14, 26, 45, .95);
  border-radius: 9px;
  box-shadow: 0 10px 26px rgba(12, 26, 48, .28);
  font-family: Onest, Arial, sans-serif;
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: none;
}
.chart-tip strong { display: block; margin-bottom: 5px; font-size: 13px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-row i { width: 9px; height: 9px; flex: none; border-radius: 2px; }
.chart-tip .tip-row span { flex: 1; color: #b9c5d6; }
.chart-tip .tip-row b { font-variant-numeric: tabular-nums; font-weight: 650; }
.chart-tip .tip-hint { margin-top: 6px; color: #8d9ab0; font-size: 11.5px; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; margin-top: 8px; }
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  color: #46536b;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12.5px;
}
.legend-item:hover { background: #f2f5fa; border-color: #e4e9f1; }
.legend-item i { width: 14px; height: 3px; flex: none; border-radius: 2px; }
.legend-item.is-off { color: #a2abba; }
.legend-item.is-off i { opacity: .3; }

/* ========================================================================== */
/* Таблицы                                                                    */
/* ========================================================================== */
.table-scroll { max-width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { min-width: 92px; padding: 9px 11px; border: 1px solid #e1e5eb; text-align: right; white-space: nowrap; }
.data-table th { position: relative; color: #475467; background: #f8f9fb; font-weight: 650; }
/* Заголовки переносятся на две строки: иначе длинное «Стоимость обращения» задаёт ширину
   столбца и таблица из 10+ колонок уходит в горизонтальный скролл уже на 1440. */
.data-table thead th { min-width: 76px; max-width: 132px; white-space: normal; vertical-align: bottom; line-height: 1.3; }
.data-table td { min-width: 72px; }
.data-table th.txt, .data-table td.txt { text-align: left; }
.data-table th:first-child, .data-table td:first-child { position: sticky; left: 0; z-index: 1; min-width: 168px; text-align: left; background: #fff; }
.data-table th:first-child { z-index: 2; background: #f8f9fb; }
.data-table tbody tr:hover td { background: #f7f9fd; }
.data-table tbody tr:hover td:first-child { background: #f7f9fd; }
.data-table tfoot td { background: #f0f2f5; font-weight: 750; }
.data-table tfoot td:first-child { background: #f0f2f5; }
.data-table .muted-cell { color: #667085; }

.data-table th[data-col] { cursor: pointer; user-select: none; padding-right: 20px; }
.data-table th[data-col]:hover { color: var(--blue); }
.sort-mark { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); color: #b6bec9; font-size: 9px; font-style: normal; }
.data-table th[aria-sort="ascending"] .sort-mark::after { content: '▲'; color: var(--blue); }
.data-table th[aria-sort="descending"] .sort-mark::after { content: '▼'; color: var(--blue); }
.data-table th[data-col]:not([aria-sort]) .sort-mark::after { content: '⇅'; }

.cell-filter {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed #b8c2d2;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.cell-filter:hover { color: var(--blue); border-bottom-color: var(--blue); }
.cell-filter.is-active { color: var(--blue); font-weight: 650; }

.drill-toggle {
  width: 18px;
  height: 18px;
  margin-right: 7px;
  padding: 0;
  color: #55637a;
  background: #eef1f6;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
}
.drill-toggle:hover { color: #fff; background: var(--blue); }
.drill-child td { color: #52607a; background: #fbfcfe; }
.drill-child td:first-child { padding-left: 38px; background: #fbfcfe; font-size: 12.5px; }

/* Тепловая карта: сине-оранжевая дивергентная шкала (различима при дальтонизме) */
.heat-cell { color: #172033; font-weight: 650; }
.heat-1 { background: #f3b98c; }
.heat-2 { background: #fadfc6; }
.heat-3 { background: #eef1f5; }
.heat-4 { background: #d3e2f8; }
.heat-5 { background: #a8c8f2; }

.heat-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.heat-legend i { width: 26px; height: 11px; display: block; border-radius: 2px; }
.heat-legend .heat-scale { display: flex; gap: 2px; }

/* ========================================================================== */
/* Карточки каналов, доменов, воронка                                         */
/* ========================================================================== */


.funnel { display: grid; gap: 10px; padding: 8px 0; }
.funnel-row { display: grid; grid-template-columns: 140px minmax(120px, 1fr) 78px; align-items: center; gap: 10px; font-size: 13px; }
.funnel-track { height: 32px; overflow: hidden; background: #f0f3f7; border-radius: 6px; }
.funnel-fill { display: block; min-width: 3px; height: 100%; background: linear-gradient(90deg, #82aefb, #3975e8); }
.funnel-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-step { display: flex; justify-content: space-between; gap: 10px; padding: 0 2px; color: var(--muted); font-size: 12px; }


.demo-explanation {
  max-width: 1540px;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin: 22px auto 0;
  padding: 18px 20px;
  color: #e8edf7;
  background: #0c2340;
  border-radius: 14px;
}

.demo-explanation > span { color: #9fb0c9; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.demo-explanation p { margin: 0; font-size: 13px; line-height: 1.55; }
.demo-explanation a { color: #fff; font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.demo-explanation a b { color: #f5a623; }


/* ========================================================================== */
/* Адаптив                                                                    */
/* ========================================================================== */
@media (max-width: 1180px) {
  .grid-2, .grid-equal { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .demo-header { min-height: 60px; gap: 14px; padding: 10px 16px; }
  .demo-header-copy span { display: none; }
  .demo-header-copy strong { display: block; max-width: 190px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .demo-back { padding: 8px 10px; font-size: 0; }
  .demo-back span { font-size: 15px; }
  .dashboard-shell { padding: 20px 10px 36px; }
  .dashboard-intro { display: block; }
  .demo-notice { margin-top: 14px; }
  .dashboard-tabs { margin-right: -10px; }
  .dashboard-tabs button { padding-right: 13px; padding-left: 13px; font-size: 14px; }
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-control { min-width: 0; }
  .filter-control:first-child { grid-column: span 2; }
  .preset-group { grid-column: span 2; }
  .preset-group button { flex: 1; padding: 10px 6px; }
  .reset-filters { grid-column: span 2; min-height: 44px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
  .kpi-card { min-height: 142px; padding: 14px; }
  .kpi-card strong { font-size: 26px; }
  .panel { padding: 12px; }
  .funnel-row { grid-template-columns: 104px minmax(90px, 1fr) 62px; font-size: 12px; }
  .demo-explanation { grid-template-columns: 1fr; gap: 9px; }
}

@media (max-width: 390px) {
  .demo-header-copy { display: none; }
  /* Две карточки в ряд: пять KPI столбиком занимали почти два экрана телефона */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-grid > .kpi-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi-card { min-height: 0; padding: 12px 12px 11px; }
  .kpi-card .kpi-label { min-height: 0; font-size: 12.5px; }
  .kpi-card strong { font-size: 22px; }
  .kpi-card strong.is-text { font-size: 17px; }
}

/* ========================================================================== */
/* Сценарии показа и пояснения                                                */
/* ========================================================================== */
.demo-notice { max-width: 560px; }

.scenario-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 10px; }

.scenario-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px 16px;
  background: #fff;
  border: 1px solid #e8ecf2;
  border-radius: 12px;
}

.scenario-card b { font-size: 14.5px; }
.scenario-card p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.scenario-card button {
  align-self: flex-start;
  margin-top: auto;
  padding: 8px 12px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}
.scenario-card button:hover { background: #2d63cc; }

.notes { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; counter-reset: note; }
.notes li { position: relative; padding-left: 21px; color: #475467; font-size: 13.5px; line-height: 1.55; }

.notes li::before {
  counter-increment: note;
  content: counter(note);
  position: absolute;
  top: 1px;
  left: 0;
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  color: #45607f;
  background: #eef1f6;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
}

.notes b { color: var(--ink); font-weight: 650; }

/* ========================================================================== */
/* Метки состояний                                                            */
/* ========================================================================== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-high { color: #8d2439; background: #fbe4e8; }
.badge-mid { color: #8a5a11; background: #fdf0da; }
.badge-low { color: #475467; background: #eef1f6; }
.badge-ok { color: #1f6b3a; background: #e2f3e7; }
.badge-note { color: #5a4a86; background: #efeaf9; }
.badge-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 340px; }

.link-btn { padding: 0; color: var(--blue); background: transparent; border: 0; border-bottom: 1px dashed #9bbcf8; cursor: pointer; font: inherit; text-align: left; }
.link-btn:hover { color: #2d63cc; border-bottom-style: solid; }

.stage-rail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stage-step { padding: 4px 9px; color: #5d6778; background: #f2f4f7; border-radius: 999px; font-size: 12px; }
.stage-step.is-done { color: #1f6b3a; background: #e2f3e7; font-weight: 650; }
.stage-step.is-miss { color: #8d2439; background: #fbe4e8; }
.stage-arrow { color: #b6bec9; font-size: 11px; }

/* ========================================================================== */
/* Карточка обращения и диалог                                                 */
/* ========================================================================== */
.chat-head { display: flex; flex-wrap: wrap; gap: 7px 18px; margin-bottom: 12px; color: var(--muted); font-size: 12.5px; }
.chat-head b { color: var(--ink); font-weight: 650; }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); align-items: start; gap: 14px; }
.chat-thread { display: grid; gap: 8px; padding: 12px; background: #f7f9fc; border: 1px solid #e6ebf3; border-radius: 12px; }

.msg { max-width: 88%; padding: 8px 11px; border-radius: 11px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.msg span { display: block; margin-top: 5px; color: #667085; font-size: 11.5px; }
.msg-buyer { justify-self: start; background: #fff; border: 1px solid #e3e8f0; }
.msg-operator { justify-self: end; margin-left: auto; color: #14335f; background: var(--blue-soft); border: 1px solid #cadcfd; }
.msg-bot { justify-self: end; margin-left: auto; color: #5a4a86; background: #efeaf9; border: 1px solid #ded2f5; }
.msg-system { justify-self: center; color: var(--muted); background: transparent; font-size: 11.5px; text-align: center; }
.msg.is-evidence { box-shadow: inset 0 0 0 2px #d88a1e; }

.chat-side { display: grid; gap: 10px; }
.chat-block { padding: 12px; background: #fff; border: 1px solid #e8ecf2; border-radius: 12px; }
.chat-block h4 { margin: 0 0 8px; color: #667085; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.chat-block .notes li, .chat-block .check-item { font-size: 12.5px; }

.summary-row { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 8px; padding: 5px 0; border-bottom: 1px dashed #eef1f6; font-size: 12.5px; }
.summary-row:last-child { border-bottom: 0; }
.summary-row span { color: var(--muted); }
.summary-row span:last-child { color: var(--ink); }


/* ========================================================================== */
/* Чеклист качества и очередь разбора                                          */
/* ========================================================================== */
.checklist { display: grid; gap: 6px; }
.check-item { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 1.45; }
.check-item.is-muted { color: #667085; }

.check-mark { display: grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 5px; font-size: 10px; font-weight: 700; }
.check-mark.ck-done { color: #1f6b3a; background: #e2f3e7; }
.check-mark.ck-not { color: #8d2439; background: #fbe4e8; }
.check-mark.ck-na { color: #7a8496; background: #f2f4f7; }
.check-mark.ck-check { color: #8a5a11; background: #fdf0da; }

.queue { display: grid; gap: 8px; }

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e8ecf2;
  border-left: 3px solid #d88a1e;
  border-radius: 10px;
}
.queue-item.sev-3 { border-left-color: var(--red); }
.queue-item.sev-1 { border-left-color: #b6bec9; }
.queue-title { font-size: 13px; line-height: 1.45; }
.queue-meta { margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.queue-actions { display: grid; gap: 5px; justify-items: end; }

.empty-state { display: grid; place-items: center; min-height: 190px; padding: 20px; color: var(--muted); background: #fff; border: 1px dashed #d7dde7; border-radius: 12px; font-size: 13.5px; text-align: center; }

.filter-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 10px; }
.filter-inline label { display: grid; gap: 4px; width: min(100%, 340px); color: var(--muted); font-size: 12.5px; }
.filter-inline input, .filter-inline select { padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #dfe4ec; border-radius: 9px; font-size: 13px; }
.mini-note { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

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

@media (max-width: 760px) {
  .scenario-grid { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: 100px minmax(0, 1fr); }
  .msg { max-width: 100%; }
  .queue-item { grid-template-columns: 1fr; }
  .queue-actions { justify-items: start; }
  .filter-inline label { min-width: 0; flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

/* ========================================================================== */
/* Редизайн v2: KPI с изменением, строка показателей, выводы, легенды         */
/* ========================================================================== */
.kpi-delta { display: inline-flex; align-self: flex-start; margin-top: 8px; padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-delta.is-good { color: #1f6b3a; background: #e2f3e7; }
.kpi-delta.is-bad { color: #8d2439; background: #fbe4e8; }
.kpi-delta.is-flat { color: #475467; background: #eef1f6; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0;
  margin: 0 0 10px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid #edf0f4;
  border-radius: var(--radius);
}
.metric-strip > div { min-width: 0; padding: 12px 16px; border-right: 1px solid #eef1f5; border-bottom: 1px solid #eef1f5; }
.metric-strip dt { color: #475467; font-size: 12.5px; line-height: 1.3; }
.metric-strip dd { margin: 4px 0 0; color: var(--ink); font-size: 17px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric-strip dd span { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; letter-spacing: 0; }
.metric-strip + .panel, .metric-strip + .grid-2 { margin-top: 10px; }

.insight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.insight { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 14px 15px; background: #fff; border: 1px solid #e8ecf2; border-left: 4px solid #98a2b3; border-radius: 12px; }
.insight p { margin: 0; color: #344054; font-size: 14px; line-height: 1.5; }
.insight-kicker { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.insight-good { border-left-color: var(--green); }
.insight-good .insight-kicker { color: #1f6b3a; }
.insight-bad { border-left-color: var(--red); }
.insight-bad .insight-kicker { color: #8d2439; }
.insight-warn { border-left-color: var(--amber); }
.insight-warn .insight-kicker { color: #8a5a11; }
.insight-info { border-left-color: var(--blue); }
.insight-info .insight-kicker { color: #1c4fae; }
.insight-action { align-self: flex-start; margin-top: auto; padding: 5px 11px; color: var(--blue); background: var(--blue-soft); border: 1px solid #cadcfd; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.insight-action:hover { color: #fff; background: var(--blue); border-color: var(--blue); }

.swatch-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; color: #475467; font-size: 13px; }
.swatch-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch-legend i { width: 12px; height: 12px; flex: none; border-radius: 3px; }
.legend-axis { color: var(--muted); font-size: 12px; }

.block-head { margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid #dfe4ec; }
.block-head h3 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.block-head p { max-width: 720px; margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }

.unit-costs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-top: 10px; padding: 10px 12px; background: #f7f9fc; border-radius: 10px; font-size: 13.5px; }
.unit-costs span { color: var(--muted); }
.unit-costs b { font-weight: 650; font-variant-numeric: tabular-nums; }

.scenario-index { display: grid; place-items: center; width: 24px; height: 24px; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-size: 13px; font-weight: 700; }

.notes-panel { margin-top: 10px; padding: 0 16px; background: var(--surface); border: 1px solid #edf0f4; border-radius: var(--radius); }
.notes-panel summary { padding: 14px 0; color: #344054; cursor: pointer; font-size: 14px; font-weight: 650; }
.notes-panel summary:hover { color: var(--blue); }
.notes-panel[open] summary { border-bottom: 1px solid #eef1f5; }
.notes-panel .notes { padding: 12px 0 16px; }

.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.data-table .quiet-cell { color: var(--muted); }
.data-table td.wrap-cell { min-width: 220px; max-width: 360px; white-space: normal; }
.data-table td.is-negative { color: #a82a44; font-weight: 650; }

.table-more { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.more-btn { padding: 7px 13px; color: #fff; background: var(--blue); border: 1px solid var(--blue); border-radius: 9px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.more-btn:hover { background: #2d63cc; }
.more-btn.is-quiet { color: var(--blue); background: #fff; border-color: #cadcfd; }
.more-btn.is-quiet:hover { background: var(--blue-soft); }

/* Карточка обращения — боковая панель поверх вкладки */
body.has-drawer { overflow: hidden; }
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .42); }
.drawer .chat-card {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(940px, 100vw);
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 0;
  box-shadow: -18px 0 48px rgba(16, 24, 40, .22);
}
/* Без верхнего паддинга у скроллера: иначе sticky-шапка встаёт на 16px ниже своего
   места в потоке и перекрывает строку с датой и ответственным. */
.drawer .chat-card { padding-top: 0; }
.drawer .chat-card .panel-title { position: sticky; top: 0; z-index: 2; margin: 0 -16px 12px; padding: 16px; background: var(--surface); border-bottom: 1px solid #eef1f5; }
.drawer-close { color: #344054 !important; font-size: 13px !important; font-weight: 600; }

@media (min-width: 1920px) {
  .dashboard { max-width: 1680px; }
  .dashboard-shell .demo-explanation { max-width: 1680px; }
}

@media (max-width: 760px) {
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip > div { padding: 10px 12px; }
  .metric-strip dd { font-size: 16px; }
  .insight-grid { grid-template-columns: 1fr; }
  .block-head h3 { font-size: 18px; }
  .drawer .chat-card { width: 100vw; }
}
