:root {
  /* Redesign tokens (design_handoff_safora_redesign) — старые имена переменных
     сохранены, чтобы весь остальной CSS в этом файле (карточки, таблицы,
     бейджи, модалки) автоматически подхватил новую палитру без переписывания
     каждого правила — точечная ретема отдельных секций будет по мере того,
     как каждый раздел будет пересобираться по своему .dc.html прототипу. */
  --berry: #1F9D6B;        /* было тёмно-бордовым (акцентная кнопка/активный таб) → акцентный зелёный */
  --berry-dark: #17181A;   /* было тёмно-бордовым (текст/тёмные поверхности) → ink */
  --rose: #A8D8C1;         /* было розовым (акцентная полоска) → светлый акцент */
  --cream: #F3F3F1;        /* было кремовым (фон бренд-плашки) → page bg */
  --paper: #F3F3F1;        /* фон страницы */
  --white: #FFFFFF;
  --ink: #17181A;
  --ink-soft: #6E6F6B;
  --line: #E2E2DE;
  --good: #17704D;
  --warn: #8A5B12;
  --bad: #A13F2E;
  --radius: 6px;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}

h1, h2, h3, .display {
  font-family: 'Geist', system-ui, sans-serif;
  color: var(--ink);
  font-weight: 600;
  margin: 0;
}

.shell {
  display: flex;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: #17181A;
  color: #B5B6B2;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  min-height: 52px;
  font-weight: 600;
  font-size: 14px;
  color: #FFFFFF;
  white-space: nowrap;
  border-bottom: 1px solid #26272A;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #1F9D6B;
  color: #FFFFFF;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name { font-weight: 600; font-size: 14px; color: #FFFFFF; }
.brand-name em { font-weight: 400; font-style: normal; color: #9A9B97; }

.nav { flex: 1; overflow-y: auto; padding: 8px 8px 12px; display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  color: #B5B6B2;
  transition: background 0.12s, color 0.12s;
}
.nav-icon { flex-shrink: 0; }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-item:hover { color: #FFFFFF; }
.nav-item.active { background: #26272A; color: #FFFFFF; }

.nav-group-toggle .nav-chevron { font-size: 10px; color: #6E6F6B; transition: transform 0.15s; padding: 8px; margin: -8px; }
.nav-group-toggle.open .nav-chevron { transform: rotate(0deg); }
.nav-group-toggle:not(.open) .nav-chevron { transform: rotate(-90deg); }

.nav-subtree {
  margin: 2px 0 4px 18px;
  padding-left: 10px;
  border-left: 1px solid #2E2F32;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-subtree[hidden] { display: none; }

.nav-subitem {
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  white-space: nowrap;
  color: #9A9B97;
  transition: background 0.12s, color 0.12s;
}
.nav-subitem:hover { color: #FFFFFF; }
.nav-subitem.active { background: #1F2B25; color: #FFFFFF; }
.nav-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; background: #3A3B3E; }
.nav-subitem.active .nav-dot { background: #1F9D6B; }

.nav-group-label {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6E6F6B;
}

.sidebar-footer {
  border-top: 1px solid #26272A;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  flex-shrink: 0;
}

.sidebar-footer-row { display: flex; align-items: center; gap: 6px; }

.notif-toggle { position: relative; flex: 1; min-width: 0; }
.notif-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #1F9D6B; color: #FFFFFF; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.notif-badge[hidden] { display: none; }

.lang-switch { display: flex; border: 1px solid #3A3B3E; border-radius: 5px; overflow: hidden; flex-shrink: 0; }
.lang-btn {
  border: 0; cursor: pointer; font-size: 11px; font-weight: 600; padding: 5px 7px;
  text-transform: uppercase; background: transparent; color: #9A9B97; font-family: inherit;
}
.lang-btn.active { background: #FFFFFF; color: #17181A; }

.notif-popover {
  position: absolute; left: 10px; right: 10px; bottom: 100%; margin-bottom: 6px;
  background: #FFFFFF; color: #17181A; border: 1px solid #DADAD5; border-radius: 8px;
  box-shadow: 0 12px 32px rgba(23, 24, 26, 0.2); z-index: 40; overflow: hidden;
}
.notif-popover[hidden] { display: none; }
.notif-popover-header {
  display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid #EDEDEA;
  font-size: 13px; font-weight: 600;
}
.notif-readall {
  margin-left: auto; border: 0; background: transparent; cursor: pointer; font-size: 12px;
  color: #1F9D6B; font-family: inherit;
}
.notif-popover-body { max-height: 260px; overflow-y: auto; }
.notif-empty { padding: 18px 12px; font-size: 12.5px; color: #9A9B97; text-align: center; }
.notif-row { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #F3F3F1; }
.notif-row:last-child { border-bottom: none; }
.notif-row-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-row-title { font-size: 12px; font-weight: 500; }
.notif-row-time { font-size: 11px; color: #9A9B97; }

.profile-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #2E3A34; color: #8FD3B2;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.profile-meta { display: flex; flex-direction: column; min-width: 0; }
.profile-name { font-size: 13px; font-weight: 500; color: #FFFFFF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-role { font-size: 11px; color: #9A9B97; }

/* ---------------- Content / subheader ---------------- */

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

.subheader {
  background: #FFFFFF;
  border-bottom: 1px solid #E2E2DE;
}
.subheader-title {
  max-width: 1440px; margin: 0 auto; padding: 10px 20px 0;
  display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
}
.subheader-crumb { font-size: 13px; color: #9A9B97; }
.subheader-crumb[hidden] { display: none; }
#page-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-meta {
  max-width: 1440px; margin: 0 auto; padding: 2px 20px 10px;
  font-size: 12px; color: #6E6F6B;
}
.topbar-meta:empty { display: none; }

.content { max-width: 1440px; width: 100%; margin: 0 auto; padding: 12px 20px 32px; }

.view[hidden] { display: none; }

/* ---------------- Cards / tables ---------------- */

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--berry-dark);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--paper); }

.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--ink-soft); }

/* ---------------- Buttons / inputs ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 7px;
  padding: 9px 15px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--berry); color: var(--white); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--berry); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--cream); }
.btn-danger { background: transparent; color: var(--bad); }
.btn-danger:hover { background: #FBEAEA; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

input[type=text], input[type=number], input[type=search], select {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}
input:focus, select:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(162, 103, 105, 0.14);
}

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.period-tabs { display: flex; gap: 2px; background: var(--paper); border-radius: 8px; padding: 3px; }

.pipeline-multiselect { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 6px; }

/* Модальное окно (карточка деталей заказа) — с уникальным префиксом
   order-modal-*, чтобы не конфликтовать с уже существующей модалкой
   товаров (.modal / .modal-backdrop ниже по файлу, другая ширина). */
.order-modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 12, 14, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; z-index: 1000; overflow-y: auto;
}
.order-modal {
  background: var(--white); border-radius: 12px; width: 100%; max-width: 920px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25); display: flex; flex-direction: column;
  max-height: calc(100vh - 80px);
}
.order-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.order-modal-header h2 { margin: 0; font-size: 18px; color: var(--berry-dark); }
.order-modal-close {
  border: none; background: none; font-size: 24px; line-height: 1; cursor: pointer;
  color: var(--ink-soft); padding: 0 4px;
}
.order-modal-close:hover { color: var(--berry); }
.order-modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.order-modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px;
  justify-content: flex-end; flex-shrink: 0;
}
.detail-section-title {
  font-weight: 700; color: var(--berry-dark); font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 8px;
}
.detail-row {
  display: grid; grid-template-columns: 220px 1fr; gap: 14px;
  padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--paper);
}
.detail-label { color: var(--ink-soft); }
.detail-value { color: var(--ink); word-break: break-word; }

.pipeline-check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.pipeline-check input { cursor: pointer; }
.period-tab {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 13px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); border-radius: 6px; font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.period-tab:hover { color: var(--berry-dark); }
.period-tab.active { background: var(--white); color: var(--berry); box-shadow: var(--shadow); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-on { background: #E4F0E9; color: var(--good); }
.badge-off { background: #F1E9E9; color: var(--ink-soft); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* ---------------- Modal ---------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(46, 34, 41, 0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 26px 26px 20px;
  width: 380px;
  box-shadow: 0 20px 50px rgba(46,34,41,0.25);
}
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------------- Bar charts (dataviz) ---------------- */
/* Одна и та же горизонтальная полоса-диаграмма — для воронки, топ товаров,
   причин отказа, операторов. Цвет — последовательная рампа одного оттенка
   (--cream -> --berry-dark), светлее = меньше, темнее = больше (или раньше
   -> позже по воронке) — см. dataviz skill: sequential/ordinal = один
   оттенок, не "радуга" случайных цветов на каждый ряд. */

.dv-bars { display: flex; flex-direction: column; gap: 3px; }

.dv-bar-row {
  display: grid;
  grid-template-columns: 190px 1fr 100px;
  align-items: center;
  gap: 14px;
  padding: 5px 0;
}
.dv-bar-label {
  font-size: 13px; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dv-bar-track { background: var(--paper); border-radius: 4px; overflow: hidden; height: 20px; }
.dv-bar-fill {
  height: 100%;
  border-radius: 0 4px 4px 0;   /* скруглённый край данных справа, прямой у базовой линии слева */
  transition: width 0.4s ease, filter 0.15s ease;
}
.dv-bar-row:hover .dv-bar-fill { filter: brightness(1.1); }
.dv-bar-value { font-size: 12.5px; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.dv-bar-value-sub { font-size: 11px; color: var(--ink-soft); font-weight: 400; margin-top: 1px; }

.dv-chart-card { margin-top: 0; }
.dv-chart-hint { font-size: 12px; color: var(--ink-soft); margin: -6px 0 10px; }

/* Компактный вариант — для карточек в сетке дашборда, где несколько
   графиков стоят рядом и должны уместиться на экране без прокрутки
   страницы. */
.dv-bars--compact .dv-bar-row { padding: 3px 0; grid-template-columns: 128px 1fr 74px; gap: 8px; }
.dv-bars--compact .dv-bar-track { height: 15px; }
.dv-bars--compact .dv-bar-label { font-size: 12px; }
.dv-bars--compact .dv-bar-value { font-size: 11.5px; }
.dv-bars--compact .dv-bar-value-sub { font-size: 10px; }

.dv-bar-row.dv-clickable { cursor: pointer; }

/* Если строк слишком много даже для компактного вида — скроллим ВНУТРИ
   карточки, а не всю страницу целиком (см. просьбу "всё видно на одном
   экране без скролла страницы"). */
.dv-scroll { max-height: 340px; overflow-y: auto; padding-right: 4px; margin: -2px -4px -2px 0; }

.dv-show-all {
  display: inline-block; margin-top: 8px; font-size: 12px; color: var(--berry);
  cursor: pointer; background: none; border: none; padding: 0; font-family: inherit;
}
.dv-show-all:hover { text-decoration: underline; }

/* Сетка дашборда — воронка на всю ширину сверху, остальные карточки
   (операторы/товары/причины отказа/повторные клиенты) в 2 колонки рядом,
   а не одна под другой на всю высоту страницы. */
/* Воронка слева (шире), метрики — колонкой справа, СРАЗУ рядом с ней,
   а не ниже во всю ширину — чтобы "Повторные клиенты"/"Операторы" были
   видны сразу, без прокрутки мимо высокой воронки. */
.dashboard-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; margin-top: 16px; }
.dashboard-main { display: flex; flex-direction: column; gap: 16px; }
.dashboard-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* Продажи по часам суток — вертикальные колонки (24 часа), не список
   строк — иначе на 24 категории горизонтальный бар-чарт вышел бы длиннее
   самой воронки. Метка "пик" — прямая подпись экстремума (см. dataviz
   skill: label the endpoint/extreme, не всё подряд). */
.dv-hours-peak { font-size: 12.5px; color: var(--ink-soft); margin: -6px 0 12px; }
.dv-hours-peak strong { color: var(--berry-dark); font-weight: 600; }
.dv-hours { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.dv-hour-col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.dv-hour-bar {
  width: 100%; min-height: 2px; border-radius: 2px 2px 0 0;
  transition: filter 0.15s ease;
}
.dv-hour-col:hover .dv-hour-bar { filter: brightness(1.15); }
.dv-hours-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-soft); margin-top: 6px; }

/* auto-fit вместо repeat(3, 1fr) — плитки "Повторные клиенты" и т.п.
   встают рядом с "Этапов" в тот же ряд, не требуя отдельной карточки ниже. */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.stat-card .value { font-family: 'Fraunces', serif; font-size: 26px; color: var(--berry-dark); font-weight: 600; }
.stat-card-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; }

.notice {
  background: #FBF3E7;
  border: 1px solid #EAD5AE;
  color: #8A6421;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 18px;
}
.notice.error { background: #FBEAEA; border-color: #E5B8B8; color: var(--bad); }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--berry-dark);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 100;
}
.toast[hidden] { display: none; }
.toast.error { background: var(--bad); }

/* ---------------- CEO Дашборд ---------------- */

.ceo-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.ceo-tab {
  border: 1px solid var(--line); background: var(--white); color: var(--ink-soft);
  padding: 9px 18px; border-radius: 8px; cursor: pointer; font-weight: 600;
  font-size: 13.5px; font-family: inherit; transition: background 0.15s, color 0.15s;
}
.ceo-tab:hover { color: var(--berry-dark); }
.ceo-tab.active { background: var(--berry); color: var(--white); border-color: var(--berry); }

.ceo-focus { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.focus-card .tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
}
.focus-card .msg { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 600; color: var(--berry-dark); margin-top: 11px; }
.focus-card .desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 7px; line-height: 1.5; }
.focus-card.tone-bad { border-color: #E8C3C3; background: linear-gradient(180deg, var(--white), #FBEFEF); }
.focus-card.tone-bad .tag { background: #FBEAEA; color: var(--bad); }
.focus-card.tone-warn { border-color: #EAD5AE; background: linear-gradient(180deg, var(--white), #FBF3E7); }
.focus-card.tone-warn .tag { background: #FBF3E7; color: var(--warn); }
.focus-card.tone-ok { border-color: #C9DBCD; background: linear-gradient(180deg, var(--white), #EEF5F0); }
.focus-card.tone-ok .tag { background: #E4F0E9; color: var(--good); }

.dv-line-chart { width: 100%; height: 190px; display: block; }
.dv-line-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-soft); margin-top: 8px; }
.dv-line-point { fill: var(--berry); }
.dv-line-point:hover { fill: var(--berry-dark); }

.kpi-tone-ok .value { color: var(--good); }
.kpi-tone-warn .value { color: var(--warn); }
.kpi-tone-bad .value { color: var(--bad); }

.problem-badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.problem-badge.failed { background: #FBEAEA; color: var(--bad); }
.problem-badge.stuck { background: #FBF3E7; color: var(--warn); }

/* ---------------- AI-помощник (плавающая кнопка + панель) ---------------- */

.ai-fab {
  position: fixed; z-index: 51; width: 52px; height: 52px; border-radius: 50%;
  border: 0; background: #17181A; color: #FFFFFF; cursor: grab; touch-action: none;
  user-select: none; display: flex; align-items: center; justify-content: center;
  padding: 0; right: 24px; bottom: 24px;
  box-shadow: 0 6px 20px rgba(23, 24, 26, 0.28), 0 0 0 3px transparent;
}
.ai-fab.open { box-shadow: 0 6px 20px rgba(23, 24, 26, 0.28), 0 0 0 3px rgba(31, 157, 107, 0.45); }
.ai-fab.dragging { cursor: grabbing; }
.ai-fab-mark {
  width: 24px; height: 24px; background: #1F9D6B; display: flex; align-items: center;
  justify-content: center; font-size: 12px; border-radius: 5px; pointer-events: none;
}
.ai-fab-dot {
  position: absolute; top: 3px; right: 3px; width: 10px; height: 10px; border-radius: 50%;
  background: #E9C46A; border: 2px solid #17181A; pointer-events: none;
}
.ai-fab-dot[hidden] { display: none; }

.ai-panel {
  position: fixed; z-index: 50; width: 380px; height: 540px;
  background: #FFFFFF; border: 1px solid #DADAD5; border-radius: 8px;
  box-shadow: 0 12px 40px rgba(23, 24, 26, 0.18), 0 2px 6px rgba(23, 24, 26, 0.08);
  display: flex; flex-direction: column; overflow: hidden;
  right: 24px; bottom: 88px;
}
.ai-panel[hidden] { display: none; }
.ai-panel-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid #EDEDEA; background: #17181A; color: #FFFFFF; flex-shrink: 0;
}
.ai-panel-mark {
  width: 18px; height: 18px; background: #1F9D6B; color: #FFFFFF; display: flex;
  align-items: center; justify-content: center; font-size: 9px; border-radius: 3px; flex-shrink: 0;
}
.ai-panel-header h2 { margin: 0; font-size: 13px; font-weight: 600; white-space: nowrap; color: #FFFFFF; }
.ai-panel-section { font-size: 11px; color: #9A9B97; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ai-panel-close {
  margin-left: auto; border: 0; background: transparent; color: #9A9B97; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 4px; font-family: inherit;
}
.ai-panel-close:hover { color: #FFFFFF; }
.ai-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 85%; padding: 8px 11px; border-radius: 8px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.ai-msg-user { align-self: flex-end; background: #17181A; color: #FFFFFF; }
.ai-msg-assistant { align-self: flex-start; background: #F3F3F1; color: #17181A; }
.ai-msg-error { align-self: flex-start; background: #FBEDE9; color: #A13F2E; }
.ai-thinking { align-self: flex-start; font-size: 12px; color: #9A9B97; padding: 4px 2px; }
.ai-suggestions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 8px; flex-shrink: 0; }
.ai-suggestion {
  border: 1px solid #DADAD5; border-radius: 4px; background: #FFFFFF; cursor: pointer;
  font-size: 12px; padding: 4px 8px; color: #3C3D3A; text-align: left; font-family: inherit;
}
.ai-suggestion:hover { border-color: #1F9D6B; }
.ai-input-row { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid #EDEDEA; flex-shrink: 0; }
.ai-input-row input {
  flex: 1; min-width: 0; border: 1px solid #DADAD5; border-radius: 5px; padding: 7px 10px;
  font-size: 13px; outline: none; color: #17181A; font-family: inherit;
}
.ai-send {
  border: 0; border-radius: 5px; background: #1F9D6B; color: #FFFFFF; cursor: pointer;
  font-size: 13px; font-weight: 500; padding: 7px 12px; font-family: inherit;
}
.ai-send:disabled { opacity: 0.6; cursor: default; }

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

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; }
  .nav { flex-direction: column; }
  .content { padding: 20px; }
  .stat-row { grid-template-columns: 1fr; }
  .dv-bar-row { grid-template-columns: 110px 1fr 80px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .ai-panel { width: calc(100vw - 24px); right: 12px; left: 12px; }
}

/* ---------------- KPI-полоса (design_handoff_safora_redesign) ----------------
   Общий компонент "5 показателей в одной белой карточке, разделённых тонкой
   линией" — из README "Shared component patterns". Первым использует раздел
   Заказы, дальше переиспользуется другими разделами по мере их пересборки. */

.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  background: #FFFFFF; border: 1px solid #E2E2DE; border-radius: 6px; overflow: hidden;
}
.kpi-cell {
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: 1px 0 0 #E2E2DE, 0 1px 0 #E2E2DE;
}
.kpi-label { font-size: 12px; color: #6E6F6B; }
.kpi-value-row { display: flex; align-items: baseline; gap: 4px; }
.kpi-value { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.kpi-unit { font-size: 11px; color: #6E6F6B; }
.kpi-sub { font-size: 11px; color: #9A9B97; }

/* Пилюли-фильтры (статус-чипы, scope-переключатель) — общий компонент. */
.chip-row { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  border: 1px solid #DADAD5; border-radius: 4px; background: #FFFFFF; color: #3C3D3A;
  cursor: pointer; font-size: 12px; font-weight: 500; padding: 4px 8px; white-space: nowrap;
  display: inline-flex; gap: 5px; font-family: inherit;
}
.chip.active { background: #17181A; color: #FFFFFF; border-color: #17181A; }
.chip .chip-count { opacity: 0.6; }
.chip.chip-danger { background: #FBEDE9; color: #A13F2E; border-color: #F0C9BF; }

.segmented { display: flex; border: 1px solid #DADAD5; border-radius: 5px; overflow: hidden; }
.segmented button {
  border: 0; cursor: pointer; font-size: 12px; font-weight: 500; padding: 5px 10px;
  white-space: nowrap; background: #FFFFFF; color: #3C3D3A; font-family: inherit;
}
.segmented button.active { background: #17181A; color: #FFFFFF; }

/* Статус-бейджи — переиспользуемые (Заказы/Финансы/Доставка). */
.status-badge { font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 3px; display: inline-block; white-space: nowrap; }
.tsh-badge { font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 3px; background: #17181A; color: #FFFFFF; flex-shrink: 0; }

/* ---------------- Заказы: тулбар + таблица ---------------- */

.ord-toolbar {
  background: #FFFFFF; border: 1px solid #E2E2DE; border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #EDEDEA; padding: 10px 14px; display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.ord-toolbar input[type="search"] {
  width: 220px; max-width: 100%; border: 1px solid #DADAD5; border-radius: 5px;
  padding: 6px 10px; font-size: 12px; outline: none; color: #17181A;
}
.ord-card { background: #FFFFFF; border: 1px solid #E2E2DE; border-top: 0; border-radius: 0 0 6px 6px; }
.dtable-wrap { overflow-x: auto; }
.dtable { font-size: 12px; }
.drow {
  display: grid; align-items: center; white-space: nowrap; cursor: pointer;
  border-bottom: 1px solid #F3F3F1;
}
.drow:hover { background: #FAFAF8; }
.drow.selected { background: #F1F8F4; }
.dhead {
  display: grid; align-items: center; white-space: nowrap; color: #6E6F6B;
}
.dcell { padding: 7px 8px; overflow: hidden; text-overflow: ellipsis; }
.dcell:first-child { padding-left: 14px; }
.dcell-head { padding: 7px 8px; border-bottom: 1px solid #EDEDEA; }
.dcell-head:first-child { padding-left: 14px; }
.ord-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.ord-phone { font-size: 11px; color: #9A9B97; }
.ord-warn { color: #C8503C; font-weight: 600; text-align: center; }
.ord-region-missing { color: #C8503C; }
.dtable-empty { padding: 28px 14px; text-align: center; color: #9A9B97; }
.ord-delivery { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; }
.ord-delivery-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ---------------- Заказы: боковая панель (drawer) ---------------- */

.ord-drawer-overlay { position: fixed; inset: 0; background: rgba(23, 24, 26, 0.25); z-index: 30; }
.ord-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%);
  background: #FFFFFF; z-index: 31; box-shadow: -12px 0 40px rgba(23, 24, 26, 0.16);
  display: flex; flex-direction: column;
}
.ord-drawer-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #EDEDEA; flex-shrink: 0; }
.ord-drawer-title { font-size: 15px; font-weight: 600; }
.ord-drawer-sub { font-size: 12px; color: #9A9B97; }
.ord-drawer-close { margin-left: auto; border: 0; background: transparent; cursor: pointer; font-size: 20px; line-height: 1; color: #9A9B97; padding: 2px 4px; font-family: inherit; flex-shrink: 0; }
.ord-drawer-close:hover { color: #17181A; }
.ord-drawer-body { flex: 1; overflow-y: auto; padding: 4px 0 16px; font-size: 13px; }
.ord-banner { margin: 12px 16px 0; padding: 8px 10px; border-radius: 5px; font-size: 12px; }
.ord-banner-missing { background: #FBEDE9; color: #A13F2E; }
.ord-banner-error { background: #FBF3E3; color: #6B4A10; }
.ord-group { padding: 14px 16px 0; }
.ord-group-title { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: #9A9B97; padding-bottom: 6px; }
.ord-field-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 5px 0; border-bottom: 1px solid #F3F3F1; }
.ord-field-label { color: #6E6F6B; }
.ord-field-value { overflow-wrap: anywhere; }
.ord-log-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; padding: 0 0 10px; }
.ord-log-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; }
.ord-log-main { display: flex; flex-direction: column; gap: 1px; }
.ord-log-transition { font-size: 12px; }
.ord-log-transition .arrow { color: #9A9B97; }
.ord-log-source { font-size: 11px; color: #9A9B97; }
.ord-log-time { font-size: 11px; color: #9A9B97; }
.ord-drawer-footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid #EDEDEA; align-items: center; flex-shrink: 0; }
.ord-send-btn { white-space: nowrap; flex-shrink: 0; border: 0; border-radius: 5px; padding: 8px 14px; font-size: 13px; font-weight: 500; font-family: inherit; }
.ord-send-hint { font-size: 11px; color: #9A9B97; }

@media (max-width: 700px) {
  .ord-drawer { width: 100%; }
}

/* ---------------- Тумблер вкл/выкл — переиспользуемый (Товары и далее) ---------------- */

.toggle-btn { border: 0; background: transparent; cursor: pointer; padding: 0; display: inline-flex; font-family: inherit; }
.toggle-track { width: 26px; height: 15px; border-radius: 8px; position: relative; flex-shrink: 0; }
.toggle-knob { position: absolute; top: 2px; width: 11px; height: 11px; border-radius: 50%; background: #FFFFFF; transition: left 0.12s; }
.toggle-label-btn { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer; font-size: 12px; color: #3C3D3A; padding: 4px; font-family: inherit; }

/* ---------------- Товары ---------------- */

.prod-edit-card { background: #FFFFFF; border: 1px solid #1F9D6B; border-radius: 6px; }
.prod-edit-header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #EDEDEA; }
.prod-edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; padding: 12px 14px; }
.prod-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #6E6F6B; }
.prod-field input {
  border: 1px solid #DADAD5; border-radius: 5px; padding: 7px 9px; font-size: 13px;
  outline: none; color: #17181A; font-family: inherit;
}
.prod-field-span2 { grid-column: span 2; }
.prod-edit-actions { display: flex; align-items: center; gap: 8px; padding: 0 14px 12px; flex-wrap: wrap; }
.prod-save-btn { border: 0; border-radius: 5px; background: #1F9D6B; color: #FFFFFF; cursor: pointer; font-size: 13px; font-weight: 500; padding: 7px 14px; font-family: inherit; }
.prod-cancel-btn { border: 1px solid #DADAD5; border-radius: 5px; background: #FFFFFF; color: #3C3D3A; cursor: pointer; font-size: 13px; padding: 7px 14px; font-family: inherit; }
.prod-form-error { font-size: 12px; color: #C8503C; }

.prod-toolbar { background: #FFFFFF; border: 1px solid #E2E2DE; border-radius: 6px 6px 0 0; border-bottom: 1px solid #EDEDEA; padding: 10px 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prod-toolbar input[type="search"] { width: 200px; max-width: 100%; border: 1px solid #DADAD5; border-radius: 5px; padding: 6px 10px; font-size: 12px; outline: none; color: #17181A; }
.prod-card { background: #FFFFFF; border: 1px solid #E2E2DE; border-top: 0; border-radius: 0 0 6px 6px; }
.prod-row-inactive { opacity: 0.55; }
.prod-edit-link { border: 1px solid #DADAD5; border-radius: 4px; background: #FFFFFF; cursor: pointer; font-size: 11px; padding: 3px 8px; color: #3C3D3A; font-family: inherit; }
.prod-edit-link:hover { border-color: #17181A; }
.prod-del-link { border: 0; background: transparent; cursor: pointer; font-size: 11px; padding: 3px 6px; color: #C8503C; font-family: inherit; }

/* ---------------- Регионы ---------------- */

.reg-layout { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 12px; align-items: start; }
.reg-sidebar { background: #FFFFFF; border: 1px solid #E2E2DE; border-radius: 6px; position: sticky; top: 12px; }
.reg-sidebar-header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #EDEDEA; }
.reg-sidebar-header h2 { margin: 0; font-size: 13px; font-weight: 600; }
.reg-sidebar-body { padding: 6px; max-height: 70vh; overflow-y: auto; }
.reg-region-btn {
  border: 0; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px; font-size: 12px; text-align: left; background: transparent;
  color: #3C3D3A; font-family: inherit;
}
.reg-region-btn:hover { background: #F3F3F1; }
.reg-region-btn.active { background: #EEF6F1; color: #17704D; }
.reg-region-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg-region-count { color: #9A9B97; }
.reg-region-btn.active .reg-region-count { color: #17704D; opacity: 0.7; }

.reg-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #EDEDEA; flex-wrap: wrap; }
.reg-toolbar input[type="search"] { width: 240px; max-width: 100%; border: 1px solid #DADAD5; border-radius: 5px; padding: 6px 10px; font-size: 12px; outline: none; color: #17181A; }
.reg-hint { flex-basis: 100%; font-size: 11px; color: #9A9B97; }
.reg-card { min-width: 0; background: #FFFFFF; border: 1px solid #E2E2DE; border-radius: 6px; }

@media (max-width: 700px) {
  .reg-layout { grid-template-columns: 1fr; }
  .reg-sidebar { position: static; }
  .reg-sidebar-body { max-height: 240px; }
}

/* ---------------- Маркетинг ---------------- */

.mkt-source-note { font-size: 12px; color: #6E6F6B; }
.mkt-empty {
  background: #FFFFFF; border: 1px dashed #D2D2CC; border-radius: 6px; padding: 48px 20px;
  display: grid; place-items: center;
}
.mkt-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; max-width: 400px; }
.mkt-empty-title { font-size: 15px; font-weight: 600; }
.mkt-empty-desc { font-size: 13px; color: #6E6F6B; }
.mkt-empty-btn { margin-top: 6px; border: 0; border-radius: 5px; background: #17181A; color: #FFFFFF; cursor: pointer; font-size: 13px; font-weight: 500; padding: 8px 14px; font-family: inherit; }

.dcell-head-sort { border: 0; background: transparent; cursor: pointer; font-family: inherit; font-size: 12px; }
.dcell-head-sort:hover { color: #17181A; }

.mkt-tag-cell { display: flex; flex-direction: column; gap: 3px; }
.mkt-share-track { height: 3px; background: #F0F0ED; border-radius: 2px; overflow: hidden; }
.mkt-share-fill { height: 100%; background: #1F9D6B; }
.mkt-conv-cell { display: flex; align-items: center; gap: 8px; }
.mkt-conv-track { flex: 1; height: 4px; background: #EDEDEA; border-radius: 2px; overflow: hidden; }
.mkt-conv-fill { height: 100%; }
.mkt-conv-value { width: 44px; font-weight: 500; text-align: right; }
.mkt-notag-row { background: #F7F7F5; color: #6E6F6B; }
.mkt-notag-row .dcell:first-child { display: flex; flex-direction: column; }
.mkt-notag-name { font-weight: 500; color: #3C3D3A; }
.mkt-notag-sub { font-size: 11px; }

/* ---------------- Финансы ---------------- */

.row-dim { opacity: 0.6; }
.fin-caret { color: #9A9B97; font-size: 10px; }
.fin-status-cell { display: flex; flex-direction: column; gap: 1px; }
.fin-status-sub { font-size: 11px; color: #9A9B97; }
.fin-expand-row { padding: 10px 14px 12px 38px; background: #FAFAF8; border-bottom: 1px solid #EDEDEA; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 240px); gap: 16px; }
.fin-expand-col { display: flex; flex-direction: column; gap: 4px; }
.fin-expand-label { font-size: 11px; color: #9A9B97; }
.fin-expand-label-spaced { font-size: 11px; color: #9A9B97; margin-top: 6px; }
.fin-msg-box { white-space: pre-wrap; font-size: 12px; line-height: 1.5; background: #FFFFFF; border: 1px solid #EDEDEA; border-radius: 5px; padding: 8px 10px; }
.fin-expand-value { font-size: 12px; }

/* ---------------- Настройки ---------------- */

.settings-wrap { display: flex; flex-direction: column; gap: 12px; max-width: 980px; padding-bottom: 64px; }
.settings-card { background: #FFFFFF; border: 1px solid #E2E2DE; border-radius: 6px; }
.settings-section-header { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-bottom: 1px solid #EDEDEA; }
.settings-section-header--row { flex-direction: row; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.settings-section-header h2 { margin: 0; font-size: 13px; font-weight: 600; }
.settings-section-desc { font-size: 12px; color: #6E6F6B; flex: 1; min-width: 240px; }
.settings-section-desc-solo { font-size: 12px; color: #6E6F6B; }

.pipe-row {
  border: 0; border-bottom: 1px solid #F3F3F1; background: transparent; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 18px minmax(0, 1fr) 90px 110px; gap: 12px; align-items: center;
  padding: 10px 14px; text-align: left; font-size: 13px; font-family: inherit;
}
.pipe-row:last-child { border-bottom: 0; }
.pipe-row:hover { background: #FAFAF8; }
.pipe-check-box { width: 16px; height: 16px; border-radius: 3px; display: grid; place-items: center; font-size: 11px; color: #FFFFFF; }
.pipe-name { font-weight: 500; }
.pipe-id { font-size: 12px; color: #9A9B97; }
.pipe-deals { font-size: 12px; color: #6E6F6B; text-align: right; }

.tag-chip-box { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; }
.tag-chip {
  display: flex; align-items: center; gap: 6px; border: 1px solid #DADAD5; border-radius: 4px;
  background: #FFFFFF; color: #3C3D3A; cursor: pointer; font-size: 12px; font-weight: 500; padding: 5px 9px;
  font-family: inherit;
}
.tag-chip.selected { background: #EEF6F1; color: #17704D; border-color: #A8D8C1; }
.tag-chip-count { opacity: 0.55; font-weight: 400; }
.settings-selected-note { padding: 0 14px 12px; font-size: 12px; color: #6E6F6B; }

.sync-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.sync-stat-cell { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; box-shadow: 1px 0 0 #EDEDEA; }
.sync-stat-label { font-size: 12px; color: #6E6F6B; }
.sync-stat-value { font-size: 15px; font-weight: 500; }
.sync-stat-sub { font-size: 11px; color: #9A9B97; }
.sync-actions { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-top: 1px solid #EDEDEA; flex-wrap: wrap; }
.sync-btn-primary { border: 0; border-radius: 5px; background: #17181A; color: #FFFFFF; cursor: pointer; font-size: 12px; font-weight: 500; padding: 7px 12px; font-family: inherit; }
.sync-btn-ghost { border: 1px solid #DADAD5; border-radius: 5px; background: #FFFFFF; color: #3C3D3A; cursor: pointer; font-size: 12px; padding: 7px 12px; font-family: inherit; }
.sync-hint { font-size: 11px; color: #9A9B97; }

.settings-savebar {
  position: sticky; bottom: 12px; display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #17181A; color: #FFFFFF; border-radius: 6px; box-shadow: 0 8px 24px rgba(23, 24, 26, 0.25);
}
.settings-savebar span { font-size: 13px; }
.settings-savebar-cancel { margin-left: auto; border: 1px solid #3A3B3E; border-radius: 5px; background: transparent; color: #E9E9E6; cursor: pointer; font-size: 12px; padding: 6px 12px; font-family: inherit; }
.settings-savebar-save { border: 0; border-radius: 5px; background: #1F9D6B; color: #FFFFFF; cursor: pointer; font-size: 12px; font-weight: 500; padding: 6px 12px; font-family: inherit; }
.settings-saved-toast { position: sticky; bottom: 12px; align-self: flex-start; padding: 8px 12px; border-radius: 5px; background: #DDF0E6; color: #17704D; font-size: 12px; font-weight: 500; }
