:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e4e6ea;
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-soft-hover: #e0e7ff;
  --accent-strong: #3730a3;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --panel-hover: #f3f4f6;
  --panel-hover-strong: #e5e7eb;
  --panel-soft: #fafbfc;
  --border-strong: #c7cbd4;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success-bg: #dcfce7;
  --scroll-thumb: #d1d5db;
  --scroll-thumb-hover: #b6bcc7;
  --auth-bg: linear-gradient(135deg, #eef2ff 0%, #f4f5f7 60%, #ffffff 100%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

textarea {
  font-family: inherit;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Боковые панели ---------- */

.sidebar {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-left {
  width: 280px;
  border-right: 1px solid var(--border);
}

.sidebar-right {
  width: 320px;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

/* ---------- Бренд ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-footer {
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.user-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-email {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-logout:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---------- Кнопка «Новый чат» ---------- */

.btn-new-chat {
  margin: 0 12px 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.btn-new-chat:hover {
  background: var(--accent-soft-hover);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Список чатов ---------- */

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

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-item:hover {
  background: var(--panel-hover);
}

.chat-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.chat-item-icon {
  display: flex;
  flex-shrink: 0;
  opacity: 0.7;
}

.chat-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}

.chat-item-delete {
  display: flex;
  opacity: 0;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ---------- Центр: чат ---------- */

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

.chat-header {
  height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Сообщения ---------- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.messages-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.msg-row {
  display: flex;
  margin-bottom: 14px;
  justify-content: flex-end;
}

.msg-row.agent {
  justify-content: flex-start;
}

.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.agent {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.bubble.agent.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: none;
}

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 2px;
}

.msg-row.user .msg-time {
  text-align: right;
}

/* Индикатор «печатает…» */

.typing-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 13px 16px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---------- Приветствие (пустой чат) ---------- */

.welcome {
  text-align: center;
  margin: auto;
  padding: 24px 0;
}

.welcome-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.welcome-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ---------- Быстрые запросы ---------- */

.quick-prompts {
  padding: 0 24px 12px;
}

.quick-prompts-inner {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.quick-prompt {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.quick-prompt:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.quick-prompt-tag {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 5px;
}

.quick-prompt-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* ---------- Поле ввода ---------- */

.chat-input-wrap {
  padding: 0 24px 20px;
}

.chat-input-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chatInput {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#chatInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.btn-send:hover {
  background: var(--accent-hover);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Правая панель: коннекторы ---------- */

.panel-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.connector-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.connector-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 4px 16px;
}

.connector-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  transition: box-shadow 0.15s ease;
}

.connector-row:hover {
  box-shadow: var(--shadow);
}

.connector-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.connector-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.connector-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.connector-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connector-desc {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connector-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.connector-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.connector-status.ok {
  color: var(--success);
}

.connector-status.ok .dot {
  background: var(--success);
}

.connector-status.pending {
  color: var(--warning);
}

.connector-status.pending .dot {
  background: var(--warning);
}

.connector-remove {
  display: flex;
  opacity: 0;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.connector-row:hover .connector-remove {
  opacity: 1;
}

.connector-remove:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.btn-add-connector {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border-strong);
  background: var(--panel-soft);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-add-connector:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Модалка ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  width: 440px;
  max-width: 100%;
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from {
    transform: translateY(10px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.modal-close:hover {
  background: var(--panel-hover);
}

.modal-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
}

.modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.modal-row:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.modal-row.added {
  cursor: default;
  opacity: 0.65;
}

.modal-row.added:hover {
  border-color: var(--border);
  background: var(--panel);
}

.modal-row-info {
  flex: 1;
  min-width: 0;
}

.modal-row-name {
  font-size: 14px;
  font-weight: 600;
}

.modal-row-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-connect {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.btn-connect:hover {
  background: var(--accent-hover);
}

.added-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- Вспомогательное ---------- */

.hidden {
  display: none !important;
}

/* Скроллбары */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

/* ---------- Адаптивность ---------- */

@media (max-width: 1100px) {
  .sidebar-right {
    display: none;
  }
}

@media (max-width: 720px) {
  .sidebar-left {
    display: none;
  }

  .quick-prompts-inner {
    grid-template-columns: 1fr;
  }

  .bubble {
    max-width: 85%;
  }
}
/* ---------- Формы в модалках ---------- */

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.modal-error {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-secondary {
  background: var(--panel-hover);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.btn-secondary:hover {
  background: var(--panel-hover-strong);
}

/* Шаг «Готово» в модалке Telegram */

.tg-done {
  text-align: center;
  padding: 8px 0 4px;
}

.tg-done-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--success-bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

/* Статус «Не подключён» */

.connector-status.off {
  color: var(--text-muted);
}

.connector-status.off .dot {
  background: var(--text-muted);
}

/* ---------- Модалка Telegram: улучшенные шаги ---------- */

.tg-account-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.tg-account-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tg-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.tg-phone-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 12px;
}

.tg-phone-icon {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.tg-phone-number {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  letter-spacing: 0.3px;
}

.tg-phone-edit {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 6px;
  border-radius: 6px;
}

.tg-phone-edit:hover {
  background: var(--accent-soft);
}

.tg-code-input {
  font-size: 20px;
  letter-spacing: 8px;
  text-align: center;
  padding: 12px;
}

.tg-resend {
  width: 100%;
  margin-top: 12px;
  padding: 9px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease;
}

.tg-resend:hover {
  background: var(--accent-soft-hover);
}

.tg-resend:disabled {
  opacity: 0.55;
  cursor: default;
  background: var(--panel-hover);
  color: var(--text-muted);
}

.tg-done-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.tg-done .modal-subtitle {
  max-width: 300px;
  margin: 0 auto;
}

/* ---------- Модалка: информация об аккаунте Telegram ---------- */

.tg-info-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 16px;
}

.tg-info-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tg-info-main {
  min-width: 0;
}

.tg-info-name {
  font-size: 16px;
  font-weight: 700;
}

.tg-info-username {
  font-size: 13px;
  color: var(--text-secondary);
}

.tg-info-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.tg-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.tg-info-row + .tg-info-row {
  border-top: 1px solid var(--border);
}

.tg-info-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.tg-info-value {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.btn-danger {
  width: 100%;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--danger-border);
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.tg-info-confirm {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  border-radius: 10px;
}

/* ---------- Экран входа через Google ---------- */

.auth-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--auth-bg);
  z-index: 1000;
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.12);
  padding: 48px 44px;
  width: 380px;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn-google:hover {
  background: var(--panel-hover);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.1);
}

.auth-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Модалка подтверждения выхода ---------- */

.modal-narrow {
  width: 400px;
  max-width: calc(100vw - 32px);
}

.logout-body {
  text-align: center;
  padding: 8px 8px 0;
}

.logout-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-body .modal-subtitle {
  line-height: 1.6;
}

.logout-body + .modal-actions {
  justify-content: center;
}

/* ---------- Тёмная тема (синеватая, не чёрная) ---------- */

html[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #1e293b;
  --border: #2e3d54;
  --panel-hover: #26334a;
  --panel-hover-strong: #33445f;
  --panel-soft: #223047;
  --border-strong: #3b4d68;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.18);
  --accent-soft-hover: rgba(99, 102, 241, 0.28);
  --accent-strong: #c7d2fe;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.35);
  --success-bg: rgba(52, 211, 153, 0.14);
  --scroll-thumb: #33445f;
  --scroll-thumb-hover: #475569;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.35);
  --auth-bg: linear-gradient(135deg, #111c33 0%, #0f172a 60%, #1e293b 100%);
}

html[data-theme="dark"] .modal-overlay {
  background: rgba(2, 6, 23, 0.6);
}

html[data-theme="dark"] .auth-card {
  box-shadow: 0 8px 30px rgba(2, 6, 23, 0.5);
}

html[data-theme="dark"] .chat-input-inner,
html[data-theme="dark"] .sidebar {
  transition: background 0.25s ease, border-color 0.25s ease;
}

/* ---------- Кнопка переключения темы ---------- */

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-theme {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-hover);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-theme:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ==================== Страница тасок ==================== */

.tasks-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}

.tasks-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tasks-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-hover);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tasks-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.tasks-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
}

.tasks-header-icon {
  color: var(--accent);
  display: flex;
}

.tasks-header-hint {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 480px;
  text-align: right;
}

.tasks-theme-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-hover);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tasks-theme-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--panel-hover-strong);
}

.tasks-main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tasks-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}

.tasks-empty svg {
  color: var(--accent);
}

.task-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: opacity 0.2s ease;
}

.task-card.disabled {
  opacity: 0.62;
}

.task-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.task-card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-card-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
  background: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

.task-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-trigger,
.task-actions {
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.task-row-label {
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 500;
}

.task-row-value {
  color: var(--text);
  min-width: 0;
}

.task-actions {
  align-items: flex-start;
}

.task-actions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.task-action-row {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--panel-hover);
  color: var(--text-secondary);
  overflow-wrap: break-word;
}

.task-runs {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-runs-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.task-run-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
}

.task-run-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}

.task-run-row.ok .task-run-dot {
  background: var(--success);
}

.task-run-row.error .task-run-dot {
  background: var(--danger);
}

.task-run-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.task-run-detail {
  color: var(--text-secondary);
  min-width: 0;
  overflow-wrap: break-word;
}

.task-run-row.error .task-run-detail {
  color: var(--danger);
}

.task-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.task-created {
  font-size: 12px;
  color: var(--text-muted);
}

.task-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-hover);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.task-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-bg);
}

@media (max-width: 720px) {
  .tasks-header-hint {
    display: none;
  }
  .tasks-main {
    padding: 16px;
  }
}

.btn-tasks {
  margin-top: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
