/* css/aggregator-chat-v2.css — premium чат агрегатора; только #sec-chat / chat-v2 (aggregator-modern.html). */
/* ═══ AGGREGATOR #sec-chat — premium workspace (chat-v2) ═══ */
#sec-chat .chat-workspace.chat-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 100%;
}

#sec-chat .chat-hero.chat-m-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 20px;
  margin-bottom: 16px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: linear-gradient(145deg, #ffffff 0%, #f4f6ff 40%, #f8fafc 100%);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
}

#sec-chat .chat-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
  flex: 1 1 320px;
  min-width: 0;
}

#sec-chat .chat-hero-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

#sec-chat .chat-hero-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  flex: 1 1 220px;
  max-width: 420px;
}

#sec-chat .chat-hero-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(226, 232, 240, 0.85);
}

#sec-chat .chat-hero-kpi-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}

#sec-chat .chat-hero-kpi-val {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text, #0f172a);
}

#sec-chat .chat-hero-right#chatHeroStat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.65);
}

#sec-chat #chat-m-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

#sec-chat .chat-tabs-premium .chat-tab-btn {
  gap: 8px;
}

#sec-chat .chat-tab-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}

#sec-chat .chat-v2-folder-row {
  flex-wrap: wrap;
}

#sec-chat .chat-v2-folder-row .chat-folder-tab {
  flex: 1 1 calc(33.33% - 8px);
  min-width: 76px;
}

#sec-chat .chat-order-time {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted, #64748b);
  white-space: nowrap;
}

#sec-chat .chat-order-preview {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sec-chat .chat-panel-wrap {
  min-width: 0;
  min-height: 0;
}

#sec-chat #chat-conversation.chat-panel,
#sec-chat #support-conversation.chat-panel {
  flex: 1;
  min-height: 0;
  background: var(--card, #fff);
}

#sec-chat #chat-conversation #chat-conv-premium-card.chat-conv-premium-card {
  flex-shrink: 0;
}

body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conversation #chat-conv-premium-card.chat-conv-premium-card {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--card, #fff);
}

#sec-chat #chat-conversation .chat-panel-head {
  position: relative;
  z-index: 1;
  background: var(--card, #fff);
  border-bottom: 1px solid var(--line, #f1f5f9);
}

#sec-chat #support-conversation .chat-panel-head {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--card, #fff);
  border-bottom: 1px solid var(--line, #f1f5f9);
}

body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conversation .chat-panel-head.chat-conv-header--premium {
  border-bottom: 1px solid rgba(241, 245, 249, 0.95);
}

#sec-chat .chat-conv-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#sec-chat .chat-conv-name-row #chat-conv-name {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

#sec-chat .chat-conv-call-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(22, 163, 74, 0.35);
  border: 1px solid rgba(21, 128, 61, 0.35);
  box-sizing: border-box;
}

#sec-chat .chat-conv-call-btn[aria-hidden="true"] {
  display: none !important;
}

#sec-chat .chat-qa-chip--call {
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}

#sec-chat .chat-panel-head-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
}

#sec-chat .chat-panel-head-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#sec-chat #chat-conv-name {
  font-size: 15px;
  font-weight: 800;
  font-family: Manrope, system-ui, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(52vw, 280px);
}

#sec-chat .chat-panel-head.chat-conv-header--premium #chat-conv-name {
  max-width: 100%;
}

#sec-chat #chat-conv-avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  padding: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#sec-chat .chat-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#sec-chat .chat-v2-round-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  transition: background 0.15s ease;
}

#sec-chat .chat-v2-round-btn:hover {
  background: rgba(99, 102, 241, 0.18);
}

#sec-chat .chat-v2-round-btn--primary {
  background: rgba(99, 102, 241, 0.14);
}

#sec-chat .chat-v2-round-btn--danger {
  background: rgba(239, 68, 68, 0.09);
  color: #ef4444;
}

#sec-chat .chat-v2-round-btn--danger:hover {
  background: rgba(239, 68, 68, 0.16);
}

#sec-chat #chatMessages.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
}

#sec-chat .chat-rules-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted, #64748b);
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(254, 243, 199, 0.35);
}

#sec-chat .chat-input-row.chat-composer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border, #e5e7eb);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), var(--card, #fff));
}

#sec-chat .chat-input-row.chat-composer input {
  min-height: 44px;
}

#sec-chat .chat-input-row.chat-composer .chat-send-btn {
  min-width: 48px;
  min-height: 44px;
}

#sec-chat .chat-v2-news-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#sec-chat .chat-v2-news-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

#sec-chat .chat-v2-news-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

#sec-chat .chat-v2-icon-btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  min-height: 44px;
}

#sec-chat .chat-v2-news-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}

#sec-chat .chat-v2-news-loading {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

#sec-chat .chat-v2-support-split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 0;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  overflow: hidden;
  min-height: min(72vh, 620px);
  background: var(--card);
}

#sec-chat .chat-v2-support-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg, #f8fafc);
  overflow-y: auto;
  max-height: 72vh;
  padding: 10px 10px 14px;
}

#sec-chat .chat-v2-support-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--card);
}

#sec-chat #support-panel-empty.chat-v2-support-placeholder {
  flex: 1;
  min-height: 280px;
}

#sec-chat #support-conversation.chat-panel {
  flex: 1;
  min-height: 0;
}

#sec-chat #supportMessages.chat-messages {
  flex: 1;
  min-height: 200px;
  max-height: none;
  overflow-y: auto;
}

#sec-chat #gcRulesBanner {
  max-height: min(42vh, 320px) !important;
  border-radius: 14px !important;
  margin: 8px !important;
  padding: 14px 16px !important;
  font-size: 12px !important;
}

@media (min-width: 769px) {
  /* Базовая сетка; детальная высота/колонки — ниже body.cabinet-role-agg */
  body.cabinet-role-agg #sec-chat .chat-split {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    height: clamp(620px, calc(100dvh - 300px), 820px);
    min-height: clamp(620px, calc(100dvh - 300px), 820px);
    max-height: none;
    overflow: hidden;
    border-radius: 22px;
  }

  body.cabinet-role-agg #sec-chat .chat-split-sidebar {
    width: auto !important;
    min-width: 0;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.cabinet-role-agg #sec-chat .chat-split-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  #sec-chat .chat-hero-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  #sec-chat .chat-hero-right#chatHeroStat {
    width: 100%;
    align-items: flex-start;
  }

  #sec-chat .chat-split {
    display: flex;
    flex-direction: column;
    max-height: none;
    min-height: 0;
    border-radius: 16px;
  }

  #sec-chat .chat-split-sidebar {
    width: 100% !important;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  #sec-chat .chat-split.conv-open .chat-split-sidebar {
    display: none;
  }

  /* Высоту .chat-split-main задаёт mobile-profi-style (fixed + 100dvh). Не переопределять — иначе пустота снизу. */

  body.cabinet-role-agg.chat-conv-open.profi-mobile-ready .app-main {
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
  }

  body.cabinet-role-agg.chat-conv-open #mobileBottomNav,
  body.cabinet-role-agg.chat-conv-open .mobile-bottom-nav,
  body.cabinet-role-agg.chat-conv-open .agg-mobile-bottom-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.cabinet-role-agg.chat-conv-open #maint-badge {
    bottom: auto !important;
    top: max(12px, env(safe-area-inset-top, 0px)) !important;
    right: 10px !important;
    z-index: 260 !important;
    max-width: min(200px, calc(100vw - 24px));
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conv-premium-card.chat-conv-premium-card {
    margin: 8px 10px 6px;
    border-radius: 20px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.95);
    overflow: hidden;
  }

  /* Premium шапка открытого диалога: одна строка + текстовый блок с ellipsis */
  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-panel-head.chat-conv-header--premium .chat-panel-head-row {
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 10px 10px 8px !important;
    border-bottom: 1px solid rgba(241, 245, 249, 0.95);
    background: transparent !important;
    box-shadow: none !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-panel-head.chat-conv-header--premium {
    background: transparent !important;
    border-bottom: none !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-panel-head-info {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conv-premium-meta.chat-conv-premium-meta {
    margin-left: 8px !important;
    margin-right: 8px !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-qa-refresh-desktop {
    display: none !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conv-sub {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.35 !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conv-name {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-rules-card {
    margin: 4px 8px !important;
    padding: 6px 8px !important;
    font-size: 10px !important;
    line-height: 1.35 !important;
  }

  /* Только при открытом диалоге: иначе display:flex !important ломает inline display:none */
  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conversation.chat-panel {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chatMessages.chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-input-row.chat-composer {
    position: relative !important;
    bottom: auto !important;
    flex-shrink: 0 !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
  }

  #sec-chat .chat-split .chat-conv-back {
    display: flex !important;
  }

  #sec-chat .chat-v2-support-split {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  #sec-chat .chat-v2-support-sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  #sec-chat .chat-v2-support-main {
    min-height: min(48vh, 420px);
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
}

/* Пузыри: перенос длинных строк (aggregator-modern #sec-chat) */
body.cabinet-role-agg #sec-chat .chat-msg {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: min(72%, calc(100vw - 48px));
  box-sizing: border-box;
}

/* Desktop: сетка чата без лишней «дырявости», скролл в ленте сообщений */
@media (min-width: 769px) {
  /*
   * Поиск + табы: mobile-profi-style задаёт .chat-m-search-wrap max-width:320px без media —
   * на desktop это даёт «узкую плашку». Перекрываем только агрегатор.
   */
  body.cabinet-role-agg #sec-chat .chat-workspace.chat-shell {
    max-width: min(1180px, 100%);
    margin-left: auto;
    margin-right: auto;
  }

  body.cabinet-role-agg #sec-chat .chat-hero.chat-m-hero {
    margin-bottom: 12px;
  }

  body.cabinet-role-agg #sec-chat #chat-m-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
    margin-bottom: 18px;
  }

  body.cabinet-role-agg #sec-chat .chat-m-search-wrap {
    width: min(560px, 100%) !important;
    max-width: min(560px, 100%) !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    align-self: center;
    margin: 0 auto 12px;
    box-sizing: border-box;
  }

  body.cabinet-role-agg #sec-chat .chat-m-search-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }

  body.cabinet-role-agg #sec-chat #chat-tabs.chat-tab-switcher {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: min(720px, 100%);
    margin: 0 auto 20px;
    gap: 10px;
    padding: 6px 10px;
    box-sizing: border-box;
  }

  body.cabinet-role-agg #sec-chat #chat-tabs .chat-tab-btn {
    flex: 0 1 auto;
    min-height: 40px;
    padding: 8px 16px;
  }

  body.cabinet-role-agg #sec-chat .chat-split-main.chat-panel-wrap {
    overflow: hidden !important;
    min-height: 0 !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conversation.chat-panel {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chatMessages.chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 14px 20px;
  }

  body.cabinet-role-agg #sec-chat .chat-msg {
    max-width: min(520px, 72%) !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conv-quick-actions.chat-conv-quick-actions--agg {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 10px;
    margin: 0;
    box-sizing: border-box;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat #chat-conv-quick-actions .chat-qa-chip {
    flex: 0 1 auto;
    min-height: 40px;
    padding: 0 12px;
    font-size: 12px;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-input-row.chat-composer {
    flex: 0 0 auto;
    position: relative;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-input-row.chat-composer input {
    min-height: 44px;
    border-radius: 12px;
    font-size: 14px;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-panel-head.chat-conv-header--premium .chat-head-actions-more > summary {
    display: none;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-panel-head.chat-conv-header--premium .chat-head-actions-more .chat-head-actions-more__panel {
    display: flex !important;
    position: static !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-panel-head.chat-conv-header--premium .chat-head-actions-more .chat-v2-round-btn {
    width: auto !important;
    min-height: 42px !important;
    height: auto !important;
    padding: 0 12px !important;
    gap: 8px !important;
    border-radius: 14px !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-head-chip-lbl {
    display: inline !important;
    font-size: 12px !important;
    font-weight: 700 !important;
  }

  body.cabinet-role-agg #sec-chat #chat-conv-premium-meta.chat-conv-premium-meta {
    margin-left: 14px;
    margin-right: 14px;
  }
}

/* ═══ Premium meta + «⋯» + быстрые кнопки (агрегатор) ═══ */
#sec-chat #chat-conv-premium-meta.chat-conv-premium-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 8px;
  padding: 8px 10px;
  margin: 0 10px 8px;
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.98));
  border: 1px solid rgba(226, 232, 240, 0.92);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

#sec-chat #chat-conv-premium-meta[hidden] {
  display: none !important;
}

#sec-chat .chat-conv-premium-meta__cell {
  min-width: 0;
  text-align: center;
}

#sec-chat .chat-conv-premium-meta__lbl {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
  margin-bottom: 2px;
}

#sec-chat .chat-conv-premium-meta__val {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sec-chat .chat-conv-quick-actions {
  display: none;
  gap: 8px;
  padding: 0 10px 10px;
  box-sizing: border-box;
}

#sec-chat .chat-qa-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 15px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text, #0f172a);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  white-space: nowrap;
  min-width: 0;
}

#sec-chat .chat-qa-chip i {
  font-size: 13px;
  opacity: 0.9;
}

#sec-chat .chat-qa-chip--primary {
  border-color: rgba(99, 102, 241, 0.35);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.1));
  color: #4f46e5;
}

#sec-chat .chat-qa-chip--ghost {
  background: rgba(248, 250, 252, 0.95);
  color: var(--muted, #64748b);
}

#sec-chat .chat-qa-chip--danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
}

#sec-chat .chat-panel-head .chat-head-actions-more {
  position: relative;
  flex-shrink: 0;
}

#sec-chat .chat-head-actions-more__summary {
  list-style: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(99, 102, 241, 0.1);
  color: #6366f1;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(226, 232, 240, 0.85);
}

#sec-chat .chat-head-actions-more__summary::-webkit-details-marker {
  display: none;
}

#sec-chat .chat-head-actions-more__panel--round {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  padding: 8px !important;
  min-width: 168px;
  border-radius: 15px !important;
  background: #fff !important;
  border: 1px solid rgba(226, 232, 240, 0.95) !important;
  box-shadow: 0 14px 44px rgba(15, 23, 42, 0.14) !important;
}

#sec-chat .chat-head-actions-more__panel--round .chat-v2-round-btn {
  width: 100% !important;
  justify-content: flex-start !important;
  padding: 0 12px !important;
  border-radius: 12px !important;
}

@media (max-width: 767.98px) {
  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-conv-quick-actions--agg {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px !important;
    padding: 0 8px 10px !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-conv-quick-actions--agg .chat-qa-chip {
    flex-direction: column !important;
    gap: 4px !important;
    min-height: 56px !important;
    padding: 8px 4px !important;
    font-size: 10px !important;
    white-space: normal !important;
    line-height: 1.2 !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-conv-quick-actions--agg .chat-qa-chip i {
    font-size: 15px !important;
  }
}

/* Курилка: скрыть заказный диалог (display:flex !important на desktop/mobile перебивает inline display:none) */
body.cabinet-role-agg.global-chat-open #sec-chat #chat-conversation.chat-panel {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  flex: 0 0 0 !important;
  pointer-events: none !important;
}

/* Курилка (#gcConversation) — flex-колонка в .chat-split-main */
#gcConversation.gc-conv-root {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
  position: relative;
  background: var(--card, #fff);
}

#gcConversation .gc-conv-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(241, 245, 249, 0.95);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 3px 16px rgba(15, 23, 42, 0.06);
}

#gcConversation #gcMessages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

#gcConversation #gcInputRow {
  flex-shrink: 0;
}

/* Этап 1: без открытого заказного треда скрываем панель целиком (перебивает гонки inline/CSS после close Help/Global). */
body.cabinet-role-agg:not(.chat-conv-open) #sec-chat #chat-conversation.chat-panel {
  display: none !important;
}

/* mobile-profi-style задаёт #chat-conv-actions-bar { display:flex !important } без .conv-open — глушим, пока split закрыт */
@media (max-width: 768px) {
  body.cabinet-role-agg #sec-chat .chat-split:not(.conv-open) #chat-conv-actions-bar {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Chat V3 — этап 2.2 (заметный premium workspace; только scoped, без JS)
   Scope: body.cabinet-role-agg #sec-chat .chat-v3-surface (= .chat-workspace)
   ═══════════════════════════════════════════════════════════════════════════ */

body.cabinet-role-agg #sec-chat.cabinet-section {
  background: linear-gradient(165deg, #eef2ff 0%, #f8fafc 42%, #e8edf5 100%);
}

body.cabinet-role-agg #sec-chat .chat-workspace.chat-v3-surface {
  box-sizing: border-box;
  margin: 0 auto;
  padding: 18px 18px 20px;
  max-width: min(1240px, 100%);
  border-radius: 24px;
  border: 1px solid rgba(199, 210, 254, 0.55);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 55%, #eef2ff 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 4px 6px rgba(15, 23, 42, 0.04),
    0 22px 48px rgba(79, 70, 229, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.75) inset;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-hero.chat-m-hero {
  margin-bottom: 8px;
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.05);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(238, 242, 255, 0.55) 48%,
    rgba(248, 250, 252, 0.98) 100%
  );
}

/* Toolbar + вкладки — одна «рейка» внутри карточки workspace */
body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-m-toolbar.chat-m-toolbar {
  margin-bottom: 0;
  padding: 14px 14px 12px;
  border-radius: 16px 16px 0 0;
  border: 1px solid rgba(226, 232, 240, 0.98);
  border-bottom: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(248, 250, 252, 0.92) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-tabs.chat-tabs-premium {
  margin-top: 4px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(241, 245, 249, 0.65);
  border: 1px solid rgba(226, 232, 240, 0.85);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-tab-orders.chat-v2-orders-tab {
  margin-top: 0;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-tab-orders .chat-split#chatSplit {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-tab-news.chat-v2-news-tab,
body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-tab-support.chat-v2-support-tab {
  margin-top: 0;
  border-radius: 0 0 18px 18px;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-top: none;
  background: var(--card, #fff);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-split#chatSplit {
  border-radius: 0 0 18px 18px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 10px 36px rgba(15, 23, 42, 0.07);
  background: var(--card, #fff);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-sidebar-head {
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.98) 0%, rgba(241, 245, 249, 0.55) 100%);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-order-list.chat-order-list {
  padding: 12px 12px 14px;
  gap: 0;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.35) 0%, rgba(255, 255, 255, 0.2) 100%);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.98);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item:hover {
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.12);
  transform: translateY(-1px);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.active {
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow:
    inset 4px 0 0 0 #6366f1,
    0 0 0 1px rgba(99, 102, 241, 0.12),
    0 8px 26px rgba(99, 102, 241, 0.14);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.chat-unread {
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.18) 0%,
    rgba(255, 255, 255, 0.9) 42%,
    rgba(240, 253, 244, 0.95) 100%
  );
  border-color: rgba(22, 163, 74, 0.85);
  box-shadow:
    inset 6px 0 0 0 rgba(21, 128, 61, 0.92),
    0 3px 18px rgba(34, 197, 94, 0.2),
    0 0 0 1px rgba(22, 163, 74, 0.22);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-av-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes agg-chat-unread-dot-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.98),
      0 2px 10px rgba(22, 163, 74, 0.5);
  }
  50% {
    opacity: 0.9;
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.98),
      0 2px 14px rgba(22, 163, 74, 0.62);
  }
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.chat-unread .chat-order-unread-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: linear-gradient(145deg, #22c55e 0%, #15803d 100%);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.98),
    0 2px 10px rgba(22, 163, 74, 0.55);
  z-index: 2;
  pointer-events: none;
  animation: agg-chat-unread-dot-pulse 2.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.chat-unread .chat-order-unread-dot {
    animation: none;
  }
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.chat-unread .chat-order-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #fff;
  background: linear-gradient(145deg, #16a34a 0%, #15803d 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 2px 10px rgba(22, 163, 74, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-info {
  flex: 1;
  min-width: 0;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-split-main#chatMain {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.75) 0%, rgba(255, 255, 255, 0.95) 45%, #f8fafc 100%);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface #chatMain .chat-empty-state,
body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-state {
  box-sizing: border-box;
  width: min(100% - 28px, 26rem);
  max-width: 26rem;
  min-width: min(100%, 320px);
  margin: auto;
  min-height: min(52vh, 460px);
  padding: 40px 32px;
  gap: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: linear-gradient(165deg, #ffffff 0%, #f8fafc 50%, #eef2ff 100%);
  box-shadow:
    0 14px 40px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.14) 0%, rgba(129, 140, 248, 0.08) 100%);
  border: 1px solid rgba(99, 102, 241, 0.22);
  color: #4f46e5;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.12);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-sub {
  max-width: 22rem;
  line-height: 1.6;
  font-size: 0.95rem;
  color: #64748b;
}

@media (min-width: 769px) {
  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-split#chatSplit {
    grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
    min-height: clamp(560px, calc(100dvh - 280px), 840px);
  }
}

@media (max-width: 768px) {
  body.cabinet-role-agg #sec-chat .chat-workspace.chat-v3-surface {
    padding: 12px 10px 14px !important;
    border-radius: 18px !important;
    margin-left: 0;
    margin-right: 0;
    max-width: 100% !important;
    border-color: rgba(199, 210, 254, 0.45) !important;
    box-shadow:
      0 10px 28px rgba(15, 23, 42, 0.07),
      0 0 0 1px rgba(255, 255, 255, 0.65) inset !important;
  }

  body.cabinet-role-agg.chat-conv-open #sec-chat .chat-workspace.chat-v3-surface {
    padding: 8px 6px 10px !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface #chat-m-toolbar.chat-m-toolbar {
    border-radius: 14px 14px 0 0 !important;
    padding: 12px 10px 10px !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item {
    margin-bottom: 10px !important;
    padding: 14px 12px 14px 14px !important;
    border-radius: 16px !important;
    border: 1px solid rgba(226, 232, 240, 0.98) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05) !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.active {
    box-shadow:
      inset 4px 0 0 0 #6366f1,
      0 4px 14px rgba(99, 102, 241, 0.12) !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.chat-unread {
    background: linear-gradient(
      135deg,
      rgba(34, 197, 94, 0.2) 0%,
      rgba(255, 255, 255, 0.92) 42%,
      rgba(240, 253, 244, 0.96) 100%
    ) !important;
    border-color: rgba(22, 163, 74, 0.88) !important;
    box-shadow:
      inset 6px 0 0 0 rgba(21, 128, 61, 0.92),
      0 3px 16px rgba(34, 197, 94, 0.18),
      0 0 0 1px rgba(22, 163, 74, 0.24) !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-order-item.chat-unread .chat-order-unread-badge {
    color: #fff !important;
    background: linear-gradient(145deg, #16a34a 0%, #15803d 100%) !important;
    border: 1px solid rgba(34, 197, 94, 0.55) !important;
    box-shadow:
      0 2px 10px rgba(22, 163, 74, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface #chatMain .chat-empty-state,
  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-state {
    width: min(100% - 20px, 26rem) !important;
    max-width: none !important;
    min-width: min(100%, 280px) !important;
    min-height: min(46vh, 380px) !important;
    padding: 32px 20px !important;
    margin: 12px auto !important;
    border-radius: 18px !important;
    border: 1px solid rgba(226, 232, 240, 0.95) !important;
    background: linear-gradient(165deg, #ffffff 0%, #f1f5f9 100%) !important;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07) !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-icon {
    width: 88px !important;
    height: 88px !important;
    font-size: 32px !important;
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-title {
    font-size: 1.15rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Chat V3 polish — Phase 1 (CSS-only). Scoped to .chat-v3-surface where noted.
   Bubbles / composer / quick chips / empty state. No DOM/JS changes.
   ═══════════════════════════════════════════════════════════════════════════ */

body.cabinet-role-agg #sec-chat .chat-v3-surface #chatMessages.chat-messages {
  gap: 10px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg {
  padding: 11px 15px 10px;
  border-radius: 18px;
  line-height: 1.55;
  font-size: 14px;
  border: 1px solid transparent;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.055);
  transition: box-shadow 0.18s ease, transform 0.14s ease, border-color 0.18s ease;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.incoming {
  align-self: flex-start;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: var(--text, #0f172a);
  border-color: rgba(226, 232, 240, 0.92);
  border-bottom-left-radius: 6px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.outgoing {
  align-self: flex-end;
  background: linear-gradient(145deg, #6366f1 0%, #4f46e5 48%, #6d28d9 100%);
  color: #fff;
  border-color: rgba(79, 70, 229, 0.38);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 18px rgba(79, 70, 229, 0.2);
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.incoming .chat-msg-time {
  color: var(--muted, #64748b);
  opacity: 0.9;
  font-weight: 600;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.outgoing .chat-msg-time {
  color: rgba(255, 255, 255, 0.88);
  opacity: 1;
  font-weight: 600;
}

@media (hover: hover) {
  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.incoming:hover {
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.075);
  }

  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.outgoing:hover {
    box-shadow: 0 6px 24px rgba(79, 70, 229, 0.26);
  }
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg:active {
  transform: scale(0.992);
}

@media (min-width: 769px) {
  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg {
    max-width: min(560px, 76%);
  }
}

@media (max-width: 768px) {
  body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg {
    max-width: min(86%, calc(100% - 22px));
    padding: 10px 13px 9px;
  }
}

/* Composer: input + send (order thread only — inside #chat-conversation) */
body.cabinet-role-agg #sec-chat #chat-conversation.chat-panel .chat-input-row.chat-composer input {
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.98);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.cabinet-role-agg #sec-chat #chat-conversation.chat-panel .chat-input-row.chat-composer input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

body.cabinet-role-agg #sec-chat #chat-conversation.chat-panel .chat-input-row.chat-composer .chat-send-btn {
  border-radius: 14px;
  border: 1px solid rgba(67, 56, 202, 0.45);
  background: linear-gradient(145deg, #6366f1 0%, #4f46e5 55%, #4338ca 100%);
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.32);
  transition: box-shadow 0.18s ease, transform 0.12s ease, filter 0.15s ease;
}

body.cabinet-role-agg #sec-chat #chat-conversation.chat-panel .chat-input-row.chat-composer .chat-send-btn:hover {
  filter: brightness(1.04);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.36);
}

body.cabinet-role-agg #sec-chat #chat-conversation.chat-panel .chat-input-row.chat-composer .chat-send-btn:active {
  transform: scale(0.97);
  filter: brightness(0.97);
}

/* Quick actions: spacing + interaction */
body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-conv-quick-actions {
  gap: 10px;
}

#sec-chat .chat-qa-chip {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease, background 0.16s ease;
}

@media (hover: hover) {
  #sec-chat .chat-qa-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.09);
  }
}

#sec-chat .chat-qa-chip:active {
  transform: translateY(0) scale(0.98);
}

/* Empty state: typography (structure unchanged) */
body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-icon {
  line-height: 1;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-title {
  text-wrap: balance;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-empty-sub {
  text-wrap: balance;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Chat V3 — Phase 2 (classed templates). Scoped to .chat-v3-surface.
   ═══════════════════════════════════════════════════════════════════════════ */

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-date-sep {
  text-align: center;
  margin: 14px 0 8px;
  flex-shrink: 0;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-date-sep__pill {
  display: inline-block;
  background: var(--bg-alt, #f1f5f9);
  color: var(--muted, #94a3b8);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  word-break: break-word;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg-system.chat-msg-system--order-info {
  margin: 12px auto;
  max-width: min(340px, calc(100% - 16px));
  box-sizing: border-box;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1.5px solid #a5b4fc;
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  flex-shrink: 0;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg-system__title {
  font-size: 10px;
  font-weight: 800;
  color: #4f46e5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg-system__line {
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg-system--order-info > .chat-msg-system__line:last-of-type {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty {
  padding: 20px 16px 8px;
  box-sizing: border-box;
  max-width: 100%;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__card {
  background: linear-gradient(135deg, #f0f4ff, #e8eeff);
  border: 1.5px solid #c7d2fe;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__card > .chat-thread-empty__sub:first-of-type {
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__icon {
  margin-right: 6px;
  opacity: 0.95;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__title {
  font-size: 15px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 4px;
  line-height: 1.35;
  word-break: break-word;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__card > .chat-thread-empty__sub:not(:first-of-type):not(:last-of-type) {
  font-size: 12px;
  color: #475569;
  margin-bottom: 3px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__card > .chat-thread-empty__sub:not(:first-of-type) .fa-map-marker-alt {
  color: #6366f1;
  margin-right: 4px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__card > .chat-thread-empty__sub:not(:first-of-type) .fa-circle {
  color: #10b981;
  font-size: 7px;
  vertical-align: middle;
  margin-right: 5px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty__card > .chat-thread-empty__sub:last-of-type {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
  margin-bottom: 0;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty > .chat-thread-empty__sub:last-child {
  color: var(--muted, #64748b);
  text-align: center;
  font-size: 13px;
  padding: 8px 0 16px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-thread-empty > .chat-thread-empty__sub:last-child .fa-lock-open {
  margin-right: 5px;
  opacity: 0.4;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg-sender {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary, #6366f1);
  margin-bottom: 2px;
  line-height: 1.25;
  word-break: break-word;
}

/* Chat V3 — Phase 2b: stacked message groups (same sender / day / side). */
body.cabinet-role-agg #sec-chat .chat-v3-surface #chatMessages.chat-messages .chat-msg.chat-msg--continued {
  margin-top: -6px;
}

body.cabinet-role-agg #sec-chat .chat-v3-surface .chat-msg.chat-msg--continued .chat-msg-sender {
  display: none;
}
