/* ===== Продажник — приложение Битрикс24 ===== */

:root {
  --font: "Open Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;

  --ground: #f3f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --sidebar-bg: #f7f8fa;
  --hover: #e9edf2;
  --active: #e2f3fc;
  --border: #e0e4ea;
  --border-strong: #c9d0da;

  --text: #25303f;
  --text-muted: #606b78;
  --text-faint: #5d6773;

  --accent: #2fc6f6;
  --accent-hover: #1fb2e6;
  --accent-active: #1497c4;
  --accent-ink: #ffffff;
  --accent-soft: #e6f6fd;
  --accent-soft-2: #d4eefb;
  --accent-line: #9adcf5;

  --action: #2067b0;
  --action-hover: #1a5a9c;
  --action-active: #144d85;

  --danger: #d63f46;
  --danger-hover: #c23339;

  --bubble-user: #dff3fd;
  --bubble-user-ink: #173140;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sh-1: 0 1px 2px rgba(23, 43, 60, .06), 0 2px 8px rgba(23, 43, 60, .05);
  --sh-2: 0 2px 6px rgba(23, 43, 60, .08), 0 12px 32px rgba(23, 43, 60, .10);
  --sh-menu: 0 4px 16px rgba(23, 43, 60, .14), 0 16px 48px rgba(23, 43, 60, .10);

  --sidebar-w: 292px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: #bfe9fb; }
textarea { caret-color: var(--accent-active); }
input { caret-color: var(--accent-active); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ================= Sidebar ================= */

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
}

.app-mark {
  width: 30px; height: 30px;
  flex: none;
  display: inline-block;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(20, 151, 196, .4);
}

.app-mark--hero {
  width: 44px; height: 44px;
  border-radius: 13px;
}

.sidebar__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__collapse { display: none; }

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 14px 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--action);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(16, 69, 122, .3), 0 4px 14px rgba(32, 103, 176, .22);
  transition: background .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
}

.new-chat:hover { background: var(--action-hover); }
.new-chat:active { background: var(--action-active); transform: translateY(1px); }
.new-chat svg { width: 16px; height: 16px; stroke-width: 2; }

.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: #c3ccd6 transparent;
}

.sidebar__scroll::-webkit-scrollbar { width: 8px; }
.sidebar__scroll::-webkit-scrollbar-thumb { background: #c3ccd6; border-radius: 4px; border: 2px solid var(--sidebar-bg); }

.side-section { margin-bottom: 10px; }

.side-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 6px;
}

.side-section__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.side-section__head .icon-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  color: var(--text-muted);
}

.side-section__head .icon-btn:hover { background: var(--hover); color: var(--text); }
.side-section__head .icon-btn svg { width: 14px; height: 14px; }

.side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-item {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: var(--r-sm);
  color: var(--text);
  transition: background .12s var(--ease);
}

.side-item:hover { background: var(--hover); }

.side-item--active,
.side-item--active:hover {
  background: var(--active);
  color: #0d5b78;
}

.side-item__main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
  font-size: 13.5px;
  color: inherit;
  border-radius: var(--r-sm);
}

.side-item--active .side-item__main { font-weight: 600; }

.side-item__main > svg {
  width: 16px; height: 16px;
  color: var(--text-faint);
}

.side-item--active .side-item__main > svg { color: #0d5b78; }

.side-item__label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-item__chevron {
  width: 14px; height: 14px;
  color: var(--text-faint);
  transition: transform .18s var(--ease);
}

.side-item__chevron--open { transform: rotate(180deg); }

.side-item__menu-btn {
  width: 24px; height: 24px;
  flex: none;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity .12s var(--ease), background .12s var(--ease);
}

.side-item:hover .side-item__menu-btn,
.side-item:focus-within .side-item__menu-btn,
.side-item__menu-btn[aria-expanded="true"] {
  opacity: 1;
}

.side-item__menu-btn:hover { background: rgba(23, 43, 60, .09); }
.side-item__menu-btn svg { width: 15px; height: 15px; }

.side-item__rename {
  flex: 1;
  min-width: 0;
  margin: 5px 8px;
  font: inherit;
  font-size: 13.5px;
  color: inherit;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  padding: 6px 8px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 198, 246, .16);
}

.side-sublist {
  list-style: none;
  margin: 1px 0 2px;
  padding: 0 0 0 15px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-sublist .side-item { position: relative; }

.side-sublist .side-item__main {
  font-size: 13px;
  padding-left: 12px;
}

.side-sublist .side-item::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.side-sublist__empty {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.side-empty {
  margin: 2px 10px 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.side-inline {
  margin: 2px 6px 6px;
}

.side-inline__input {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--panel);
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 198, 246, .18);
}

.side-inline__input::placeholder { color: var(--text-faint); }

.sidebar__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
}

.sidebar__foot-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #f4b544;
  flex: none;
}

/* ================= Main ================= */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--ground);
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(8px);
}

.topbar__menu { display: none; }

.topbar__crumb {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.topbar__project {
  font-size: 12px;
  font-weight: 600;
  color: #0d5b78;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ================= Chat ================= */

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c3ccd6 transparent;
}

.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: #c3ccd6; border-radius: 4px; border: 2px solid var(--ground); }

.chat__empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 32px 24px 22px;
  gap: 12px;
}

.chat__greeting {
  margin: 6px 0 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.chat__sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  max-width: 46ch;
}

.chat__suggest {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  max-width: 620px;
}

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  font-size: 13px;
  color: var(--text-muted);
  transition: border-color .14s var(--ease), color .14s var(--ease), background .14s var(--ease);
}

.chip:hover {
  border-color: var(--accent);
  color: #0d5b78;
  background: var(--accent-soft);
}

.chat__log {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg {
  display: flex;
  gap: 10px;
  animation: msg-in .24s var(--ease);
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg__avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--accent);
  margin-top: 2px;
}

.msg__body {
  min-width: 0;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg--assistant .msg__body { align-items: flex-start; }
.msg--user { justify-content: flex-end; }
.msg--user .msg__body { align-items: flex-end; }

.msg__bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg--assistant .msg__bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
  box-shadow: var(--sh-1);
}

.msg--user .msg__bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-ink);
  border-top-right-radius: 6px;
}

.msg__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.file-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  max-width: 260px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.file-tag svg { width: 14px; height: 14px; }
.file-tag--xls svg { color: #1e9e5a; }
.file-tag--doc svg { color: #2b6cb0; }

.file-tag__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tag__size { color: var(--text-faint); font-weight: 400; flex: none; white-space: nowrap; }

.msg__time {
  font-size: 12px;
  color: var(--text-faint);
  padding: 0 4px;
}

.date-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 -4px;
}

.date-sep span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 13px 14px;
}

.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: typing-b 1.1s ease-in-out infinite;
}

.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

@keyframes typing-b {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ================= Composer ================= */

.composer-zone {
  flex: none;
  padding: 10px 24px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.composer-zone--center {
  flex: 1;
  justify-content: center;
  padding-bottom: 20vh;
  animation: composer-up .3s var(--ease);
}

.composer-zone--travel {
  transition: transform .38s var(--ease);
}

@keyframes composer-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.composer {
  width: 100%;
  max-width: 780px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: var(--sh-2);
  padding: 8px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--sh-2), 0 0 0 3px rgba(47, 198, 246, .20);
}

.composer__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 6px 8px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  padding: 6px 8px 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 12.5px;
}

.file-chip svg { width: 15px; height: 15px; }
.file-chip--xls svg { color: #1e9e5a; }
.file-chip--doc svg { color: #2b6cb0; }

.file-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.file-chip__size { color: var(--text-faint); flex: none; }

.file-chip__x {
  width: 20px; height: 20px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
}

.file-chip__x:hover { background: var(--hover); color: var(--danger); }
.file-chip__x svg { width: 11px; height: 11px; stroke-width: 2.2; color: inherit; }

.composer__row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.composer__attach {
  width: 40px; height: 40px;
  border-radius: 12px;
  color: var(--text-muted);
}

.composer__attach:hover { background: var(--hover); color: var(--text); }
.composer__attach svg { width: 19px; height: 19px; }

.composer__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text);
  background: transparent;
  padding: 9px 4px;
  max-height: 180px;
  overflow-y: auto;
}

.composer__input::placeholder { color: var(--text-faint); }

.composer__send {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--action);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 69, 122, .4);
  transition: background .14s var(--ease), opacity .14s var(--ease), transform .1s var(--ease);
}

.composer__send:hover:not(:disabled) { background: var(--action-hover); }
.composer__send:active:not(:disabled) { background: var(--action-active); transform: translateY(1px); }
.composer__send:disabled { opacity: .38; cursor: default; box-shadow: none; }
.composer__send svg { width: 18px; height: 18px; stroke-width: 2; }

.composer__hint {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

.composer__hint--error {
  color: var(--danger);
  font-weight: 600;
}

.composer--deny { animation: deny .3s var(--ease); }

.composer--drop {
  border-color: var(--accent) !important;
  box-shadow: var(--sh-2), 0 0 0 4px rgba(47, 198, 246, .28);
}

@keyframes deny {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ================= Menus / dialogs ================= */

.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background .12s var(--ease), color .12s var(--ease);
}

.icon-btn:hover { background: var(--hover); color: var(--text); }

.menu {
  position: fixed;
  z-index: 60;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-menu);
  padding: 5px;
  animation: menu-in .14s var(--ease);
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  text-align: left;
  transition: background .1s var(--ease);
}

.menu__item:hover { background: var(--hover); }
.menu__item svg { width: 15px; height: 15px; color: var(--text-muted); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__item--danger:hover { background: #fdecec; }

.menu__label {
  padding: 7px 10px 3px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.menu__divider {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(23, 35, 48, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in .16s var(--ease);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.dialog {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-menu);
  padding: 20px;
  animation: dialog-in .18s var(--ease);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.dialog__title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}

.dialog__text {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .13s var(--ease);
}

.btn--ghost { color: var(--text-muted); }
.btn--ghost:hover { background: var(--hover); color: var(--text); }

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:hover { background: var(--danger-hover); }

/* ================= Settings / connectors ================= */

.topbar__settings {
  margin-left: auto;
  flex: none;
}

.settings {
  width: 100%;
  max-width: 560px;
  max-height: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-menu);
  animation: dialog-in .18s var(--ease);
}

.settings__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.settings__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.settings__body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 20px;
  scrollbar-width: thin;
  scrollbar-color: #c3ccd6 transparent;
}

.settings__section + .settings__section { margin-top: 22px; }

.settings__section-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.settings__section-sub {
  margin: 4px 0 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.connectors {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.connector {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel-2);
}

.connector__icon {
  width: 36px; height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #e6f3ea;
  color: #1a7f47;
  margin-top: 1px;
}

.connector__icon svg { width: 20px; height: 20px; }

.connector__main {
  flex: 1;
  min-width: 0;
}

.connector__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.connector__name {
  font-size: 14px;
  font-weight: 600;
}

.tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #eed9a6;
  background: #fdf1d6;
  color: #7d5410;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}

.connector__desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.connector__note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.connector__status {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.connector__dot {
  width: 7px; height: 7px;
  flex: none;
  border-radius: 50%;
  background: #b3bcc7;
}

.connector--on .connector__dot { background: #f4b544; }
.connector--on .connector__status { color: #7d5410; }

.switch {
  width: 38px; height: 22px;
  flex: none;
  position: relative;
  margin-top: 2px;
  border-radius: 999px;
  background: #c3ccd6;
  transition: background .15s var(--ease);
}

.switch[aria-checked="true"] { background: var(--action); }

.switch__dot {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 43, 60, .3);
  transition: transform .15s var(--ease);
}

.switch[aria-checked="true"] .switch__dot { transform: translateX(16px); }

.switch:disabled { opacity: .5; cursor: default; }

.connector__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.connector--ok { border-color: #b9e2c5; }
.connector--ok .connector__dot { background: #2ea65f; }
.connector--ok .connector__status { color: #1a7f47; }

.connector--err { border-color: #f0c4c6; }
.connector--err .connector__dot { background: var(--danger); }
.connector--err .connector__status { color: var(--danger); }

.connector__icon--mail { background: var(--accent-soft); color: var(--action); }

.tag--ok {
  border-color: #b9e2c5;
  background: #e8f7ee;
  color: #1a7f47;
}

/* ================= Почтовый ящик (IMAP) ================= */

.mail-dialog { max-width: 600px; }

.mail-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.mail-providers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  .mail-providers { grid-template-columns: 1fr; }
}

.mail-provider {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .13s var(--ease), box-shadow .13s var(--ease), background .13s var(--ease);
}

.mail-provider:hover { border-color: var(--border-strong); }

.mail-provider input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mail-provider:has(input:checked) {
  border-color: var(--action);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(47, 198, 246, .16);
}

.mail-provider:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mail-provider__icon {
  width: 32px; height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--panel);
  color: var(--action);
}

.mail-provider__icon svg { width: 17px; height: 17px; }

.mail-provider__icon b {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

/* Фирменные тона плиток провайдеров — как тайлы приложений в Б24 */
.mail-provider[data-prov="yandex"]  .mail-provider__icon { background: #fdeceb; color: #d0341c; }
.mail-provider[data-prov="mailru"]  .mail-provider__icon { background: #e9f0fd; color: #0f5bd6; }
.mail-provider[data-prov="gmail"]   .mail-provider__icon { background: #fdecea; color: #c5221f; }
.mail-provider[data-prov="outlook"] .mail-provider__icon { background: #e7f2fb; color: #0f6cbd; }
.mail-provider[data-prov="yahoo"]   .mail-provider__icon { background: #f1ecfc; color: #5f01d1; }
.mail-provider[data-prov="icloud"]  .mail-provider__icon { background: #eaf4fc; color: #3986d4; }
.mail-provider[data-prov="rambler"] .mail-provider__icon { background: #eceffd; color: #3b44e3; }
.mail-provider[data-prov="custom"]  .mail-provider__icon { background: var(--hover); color: var(--text-muted); }

.mail-provider__check {
  width: 18px; height: 18px;
  flex: none;
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--action);
  color: #fff;
  opacity: 0;
  transform: scale(.5);
  transition: opacity .15s var(--ease), transform .15s var(--ease);
}

.mail-provider__check svg {
  width: 11px; height: 11px;
  stroke-width: 2.6;
}

.mail-provider:has(input:checked) .mail-provider__check {
  opacity: 1;
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .mail-provider__check { transform: none; }
}

.mail-provider__txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mail-provider__name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-provider__host {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-custom {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .13s var(--ease), background .13s var(--ease), color .13s var(--ease);
}

.auth-tab:hover { border-color: var(--border-strong); }

.auth-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.auth-tab:has(input:checked) {
  border-color: var(--action);
  background: var(--accent-soft);
  color: var(--action);
}

.auth-tab:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mail-hint { margin-top: 4px; }

.mail-hint--setup {
  padding: 10px 12px;
  border: 1px solid var(--border-soft, #e4e8ec);
  border-radius: var(--r-md);
  background: var(--bg-soft, #f7f9fb);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
}

.mail-hint__steps {
  margin: 6px 0 4px;
  padding-left: 18px;
}

.mail-hint__steps li { margin: 3px 0; }

.mail-hint code {
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(37, 48, 63, 0.06);
  font-family: ui-monospace, Consolas, monospace;
}

.mail-dev { margin-top: 8px; }

.mail-dev__toggle {
  font-size: 12px;
  color: var(--text-faint);
  cursor: pointer;
}

.mail-dev__toggle:hover { color: var(--text, #25303f); }

.mail-dev .field__label { margin-top: 8px; display: inline-block; }

/* Блок «Почта Битрикс24» в диалоге ящика */
.mail-b24 {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft, #e4e8ec);
  border-radius: var(--r-md);
  background: var(--bg-soft, #f7f9fb);
}

.mail-b24--on {
  border-color: rgba(26, 127, 71, 0.35);
  background: rgba(26, 127, 71, 0.05);
}

.mail-b24__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text, #25303f);
}

.mail-b24__head .tag { margin-inline-start: auto; }

.mail-b24__logo {
  width: 22px; height: 22px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #2fc6f6;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.mail-b24__boxes {
  margin: 4px 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #25303f);
  word-break: break-word;
}

.mail-b24 .connector__actions { margin-top: 6px; }

.mail-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
}

.mail-note svg {
  width: 14px; height: 14px;
  flex: none;
  margin-top: 2px;
}

.mail-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid #f0c4c6;
  border-radius: var(--r-md);
  background: #fdf3f3;
  color: var(--danger);
  font-size: 12.5px;
}

.mail-view__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mail-view__icon {
  width: 40px; height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: #e6f3ea;
  color: #1a7f47;
}

.mail-view__icon svg { width: 20px; height: 20px; }

.mail-view__who { flex: 1; min-width: 0; }

.mail-view__email {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mail-view__prov {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.mail-check {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel-2);
}

.mail-check--ok { border-color: #b9e2c5; background: #f3fbf5; }
.mail-check--err { border-color: #f0c4c6; background: #fdf3f3; }

.mail-check__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.mail-check--ok .mail-check__title { color: #1a7f47; }
.mail-check--err .mail-check__title { color: var(--danger); }

.mail-check__err {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.mail-check__time {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
}

.mail-subjects {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(23, 43, 60, .07);
}

.mail-subj {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(23, 43, 60, .07);
}

.mail-subj:last-child { border-bottom: 0; }

.mail-subj__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-subj__from {
  flex: none;
  max-width: 45%;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-disconnect { color: var(--danger); }
.mail-disconnect:hover { background: #fdf3f3; color: var(--danger-hover); }

/* --- Автоматическая проверка входящих --- */

.mail-sync {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel-2);
}

.mail-sync__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.mail-sync__lead { flex: 1; min-width: 0; }

.mail-sync__title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 650;
}

.mail-sync__sub {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.mail-sync__interval { margin-top: 10px; }
.mail-sync__interval .field__select { max-width: 240px; }

.mail-sync__status {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.mail-sync__error {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--danger);
}

.mail-sync__foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mail-sync__details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.mail-sync__block + .mail-sync__block { margin-top: 14px; }

.mail-sync__block-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
}

.mail-sync__runs { box-shadow: none; border-radius: var(--r-md); }
.mail-sync__runs .run { padding: 10px 12px; }

.mail-sync__note {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.mail-msgs {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.mail-msg {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
}

.mail-msg + .mail-msg { border-top: 1px solid var(--border); }

.mail-msg__main { flex: 1; min-width: 0; }

.mail-msg__subj {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-msg__meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-msg__err {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.tag--err {
  border-color: #f0c4c6;
  background: #fdf3f3;
  color: var(--danger);
}

.tag--cat {
  border-color: #bcd7ee;
  background: #eef6fd;
  color: #0d5b78;
}

.tag--warn {
  border-color: #eed9a6;
  background: #fdf1d6;
  color: #7d5410;
}

.mail-msg--clf { padding: 0; }

.mail-msg__details summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.mail-msg__details summary::-webkit-details-marker { display: none; }

.mail-msg__details summary:hover { background: rgba(23, 43, 60, .025); }

.mail-msg__details summary::after {
  content: "";
  flex: none;
  width: 7px; height: 7px;
  margin-top: 6px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(45deg);
  transition: transform .15s var(--ease);
}

.mail-msg__details[open] summary::after { transform: rotate(225deg); }

.mail-msg__facts {
  padding: 2px 12px 12px 12px;
  border-top: 1px dashed var(--border);
}

.mail-msg__fact {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.mail-msg__fact b { color: var(--text); font-weight: 650; }

.mail-msg__fact--summary { color: var(--text); }

.mail-msg__fact--warn { color: #7d5410; }

.mail-doc {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 8px);
  background: var(--panel);
}

.mail-doc__dl {
  display: inline-block;
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--action);
}

.mail-doc__unfilled {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
}

.mail-doc__unfilled li { margin: 2px 0; }

/* Отчёты ассистента — чат-лента результатов обработки писем */

.mail-reps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mail-rep {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.mail-rep__avatar {
  flex: none;
  margin-top: 2px;
  border-radius: 50%;
}

.mail-rep__bubble {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  background: var(--panel);
}

.mail-rep__label {
  margin: 8px 0 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.mail-rep__list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text);
}

.mail-rep__list li { margin: 3px 0; }

.mail-rep__list--warn li { color: #7d5410; }

.mail-doc--rep {
  background: transparent;
  border: none;
  padding: 4px 0 0;
}

.mail-rep--digest .mail-rep__bubble { border-left: 3px solid var(--accent, #1497c4); }

.mail-rep__group {
  margin-top: 8px;
  padding: 6px 0 0;
  border-top: 1px dashed var(--border);
}

.mail-rep__muted { color: var(--text-muted); }

.mail-rep__label--urgent { color: #a33b2e; }

.mail-wait {
  padding: 26px 10px;
  text-align: center;
}

.mail-wait__spinner svg {
  width: 30px; height: 30px;
  color: var(--action);
  animation: run-spin 1s linear infinite;
}

.mail-wait__title {
  margin: 12px 0 0;
  font-size: 15px;
  font-weight: 700;
}

.mail-wait__sub {
  margin: 6px auto 0;
  max-width: 400px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ================= Agents («Запланировано») ================= */

.side-item__count {
  flex: none;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
}

.side-item--active .side-item__count { background: #cdeaf8; color: #0d5b78; }

.btn--primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--action);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 69, 122, .3);
}

.btn--primary:hover { background: var(--action-hover); }
.btn--primary:active { background: var(--action-active); }
.btn--primary svg { width: 15px; height: 15px; stroke-width: 2; }
.btn--primary:disabled { opacity: .5; cursor: default; box-shadow: none; }

.btn--outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: border-color .13s var(--ease), background .13s var(--ease);
}

.btn--outline:hover { border-color: var(--accent-active); color: var(--action); background: var(--accent-soft); }
.btn--outline svg { width: 14px; height: 14px; }
.btn--outline:disabled { opacity: .5; cursor: default; }

.agents-screen,
.agent-screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c3ccd6 transparent;
}

.agents-screen::-webkit-scrollbar,
.agent-screen::-webkit-scrollbar { width: 8px; }
.agents-screen::-webkit-scrollbar-thumb,
.agent-screen::-webkit-scrollbar-thumb { background: #c3ccd6; border-radius: 4px; border: 2px solid var(--ground); }

.agents-wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 26px 24px 42px;
}

.agents-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.agents-head__text { min-width: 0; }

.agents-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.agents-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 62ch;
}

.agents-head .btn--primary { flex: none; margin-top: 2px; }

.agents-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-card {
  display: flex;
  gap: 14px;
  padding: 15px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  animation: msg-in .24s var(--ease);
}

.agent-ava {
  width: 40px; height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--action);
  margin-top: 2px;
}

.agent-ava svg { width: 21px; height: 21px; }
.agent-ava--paused { background: var(--hover); color: var(--text-muted); }

.agent-card__main {
  flex: 1;
  min-width: 0;
}

.agent-card__top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 9px;
}

.agent-card__name {
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  border-radius: 4px;
  transition: color .12s var(--ease);
}

.agent-card__name:hover { color: var(--action); }

.badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--on { background: #e6f3ea; color: #1a7f47; }
.badge--paused { background: var(--hover); color: var(--text-muted); }
.badge--running { background: var(--accent-soft); color: #0d5b78; }
.badge--running i { animation: run-pulse 1s ease-in-out infinite; }

@keyframes run-pulse {
  0%, 100% { opacity: .4; }
  50% { opacity: 1; }
}

.agent-card__desc {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-card__meta {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.agent-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.agent-card__meta-item svg { width: 14px; height: 14px; color: var(--text-faint); }

.agent-card__runs {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 3px 14px;
}

.agent-card__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-top: 4px;
}

.agent-card__actions .icon-btn { width: 30px; height: 30px; }
.agent-card__actions .icon-btn svg { width: 15px; height: 15px; }

.agents-empty {
  text-align: center;
  padding: 60px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.agents-empty__icon {
  width: 56px; height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--action);
}

.agents-empty__icon svg { width: 28px; height: 28px; }

.agents-empty__title {
  margin: 14px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.agents-empty__sub {
  margin: 6px 0 18px;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 44ch;
}

/* ----- Экран агента ----- */

.agent-wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 24px 42px;
}

.agent-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  margin: 0 0 12px -10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .12s var(--ease), color .12s var(--ease);
}

.agent-back:hover { background: var(--hover); color: var(--text); }
.agent-back svg { width: 15px; height: 15px; }

.agent-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.agent-head__main {
  flex: 1;
  min-width: 0;
}

.agent-head__name {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.agent-head__badges {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.agent-head__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-head__actions .icon-btn { width: 34px; height: 34px; border: 1px solid var(--border-strong); background: var(--panel); }
.agent-head__actions .icon-btn:hover { border-color: var(--danger); color: var(--danger); background: #fdecec; }
.agent-head__actions .icon-btn svg { width: 15px; height: 15px; }

.src-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: nowrap;
}

.src-tag svg { width: 12px; height: 12px; }

.agent-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.agent-tab-btn {
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s var(--ease), border-color .12s var(--ease);
}

.agent-tab-btn:hover { color: var(--text); }
.agent-tab-btn.is-active { color: var(--action); border-bottom-color: var(--accent); }

.agent-tab-btn .n {
  margin-left: 5px;
  font-weight: 400;
  color: var(--text-faint);
}

/* ----- Форма агента ----- */

.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--sh-1);
}

.form-card__title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.form-card__sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.form-card__body { margin-top: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 12px; }

.field__label {
  font-size: 13px;
  font-weight: 600;
}

.field__input,
.field__area,
.field__select {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}

.field__area { resize: vertical; min-height: 88px; line-height: 1.5; }

.field__input:focus,
.field__area:focus,
.field__select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 198, 246, .18);
}

.field__input::placeholder,
.field__area::placeholder { color: var(--text-faint); }

.field__hint {
  font-size: 12px;
  color: var(--text-faint);
}

.field--error .field__input,
.field--error .field__area { border-color: var(--danger); }
.field--error .field__input:focus,
.field--error .field__area:focus { box-shadow: 0 0 0 3px rgba(214, 63, 70, .15); }
.field--error .field__hint { color: var(--danger); }

.check-list {
  display: flex;
  flex-direction: column;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
}

.check + .check { border-top: 1px solid var(--border); }

.check input[type="checkbox"] {
  width: 17px; height: 17px;
  flex: none;
  margin: 2px 0 0;
  accent-color: var(--action);
  cursor: pointer;
}

.check__main { flex: 1; min-width: 0; }

.check__name {
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.check__desc {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.check--disabled { opacity: .48; }
.check--disabled .check__name { cursor: default; }

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 22px;
}

.check-grid .check + .check { border-top: 0; }
.check-grid .check:nth-child(n+3) { border-top: 1px solid var(--border); }

.sched-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.sched-row .field { flex: none; }
.sched-row .field--grow { flex: 1; min-width: 200px; }

.field__select { padding-right: 30px; }

.form-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.form-foot__note {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-faint);
}

/* ----- Источники/разрешения в форме ----- */

.agent-sources {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-sources .connector__icon { background: var(--accent-soft); color: var(--action); }

.perms-note {
  margin: 10px 0 0;
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: #fdf6e5;
  border: 1px solid #eed9a6;
  font-size: 12.5px;
  color: #7d5410;
}

.perms-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }

/* ----- Запуски ----- */

.runs {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

.run {
  display: flex;
  gap: 13px;
  padding: 13px 16px;
}

.run + .run { border-top: 1px solid var(--border); }

.run__icon {
  width: 30px; height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-top: 1px;
}

.run__icon svg { width: 15px; height: 15px; }

.run--done .run__icon { background: #e6f3ea; color: #1a7f47; }
.run--error .run__icon { background: #fdecec; color: var(--danger); }

.run--running .run__icon { background: var(--accent-soft); color: #0d5b78; }
.run--running .run__icon svg { animation: run-spin 1s linear infinite; }

@keyframes run-spin {
  to { transform: rotate(360deg); }
}

.run__main { flex: 1; min-width: 0; }

.run__top {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.run__status { font-size: 13.5px; font-weight: 600; }
.run--done .run__status { color: #1a7f47; }
.run--error .run__status { color: var(--danger); }
.run--running .run__status { color: #0d5b78; }

.run__when {
  font-size: 12.5px;
  color: var(--text-faint);
}

.run__summary {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.run__meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 8px;
  font-size: 12px;
  color: var(--text-faint);
}

.runs-empty {
  padding: 26px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}

/* ================= Responsive ================= */

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(23, 35, 48, .34);
  animation: fade-in .16s var(--ease);
}

.icon-btn.topbar__menu,
.icon-btn.sidebar__collapse { display: none; }

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform .22s var(--ease);
    box-shadow: var(--sh-menu);
    width: min(300px, 86vw);
  }

  .app--side-open .sidebar { transform: none; }
  .app--side-open .icon-btn.sidebar__collapse { display: inline-flex; }
  .icon-btn.topbar__menu { display: inline-flex; }

  .chat__log { padding: 18px 14px 22px; }
  .composer-zone { padding: 8px 12px 12px; }
  .chat__greeting { font-size: 22px; }
  .msg__body { max-width: 88%; }

  .agents-wrap, .agent-wrap { padding-left: 14px; padding-right: 14px; }
  .agents-head { flex-direction: column; gap: 12px; }
  .agents-head .btn--primary { margin-top: 0; }
  .agent-card { flex-wrap: wrap; }
  .agent-card__actions { align-self: stretch; justify-content: flex-end; margin-top: 0; }
  .agent-head { flex-wrap: wrap; }
  .agent-head__actions { width: 100%; justify-content: flex-end; }
  .check-grid { grid-template-columns: 1fr; }
  .check-grid .check + .check { border-top: 1px solid var(--border); }
}

@media (max-width: 480px) {
  .chat__suggest { flex-direction: column; width: 100%; }
  .chip { width: 100%; }
  .composer-zone--center { padding-bottom: 10vh; }
}

/* ================= Toast ================= */

.toast-zone {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: #25303f;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--sh-menu);
  animation: toast-in .22s var(--ease);
  max-width: 320px;
}

.toast svg { width: 15px; height: 15px; color: #7fd8f5; }
.toast--out { opacity: 0; transform: translateY(6px); transition: opacity .25s var(--ease), transform .25s var(--ease); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ===== Анализ Excel ===== */

.analysis-screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c3ccd6 transparent;
}

.analysis-screen::-webkit-scrollbar { width: 8px; }
.analysis-screen::-webkit-scrollbar-thumb { background: #c3ccd6; border-radius: 4px; border: 2px solid var(--ground); }

.an-wrap--wide { max-width: 1040px; }

.an-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.an-back:hover { color: var(--action); }

.an-head__badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.badge--warn { background: #fdf0e3; color: #a15c14; }

/* Дропзона */
.an-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 38px 20px;
  background: var(--panel);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.an-drop:hover, .an-drop:focus-visible, .an-drop--over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.an-drop__icon { width: 30px; height: 30px; color: var(--action); }
.an-drop__title { margin: 4px 0 0; font-size: 14.5px; font-weight: 600; }
.an-drop__sub { margin: 0; font-size: 12.5px; color: var(--text-muted); }

/* Прогресс / ошибка */
.an-progress, .an-error {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.an-progress__spin {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  border: 2.5px solid var(--accent-soft-2);
  border-top-color: var(--action);
  border-radius: 50%;
  animation: an-spin .8s linear infinite;
}
@keyframes an-spin { to { transform: rotate(360deg); } }
.an-progress__title { margin: 0; font-size: 14.5px; font-weight: 600; }
.an-progress__sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }
.an-error { flex-direction: column; }
.an-error__title { margin: 0; font-size: 15px; font-weight: 600; color: var(--danger); }
.an-error__text { margin: 4px 0 10px; font-size: 13px; color: var(--text-muted); }
.an-error .btn--outline { align-self: flex-start; }

/* Список анализов */
.an-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.an-list__title { margin: 6px 0 2px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.an-list__empty { padding: 18px 4px; font-size: 13px; color: var(--text-muted); }
.an-list__empty--err code { font-size: 12px; background: var(--hover); padding: 1px 6px; border-radius: 5px; }
.an-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.an-row:hover { border-color: var(--accent-line); box-shadow: var(--sh-1); }
.an-row__name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-row__meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.an-row__badges { display: flex; gap: 5px; }
.an-row__date { font-size: 12px; color: var(--text-faint); white-space: nowrap; }

/* Листы и блоки */
.an-sheetsnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; }
.an-sheetnav {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12.5px;
  color: var(--text);
  text-decoration: none;
}
.an-sheetnav:hover { border-color: var(--accent); color: var(--action); background: var(--accent-soft); }

.an-sheet { margin: 0 0 22px; }
.an-sheet__title { margin: 0 0 10px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.an-sheet__meta { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--text-muted); }

.an-block {
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.an-block__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.an-block__title-text { font-size: 13px; font-weight: 600; }
.an-block__meta { font-size: 12px; color: var(--text-muted); }

.an-coord {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--hover);
  color: var(--text-muted);
}

.an-cols { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.an-cols th {
  padding: 5px 8px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.an-cols td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.an-cols tr:last-child td { border-bottom: 0; }
.an-col__letter { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text-muted); width: 40px; }
.an-col__name { font-weight: 600; }
.an-col__path { display: block; font-size: 11px; font-weight: 400; color: var(--text-faint); }
.an-col__samples code {
  display: inline-block;
  margin: 0 4px 2px 0;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 11px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.an-type { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--hover); color: var(--text-muted); }
.an-type--number { background: #e6f3ea; color: #1a7f47; }
.an-type--text { background: var(--accent-soft); color: #0d5b78; }
.an-type--formula { background: #f0eafd; color: #6b43b8; }
.an-type--date { background: #fdf0e3; color: #a15c14; }
.an-type--mixed { background: #fbe9ea; color: var(--danger); }

.an-preview { margin-top: 10px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.an-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.an-preview th {
  padding: 6px 8px;
  text-align: left;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
.an-preview td { padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.an-preview tr:last-child td { border-bottom: 0; }

/* Все ячейки */
.an-cells { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel); }
.an-cells summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.an-cells__n { margin-left: 6px; font-weight: 400; color: var(--text-muted); }
.an-cells__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  max-height: 420px;
  overflow-y: auto;
}
.an-cell {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 8px;
  background: var(--panel);
  font-size: 12px;
  min-width: 0;
}
.an-cell__coord { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; color: var(--text-muted); flex: none; }
.an-cell__raw { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-cell--formula .an-cell__raw { color: #6b43b8; }
.an-cell--hidden { opacity: .55; }
.an-cell--merged .an-cell__coord::after { content: "⊞"; margin-left: 3px; }

/* Секции: совпадения, AI, проверка */
.an-sect {
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.an-sect__title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 14.5px; font-weight: 700; }
.an-sect__sub { margin: 2px 0 10px; font-size: 12.5px; color: var(--text-muted); }
.an-warn {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: #fdf0e3;
  color: #a15c14;
  font-size: 13px;
}

.an-match { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.an-match:last-child { border-bottom: 0; }
.an-match__pair { flex: 1; min-width: 0; }
.an-match__score { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; color: var(--text-muted); }

.an-claim { padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.an-claim:last-child { border-bottom: 0; }
.an-claim__meta { display: inline-flex; flex-wrap: wrap; gap: 5px; margin-left: 8px; align-items: center; font-size: 11.5px; color: var(--text-muted); }

.an-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin-bottom: 8px; }
.an-check { display: flex; align-items: baseline; gap: 8px; padding: 6px 9px; border-radius: var(--r-sm); background: var(--panel-2); font-size: 12.5px; }
.an-check__mark { color: #1a7f47; font-weight: 700; }
.an-check--fail .an-check__mark { color: var(--danger); }
.an-check__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-check__vals { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11.5px; color: var(--text-muted); }

.an-issues { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.an-issue { display: flex; gap: 9px; align-items: baseline; padding: 6px 9px; border-radius: var(--r-sm); font-size: 12.5px; }
.an-issue--err { background: #fbe9ea; }
.an-issue--warn { background: #fdf0e3; }
.an-issue--info { background: var(--panel-2); color: var(--text-muted); }
.an-issue__code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; color: var(--text-muted); flex: none; }

/* Обогащение: заказ × Google Sheets */
.an-head__actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; margin-top: 2px; }
.an-enrich__conn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.an-enrich__form {
  display: grid;
  grid-template-columns: minmax(200px, 1.4fr) minmax(140px, 1fr) minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.an-enrich__form .field + .field { margin-top: 0; }
.an-enrich__tbl { margin-top: 12px; }
.an-enrich__tbl td b { font-weight: 600; }
@media (max-width: 900px) {
  .an-enrich__form { grid-template-columns: 1fr 1fr; }
}

/* Карточка анализа в сообщении */
.analysis-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--panel-2);
  max-width: 480px;
}
.analysis-card__file { align-self: flex-start; }
.analysis-card__stats { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; font-size: 12.5px; color: var(--text-muted); }
.analysis-card__open { align-self: flex-start; }

.msg__bubble--error { border: 1px solid #efcdd0; background: #fdf1f1; color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
