:root {
  --bg: #f3f4f7;
  --rail: #1b1c20;
  --sidebar: #f7f8fa;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #8b909a;
  --line: #eceef2;
  --hover: #eef1f4;
  --active: #e4f3ec;
  --mint: #2f8f6d;
  --ink: #111111;
  --danger: #e24b4b;
  --orange: #ff6a1a;
  --tg: #2aabee;
  --max: #5b6cff;
  --wa: #25d366;
  --b24: #2fc6f6;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(22, 24, 29, 0.06);
  --ease: cubic-bezier(.2, .75, .25, 1);
  --fast: 160ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, "Segoe UI", system-ui, sans-serif;
  min-height: 100%;
}

body {
  overflow: hidden;
}

a { color: var(--mint); }

.hidden { display: none !important; }

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.rail {
  width: 76px;
  flex: 0 0 76px;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 18px;
}

.rail-stack,
.rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rail-stack { flex: 1; }

.rail-btn {
  position: relative;
  width: 46px;
  height: 46px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: #c8ccd3;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.rail-dot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: #4b5160;
}

.rail-dot.all { background: #6d7484; }
.rail-dot.cab { background: #2f8f6d; }
.rail-dot.tg { background: var(--tg); }
.rail-dot.max { background: var(--max); }
.rail-dot.wa { background: var(--wa); color: #083318; }

a.rail-btn { text-decoration: none; }

.rail-btn.off .rail-dot { opacity: 0.38; }
.rail-btn.active .rail-dot {
  box-shadow: 0 0 0 3px #111, 0 0 0 6px #dceee6;
}

.rail-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.rail-settings {
  background: rgba(255, 255, 255, 0.06);
  color: #d7dbe2;
}

.rail-settings:hover { background: rgba(255, 255, 255, 0.1); }

.sidebar {
  width: 360px;
  min-width: 280px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  flex: 0 0 auto;
  overflow: hidden;
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-mark rect { fill: #111; }
.brand-mark path {
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.rail-dot.brand-dot {
  background: #111;
  color: #fff;
}

.rail-dot.brand-dot svg {
  width: 22px;
  height: 22px;
  display: block;
}

.rail-dot.brand-dot path {
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
}

.brand strong,
#chat-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.muted.online,
#chat-meta.online,
.chat-presence.on {
  color: var(--mint);
  font-weight: 600;
}

.ticks {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  color: #9aa3ad;
  line-height: 0;
  vertical-align: -1px;
}

.ticks svg {
  display: block;
}

.ticks path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ticks.sending {
  opacity: 0.72;
}

.ticks.failed,
.msg.out .ticks.failed {
  color: #ffb4b4;
  font-size: 12px;
  font-weight: 800;
  width: 14px;
  justify-content: center;
}

.ticks.read,
.msg.out .ticks.read {
  color: #5ec8f0;
}

.msg.out .ticks {
  color: rgba(255, 255, 255, 0.62);
}

.preview .ticks {
  margin-left: 0;
  margin-right: 5px;
  color: #9aa3ad;
}

.preview .ticks.read {
  color: #3aa6d6;
}

.brand .muted { display: block; }

.search-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 16px 12px;
}

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  color: var(--muted);
}

.search-field input {
  border: 0;
  background: transparent;
  padding: 11px 0;
}

.list-head {
  padding: 6px 20px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b0b5be;
}

.chat-list {
  overflow: auto;
  flex: 1;
  padding: 0 10px 10px;
}

.contact-group {
  margin-bottom: 4px;
}

.contact-main {
  position: relative;
}

.contact-main:has(.contact-caret) .chat-item {
  width: 100%;
  padding-right: 38px;
}

.chat-item .badge {
  padding: 2px 6px;
  font-size: 9px;
}

.contact-caret {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.contact-caret::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  margin: 9px auto 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.contact-caret:hover,
.account-toggle:hover .contact-caret {
  color: var(--text);
  background: rgba(22, 24, 29, 0.06);
}

.contact-group.open > .contact-main > .contact-caret::before {
  margin-top: 11px;
  transform: rotate(225deg);
}

.contact-channels {
  display: none;
  padding: 0 6px 8px 18px;
}

.contact-group.open > .contact-channels {
  display: block;
}

.contact-channels-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa3ad;
}

.channel-dot.tg { background: var(--tg); }
.channel-dot.max { background: var(--max); }
.channel-dot.wa { background: var(--wa); }

.chat-item.nested {
  grid-template-columns: 32px 1fr;
  padding: 8px 10px;
  margin-bottom: 2px;
}

.chat-item.nested .avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.contact-create {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding: 8px 10px;
  border: 1px dashed #d5d9e0;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.contact-create:hover {
  border-color: var(--mint);
  background: #f3faf6;
}

.sidebar-foot {
  position: relative;
  padding: 8px 10px 12px;
  border-top: 1px solid var(--line);
  background: #f3f4f7;
}

.account-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr 28px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(22, 24, 29, 0.04);
}

.account-toggle.open,
.account-toggle:hover {
  background: var(--hover);
}

.account-toggle .contact-caret {
  position: static;
  transform: none;
}

.account-toggle.open .contact-caret::before {
  margin-top: 11px;
  transform: rotate(225deg);
}

.account-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.account-copy strong {
  font-size: 13px;
  font-weight: 700;
}

.account-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% - 4px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(22, 24, 29, 0.12);
  z-index: 6;
}

.account-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.account-row:hover,
.account-row.active {
  background: var(--hover);
}

.account-row.off {
  opacity: 0.48;
}

.account-row .rail-dot {
  width: 36px;
  height: 36px;
}

.account-plus {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  font-weight: 700;
}

.profile-channels {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.profile-channels:empty { display: none; }

.profile-channels-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.profile-channel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.profile-channel.active,
.profile-channel:hover {
  background: var(--hover);
}

.profile-channel.create {
  border-style: dashed;
}

.empty-list {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

.chat-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-item {
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.chat-item:hover { background: var(--hover); transform: translateX(2px); }
.chat-item.active { background: var(--active); }

.chat-item-body { min-width: 0; }
.chat-item-top,
.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chat-item-bottom { margin-top: 2px; }

.chat-item strong {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview {
  color: #8f959f;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item.active .preview { color: #5f6b66; }

.chat-item-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: #7aa0c8;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.badge {
  height: auto;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.badge.tg { background: var(--tg); }
.badge.max { background: var(--max); }
.badge.wa { background: var(--wa); color: #083318; }
.badge.b24 { background: var(--b24); color: #06314a; }
.badge.amo { background: #41479b; }
.badge.ext { background: #111111; }

.unread {
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

.chat-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.empty-chat {
  margin: auto;
  max-width: 520px;
  padding: 32px;
  text-align: left;
}

.empty-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b0b5be;
}

.empty-chat h1 {
  margin: 0 0 10px;
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.empty-lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
  max-width: 420px;
}

.active-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  position: relative;
}

.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 14px;
}

.chat-person:hover { background: var(--hover); }

.chat-head,
.chat-head-text {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.crm-panels,
.bitrix-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.crm-panels { margin-left: 0; }

.bitrix-link {
  font-size: 12px;
  font-weight: 700;
  color: #0b5aa8;
  text-decoration: none;
  background: #e8f6fc;
  border-radius: 999px;
  padding: 5px 10px;
}

.bitrix-link:hover { background: #d5eef8; }

.amo-link {
  font-size: 12px;
  font-weight: 700;
  color: #2c3278;
  text-decoration: none;
  background: #eceefc;
  border-radius: 999px;
  padding: 5px 10px;
}

.amo-link:hover { background: #dddff6; }

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.integration-card .field-hint { margin-bottom: 10px; }

.token-box {
  display: block;
  word-break: break-all;
  background: #f3f4f7;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  margin-bottom: 12px;
}

.token-docs {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: #f7f8fa;
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  overflow: auto;
}

.btn.tiny {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 12px;
}

.chat-head-text {
  min-width: 0;
  flex: 1;
  display: block;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.chat-head-actions .btn.icon {
  width: 36px;
  height: 36px;
}

.crm-panels { margin-left: 0; }

.search-field.grow {
  flex: 1;
  min-width: 0;
}

.chat-subpanel {
  border-bottom: 1px solid var(--line);
  background: #fff;
  max-height: 46%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  animation: panel-in 180ms var(--ease);
}

.profile-panel {
  width: 360px;
  flex: 0 0 360px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--line);
  animation: panel-in 180ms var(--ease);
}

.profile-panel.hidden { display: none; }

.profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 10px;
}

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 20px 14px;
  text-align: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  font-size: 24px;
  margin-bottom: 4px;
}

.profile-hero strong {
  font-size: 18px;
  font-weight: 750;
}

.profile-facts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.profile-media {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.profile-media-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px 0;
}

.profile-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 10px 12px 8px;
}

.profile-tabs button {
  width: 100%;
  text-align: center;
}

.profile-search {
  margin: 0 12px 8px;
}

.profile-media .chat-subpanel-results {
  flex: 1;
}

.profile-media .files-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
}

.profile-media .file-tile {
  border-radius: 4px;
}

.profile-media .files-list {
  padding: 0 6px 10px;
}

.file-voice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
}

.file-voice:hover { background: var(--hover); }

.file-voice .voice-player {
  min-width: 0;
}

.ctx-menu {
  position: fixed;
  z-index: 200;
  min-width: 220px;
  padding: 6px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(22, 24, 29, 0.16);
  border: 1px solid var(--line);
}

.ctx-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}

.ctx-menu button:hover { background: var(--hover); }

.chat-files-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.chat-files-title strong { font-size: 14px; }

.chat-subpanel.hidden { display: none; }

.chat-subpanel-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 6px;
}

.chat-subpanel-bar strong {
  font-size: 14px;
  white-space: nowrap;
}

.chat-subpanel-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
  overflow: auto;
}

.chat-subpanel-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.chat-subpanel-tabs button.active {
  background: var(--active);
  color: var(--text);
}

.chat-subpanel-results {
  overflow: auto;
  flex: 1;
  padding: 0 12px 12px;
}

.list-section {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 12px 6px;
}

.hit-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.hit-item:hover { background: var(--hover); }

.hit-thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #eef1f4;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.hit-thumb img,
.hit-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hit-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hit-body .preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-body mark {
  background: #d8f3e6;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.files-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
}

.files-skeleton span {
  aspect-ratio: 1;
  border-radius: 12px;
  background: linear-gradient(90deg, #eceef1 25%, #f7f8fa 45%, #eceef1 65%);
  background-size: 300% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
}

.file-tile {
  position: relative;
  padding: 0;
  border: 0;
  background: #eef1f4;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
}

.file-tile-ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #b0b6be;
  font-size: 18px;
  background: linear-gradient(90deg, #eceef1 25%, #f7f8fa 45%, #eceef1 65%);
  background-size: 300% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
}

.file-tile.ready .file-tile-ph,
.file-tile.broken .file-tile-ph { animation: none; }
.file-tile.ready .file-tile-ph { opacity: 0; }
.file-tile.broken {
  background: #eceff3;
}
.file-tile.broken .file-tile-ph {
  background: #eceff3;
  color: #8b909a;
  font-size: 11px;
  font-weight: 700;
}
.file-tile.broken .file-tile-ph:empty::after { content: "нет превью"; }

.file-tile img,
.file-tile video {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-tile .media-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  z-index: 1;
  pointer-events: none;
}

.thumb-broken { display: none; }

.files-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-icon {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e8eef0;
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.msg.out .file-icon {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.file-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg.hit {
  outline: 2px solid var(--mint);
  box-shadow: 0 0 0 4px rgba(47, 143, 109, 0.16);
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 22px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(180deg, #fbfbfc 0%, #f6f7f9 100%);
  overflow-anchor: none;
}

.day-sep {
  align-self: center;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.msg {
  max-width: min(68%, 640px);
  padding: 10px 12px 8px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: message-in 180ms var(--ease);
}

.msg.out {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.msg.in { align-self: flex-start; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .media { color: inherit; font-size: 13px; margin-bottom: 2px; opacity: 0.85; }

.msg .media-audio {
  display: block;
  width: min(280px, 100%);
  margin: 2px 0 6px;
}

.voice-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(260px, 100%);
  margin: 2px 0 6px;
}

.voice-play {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 50%;
  background: var(--mint);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.msg.out .voice-play {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.voice-track {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.voice-wave {
  display: block;
  width: 100%;
  min-width: 140px;
  height: 28px;
  cursor: pointer;
  touch-action: none;
}

.voice-time { font-size: 12px; color: var(--muted); }
.msg.out .voice-time { color: rgba(255, 255, 255, 0.72); }
.voice-player audio { display: none; }

.msg .media-photo,
.msg .media-video-open {
  display: block;
  padding: 0;
  border: 0;
  background: #111;
  cursor: pointer;
  position: relative;
  margin: 2px 0 6px;
  overflow: hidden;
  border-radius: 12px;
  width: min(280px, 100%);
}

.msg .media-video-open {
  min-height: 168px;
}

.msg .media-poster {
  display: block;
  width: 100%;
  min-height: 168px;
  background: #1a1c20;
}

.msg .media-photo img,
.msg .media-video-open video,
.msg .media-video-open img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
}

.msg .media-video-open img.thumb-broken,
.msg .media-photo img.thumb-broken {
  display: none;
}

.msg .media-video-open.no-thumb .media-poster {
  background:
    radial-gradient(circle at 30% 20%, #3a3d44 0%, #1a1c20 55%);
}

.msg .media-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.msg .media-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 2px 0 6px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: #f3f4f7;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.msg.out .media-file {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}

.msg.out .msg-meta { color: rgba(255, 255, 255, 0.62); }

.composer-wrap {
  background: var(--panel);
  border-top: 1px solid var(--line);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background var(--fast) var(--ease);
}

.composer-wrap.dragover {
  background: #eef7f2;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 20px 18px;
  background: transparent;
}

.composer textarea {
  resize: none;
  max-height: 140px;
  min-height: 48px;
  background: #f6f7f9;
}

.composer .btn.icon {
  width: 48px;
  height: 48px;
}

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 0;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f6f7f9;
  animation: panel-in 180ms var(--ease);
}

.attach-chip img,
.attach-chip .file-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
}

.attach-chip .file-icon {
  font-size: 10px;
}

.attach-chip-copy {
  min-width: 0;
  flex: 1;
}

.attach-chip-copy strong,
.attach-chip-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip-copy strong {
  font-size: 12px;
  font-weight: 650;
}

.attach-chip-copy span {
  font-size: 11px;
  color: var(--muted);
}

.attach-chip-remove {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.attach-chip-remove:hover {
  background: var(--hover);
  color: var(--text);
}

.send { height: 48px; padding-left: 18px; padding-right: 18px; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 11px 12px;
  font: inherit;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: #c9d8d1;
  box-shadow: 0 0 0 3px rgba(47, 143, 109, 0.12);
}

:focus-visible {
  outline: 3px solid rgba(47, 143, 109, 0.32);
  outline-offset: 2px;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease), color var(--fast) var(--ease), opacity var(--fast) var(--ease);
}

.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled,
button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn.loading::before,
.is-busy > .btn.primary::before,
.is-busy.btn::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.btn.primary {
  background: var(--ink);
  color: #fff;
  font-weight: 650;
}

.btn.primary:hover { background: #2a2b30; }
.btn.primary:disabled { opacity: 0.6; cursor: wait; }
a.btn { text-decoration: none; color: inherit; }

.btn.ghost,
.btn.icon {
  background: transparent;
  color: var(--muted);
}

.btn.ghost:hover,
.btn.icon:hover {
  color: var(--text);
  background: var(--hover);
}

.btn.icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 14px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-form { display: grid; gap: 12px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  border: 1px solid var(--line);
  background: #f6f7f9;
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--text);
  background: var(--active);
  border-color: #cfe4d8;
}

.auth-panel.hidden { display: none; }

.qr-box {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin-top: 8px;
}

.qr-canvas-wrap {
  background: #fff;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.qr-canvas-wrap canvas,
.qr-canvas-wrap img {
  display: block;
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
}

.channel-card .qr-canvas-wrap {
  display: flex;
  justify-content: center;
  min-height: 268px;
}

.qr-loading {
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
  color: #888;
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

.error {
  color: var(--danger);
  margin: 14px 0 0;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 24, 29, 0.28);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(22, 24, 29, 0.16);
  animation: modal-in 200ms var(--ease);
}

.modal-card.wide { width: min(980px, 100%); }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.channel-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.channel-card {
  border: 1px solid var(--line);
  background: #fbfbfc;
  border-radius: 20px;
  padding: 16px;
}

.channel-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field-hint,
.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}

.hint { text-align: center; }

.files-list .file-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.files-list .file-row:hover {
  background: var(--hover);
}

.file-icon.pdf { background: #fde8e8; color: #c0392b; }
.file-icon.doc,
.file-icon.docx { background: #e4eefc; color: #1d4f91; }
.file-icon.xls,
.file-icon.xlsx { background: #e5f6ea; color: #1e7a3a; }
.file-icon.zip,
.file-icon.rar { background: #fff1dc; color: #9a641d; }
.file-icon.txt,
.file-icon.md { background: #eeeef2; color: #4b5160; }

.media-modal { padding: 12px; z-index: 120; }
.media-modal-card {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.media-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(17, 17, 17, 0.72);
  color: #fff;
  border-radius: 14px;
  padding: 6px 8px;
}
.media-toolbar .btn.icon {
  background: transparent;
  color: #fff;
}
.media-caption {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.media-close { position: static; background: transparent; }
.media-error {
  color: #fff;
  padding: 24px;
  text-align: center;
}
.media-stage {
  display: grid;
  place-items: center;
  min-height: 120px;
}
.media-stage img,
.media-stage video {
  display: block;
  max-width: min(92vw, 960px);
  max-height: 78vh;
  border-radius: 16px;
  background: #000;
}
.media-stage audio {
  width: min(420px, 90vw);
}
.media-frame {
  width: min(92vw, 960px);
  height: min(78vh, 820px);
  border: 0;
  border-radius: 16px;
  background: #fff;
}
.media-text {
  width: min(92vw, 860px);
  max-height: 78vh;
  overflow: auto;
  margin: 0;
  padding: 16px 18px;
  border-radius: 16px;
  background: #111;
  color: #f3f4f7;
  font: 13px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.media-file-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: var(--text);
  border-radius: 18px;
  padding: 28px 32px;
  min-width: min(320px, 90vw);
  text-align: center;
}
.media-file-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.back { display: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 40;
  box-shadow: 0 12px 38px rgba(17, 17, 17, .2);
  animation: toast-in 180ms var(--ease);
  max-width: min(460px, calc(100vw - 28px));
  text-align: center;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 18, 22, 0.55);
  backdrop-filter: blur(8px);
}

.call-overlay.hidden { display: none !important; }

.call-card {
  width: min(360px, calc(100vw - 32px));
  background: #fff;
  border-radius: 28px;
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 24px 80px rgba(16, 18, 22, 0.28);
  text-align: center;
}

.call-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  font-size: 28px;
  margin-bottom: 8px;
}

.call-card strong {
  font-size: 20px;
  font-weight: 750;
}

.call-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--text);
}

.call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  width: 100%;
}

.call-hangup {
  background: #e24c4c;
  color: #fff;
  font-weight: 650;
  min-width: 120px;
}

.call-hangup:hover { background: #c93c3c; }

.call-mute.muted {
  background: #f3d2d2;
  color: #9b2c2c;
}

#call-remote { display: none; }

.cabinet-app .cabinet-sidebar {
  width: 248px;
  min-width: 248px;
  background: var(--sidebar);
}

.cab-nav-label {
  margin: 14px 14px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cab-nav-label:first-child { margin-top: 4px; }

a.cab-nav-btn { text-decoration: none; color: inherit; }

.cab-logout {
  margin: 8px 12px 16px;
  width: auto;
}

.cab-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 16px;
  flex: 1;
}

.cab-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #5c636c;
  border-radius: 16px;
  padding: 11px 14px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cab-nav-btn.active {
  background: var(--active);
  color: var(--text);
  font-weight: 650;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.cab-back {
  margin: 0 16px 18px;
  justify-content: flex-start;
}

.dash {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: var(--panel);
  padding: 28px 36px 48px;
}

.dash-page { max-width: 1120px; }
.dash-page:not(.hidden) { animation: panel-in 220ms var(--ease); }

.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.dash-head h1 {
  margin: 0 0 8px;
  font-size: 40px;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card,
.settings-card,
.overview-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px 20px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.dash-columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.dash-columns h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.overview-list {
  display: grid;
  gap: 10px;
}

.overview-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  text-align: left;
}

.overview-item:hover { background: #fbfbfc; }
.overview-item { transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease); }
.overview-item:hover { transform: translateY(-1px); box-shadow: 0 14px 34px rgba(22, 24, 29, .08); }

.lk-block { margin-top: 8px; }
.lk-block h3 { margin: 0 0 12px; font-size: 16px; }

.lk-table {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: visible;
}

.lk-table-head,
.lk-row-main {
  display: grid;
  grid-template-columns: minmax(170px, 1.05fr) minmax(180px, 1.5fr) 132px minmax(150px, auto);
  align-items: center;
  gap: 12px 16px;
  padding: 14px 20px;
}

.lk-table-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
}

.lk-row {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.lk-row:last-child {
  border-bottom: 0;
  border-radius: 0 0 18px 18px;
}

.lk-row:last-child .lk-row-main { border-radius: 0 0 18px 18px; }

.lk-row.is-on .lk-cta { display: none; }

.lk-row-btn {
  width: 100%;
  border: 0;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.lk-row-btn:hover,
.lk-row-main:hover { background: #fbfbfc; }

.lk-channel {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lk-channel strong { font-size: 15px; letter-spacing: -0.02em; }

.lk-table .connector-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: none;
}

.lk-meta { min-width: 0; }
.lk-plan,
.lk-sub { margin: 0; }
.lk-plan { font-size: 14px; }
.lk-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.lk-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.lk-menu { position: relative; }

.lk-kebab {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 700 16px/1 inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lk-kebab:hover { background: var(--hover); color: var(--text); }

.lk-menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  min-width: 180px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid;
}

.lk-menu-pop button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}

.lk-menu-pop button:hover { background: var(--hover); }

.lk-expand {
  display: none;
  padding: 0 20px 18px;
  max-width: 640px;
}

.lk-expand.is-open { display: grid; gap: 12px; }

.lk-row .connector-setup {
  padding: 0 20px 20px;
  max-width: 520px;
}

.lk-cta { min-width: 128px; }

.cabinet-page .modal-card .empty-lead { margin: 6px 0 0; }
.cabinet-page .modal-card .qr-box { justify-items: center; }
.cabinet-page .modal-card .qr-canvas-wrap,
.cabinet-page .modal-card .connector-qr {
  width: 220px;
  min-height: 0;
  margin: 0 auto 12px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}
.cabinet-page .modal-card .qr-canvas-wrap img,
.cabinet-page .modal-card .qr-loading {
  width: 196px;
  height: 196px;
}
.cabinet-page.modal-open { overflow: hidden; }

.account-grid {
  align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.connector-card {
  display: grid;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  min-height: 0;
}

.connector-card.is-on {
  border-color: #d7ece2;
  box-shadow: 0 12px 28px rgba(47, 143, 109, 0.08);
}

.connector-top {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.connector-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: block;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(22, 24, 29, 0.12);
}

.connector-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.connector-logo.tg svg rect { fill: #2aabee; }
.connector-logo.tg svg path { fill: #fff; }
.connector-logo.max svg rect { fill: #4f5dff; }
.connector-logo.max svg path { fill: #fff; }
.connector-logo.wa svg rect { fill: #25d366; }
.connector-logo.wa svg path { fill: #fff; }
.connector-logo.b24 svg rect { fill: #2fc6f6; }
.connector-logo.b24 svg path { fill: #fff; }
.connector-logo.amo svg rect { fill: #41479b; }
.connector-logo.amo svg path { fill: #fff; }
.connector-logo.ext svg rect { fill: #17181c; }
.connector-logo.ext svg path { fill: #fff; }

.connector-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.connector-copy strong {
  font-size: 17px;
  letter-spacing: -0.03em;
}

.connector-copy span,
.connector-lead,
.connector-me {
  color: var(--muted);
  font-size: 13px;
}

.connector-lead,
.connector-me { margin: 0; }

.connector-me {
  color: var(--text);
  font-weight: 650;
}

.connector-pill {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f3f6;
  color: #6d7380;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  white-space: nowrap;
}

.connector-pill.on {
  background: #e6f6ee;
  color: #1d7a4f;
}

.connector-pill.wait {
  background: #fff4dc;
  color: #9a641d;
}

.connector-pill.err {
  background: #fde8e8;
  color: #c0392b;
}

.connector-cta { width: 100%; }

.connector-setup {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.connector-card .qr-box { margin: 0; }

.connector-card .qr-canvas-wrap,
.connector-card .connector-qr {
  min-height: 0;
  width: 188px;
  margin: 0 auto;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.connector-card .qr-canvas-wrap img,
.connector-card .qr-canvas-wrap canvas,
.connector-card .qr-loading {
  width: 168px;
  height: 168px;
}

.connector-card .hint { margin: 0; }

.overview-item.overview-connector {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  flex-direction: unset;
}

.overview-connector .connector-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  box-shadow: 0 6px 14px rgba(22, 24, 29, 0.1);
}

.overview-connector .connector-copy strong {
  font-size: 15px;
}

.settings-card {
  display: grid;
  gap: 16px;
  max-width: 560px;
  padding: 22px;
}

.ai-card { max-width: 720px; }

.ai-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-card textarea {
  min-height: 72px;
  resize: vertical;
}

.ai-preview {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f6f7f9;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.45;
}

#chat-ai.active {
  color: var(--mint);
  background: var(--active);
}

.msg-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg-ai {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

@media (max-width: 720px) {
  .ai-grid { grid-template-columns: 1fr; }
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--text) !important;
}

.check-row input { width: auto; }

body.compact-list .chat-item { padding: 7px 10px; }
body.compact-list .avatar { width: 34px; height: 34px; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #d7dce1;
  border-right-color: var(--mint);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.result-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  min-height: 110px;
}

.chat-list.is-searching::before {
  content: "";
  display: block;
  height: 3px;
  margin: 0 8px 8px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  background-size: 200% 100%;
  animation: search-progress 1s linear infinite;
}

.message-skeleton {
  width: min(56%, 420px);
  padding: 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}
.message-skeleton.out { align-self: flex-end; background: #e9ebee; }
.message-skeleton span,
.message-skeleton small {
  display: block;
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eceef1 25%, #f7f8fa 45%, #eceef1 65%);
  background-size: 300% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
}
.message-skeleton small { width: 38%; height: 8px; margin-top: 9px; }
.message-skeleton:nth-child(2n) { width: min(42%, 320px); }

.state-card,
.messages-empty {
  margin: auto;
  display: grid;
  justify-items: center;
  gap: 7px;
  max-width: 360px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}
.state-card strong,
.messages-empty strong { color: var(--text); }
.error-state strong { color: var(--danger); }

.upload-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  padding: 10px 20px 0;
}
.upload-progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.upload-progress-track { height: 4px; overflow: hidden; border-radius: 4px; background: var(--line); }
.upload-progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--mint); transition: width 120ms linear; }
.upload-progress .btn { grid-row: 1 / 3; grid-column: 2; }

.ai-chat-banner {
  padding: 7px 20px;
  border-bottom: 1px solid #d9eee4;
  background: #f0faf5;
  color: var(--mint);
  font-size: 12px;
  font-weight: 650;
}
.ai-chat-banner.paused { border-color: #f1dfc4; background: #fff8ee; color: #9a641d; }

.scroll-bottom {
  position: absolute;
  right: 22px;
  bottom: 86px;
  z-index: 5;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.chat-main .scroll-bottom { right: 22px; }

.connection-status {
  position: fixed;
  z-index: 160;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff4df;
  color: #8b5a17;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 650;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes search-progress { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes message-in { from { opacity: 0; transform: translateY(5px) scale(.99); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(5px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .profile-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 100%);
    flex-basis: auto;
    z-index: 8;
    box-shadow: -16px 0 40px rgba(22, 24, 29, 0.08);
  }
}

@media (max-width: 980px) {
  .stat-grid,
  .dash-columns { grid-template-columns: 1fr; }
  .dash-head { flex-direction: column; }
}

@media (max-width: 800px) {
  .rail { width: 64px; flex-basis: 64px; }
  .sidebar { width: 100%; min-width: 0; }
  .chat-pane { display: none; }
  body.chat-open .sidebar,
  body.chat-open .rail { display: none; }
  body.chat-open .chat-pane { display: flex; }
  .back { display: inline-flex; }
  .empty-chat h1 { font-size: 32px; }

  .chat-head {
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 8px;
  }
  .chat-head .avatar { width: 36px; height: 36px; }
  .chat-head-actions { gap: 2px; }
  .chat-head-actions .btn.icon { width: 34px; height: 34px; }
  .crm-panels { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .messages { padding: 14px 12px 10px; }
  .msg { max-width: 86%; }
  .composer { padding: 9px 10px 10px; gap: 7px; }
  .composer .btn.icon { width: 44px; height: 44px; }
  .composer textarea { min-height: 44px; }
  .send { height: 44px; padding-inline: 13px; }
  .attach-preview { padding: 9px 10px 0; flex-wrap: nowrap; overflow-x: auto; }
  .upload-progress { padding-inline: 10px; }
  .chat-subpanel { max-height: 58%; }
  .chat-subpanel-bar { flex-wrap: wrap; }
  .chat-subpanel-bar strong { width: 100%; }
  .scroll-bottom { right: 14px; bottom: 76px; }

  .profile-panel {
    position: absolute;
    inset: 0;
    width: auto;
    flex-basis: auto;
    z-index: 8;
    border-left: 0;
  }

  .cabinet-page { overflow: auto; }
  .cabinet-page .app { height: auto; min-height: 100dvh; flex-direction: column; }
  .cabinet-page > .app > .rail { display: none; }
  .cabinet-page .cabinet-sidebar {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .cabinet-page .brand { padding: 12px 14px 8px; }
  .cabinet-page .brand-mark { width: 34px; height: 34px; }
  .cabinet-page .cab-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 4px 10px 10px;
    gap: 5px;
  }
  .cabinet-page .cab-nav-btn {
    width: auto;
    flex: 0 0 auto;
    padding: 9px 11px;
    border-radius: 12px;
    white-space: nowrap;
  }
  .cabinet-page .cab-nav-btn svg { display: none; }
  .cabinet-page .cab-nav-label,
  .cabinet-page .cab-logout { display: none; }
  .cabinet-page .lk-table-head { display: none; }
  .cabinet-page .lk-row-main {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }
  .cabinet-page .lk-meta { grid-column: 1 / -1; }
  .cabinet-page .lk-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .cabinet-page .dash { overflow: visible; padding: 22px 16px 36px; }
  .cabinet-page .dash-head h1 { font-size: 32px; }
  .cabinet-page .channel-cards,
  .cabinet-page .integration-grid { grid-template-columns: 1fr; }
  .cabinet-page .qr-canvas-wrap img,
  .cabinet-page .qr-canvas-wrap canvas,
  .cabinet-page .qr-loading { width: min(240px, 70vw); height: min(240px, 70vw); }
  .cabinet-page .channel-card .qr-canvas-wrap { min-height: min(268px, calc(70vw + 28px)); }
  .cabinet-page .connector-card .qr-canvas-wrap,
  .cabinet-page .connector-card .connector-qr { min-height: 0; width: min(188px, 70vw); }
  .cabinet-page .connector-card .qr-canvas-wrap img,
  .cabinet-page .connector-card .qr-canvas-wrap canvas,
  .cabinet-page .connector-card .qr-loading { width: min(168px, calc(70vw - 20px)); height: min(168px, calc(70vw - 20px)); }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-card strong { font-size: 23px; }
  .chat-head-actions .btn.icon:nth-last-child(-n+2) { display: none; }
  .modal { padding: 10px; }
  .modal-card { padding: 18px; border-radius: 20px; max-height: 94dvh; }
}

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 0%, #e7f4ee 0%, transparent 40%),
    var(--bg);
}

.auth-page .auth-shell { width: min(440px, 100%); }

.auth-page .auth-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}

.auth-page .auth-brand { padding: 0 0 18px; }

.auth-page .auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

.auth-page .auth-tabs button {
  border: 0;
  background: var(--hover);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.auth-page .auth-tabs button.active {
  background: #111;
  color: #fff;
}

.auth-page .auth-form .btn { width: 100%; }

.auth-page .auth-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
