/* ==========================================================================
   pages.css — стили конкретных экранов кабинета
   ========================================================================== */

/* ==========================================================================
   ГЛАВНАЯ · Hero
   ========================================================================== */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  min-height: 340px;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  background: var(--color-surface-ink);
  color: #fff;
  isolation: isolate;
}

.hero__media { position: absolute; inset: 0; z-index: 0; }

.hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 42%;
}

.hero__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(20, 18, 17, 0.94) 0%, rgba(20, 18, 17, 0.82) 34%, rgba(20, 18, 17, 0.34) 62%, rgba(20, 18, 17, 0.18) 100%),
    linear-gradient(to top, rgba(58, 12, 17, 0.34), transparent 58%);
}

.hero__body {
  position: relative;
  z-index: 1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-9) var(--space-8);
  max-width: 720px;
}

.hero__greeting {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: var(--tracking-normal);
}

.hero__title {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: var(--weight-light);
  line-height: 1.04;
  letter-spacing: var(--tracking-tighter);
  color: #fff;
  max-width: 17ch;
}

.hero__title strong {
  display: block;
  font-weight: var(--weight-medium);
}

.hero__text {
  font-size: var(--text-body);
  line-height: var(--leading-relaxed);
  color: rgba(255, 255, 255, 0.7);
  max-width: 46ch;
}

.hero__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-1); }

/* Ключевой показатель поверх фотографии — единственное место с glass */
.hero__figure {
  position: relative;
  z-index: 1;
  grid-column: 2;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: var(--space-8);
}

.hero__panel {
  padding: var(--space-6);
  min-width: 268px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.17);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.hero__panel-label {
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
}

.hero__panel-value {
  margin-top: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1;
  color: #fff;
  font-variant-numeric: proportional-nums;
}

.hero__panel-note {
  margin-top: var(--space-2);
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.66);
}

.hero__panel-foot {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-micro);
  color: rgba(255, 255, 255, 0.62);
}

/* ==========================================================================
   ГЛАВНАЯ · KPI
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
}

.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
  overflow: hidden;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}

.kpi:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kpi__label {
  font-size: var(--text-2xs);
  color: var(--color-text-secondary);
  font-weight: var(--weight-medium);
}

.kpi__value {
  font-family: var(--font-display);
  font-size: var(--text-figure);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1;
  font-variant-numeric: proportional-nums;
}

.kpi__unit {
  font-size: 0.5em;
  font-weight: var(--weight-regular);
  color: var(--color-text-secondary);
  letter-spacing: var(--tracking-normal);
  margin-left: 0.18em;
}

.kpi__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: auto;
}

.kpi__note {
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  line-height: 1.4;
}

.kpi__spark { width: 76px; flex: none; }

/* Главный результат — выделен глубиной, а не заливкой */
.kpi--result {
  background: var(--color-brand-softer);
  border-color: rgba(147, 31, 43, 0.16);
}

.kpi--result .kpi__value { color: var(--color-brand-dark); }
.kpi--result .kpi__label { color: var(--color-brand-dark); }
.kpi--result::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--color-brand);
}

/* ==========================================================================
   ГЛАВНАЯ · Лучшие подразделения
   ========================================================================== */

.dept-rank { display: grid; gap: 0; }

/* Две строки вместо пяти колонок: карточка на «Главной» узкая, и ряд из
   пяти ячеек в ней неизбежно выдавливал значения за пределы страницы. */
.dept-rank__item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  grid-template-areas:
    'pos  body foot'
    'pos  bar  bar';
  align-items: center;
  gap: var(--space-2) var(--space-3);
  width: 100%;
  min-width: 0;
  padding: var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--color-border-hairline);
  text-align: left;
  transition: background var(--t-fast);
}

.dept-rank__item:last-child { border-bottom: 0; }
.dept-rank__item:hover { background: var(--color-surface-sunk); }

.dept-rank__pos {
  grid-area: pos;
  align-self: start;
  padding-top: 2px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-quiet);
  font-variant-numeric: tabular-nums;
}

.dept-rank__item:first-child .dept-rank__pos { color: var(--color-brand); }

.dept-rank__body { grid-area: body; min-width: 0; }

.dept-rank__name {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dept-rank__branch {
  display: block;
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  margin-top: 1px;
}

.dept-rank__amount {
  grid-area: foot;
  text-align: right;
  min-width: 0;
  white-space: nowrap;
}

.dept-rank__amount-value {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.dept-rank__amount-label {
  display: block;
  font-size: var(--text-micro);
  color: var(--color-text-quiet);
}

.dept-rank__bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.dept-rank__tags {
  display: flex;
  gap: var(--space-3);
  flex: none;
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   ГЛАВНАЯ · Требует внимания
   ========================================================================== */

.attention { display: grid; gap: var(--space-1); }

.attention__item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background var(--t-fast);
}

.attention__item:hover { background: var(--color-surface-sunk); }

.attention__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
  color: var(--color-text-secondary);
}

.attention__icon--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.attention__icon--brand   { background: var(--color-brand-soft);   color: var(--color-brand); }
.attention__icon--info    { background: var(--color-info-soft);    color: var(--color-info); }
.attention__icon--success { background: var(--color-success-soft); color: var(--color-success); }

.attention__title { font-size: var(--text-sm); line-height: 1.35; }
.attention__note  { font-size: var(--text-micro); color: var(--color-text-tertiary); margin-top: 1px; }

.attention__count {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}

.attention__arrow { color: var(--color-text-quiet); transition: transform var(--t-fast), color var(--t-fast); }
.attention__item:hover .attention__arrow { transform: translateX(2px); color: var(--color-brand); }

/* ==========================================================================
   ЗАЯВКИ · панель фильтров
   ========================================================================== */

.filters {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.filters__bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  flex-wrap: wrap;
}

.filters__search { flex: 1; min-width: 220px; max-width: 420px; }

.filters__spacer { flex: 1; }

.filters__count {
  font-size: var(--text-2xs);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.filters__count strong { color: var(--color-text-primary); font-weight: var(--weight-semibold); }

.filters__advanced {
  padding: 0 var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-sunk);
}

.filters__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5) 0;
}

.filters__chips {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-brand-softer);
}

/* ==========================================================================
   ЗАЯВКИ · Kanban
   ========================================================================== */

/* --- Панель управления представлением ----------------------------------- */
.apps-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-width: 0;
}

/* --- Горизонтальная навигация доски -------------------------------------- */
.kanban-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.kanban-nav.is-idle { opacity: 0.4; pointer-events: none; }

.kanban-nav__hint {
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Индикатор положения: показывает, какая часть доски сейчас видна */
.kanban-nav__track {
  position: relative;
  width: 108px;
  height: 4px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--color-surface-warm);
  overflow: hidden;
}

.kanban-nav__thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  opacity: 0.55;
  transition: left var(--t-fast) linear, width var(--t-fast);
}

.kanban-nav__btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  transition: background var(--t-fast), color var(--t-fast),
              border-color var(--t-fast), opacity var(--t-fast);
}

.kanban-nav__btn:hover:not(:disabled) {
  background: var(--color-surface-soft);
  color: var(--color-text-primary);
  border-color: rgba(23, 22, 20, 0.2);
}

.kanban-nav__btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

/* --- Доска ---------------------------------------------------------------
   Прокручивается только этот контейнер. Страница вбок не едет, потому что
   .kanban-scroll ограничен шириной контентной колонки.                      */
.kanban-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-padding-left: var(--space-1);
  -webkit-overflow-scrolling: touch;   /* инерционный скролл на iOS */
  overscroll-behavior-x: contain;      /* скролл доски не «протекает» на страницу */
  padding-bottom: var(--space-2);
}

.kanban-scroll:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

.kanban {
  display: flex;
  gap: var(--space-4);
  align-items: stretch;
  width: max-content;
}

/* Стадия — самостоятельный вертикальный контейнер с лёгкой границей */
.kanban__col {
  flex: 0 0 auto;
  width: 300px;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  max-height: clamp(340px, calc(100vh - 330px), 900px);
  background: var(--color-surface-sunk);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;                    /* скругление обрезает содержимое */
}

.kanban__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.kanban__head-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.kanban__title {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-primary);
  white-space: nowrap;
}

.kanban__count {
  flex: none;
  font-size: var(--text-micro);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-surface-soft);
}

.kanban__sum {
  flex: none;
  font-size: var(--text-micro);
  color: var(--color-text-quiet);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Карточки прокручиваются внутри стадии — страница не растягивается
   на высоту самой длинной колонки. */
.kanban__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
}

.kanban__empty {
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: var(--text-micro);
  color: var(--color-text-quiet);
}

/* --- Карточка заявки в Kanban -------------------------------------------
   Все карточки одной высоты независимо от стадии и объёма текста.
   Разброс давали два места: имя клиента (одна строка против двух) и ряд
   значков, который то был, то отсутствовал. Поэтому под имя всегда
   резервируются ровно две строки, а ряду значков задана постоянная высота.
   Нижний блок прижат margin-top:auto — карточка не «схлопывается».        */
.app-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 306px;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: left;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.app-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.app-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 20px;                    /* ряд значков не меняет высоту */
  margin-bottom: var(--space-2);
}

/* Внутренности карточки — <span>, поэтому им нужен явный display:block,
   иначе вертикальные отступы и высота изображения не применяются. */
.app-card__object,
.app-card__media { display: block; }

.app-card__id {
  font-size: var(--text-micro);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-quiet);
  letter-spacing: 0.01em;
}

.app-card__flags { display: flex; align-items: center; gap: var(--space-1); }

.app-card__flag {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-xs);
  color: var(--color-text-tertiary);
}

.app-card__flag--attention { background: var(--color-warning-soft); color: var(--color-warning); }
.app-card__flag--message   { background: var(--color-brand-soft);   color: var(--color-brand); }

/* Ровно две строки под имя клиента: длинное переносится и обрезается
   по второй строке, короткое занимает то же место — карточки совпадают. */
.app-card__client {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  min-height: calc(2 * 1.35em);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.35;
  margin-bottom: var(--space-1);
}

.app-card__object {
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  line-height: 1.4;
  min-height: 1.4em;
  margin-bottom: var(--space-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card__media {
  flex: none;
  margin: 0 calc(var(--space-4) * -1) var(--space-3);
  height: 96px;
  overflow: hidden;
  background: var(--color-surface-warm);
}

.app-card__media img { width: 100%; height: 100%; object-fit: cover; }

/* margin-top:auto прижимает финансовый блок и подпись к низу карточки —
   нижние строки всех карточек колонки выстраиваются на одной линии. */
.app-card__sums {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-hairline);
}

.app-card__amount {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}

.app-card__of {
  font-size: var(--text-micro);
  color: var(--color-text-quiet);
  font-variant-numeric: tabular-nums;
}

.app-card__foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  min-width: 0;
}

.app-card__mgr {
  font-size: var(--text-micro);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.app-card__date {
  margin-left: auto;
  flex: none;
  font-size: var(--text-micro);
  color: var(--color-text-quiet);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   КАРТОЧКА ЗАЯВКИ
   ========================================================================== */

.appd__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.appd__id {
  font-size: var(--text-2xs);
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.appd__client {
  margin-top: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tighter);
  line-height: 1.14;
}

.appd__object {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.appd__status { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3); }

.appd__sums {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-5);
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-border);
}

/* --- Таймлайн стадий ----------------------------------------------------- */
.timeline {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: var(--space-6) 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.timeline::-webkit-scrollbar { display: none; }

.timeline__step {
  position: relative;
  flex: 1;
  min-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}

.timeline__dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  color: transparent;
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
}

.timeline__step.is-done .timeline__dot {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.timeline__step.is-current .timeline__dot {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
  box-shadow: 0 0 0 4px var(--color-brand-tint);
}

.timeline__step.is-declined .timeline__dot {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

/* Соединительная линия */
.timeline__step::before {
  content: '';
  position: absolute;
  top: 11px;
  right: 50%;
  left: -50%;
  height: 1.5px;
  background: var(--color-border-strong);
}

.timeline__step:first-child::before { display: none; }
.timeline__step.is-done::before,
.timeline__step.is-current::before { background: var(--color-success); }

.timeline__label {
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  line-height: 1.3;
  padding-inline: var(--space-1);
}

.timeline__step.is-current .timeline__label { color: var(--color-text-primary); font-weight: var(--weight-medium); }
.timeline__step.is-done .timeline__label { color: var(--color-text-secondary); }

.timeline__date {
  font-size: 10px;
  color: var(--color-text-quiet);
  font-variant-numeric: tabular-nums;
}

/* --- Блок «Что требуется сейчас» ----------------------------------------- */
.required-now {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-surface-soft);
}

.required-now--action { background: var(--color-warning-soft); }
.required-now--calm   { background: var(--color-success-soft); }

.required-now__icon { flex: none; margin-top: 1px; color: var(--color-text-secondary); }
.required-now--action .required-now__icon { color: var(--color-warning); }
.required-now--calm .required-now__icon   { color: var(--color-success); }

.required-now__title {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.required-now__text {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
}

/* --- Чат ----------------------------------------------------------------- */
.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat__feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) 0;
  max-height: 520px;
  overflow-y: auto;
}

.msg { display: flex; gap: var(--space-3); max-width: 88%; }

.msg--own { margin-left: auto; flex-direction: row-reverse; }

.msg__body { min-width: 0; }

.msg__meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
}

.msg--own .msg__meta { justify-content: flex-end; }

.msg__author { font-weight: var(--weight-medium); color: var(--color-text-secondary); }

.msg__bubble {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-soft);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  overflow-wrap: anywhere;
}

.msg--own .msg__bubble { background: var(--color-brand-soft); color: var(--color-brand-dark); }

.msg__attach {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: var(--text-2xs);
  transition: border-color var(--t-fast);
}

.msg__attach:hover { border-color: var(--color-border-strong); }
.msg__attach svg { flex: none; color: var(--color-text-tertiary); }
.msg__attach-name { font-weight: var(--weight-medium); }
.msg__attach-size { color: var(--color-text-quiet); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Системное событие */
.msg--system { max-width: 100%; justify-content: center; }

.msg--system .msg__bubble {
  background: transparent;
  border: 1px dashed var(--color-border-strong);
  color: var(--color-text-tertiary);
  font-size: var(--text-2xs);
  text-align: center;
  padding: var(--space-2) var(--space-4);
}

.chat__composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.chat__composer .textarea { min-height: 44px; max-height: 160px; }

/* --- Вкладка «Объект» ---------------------------------------------------- */
.object-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 8;
  background: var(--color-surface-warm);
}

.object-hero img { width: 100%; height: 100%; object-fit: cover; }

.object-hero__tag {
  position: absolute;
  left: var(--space-5);
  top: var(--space-5);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
}

/* --- Вкладка «Этапы» ----------------------------------------------------- */
.stage-log { display: grid; gap: 0; }

.stage-log__row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1.3fr) 110px 92px minmax(0, 1.4fr);
  gap: var(--space-4);
  align-items: start;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border-hairline);
  font-size: var(--text-sm);
}

.stage-log__row:last-child { border-bottom: 0; }

.stage-log__marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  padding-top: 3px;
}

.stage-log__marker::after {
  content: '';
  position: absolute;
  top: 18px;
  bottom: calc(var(--space-4) * -1 - 4px);
  width: 1px;
  background: var(--color-border-strong);
}

.stage-log__row:last-child .stage-log__marker::after { display: none; }

.stage-log__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--stage-color, var(--color-text-quiet));
  box-shadow: 0 0 0 3px var(--color-surface);
  z-index: 1;
}

.stage-log__name { font-weight: var(--weight-medium); }
.stage-log__date,
.stage-log__dur { font-variant-numeric: tabular-nums; color: var(--color-text-secondary); font-size: var(--text-2xs); }
.stage-log__comment { font-size: var(--text-2xs); color: var(--color-text-secondary); line-height: var(--leading-relaxed); }
.stage-log__owner { font-size: var(--text-micro); color: var(--color-text-quiet); margin-top: 2px; }

/* --- Вкладка «Вознаграждение» -------------------------------------------- */
.reward-figure {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.reward-figure__value {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1;
  font-variant-numeric: proportional-nums;
}

/* ==========================================================================
   НОВАЯ ЗАЯВКА · мастер
   ========================================================================== */

.wizard { max-width: 940px; margin-inline: auto; }

.wizard__steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.wizard__step {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-3);
  row-gap: 0;
  padding-top: var(--space-4);
  text-align: left;
  border-top: 2px solid var(--color-border-strong);
  transition: border-color var(--t-base);
}

.wizard__step.is-done    { border-top-color: var(--color-success); }
.wizard__step.is-current { border-top-color: var(--color-brand); }

.wizard__step-num {
  flex: 0 0 auto;
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-quiet);
}

.wizard__step.is-current .wizard__step-num { color: var(--color-brand); }
.wizard__step.is-done .wizard__step-num { color: var(--color-success); }

.wizard__step-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-tertiary);
}

.wizard__step.is-current .wizard__step-name,
.wizard__step.is-done .wizard__step-name { color: var(--color-text-primary); }

.wizard__panel { animation: rise-in var(--dur-slow) var(--ease-soft) both; }

.wizard__title {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tighter);
}

.wizard__lede {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 62ch;
  line-height: var(--leading-relaxed);
}

.wizard__form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-7);
}

.wizard__form .field--full { grid-column: 1 / -1; }

.wizard__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

/* Резюме на шаге проверки */
.review-block { display: grid; gap: var(--space-2); }

.review-block + .review-block {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.review-block__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
}

/* Успех */
.success {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  animation: rise-in var(--dur-slower) var(--ease-soft) both;
}

.success__mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-success-soft);
  color: var(--color-success);
  margin-bottom: var(--space-2);
}

.success__title {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1.1;
}

.success__id {
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
  font-size: var(--text-h3);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.success__text {
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  max-width: 52ch;
  line-height: var(--leading-relaxed);
}

/* ==========================================================================
   АНАЛИТИКА
   ========================================================================== */

.metric-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.metric-hero__value {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 0.98;
  font-variant-numeric: proportional-nums;
  color: var(--color-brand);
}

.metric-hero__label {
  margin-top: var(--space-3);
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  max-width: 34ch;
  line-height: var(--leading-relaxed);
}

.forecast-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border-hairline);
}

.forecast-row:last-child { border-bottom: 0; }

.forecast-row__horizon { font-size: var(--text-sm); font-weight: var(--weight-medium); }

.forecast-row__track {
  height: 26px;
  border-radius: var(--radius-xs);
  background: var(--color-surface-soft);
  overflow: hidden;
}

.forecast-row__bar {
  height: 100%;
  border-radius: var(--radius-xs);
  background: var(--chart-primary);
  transition: width var(--dur-slower) var(--ease-soft);
}

.forecast-row__value {
  min-width: 100px;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   ПОДРАЗДЕЛЕНИЯ
   ========================================================================== */

.branch-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-1);
}

.branch-strip__item {
  padding: var(--space-5);
  border-radius: var(--radius-md);
  text-align: left;
  transition: background var(--t-fast);
}

.branch-strip__item:hover { background: var(--color-surface-sunk); }
.branch-strip__item.is-active { background: var(--color-brand-softer); }

.branch-strip__name {
  display: block;
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.branch-strip__value {
  display: block;
  margin-top: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1;
  font-variant-numeric: proportional-nums;
}

.branch-strip__meter { margin-top: var(--space-4); }

/* ==========================================================================
   ЛИДЕРЫ · «Архитекторы сделок»
   ========================================================================== */

.leaders-hero {
  position: relative;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  background: var(--color-surface-ink);
  color: #fff;
  padding: var(--space-9) var(--space-8) var(--space-8);
  isolation: isolate;
}

.leaders-hero__media { position: absolute; inset: 0; z-index: 0; }
.leaders-hero__media img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; }

.leaders-hero__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(18, 17, 15, 0.86) 0%, rgba(18, 17, 15, 0.7) 46%, rgba(18, 17, 15, 0.92) 100%);
}

/* Заголовочный блок: слева — название и пояснение, справа — показатель
   активного режима. Показатель не влияет на положение заголовка (у него
   своя колонка), а на узких экранах переносится под него, оставаясь
   прижатым к правому краю. */
.leaders-hero__body {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-7);
}

.leaders-hero__lead { min-width: 0; flex: 1 1 22rem; }

.leaders-hero__metric {
  flex: none;
  margin-left: auto;
  text-align: right;
  max-width: 100%;
}

.leaders-hero__metric-label {
  display: block;
  font-size: var(--text-micro);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

/* Тонкая цифра — вторичная по отношению к заголовку: тот же шрифт, но
   заметно меньший кегль. Сумма не разрывается на две строки. */
.leaders-hero__metric-value {
  display: block;
  margin-top: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

.leaders-hero__title {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1.05;
  color: #fff;
}

.leaders-hero__lede {
  margin-top: var(--space-3);
  font-size: var(--text-body);
  color: rgba(255, 255, 255, 0.66);
  max-width: 54ch;
  line-height: var(--leading-relaxed);
}

/* Skyline: высота силуэта = реализованный объём */
.skyline {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 132px;
  margin-top: var(--space-8);
  padding-inline: var(--space-2);
}

.skyline__tower {
  position: relative;
  flex: 1;
  max-width: 44px;
  min-width: 10px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.1));
  transform-origin: bottom;
  animation: grow-y var(--dur-slower) var(--ease-soft) both;
  animation-delay: calc(var(--i, 0) * 26ms);
  transition: background var(--t-base);
}

.skyline__tower:hover { background: rgba(255, 255, 255, 0.42); }

.skyline__tower--top {
  background: linear-gradient(to top, var(--color-brand), rgba(147, 31, 43, 0.55));
}

.skyline__tower--top:hover { background: linear-gradient(to top, var(--color-brand-hover), rgba(147, 31, 43, 0.7)); }

/* Насечки этажей — архитектурная деталь */
.skyline__tower::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: repeating-linear-gradient(
    to top,
    rgba(18, 17, 15, 0.22) 0 1px,
    transparent 1px 7px
  );
  opacity: 0.7;
}

.skyline__caption {
  position: relative;
  z-index: 1;
  margin-top: var(--space-4);
  text-align: center;
  font-size: var(--text-micro);
  color: rgba(255, 255, 255, 0.48);
}

/* --- Карточки лидеров ---------------------------------------------------- */
.podium {
  display: grid;
  grid-template-columns: 1.24fr 1fr 1fr;
  gap: var(--space-5);
  align-items: stretch;
}

.leader-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  text-align: left;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}

.leader-card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* Первое место выделено композицией и глубиной, а не блеском */
.leader-card--first {
  background: var(--color-surface-ink);
  border-color: transparent;
  color: #fff;
  padding: var(--space-7);
}

.leader-card--first .leader-card__name { color: #fff; }
.leader-card--first .leader-card__where { color: rgba(255, 255, 255, 0.6); }
.leader-card--first .leader-card__stat-label { color: rgba(255, 255, 255, 0.52); }
.leader-card--first .leader-card__stat-value { color: #fff; }
.leader-card--first .leader-card__stats { border-top-color: rgba(255, 255, 255, 0.14); }

.leader-card__rank {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-quiet);
  margin-bottom: var(--space-5);
}

.leader-card--first .leader-card__rank { color: rgba(255, 255, 255, 0.5); }

.leader-card__rank strong {
  font-size: var(--text-h2);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  color: var(--color-brand);
}

.leader-card--first .leader-card__rank strong { color: #E8A3AB; }

.leader-card__person { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }

.leader-card__name {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  line-height: 1.15;
}

.leader-card--first .leader-card__name { font-size: var(--text-figure); }

.leader-card__where {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-2xs);
  color: var(--color-text-tertiary);
}

.leader-card__volume {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-figure);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1;
  font-variant-numeric: proportional-nums;
  margin-bottom: var(--space-2);
}

.leader-card--first .leader-card__volume { font-size: var(--text-display); }

.leader-card__volume-label {
  display: block;
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
}
.leader-card--first .leader-card__volume-label { color: rgba(255, 255, 255, 0.55); }

.leader-card__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.leader-card__stat-label {
  display: block;
  font-size: 10px;
  color: var(--color-text-quiet);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.leader-card__stat-value {
  display: block;
  margin-top: 3px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}

/* --- Номинации ----------------------------------------------------------- */
.nominations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: var(--space-4);
}

.nomination {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.nomination:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-sm); }

.nomination__title {
  font-size: var(--text-micro);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

.nomination__value {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-tighter);
  line-height: 1;
  font-variant-numeric: proportional-nums;
}

.nomination__foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-hairline);
  min-width: 0;
}

/* ==========================================================================
   Переключатель demo-роли
   ========================================================================== */

.role-switch {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  max-width: 260px;
}

.role-switch:hover { background: var(--color-surface-soft); }

.role-switch__body { min-width: 0; text-align: left; }

.role-switch__name {
  display: block;
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-switch__role {
  display: block;
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-switch__caret { flex: none; color: var(--color-text-quiet); }

/* Демонстрационная плашка в меню роли */
.demo-note {
  padding: var(--space-3);
  margin-top: var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--color-surface-soft);
  font-size: var(--text-micro);
  color: var(--color-text-tertiary);
  line-height: var(--leading-normal);
}
