/* ═══════════════════════════════════════════════════════════════════════════
   AI Workspace Chat — полноценный чат-бот в Haze shell
   ═══════════════════════════════════════════════════════════════════════════ */

.ai-chat-container {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 140px);
  max-height: min(800px, 100%);
}

/* Командный центр: не режем чат потолком 800px — лента занимает высоту колонки */
.gov-cmd-chat .ai-chat-container,
.gov-a4--chat.ai-chat-container,
#aiChatContainer.ai-chat-container {
  height: 100%;
  max-height: none;
  min-height: 0;
  border-radius: 16px;
  background: var(--surface, #1c252e);
  border: 1px solid var(--border, rgba(255,255,255,.06));
  overflow: hidden;
}

/* ── Chat sidebar ─────────────────────────────────────────────────────── */

.ai-chat-sidebar {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid var(--border, rgba(255,255,255,.06));
  display: flex;
  flex-direction: column;
  background: var(--bg, #141a21);
}

.ai-chat-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.ai-chat-sidebar__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted, #8899aa);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.ai-chat-sidebar__new {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--accent, #ed5b2f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s;
}

.ai-chat-sidebar__new:hover { opacity: .85; }

.ai-chat-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.ai-chat-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
}

.ai-chat-list__item:hover {
  background: var(--surface-hover, rgba(255,255,255,.04));
}

.ai-chat-list__item--active {
  background: var(--accent-muted, rgba(237,91,47,.14));
}

.ai-chat-list__item-role {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-muted, rgba(237,91,47,.14));
  color: var(--accent, #ed5b2f);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-list__item--contractor .ai-chat-list__item-role {
  background: rgba(56,152,236,.14);
  color: #3898ec;
}

.ai-chat-list__item-title {
  flex: 1;
  font-size: 13px;
  color: var(--fg, #e0e8f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-list__item-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--fg-dim, #667788);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  opacity: 0;
  transition: opacity .12s, color .12s;
}

.ai-chat-list__item:hover .ai-chat-list__item-del { opacity: 1; }
.ai-chat-list__item-del:hover { color: #e74c3c; }

/* Role switcher (admin) */
.ai-chat-sidebar__roles {
  padding: 10px 14px;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ai-chat-sidebar__roles-label {
  font-size: 11px;
  color: var(--fg-dim, #667788);
  width: 100%;
}

.ai-chat-role-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: transparent;
  color: var(--fg-muted, #8899aa);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}

.ai-chat-role-btn:hover {
  border-color: var(--accent, #ed5b2f);
  color: var(--accent, #ed5b2f);
}

/* ── Main chat area ───────────────────────────────────────────────────── */

.ai-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Body: messages + tools column ── */
.ai-chat-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.ai-chat-body .ai-chat-messages {
  flex: 1;
  min-width: 0;
}

/* ── Tools / Documents column ── */
.ai-chat-tools-col {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,.06);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-chat-tools-col__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #64748b);
  margin: 0 0 4px;
}

.ai-chat-tools-col__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-chat-tools-col__divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,.06);
  margin: 8px 0;
}

/* ── Inline docs panel (inside tools column) ── */
.ai-chat-docs-inline .gw-chat-docs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ai-chat-docs-inline .gw-chat-docs__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-chat-docs-inline .gw-chat-docs__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text, #e2e8f0);
  transition: background .15s;
}

.ai-chat-docs-inline .gw-chat-docs__item:hover {
  background: rgba(255,255,255,.06);
}

.ai-chat-docs-inline .gw-chat-docs__item.is-selected {
  background: rgba(99,102,241,.15);
  color: #818cf8;
}

.ai-chat-docs-inline .gw-chat-docs__num {
  font-weight: 600;
  color: var(--text-muted, #64748b);
  font-size: 11px;
  min-width: 20px;
}

.ai-chat-docs-inline .gw-chat-docs__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-docs-inline .gw-chat-docs__size {
  font-size: 10px;
  color: var(--text-muted, #64748b);
  white-space: nowrap;
}

.ai-chat-docs-inline .gw-chat-docs__hint {
  font-size: 10px;
  color: var(--text-muted, #64748b);
  margin-top: 4px;
  opacity: .7;
}

.ai-chat-docs-inline .gw-chat-docs__all-btn {
  background: none;
  border: none;
  color: #818cf8;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.ai-chat-docs-inline .gw-chat-docs__all-btn:hover {
  background: rgba(129,140,248,.1);
}

.gw-tools__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #64748b);
  margin: 0;
}

/* ── Documents modal ── */
.ai-chat-docs-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-docs-modal[hidden] {
  display: none;
}

.ai-chat-docs-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
}

.ai-chat-docs-modal__card {
  position: relative;
  background: var(--surface, #1c252e);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 20px;
  max-width: 420px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0,0,0,.3);
}

.ai-chat-docs-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ai-chat-docs-modal__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #e2e8f0);
}

.ai-chat-docs-modal__close {
  background: none;
  border: none;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.ai-chat-docs-modal__close:hover {
  background: rgba(255,255,255,.06);
}

.gw-chat-docs__list--modal {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gw-chat-docs__list--modal .gw-chat-docs__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #e2e8f0);
  transition: background .15s;
}

.gw-chat-docs__list--modal .gw-chat-docs__item:hover {
  background: rgba(255,255,255,.06);
}

.gw-chat-docs__list--modal .gw-chat-docs__item.is-selected {
  background: rgba(99,102,241,.15);
  color: #818cf8;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.ai-chat-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-muted, rgba(237,91,47,.14));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-header__avatar img {
  border-radius: 10px;
  object-fit: contain;
}

.ai-chat-header__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.ai-chat-header__tender-select {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.ai-chat-header__tender-label {
  font-size: 12px;
  color: var(--fg-muted, #8899aa);
  white-space: nowrap;
}

.ai-chat-header__tender-dropdown {
  font-size: 12px;
  background: rgba(255,255,255,.06);
  color: var(--fg, #e0e8f0);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  padding: 2px 8px;
  max-width: 260px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}

.ai-chat-header__tender-dropdown:hover,
.ai-chat-header__tender-dropdown:focus {
  border-color: rgba(100,180,255,.4);
}

.ai-chat-header__tender-dropdown option {
  background: #1a2332;
  color: #e0e8f0;
}

/* ── Messages ────────────────────────────────────────────────────────────── */

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.gov-a4--chat {
  position: relative;
}

.gov-a4--chat > .gov-a4__head.gov-chat-head,
.ws-desk-layout__main > .gov-a4__head.gov-chat-head {
  position: relative;
  z-index: 13;
}

.gov-a4__foot--chat {
  position: relative;
  z-index: 13;
}

.ai-chat-scroll-jump {
  position: absolute;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  z-index: 12;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: opacity 0.15s ease;
}

.ai-chat-scroll-jump:hover {
  background: rgba(30, 41, 59, 0.96);
  border-color: rgba(147, 197, 253, 0.65);
}

.ai-chat-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: aiChatFadeIn .25s ease;
}

@keyframes aiChatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-msg--ai {
  align-self: flex-start;
}

.ai-chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
  position: relative;
}

.ai-chat-msg--system {
  align-self: center;
  max-width: 92%;
}

.ai-chat-msg--system .ai-chat-msg__avatar {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-msg--system .ai-chat-msg__text {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid rgba(59, 130, 246, 0.45);
  font-size: 0.92em;
  color: var(--text-secondary, #64748b);
}

.ai-chat-msg--system .ai-chat-msg__time {
  text-align: center;
}

.ai-chat-msg__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
}

.ai-chat-msg--ai .ai-chat-msg__avatar {
  background: var(--accent-muted, rgba(237,91,47,.14));
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-msg--user .ai-chat-msg__avatar {
  background: var(--surface-hover, rgba(255,255,255,.08));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted, #8899aa);
}

.ai-chat-msg__content {
  min-width: 0;
}

.ai-chat-loading-skeleton {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 24px 16px;
  color: var(--fg-muted, #8899aa);
}
.ai-chat-loading-skeleton__text {
  margin: 0;
  font-size: 14px;
  opacity: 0.85;
}

.ai-chat-msg__text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-chat-msg--ai .ai-chat-msg__text {
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.06));
  border-top-left-radius: 4px;
  color: var(--fg, #e8edf2);
}

.ai-chat-msg--user .ai-chat-msg__text {
  background: var(--accent, #ed5b2f);
  color: #fff;
  border-top-right-radius: 4px;
}

.ai-chat-msg__text strong {
  font-weight: 600;
}

.ai-chat-msg__text em {
  font-style: italic;
  opacity: .8;
}

.ai-chat-msg__text code {
  background: rgba(255,255,255,.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ai-chat-msg--user .ai-chat-msg__text code {
  background: rgba(255,255,255,.2);
}

.ai-chat-msg__time {
  font-size: 11px;
  color: var(--fg-dim, #667788);
  margin-top: 4px;
}

.ai-chat-msg--user .ai-chat-msg__time {
  text-align: right;
}

.ai-chat-msg__stopped-note {
  font-size: 12px;
  font-style: italic;
  /* Было #667788 — почти невидимо на тёмном фоне без выделения */
  color: var(--fg-muted, #b8c5d4);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255,255,255,.18);
}

/* ── Feedback buttons (👍👎) ─────────────────────────────────────────── */

.feedback-buttons {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ai-chat-msg--ai:hover .feedback-buttons,
.feedback-buttons:focus-within {
  opacity: 1;
}

.feedback-btn {
  background: none;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.feedback-btn:hover {
  background: var(--surface-hover, rgba(255,255,255,.06));
}

.feedback-btn--like:hover,
.feedback-btn--like.feedback-btn--active {
  color: var(--accent-green, #4caf50);
  border-color: var(--accent-green, #4caf50);
}

.feedback-btn--dislike:hover,
.feedback-btn--dislike.feedback-btn--active {
  color: var(--accent-red, #f44336);
  border-color: var(--accent-red, #f44336);
}

.feedback-comment-box {
  margin-top: 6px;
  padding: 10px;
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 8px;
}

.feedback-comment-input {
  width: 100%;
  min-height: 48px;
  padding: 8px;
  background: var(--surface, rgba(0,0,0,.2));
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 6px;
  color: var(--fg, #e0e0e0);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.feedback-comment-input::placeholder {
  color: var(--fg-dim, #667788);
}

.feedback-comment-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  justify-content: flex-end;
}

.feedback-cancel-btn,
.feedback-send-btn {
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

/* Дисклеймер фидбека — под формой комментария */
.feedback-disclaimer {
  margin: 6px 0 0 0;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--fg-dim, #667788);
  background: rgba(255, 193, 7, 0.06);
  border-left: 2px solid rgba(255, 193, 7, 0.3);
  border-radius: 0 4px 4px 0;
  line-height: 1.4;
}

.feedback-cancel-btn {
  background: var(--surface-hover, rgba(255,255,255,.08));
  color: var(--fg-dim, #667788);
}

.feedback-cancel-btn:hover {
  background: rgba(255,255,255,.12);
}

.feedback-send-btn {
  background: var(--accent, #ed5b2f);
  color: #fff;
}

.feedback-send-btn:hover {
  background: var(--accent-hover, #d44e26);
}

/* ── Typing indicator ────────────────────────────────────────────────────── */

.ai-chat-typing {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 85%;
}

.ai-chat-typing__dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.06));
  border-radius: 14px;
  border-top-left-radius: 4px;
}

.ai-chat-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-muted, #8899aa);
  animation: aiChatBounce 1.4s infinite ease-in-out;
}

.ai-chat-typing__dot:nth-child(2) { animation-delay: .2s; }
.ai-chat-typing__dot:nth-child(3) { animation-delay: .4s; }

@keyframes aiChatBounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Tool status ─────────────────────────────────────────────────────────── */

.ai-chat-tools {
  padding: 0 16px;
}

.ai-chat-tools__status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
  font-size: 13px;
  color: var(--accent, #ed5b2f);
  animation: aiChatFadeIn .2s ease;
}

.ai-chat-tools__status .ai-chat-tools__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: aiChatSpin .7s linear infinite;
}

@keyframes aiChatSpin {
  to { transform: rotate(360deg); }
}

.ai-chat-tools__progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.ai-chat-tools__progress-bar {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  overflow: hidden;
}

.ai-chat-tools__progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #ed5b2f);
  transition: width 0.35s ease;
}

.ai-chat-tools__progress-label {
  font-size: 12px;
  color: var(--accent, #ed5b2f);
}

.ai-chat-reconnect-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  font-size: 13px;
  animation: aiChatFadeIn .25s ease;
}

.ai-chat-reconnect-banner__btn {
  flex-shrink: 0;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent, #ed5b2f);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ai-chat-reconnect-banner__btn:hover {
  filter: brightness(1.05);
}

.ai-chat-context-banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 16px 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, #3b82f6 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #3b82f6 28%, transparent);
  font-size: 13px;
  line-height: 1.45;
  color: var(--fg, #e8edf2);
  animation: aiChatFadeIn .25s ease;
}

.ai-chat-context-banner__text {
  margin: 0;
}

.ai-chat-context-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chat-context-banner__btn {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.ai-chat-context-banner__btn--primary {
  background: var(--accent, #ed5b2f);
  color: #fff;
}

.ai-chat-context-banner__btn--primary:hover {
  filter: brightness(1.05);
}

.ai-chat-context-banner__btn--ghost {
  background: transparent;
  color: var(--fg-muted, #8899aa);
  border: 1px solid var(--border, rgba(255,255,255,.12));
}

.ai-chat-context-banner__btn--ghost:hover {
  color: var(--fg, #e8edf2);
}

/* ── File preview ────────────────────────────────────────────────────────── */

.ai-chat-files {
  padding: 0 16px 8px;
  flex: 0 0 auto;
  min-height: 0;
  position: relative;
  z-index: 12;
}

.ai-chat-files[hidden] {
  display: none !important;
}

.ai-chat-files:not([hidden]) {
  display: block;
}

.ai-chat-files__list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-chat-file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--gov-surface-muted, var(--surface-hover, rgba(255,255,255,.08)));
  border: 1px solid var(--gov-border, var(--border, rgba(255,255,255,.16)));
  font-size: 12px;
  color: var(--gov-text, var(--fg, #e8edf2));
  max-width: 240px;
}

.ai-chat-file-chip__icon {
  color: var(--accent, #ed5b2f);
  flex-shrink: 0;
}

.ai-chat-file-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-file-chip__size {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--gov-muted, var(--fg-muted, #8899aa));
}

.ai-chat-file-chip__remove {
  background: none;
  border: none;
  color: var(--fg-muted, #8899aa);
  cursor: pointer;
  padding: 0 0 0 4px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.ai-chat-file-chip__remove:hover {
  color: var(--accent, #ed5b2f);
}

/* ── KP Workflow bar (CHAT-KP-WORKFLOW-1) ───────────────────────────────── */

.ai-chat-kp-workflow {
  margin: 0 0 6px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(237, 91, 47, 0.28);
  background: rgba(237, 91, 47, 0.06);
}

.ai-chat-kp-workflow__details {
  margin: 0;
}

.ai-chat-kp-workflow__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  color: var(--fg, #e8edf2);
}

.ai-chat-kp-workflow__summary::-webkit-details-marker { display: none; }

.ai-chat-kp-workflow__chip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ai-chat-kp-workflow__expand {
  flex-shrink: 0;
  opacity: 0.65;
  font-size: 11px;
}

.ai-chat-kp-workflow__details[open] .ai-chat-kp-workflow__expand {
  opacity: 0.4;
}

.ai-chat-kp-workflow__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 0 10px 10px;
}

.ai-chat-kp-workflow__title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg, #e8edf2);
}

.ai-chat-kp-workflow__sub {
  display: block;
  font-size: 12px;
  color: var(--fg-muted, #8899aa);
  margin-top: 2px;
}

.ai-chat-kp-workflow__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ai-chat-kp-workflow__btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  background: var(--surface-2, #243040);
  color: var(--fg, #e8edf2);
  cursor: pointer;
}

.ai-chat-kp-workflow__btn--primary {
  border-color: rgba(237, 91, 47, 0.6);
  background: rgba(237, 91, 47, 0.2);
}

.ai-chat-kp-workflow__btn--danger {
  border-color: rgba(220, 80, 80, 0.5);
  background: rgba(220, 80, 80, 0.15);
}

.ai-chat-kp-workflow__hint {
  font-size: 12px;
  color: var(--fg-muted, #8899aa);
}

.ai-chat-estimate-memory {
  margin: 0 0 6px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.06);
  font-size: 12px;
}
.ai-chat-estimate-memory__details { margin: 0; }
.ai-chat-estimate-memory__summary {
  padding: 5px 10px;
  cursor: pointer;
  list-style: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-chat-estimate-memory__summary::-webkit-details-marker { display: none; }
.ai-chat-estimate-memory__inner { padding: 0 10px 8px; }
.ai-chat-estimate-memory__file {
  opacity: 0.8;
  margin-bottom: 4px;
  word-break: break-word;
  white-space: normal;
}
.ai-chat-estimate-memory__open { color: #f59e0b; font-weight: 600; }
.ai-chat-estimate-memory__ok { color: #34d399; }
.ai-chat-estimate-memory__facts {
  margin: 6px 0 0;
  padding-left: 18px;
  opacity: 0.9;
}
.rcard--estimate-gaps .rcard__gaps-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.rcard__gap-item {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  background: rgba(0,0,0,.12);
}
.rcard__gap-item.is-high { border-color: rgba(245, 158, 11, 0.45); }
.rcard__gap-item.is-answered { opacity: 0.75; }
.rcard__gap-q { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.rcard__gap-why { font-size: 12px; opacity: 0.75; margin-bottom: 8px; }
.rcard__gap-choices { display: flex; flex-wrap: wrap; gap: 6px; }

.rcard--supplier-pick .rcard__pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.rcard__pick-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
}

.rcard__pick-info strong {
  display: block;
  font-size: 13px;
}

.rcard__pick-meta {
  display: block;
  font-size: 11px;
  color: var(--fg-muted, #8899aa);
  margin-top: 2px;
}

.rcard__action-btn--primary {
  font-weight: 600;
}

/* ── Input area ──────────────────────────────────────────────────────────── */

.ai-chat-input-area {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
  background: var(--surface, #1c252e);
  position: relative;
}

.ai-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.ai-chat-attach-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fg-muted, #8899aa);
  transition: color .15s, background .15s;
}

.ai-chat-attach-btn:hover {
  color: var(--accent, #ed5b2f);
  background: var(--accent-muted, rgba(237,91,47,.14));
}

.ai-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  background: var(--bg, #141a21);
  color: var(--fg, #e0e8f0);
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .15s;
}

.ai-chat-input:focus {
  outline: none;
  border-color: var(--accent, #ed5b2f);
}

.ai-chat-input.is-locked {
  opacity: 0.72;
  cursor: not-allowed;
  background: var(--surface-muted, rgba(255,255,255,.04));
}

.ai-chat-input.is-locked::placeholder {
  color: var(--fg-dim, #667788);
}

.gov-chat-attach.is-disabled,
label.gov-chat-attach.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.ai-chat-input::placeholder {
  color: var(--fg-dim, #667788);
}

.ai-chat-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--accent, #ed5b2f);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.ai-chat-send-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.ai-chat-send-btn:not(:disabled):hover {
  transform: scale(1.05);
}

.ai-chat-send-btn.is-stop {
  background: #c0392b;
}

.ai-chat-msg__actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity .15s;
}

.ai-chat-msg--user:hover .ai-chat-msg__actions,
.ai-chat-msg--user:focus-within .ai-chat-msg__actions {
  opacity: 1;
}

.ai-chat-msg__action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: 8px;
  background: var(--surface-hover, rgba(255,255,255,.06));
  color: var(--fg-muted, #8899aa);
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.ai-chat-msg__action:hover {
  background: var(--accent-muted, rgba(237,91,47,.14));
  color: var(--fg, #e8edf2);
}

@media (hover: none) {
  .ai-chat-msg__actions {
    opacity: 1;
  }
}

.ai-chat-next-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 0;
}

.ai-chat-next-steps[hidden] {
  display: none !important;
}

.ai-chat-next-steps__label {
  width: 100%;
  font-size: 11px;
  color: var(--fg-muted, #8899aa);
  margin-bottom: 2px;
}

.ai-chat-next-chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: transparent;
  color: var(--fg-muted, #8899aa);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.ai-chat-next-chip:hover {
  border-color: var(--accent, #ed5b2f);
  color: var(--accent, #ed5b2f);
  background: var(--accent-muted, rgba(237,91,47,.08));
}

.ai-chat-confirm-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.12);
}

.ai-chat-confirm-bar[hidden] {
  display: none;
}

.ai-chat-confirm-bar__text {
  flex: 1 1 180px;
  font-size: 13px;
  color: var(--fg, #e8edf2);
}

.ai-chat-confirm-bar__btn {
  font-size: 13px;
}

.ai-chat-confirm {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.12);
}

.ai-chat-confirm__title {
  font-weight: 600;
  font-size: 13px;
  color: var(--fg, #e8edf2);
  margin-bottom: 4px;
}

.ai-chat-confirm__tool {
  font-size: 12px;
  color: var(--fg-muted, #8899aa);
  margin-bottom: 8px;
}

.ai-chat-confirm__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ai-chat-confirm__ok,
.ai-chat-confirm__cancel {
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .ai-chat-next-steps .ai-chat-chip,
  .ai-chat-confirm {
    transition: none;
  }
}

.ai-chat-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ai-chat-chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: transparent;
  color: var(--fg-muted, #8899aa);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  font-family: inherit;
  white-space: nowrap;
}

.ai-chat-chip:hover {
  border-color: var(--accent, #ed5b2f);
  color: var(--accent, #ed5b2f);
  background: var(--accent-muted, rgba(237,91,47,.08));
}

/* ── Chip categories (smeta/tender) ─────────────────────────────────────── */
.ai-chat-chip--smeta {
  border-color: rgba(59,130,246,.25);
  color: #60a5fa;
}
.ai-chat-chip--smeta:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: rgba(59,130,246,.1);
}
.ai-chat-chip--tender {
  border-color: rgba(16,185,129,.25);
  color: #34d399;
}
.ai-chat-chip--tender:hover {
  border-color: #10b981;
  color: #10b981;
  background: rgba(16,185,129,.1);
}

/* ── Drop zone ───────────────────────────────────────────────────────────── */

.ai-chat-dropzone {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg, #141a21) 90%, transparent);
  border: 2px dashed var(--accent, #ed5b2f);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: aiChatFadeIn .15s ease;
}

.ai-chat-dropzone[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.ai-chat-dropzone__content {
  text-align: center;
  color: var(--accent, #ed5b2f);
}

.ai-chat-dropzone__content p {
  margin: 8px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.ai-chat-dropzone__hint {
  font-size: 13px;
  color: var(--fg-muted, #8899aa) !important;
  font-weight: 400 !important;
}

/* ── Markdown in AI messages ─────────────────────────────────────────────── */

.ai-chat-msg--ai .ai-chat-msg__text h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 6px;
}

.ai-chat-msg--ai .ai-chat-msg__text ul,
.ai-chat-msg--ai .ai-chat-msg__text ol {
  margin: 6px 0;
  padding-left: 20px;
}

.ai-chat-msg--ai .ai-chat-msg__text li {
  margin: 2px 0;
}

.ai-chat-msg--ai .ai-chat-msg__text hr {
  border: none;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
  margin: 10px 0;
}

.ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}

.ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table th,
.ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table td {
  border: 1px solid var(--border, rgba(255,255,255,.12));
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table th {
  background: rgba(255,255,255,.06);
  font-weight: 600;
}
.ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table a {
  color: var(--link, #90caf9);
  text-decoration: underline;
  word-break: break-word;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table a,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table a {
  color: #1565c0;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table th,
body.haze-workspace.light-theme .ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table td {
  border-color: rgba(0,0,0,.1);
  color: #1a2332;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .ai-chat-msg__text .ai-chat-md-table th {
  background: #eef2f6;
}

/* ── Action buttons (SSE type:actions) ────────────────────────────────── */

.ai-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border, rgba(255,255,255,.06));
}

.ai-chat-actions__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(66,165,245,.4);
  background: rgba(66,165,245,.12);
  color: #42a5f5;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .2s;
}

.ai-chat-actions__btn:hover {
  background: rgba(66,165,245,.22);
  border-color: rgba(66,165,245,.6);
}

.ai-chat-actions__btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.ai-chat-actions__btn--loading {
  opacity: .65;
  border-style: dashed;
}

.ai-chat-actions__btn--done {
  border-color: rgba(102,187,106,.5);
  background: rgba(102,187,106,.12);
  color: #66bb6a;
  cursor: default;
}

.ai-chat-actions__btn--error {
  border-color: rgba(239,83,80,.5);
  background: rgba(239,83,80,.12);
  color: #ef5350;
}

.ai-chat-actions__icon {
  flex-shrink: 0;
}

/* TRUST-RESPONSE-1: след tools под ответом */
.ai-chat-work-trace {
  margin: 10px 0 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  font-size: 12.5px;
  line-height: 1.45;
}

.ai-chat-work-trace__head {
  font-weight: 650;
  color: var(--text, #e8eef5);
  margin-bottom: 6px;
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.ai-chat-work-trace__head::after {
  content: " ▾";
  opacity: .55;
  font-weight: 400;
}

.ai-chat-work-trace.is-collapsed .ai-chat-work-trace__head {
  margin-bottom: 0;
}

.ai-chat-work-trace.is-collapsed .ai-chat-work-trace__head::after {
  content: " ▸";
}

.ai-chat-work-trace.is-collapsed .ai-chat-work-trace__details {
  display: none;
}

.ai-chat-work-trace__list {
  margin: 0;
  padding-left: 18px;
}

.ai-chat-work-trace__step {
  margin: 3px 0;
  color: rgba(232,238,245,.85);
}

.ai-chat-work-trace__step.is-running .ai-chat-work-trace__label {
  font-style: italic;
}

.ai-chat-work-trace__step.is-error {
  color: #ef9a9a;
}

.ai-chat-work-trace__detail {
  display: block;
  opacity: .72;
  font-size: 12px;
  padding-left: 0;
}

.ai-chat-work-trace__sources {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.06);
  opacity: .75;
  font-size: 12px;
}

.ai-chat-md-h {
  margin: 12px 0 6px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: rgba(232,238,245,.7);
}

.ai-chat-md-h--verdict {
  color: #90caf9;
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}

.ai-chat-md-h--facts,
.ai-chat-md-h--caveat,
.ai-chat-md-h--next {
  text-transform: none;
  letter-spacing: 0;
}
.ai-chat-md-h--facts { color: #a5d6a7; }
.ai-chat-md-h--caveat { color: #ffe082; }
.ai-chat-md-h--next { color: #80cbc4; }

body.haze-workspace.light-theme .ai-chat-work-trace,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-work-trace {
  border-color: rgba(0,0,0,.08);
  background: #f4f7fa;
}

body.haze-workspace.light-theme .ai-chat-work-trace__head,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-work-trace__head {
  color: #1a2332;
}

body.haze-workspace.light-theme .ai-chat-work-trace__step,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-work-trace__step {
  color: #334155;
}

body.haze-workspace.light-theme .ai-chat-md-h--verdict,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-md-h--verdict { color: #1565c0; }

body.haze-workspace.light-theme .ai-chat-md-h--facts,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-md-h--facts { color: #2e7d32; }

body.haze-workspace.light-theme .ai-chat-md-h--caveat,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-md-h--caveat { color: #f57f17; }

body.haze-workspace.light-theme .ai-chat-md-h--next,
body.gov-workspace:not([data-theme="dark"]) .ai-chat-md-h--next { color: #00695c; }

body.haze-workspace.light-theme .ai-chat-actions {
  border-top-color: rgba(0,0,0,.06);
}

body.haze-workspace.light-theme .ai-chat-actions__btn {
  border-color: rgba(33,150,243,.3);
  background: rgba(33,150,243,.08);
  color: #1976d2;
}

body.haze-workspace.light-theme .ai-chat-actions__btn:hover {
  background: rgba(33,150,243,.16);
  border-color: rgba(33,150,243,.5);
}

body.haze-workspace.light-theme .ai-chat-actions__btn--done {
  border-color: rgba(76,175,80,.4);
  background: rgba(76,175,80,.08);
  color: #388e3c;
}

body.haze-workspace.light-theme .ai-chat-actions__btn--error {
  border-color: rgba(211,47,47,.4);
  background: rgba(211,47,47,.08);
  color: #d32f2f;
}

/* ── Бета-миссии: уведомления в чате (BETA-MISSIONS-1) ───────────────────── */

.ai-mission-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(102,187,106,.12);
  border: 1px solid rgba(102,187,106,.35);
  color: #a5d6a7;
  font-size: 13px;
  margin-top: 8px;
  animation: missionSlideIn .3s ease;
}

.ai-mission-toast__icon {
  font-size: 18px;
  flex-shrink: 0;
}

.ai-mission-toast__text {
  flex: 1;
}

.ai-mission-toast__points {
  font-weight: 700;
  color: #66bb6a;
}

@keyframes missionSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Бета-панель в сайдбаре ─────────────────────────────────────────────── */

.beta-panel {
  margin: 12px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255,183,77,.08);
  border: 1px solid rgba(255,183,77,.25);
}

.beta-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.beta-panel__title {
  font-size: 13px;
  font-weight: 700;
  color: #ffb74d;
}

.beta-panel__days {
  font-size: 12px;
  color: rgba(255,183,77,.7);
}

.beta-mission-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-secondary, rgba(255,255,255,.6));
}

.beta-mission-item--done {
  color: #66bb6a;
}

.beta-mission-item__check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.beta-mission-item--done .beta-mission-item__check {
  border-color: #66bb6a;
  background: rgba(102,187,106,.2);
  color: #66bb6a;
}

.beta-panel__progress {
  margin-top: 8px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}

.beta-panel__progress-bar {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ffb74d, #66bb6a);
  transition: width .4s ease;
}

/* Light theme */
body.haze-workspace.light-theme .beta-panel {
  background: rgba(255,152,0,.06);
  border-color: rgba(255,152,0,.2);
}
body.haze-workspace.light-theme .beta-panel__title { color: #e65100; }
body.haze-workspace.light-theme .beta-panel__days { color: rgba(230,81,0,.6); }
body.haze-workspace.light-theme .beta-mission-item { color: rgba(0,0,0,.5); }
body.haze-workspace.light-theme .beta-mission-item--done { color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-item__check { border-color: rgba(0,0,0,.2); }
body.haze-workspace.light-theme .beta-mission-item--done .beta-mission-item__check {
  border-color: #2e7d32; background: rgba(46,125,50,.12); color: #2e7d32;
}
body.haze-workspace.light-theme .beta-panel__progress { background: rgba(0,0,0,.06); }

/* ── Бета-миссии: бейджи сложности в тосте ───────────────────────────────── */

.ai-mission-toast__diff {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
  line-height: 1.4;
}

.ai-mission-toast__diff--easy {
  background: rgba(102,187,106,.18);
  color: #81c784;
  border: 1px solid rgba(102,187,106,.3);
}

.ai-mission-toast__diff--medium {
  background: rgba(255,183,77,.15);
  color: #ffb74d;
  border: 1px solid rgba(255,183,77,.3);
}

.ai-mission-toast__diff--hard {
  background: rgba(239,83,80,.15);
  color: #ef9a9a;
  border: 1px solid rgba(239,83,80,.3);
}

.ai-mission-toast__track {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(144,202,249,.12);
  color: #90caf9;
  border: 1px solid rgba(144,202,249,.25);
  vertical-align: middle;
  line-height: 1.4;
}

/* ── Бета-миссии: список в сайдбаре ──────────────────────────────────────── */

.haze-beta-track-label {
  font-weight: 700;
  color: #66bb6a;
}

.haze-beta-missions-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.beta-mission-item__icon {
  font-size: 12px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.beta-mission-item__title {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.beta-mission-item__pts {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  flex-shrink: 0;
}

.beta-mission-item--done .beta-mission-item__pts {
  color: #66bb6a;
}

.beta-mission-diff {
  font-size: 9px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 3px;
  flex-shrink: 0;
  line-height: 1.5;
}

.beta-mission-diff--easy {
  background: rgba(102,187,106,.12);
  color: #81c784;
}

.beta-mission-diff--medium {
  background: rgba(255,183,77,.1);
  color: #ffb74d;
}

.beta-mission-diff--hard {
  background: rgba(239,83,80,.1);
  color: #ef9a9a;
}

/* Light theme badges */
body.haze-workspace.light-theme .ai-mission-toast__diff--easy { background: rgba(46,125,50,.08); color: #2e7d32; border-color: rgba(46,125,50,.2); }
body.haze-workspace.light-theme .ai-mission-toast__diff--medium { background: rgba(230,81,0,.08); color: #e65100; border-color: rgba(230,81,0,.2); }
body.haze-workspace.light-theme .ai-mission-toast__diff--hard { background: rgba(198,40,40,.08); color: #c62828; border-color: rgba(198,40,40,.2); }
body.haze-workspace.light-theme .ai-mission-toast__track { background: rgba(21,101,192,.08); color: #1565c0; border-color: rgba(21,101,192,.2); }
body.haze-workspace.light-theme .haze-beta-track-label { color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-item__pts { color: rgba(0,0,0,.3); }
body.haze-workspace.light-theme .beta-mission-item--done .beta-mission-item__pts { color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-diff--easy { background: rgba(46,125,50,.06); color: #2e7d32; }
body.haze-workspace.light-theme .beta-mission-diff--medium { background: rgba(230,81,0,.06); color: #e65100; }
body.haze-workspace.light-theme .beta-mission-diff--hard { background: rgba(198,40,40,.06); color: #c62828; }

/* ── Light theme ─────────────────────────────────────────────────────────── */

body.haze-workspace.light-theme .ai-chat-container {
  background: #fff;
  border-color: rgba(0,0,0,.08);
}

body.haze-workspace.light-theme .ai-chat-msg--ai .ai-chat-msg__text {
  background: #f5f7f9;
  border-color: rgba(0,0,0,.06);
  color: #1a2332;
}

/* Result cards в чате — читаемость в тёмной теме */
.ai-chat-msg--ai .rcard {
  background: var(--surface, #1c252e);
  border-color: var(--border, rgba(255,255,255,.12));
  color: var(--fg, #e8edf2);
}

.ai-chat-msg--ai .rcard__title,
.ai-chat-msg--ai .rcard__metric-value {
  color: var(--fg, #e8edf2);
}

.ai-chat-msg--ai .rcard__subtitle,
.ai-chat-msg--ai .rcard__metric-label,
.ai-chat-msg--ai .rcard__disclaimer,
.ai-chat-msg--ai .rcard__note {
  color: var(--fg-muted, #8899aa);
}

.ai-chat-msg--ai .rcard__table th,
.ai-chat-msg--ai .rcard__table td {
  color: var(--fg, #e8edf2);
}

.ai-chat-msg--ai .rcard__table th {
  color: var(--fg-muted, #9fb0c0);
  border-bottom-color: rgba(255, 255, 255, 0.14);
}

.ai-chat-msg--ai .rcard__table td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.ai-chat-msg--ai .rcard__table-summary {
  color: var(--accent, #6eb6ff);
}

.ai-chat-msg--ai .rcard__note {
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg-muted, #9fb0c0);
}

.ai-chat-msg--ai .rcard__eis-item {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.12);
}

.ai-chat-msg--ai .rcard__eis-name {
  color: var(--fg, #f0f6fc);
}

.ai-chat-msg--ai .rcard__eis-num,
.ai-chat-msg--ai .rcard__eis-meta {
  color: var(--fg-muted, #9fb0c0);
}

.ai-chat-msg--ai .rcard__action-btn {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.18);
  color: var(--fg, #e8edf2);
}

.ai-chat-msg--ai .rcard__action-btn:hover {
  background: rgba(237, 91, 47, 0.18);
  border-color: rgba(237, 91, 47, 0.55);
  color: #fff;
}

.ai-chat-msg--ai .rcard__eis-analyze-btn {
  background: rgba(237, 91, 47, 0.16);
  border-color: rgba(237, 91, 47, 0.45);
  color: #ffb899;
}

.ai-chat-msg--ai .rcard__eis-analyze-btn:hover {
  background: rgba(237, 91, 47, 0.28);
  color: #fff;
}

/* Result cards в светлой теме */
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard {
  background: #fff;
  border-color: rgba(0,0,0,.1);
  color: #1a2332;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__title,
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__metric-value,
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__eis-name {
  color: #1a2332;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__subtitle,
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__metric-label,
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__eis-num,
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__eis-meta,
body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__disclaimer {
  color: #5a6a7a;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__eis-item {
  background: #f5f7f9;
  border-color: rgba(0,0,0,.08);
}

body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__action-btn {
  background: #fff;
  border-color: rgba(0,0,0,.14);
  color: #1a2332;
}

body.haze-workspace.light-theme .ai-chat-msg--ai .rcard__eis-analyze-btn {
  background: rgba(237, 91, 47, 0.1);
  border-color: rgba(237, 91, 47, 0.45);
  color: #c44a20;
}

body.haze-workspace.light-theme .ai-chat-input {
  background: #f5f7f9;
  color: #1a2332;
  border-color: rgba(0,0,0,.12);
}

body.haze-workspace.light-theme .ai-chat-chip {
  border-color: rgba(0,0,0,.1);
  color: #556677;
}

body.haze-workspace.light-theme .ai-chat-dropzone {
  background: rgba(255,255,255,.92);
}

/* ── Free Paywall Overlay ─────────────────────────────────────────────── */

.ai-chat-paywall {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg, #141a21) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: aiChatFadeIn .3s ease;
}

.ai-chat-paywall__card {
  position: relative;
  width: 420px;
  max-width: 92%;
  background: var(--surface, #1c252e);
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 20px;
  overflow: hidden;
}

/* Ghost messages (simulated conversation) */
.ai-chat-paywall__ghosts {
  padding: 20px 20px 0;
  max-height: 260px;
  overflow: hidden;
}

.ai-chat-paywall__ghost {
  display: flex;
  margin-bottom: 12px;
  animation: aiPaywallSlide .6s ease both;
}

.ai-chat-paywall__ghost--user { justify-content: flex-end; }
.ai-chat-paywall__ghost--ai { justify-content: flex-start; }

.ai-chat-paywall__ghost--user .ai-chat-paywall__ghost-text {
  background: var(--accent, #ed5b2f);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  max-width: 70%;
}

.ai-chat-paywall__ghost--ai .ai-chat-paywall__ghost-text {
  background: var(--surface-hover, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.06));
  border-radius: 14px 14px 14px 4px;
  max-width: 85%;
}

.ai-chat-paywall__ghost-text {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-chat-paywall__ghost:nth-child(1) { animation-delay: 0s; }
.ai-chat-paywall__ghost:nth-child(2) { animation-delay: .15s; }
.ai-chat-paywall__ghost:nth-child(3) { animation-delay: .3s; }
.ai-chat-paywall__ghost:nth-child(4) { animation-delay: .45s; }

@keyframes aiPaywallSlide {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Gradient mask over ghosts */
.ai-chat-paywall__gradient {
  height: 80px;
  background: linear-gradient(to bottom, transparent, var(--surface, #1c252e));
  margin-top: -40px;
  position: relative;
  z-index: 1;
}

/* CTA section */
.ai-chat-paywall__cta {
  padding: 0 24px 28px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.ai-chat-paywall__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-muted, rgba(237,91,47,.14));
  color: var(--accent, #ed5b2f);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.ai-chat-paywall__title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.3;
}

.ai-chat-paywall__desc {
  font-size: 13px;
  color: var(--fg-muted, #8899aa);
  margin: 0 0 18px;
  line-height: 1.5;
}

.ai-chat-paywall__features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  text-align: left;
}

.ai-chat-paywall__feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg, #e0e8f0);
}

.ai-chat-paywall__feature svg {
  color: var(--accent, #ed5b2f);
  flex-shrink: 0;
}

.ai-chat-paywall__btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 12px;
  background: var(--accent, #ed5b2f);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  border: none;
  font-family: inherit;
}

.ai-chat-paywall__btn:hover {
  opacity: .9;
  transform: translateY(-1px);
}

.ai-chat-paywall__note {
  font-size: 11px;
  color: var(--fg-dim, #667788);
  margin: 12px 0 0;
}

/* Paywall beta section */
.ai-chat-paywall__divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.ai-chat-paywall__divider::before,
.ai-chat-paywall__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.08);
}
.ai-chat-paywall__divider span {
  font-size: 11px;
  color: rgba(255,255,255,.3);
}

.ai-chat-paywall__beta {
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,183,77,.2);
  background: rgba(255,183,77,.04);
}
.ai-chat-paywall__beta-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffb74d;
  margin: 0 0 4px;
}
.ai-chat-paywall__beta-desc {
  font-size: 12px;
  color: var(--fg-muted, rgba(255,255,255,.5));
  margin: 0 0 10px;
  line-height: 1.5;
}
.ai-chat-paywall__beta-btn {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,183,77,.4);
  background: rgba(255,183,77,.12);
  color: #ffb74d;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ai-chat-paywall__beta-btn:hover {
  background: rgba(255,183,77,.22);
  border-color: rgba(255,183,77,.6);
}
.ai-chat-paywall__beta-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.ai-chat-paywall__beta-note {
  font-size: 11px;
  color: rgba(255,255,255,.3);
  margin: 8px 0 0;
  line-height: 1.4;
}
.ai-chat-paywall__beta-status {
  font-size: 11px;
  margin: 6px 0 0;
  min-height: 14px;
}

/* Light theme paywall beta */
body.haze-workspace.light-theme .ai-chat-paywall__divider::before,
body.haze-workspace.light-theme .ai-chat-paywall__divider::after {
  background: rgba(0,0,0,.08);
}
body.haze-workspace.light-theme .ai-chat-paywall__divider span {
  color: rgba(0,0,0,.3);
}
body.haze-workspace.light-theme .ai-chat-paywall__beta {
  border-color: rgba(255,152,0,.2);
  background: rgba(255,152,0,.04);
}
body.haze-workspace.light-theme .ai-chat-paywall__beta-title { color: #e65100; }
body.haze-workspace.light-theme .ai-chat-paywall__beta-desc { color: rgba(0,0,0,.5); }
body.haze-workspace.light-theme .ai-chat-paywall__beta-btn {
  border-color: rgba(230,81,0,.3);
  background: rgba(255,152,0,.08);
  color: #e65100;
}
body.haze-workspace.light-theme .ai-chat-paywall__beta-btn:hover {
  background: rgba(255,152,0,.16);
}
body.haze-workspace.light-theme .ai-chat-paywall__beta-note { color: rgba(0,0,0,.3); }

/* Light theme paywall */
body.haze-workspace.light-theme .ai-chat-paywall {
  background: rgba(255,255,255,.88);
}

body.haze-workspace.light-theme .ai-chat-paywall__card {
  background: #fff;
  border-color: rgba(0,0,0,.08);
}

body.haze-workspace.light-theme .ai-chat-paywall__ghost--user .ai-chat-paywall__ghost-text {
  background: var(--accent, #ed5b2f);
  color: #fff;
}

body.haze-workspace.light-theme .ai-chat-paywall__ghost--ai .ai-chat-paywall__ghost-text {
  background: #f5f7f9;
  border-color: rgba(0,0,0,.06);
}

body.haze-workspace.light-theme .ai-chat-paywall__gradient {
  background: linear-gradient(to bottom, transparent, #fff);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile responsive (≤768px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Container: full screen on mobile */
  .ai-chat-container {
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    max-height: none;
    border-radius: 0;
    position: fixed;
    inset: 0;
    z-index: 1000;
  }

  /* Sidebar: hidden by default, overlay on toggle */
  .ai-chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }

  .ai-chat-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }

  /* Sidebar backdrop */
  .ai-chat-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    -webkit-tap-highlight-color: transparent;
  }

  .ai-chat-sidebar-backdrop.is-visible {
    display: block;
  }

  /* Sidebar toggle button in header */
  .ai-chat-sidebar-toggle {
    display: flex;
  }

  /* Header: tighter padding */
  .ai-chat-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .ai-chat-header__title {
    font-size: 14px;
  }

  .ai-chat-header__tender-dropdown {
    max-width: 150px;
    font-size: 11px;
  }

  .ai-chat-header__tender-label {
    display: none;
  }

  /* Messages: less padding */
  .ai-chat-messages {
    padding: 12px;
    gap: 12px;
  }

  /* Tools column: hidden on mobile */
  .ai-chat-tools-col {
    display: none;
  }

  .ai-chat-msg {
    max-width: 92%;
  }

  .ai-chat-msg__avatar {
    width: 28px;
    height: 28px;
  }

  .ai-chat-msg__text {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Input area: safe area for keyboard */
  .ai-chat-input-area {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(10px + var(--sat, 0px));
  }

  .ai-chat-input {
    font-size: 16px; /* prevent iOS zoom */
    max-height: 100px;
  }

  /* Chips: horizontal scroll */
  .ai-chat-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin: 8px -12px 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  .ai-chat-chips::-webkit-scrollbar {
    display: none;
  }

  /* Typing: less padding */
  .ai-chat-typing__dots {
    padding: 10px 14px;
  }

  /* Tool status */
  .ai-chat-tools {
    padding: 0 12px;
  }

  /* File preview */
  .ai-chat-files {
    padding: 0 12px 8px;
  }

  .ai-chat-file-chip {
    max-width: 150px;
    font-size: 11px;
    padding: 5px 8px;
  }

  /* Paywall */
  .ai-chat-paywall__card {
    max-width: 96%;
    border-radius: 16px;
  }

  .ai-chat-paywall__ghosts {
    max-height: 180px;
    padding: 16px 16px 0;
  }

  .ai-chat-paywall__cta {
    padding: 0 16px 20px;
  }
}

/* ── Desktop: sidebar toggle hidden ── */
.ai-chat-sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--fg-muted, #8899aa);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}

.ai-chat-sidebar-toggle:hover {
  color: var(--fg, #e0e8f0);
}

/* ── Tool usage panel ───────────────────────────────────────────────────── */
.ai-tool-usage-panel {
  margin: 8px 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(99,102,241,.2);
  background: rgba(99,102,241,.06);
  font-size: 13px;
  max-width: 480px;
  overflow: hidden;
}
.ai-tool-usage-panel__toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.ai-tool-usage-panel__toggle-label {
  font-weight: 600;
  color: #818cf8;
  font-size: 13px;
}
.ai-tool-usage-panel__toggle-hint {
  font-size: 11px;
  color: var(--muted, #94a3b8);
}
.ai-tool-usage-panel.is-collapsed .ai-tool-usage-panel__body {
  display: none;
}
.ai-tool-usage-panel:not(.is-collapsed) .ai-tool-usage-panel__toggle-hint {
  display: none;
}
.ai-tool-usage-panel__body {
  padding: 0 14px 12px;
}
.ai-tool-usage-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ai-tool-usage-panel__title {
  font-weight: 600;
  color: #818cf8;
}
.ai-tool-usage-panel__total {
  font-weight: 700;
  color: #a5b4fc;
  font-size: 14px;
}
.ai-tool-usage-panel__tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-tool-usage-panel__tool {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,.04);
}
.ai-tool-usage-panel__tool--error {
  border-left: 2px solid #ef4444;
}
.ai-tool-usage-panel__tool-name {
  color: var(--fg, #e0e8f0);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.ai-tool-usage-panel__tool-meta {
  color: var(--fg-muted, #8899aa);
  font-size: 11px;
}
.ai-tool-usage-panel__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.06);
  color: var(--fg-muted, #8899aa);
  font-size: 12px;
}
.ai-tool-usage-panel__export {
  color: #818cf8;
  text-decoration: none;
  font-weight: 500;
}
.ai-tool-usage-panel__export:hover {
  text-decoration: underline;
}

/* ── Tool stage chips (чипы стадий выполнения инструментов) ──────────── */

.stage-chips-el {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: stageChipsFadeIn 0.3s ease-out;
}

@keyframes stageChipsFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 16px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 13px;
  color: #7dd3fc;
  transition: all 0.3s ease-out;
  max-width: 300px;
  animation: stageChipSlideIn 0.3s ease-out;
}

@keyframes stageChipSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.stage-chip--running {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
}

.stage-chip--running .stage-chip__spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: stageChipSpin 0.8s linear infinite;
}

@keyframes stageChipSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.stage-chip--done {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.stage-chip__icon {
  flex-shrink: 0;
  font-size: 14px;
}

.stage-chip__text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.stage-chip__timer,
.stage-chip__duration {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
  font-family: 'Courier New', monospace;
}

/* Свёрнутый вид чипов (после 5 секунд) */
.stage-chips-el--collapsed {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stage-chips-el--collapsed .stage-chip {
  opacity: 0.6;
  transform: scale(0.95);
}

.stage-chips-el--collapsed .stage-chip--running .stage-chip__spinner {
  animation-duration: 2s;
}

.stage-chips-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 8px;
  color: #86efac;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
}

.stage-chips-summary:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  transform: translateY(-1px);
}

/* Светлая тема */
body.haze-workspace.light-theme .stage-chips-el {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

body.haze-workspace.light-theme .stage-chip--running {
  background: rgba(14, 165, 233, 0.08);
  border-color: rgba(14, 165, 233, 0.3);
  color: #0284c7;
}

body.haze-workspace.light-theme .stage-chip--running .stage-chip__spinner {
  border-color: rgba(14, 165, 233, 0.3);
  border-top-color: #0ea5e9;
}

body.haze-workspace.light-theme .stage-chip--done {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.3);
  color: #15803d;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
  .stage-chips-el {
    gap: 6px;
    padding: 6px;
  }

  .stage-chip {
    max-width: 240px;
    font-size: 12px;
    padding: 5px 8px;
  }
}
