/* Переписка личного Telegram-аккаунта: вкладка «Мессенджеры» → «Аккаунт» */
.tg-client-runtime {
  margin: 0.75rem 0 1rem;
  padding: 1rem 1.1rem;
}
.tg-client-runtime__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.tg-client-runtime__title {
  margin: 0;
  font-size: 1.05rem;
}
.tg-client-runtime__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.tg-runtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}
.tg-runtime-badge[data-tone='ok'] {
  border-color: rgba(200, 245, 66, 0.45);
  background: rgba(200, 245, 66, 0.14);
  color: var(--lime, #c8f542);
}
.tg-runtime-badge[data-tone='warn'] {
  border-color: rgba(232, 184, 74, 0.45);
  background: rgba(232, 184, 74, 0.14);
  color: #e8b84a;
}
.tg-runtime-badge[data-tone='danger'] {
  border-color: rgba(233, 96, 96, 0.45);
  background: rgba(233, 96, 96, 0.14);
  color: #e96060;
}
.tg-client-runtime__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.35rem 0 0.75rem;
}
.tg-client-runtime__switch-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.tg-client-runtime__actions {
  margin-top: 0.15rem;
}

.tg-inbox {
  display: grid;
  grid-template-columns: minmax(240px, 330px) 1fr;
  gap: 0.85rem;
  min-height: min(66vh, 720px);
  align-items: stretch;
  margin-bottom: 1rem;
}
.tg-inbox__list,
.tg-inbox__thread {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.85rem;
}
.tg-inbox__list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.tg-inbox__list-head h3 {
  margin: 0;
  font-size: 0.98rem;
}
.tg-inbox__list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.tg-inbox__unread {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.tg-inbox__search {
  display: block;
  margin: 0 0 0.55rem;
}
.tg-inbox__search input {
  width: 100%;
}
#tgClientDialogList {
  overflow: auto;
  flex: 1;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
#maxInboxDialogList {
  overflow: auto;
  flex: 1;
  min-height: 12rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.max-qr-login {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(230px, 320px);
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
  overflow: hidden;
}
.max-qr-login__visual {
  position: relative;
  width: 78px;
  height: 78px;
  border: 1px solid rgba(200, 245, 66, 0.28);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(200,245,66,.16), rgba(124,92,255,.1));
  box-shadow: inset 0 1px rgba(255,255,255,.14), 0 12px 32px rgba(0,0,0,.2);
  display: grid;
  place-items: center;
}
.max-qr-login__corners,
.max-qr-login__corners::before,
.max-qr-login__corners::after {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 3px solid var(--lime, #c8f542);
  border-right: 0;
  border-bottom: 0;
  border-radius: 3px 0 0;
  content: '';
}
.max-qr-login__corners { inset: 11px auto auto 11px; }
.max-qr-login__corners::before { left: 40px; top: -3px; transform: rotate(90deg); }
.max-qr-login__corners::after { left: 40px; top: 40px; transform: rotate(180deg); }
.max-qr-login__phone {
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--lime, #c8f542);
}
.max-qr-login__content h3,
.max-inbox-section__head h3,
.max-inbox__crm-head h3 { margin: 0; }
.max-qr-login__content .hint { margin: .3rem 0 .65rem; max-width: 58rem; }
.max-qr-login__eyebrow {
  color: var(--lime, #c8f542);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.max-qr-login__actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.max-qr-login__boundary {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .75rem .85rem;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  background: rgba(255,255,255,.035);
  font-size: .78rem;
  color: var(--text-muted);
}
.max-qr-login__boundary strong { color: var(--text-primary, #fff); font-size: .82rem; }
.max-inbox-section { margin-top: 1rem; }
.max-inbox-section__head,
.max-inbox__crm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .7rem;
}
.max-inbox-section__head .hint { margin: .25rem 0 0; }
.max-bot-invite {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1rem;
  margin-bottom: .8rem;
}
.max-bot-invite p { margin: .2rem 0 .5rem; }
.max-bot-invite code { word-break: break-all; }
.max-bot-invite__qr { border-radius: 12px; background: #fff; padding: 5px; }
.max-inbox { grid-template-columns: minmax(230px, 310px) minmax(0, 1fr); min-height: min(62vh, 650px); }
.max-inbox:has(.max-inbox__crm:not(.hidden)) { grid-template-columns: minmax(220px, 285px) minmax(0, 1fr) minmax(250px, 310px); }
.max-inbox__crm { padding: .8rem; overflow: auto; }
.max-inbox__crm .tg-field { margin: 0 0 .65rem; }
.max-inbox__composer { grid-template-columns: minmax(0, 1fr) auto; }
.max-inbox__composer-actions { display: flex; gap: .35rem; align-items: flex-end; }
.max-inbox__composer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: .45rem; font-size: .75rem; }
.max-inbox__composer-meta select { width: auto; min-width: 150px; min-height: 32px; }
.max-inbox__composer-meta label { display: inline-flex; align-items: center; gap: .3rem; color: var(--text-muted); }
.tg-inbox__reply { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .45rem .6rem; margin-bottom: .45rem; border-left: 3px solid var(--lime, #c8f542); background: rgba(200,245,66,.07); border-radius: 8px; font-size: .8rem; }
.tg-msg__bubble { padding: .55rem .7rem; border-radius: 14px; background: rgba(255,255,255,.06); }
.tg-msg--out .tg-msg__bubble { background: rgba(200,245,66,.13); }
.tg-msg__actions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; opacity: .25; transition: opacity .15s ease; }
.tg-msg:hover .tg-msg__actions { opacity: 1; }
.tg-msg-date { align-self: center; font-size: .7rem; color: var(--text-muted); padding: .2rem .55rem; border-radius: 999px; background: rgba(255,255,255,.04); }

@media (max-width: 980px) {
  .max-qr-login { grid-template-columns: auto 1fr; }
  .max-qr-login__boundary { grid-column: 1 / -1; }
  .max-inbox:has(.max-inbox__crm:not(.hidden)) { grid-template-columns: minmax(220px, 285px) 1fr; }
  .max-inbox__crm { grid-column: 1 / -1; }
}
.tg-dialog {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  border-radius: 12px;
  padding: 0.65rem 0.7rem;
  cursor: pointer;
}
.tg-dialog:hover {
  border-color: rgba(255, 255, 255, 0.2);
}
.tg-dialog.is-active {
  border-color: rgba(200, 245, 66, 0.45);
  background: rgba(200, 245, 66, 0.1);
}
.tg-dialog__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.tg-dialog__name {
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tg-dialog__time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.tg-dialog__preview {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tg-dialog__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}
.tg-dialog__tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.tg-dialog__tag--auto {
  background: rgba(200, 245, 66, 0.16);
  color: var(--lime, #c8f542);
}
.tg-dialog__tag--suggest {
  background: rgba(232, 184, 74, 0.16);
  color: #e8b84a;
}
.tg-dialog__unread {
  display: inline-flex;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--lime, #c8f542);
  color: #111;
  font-size: 0.72rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.tg-inbox__thread-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  max-width: 24rem;
}
.tg-inbox__thread-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.tg-inbox__thread-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tg-inbox__back {
  display: none;
}
.tg-inbox__peer {
  min-width: 0;
  flex: 1;
}
.tg-inbox__peer-name {
  font-weight: 700;
}
.tg-inbox__mode select {
  min-width: 12rem;
}
.tg-inbox__notice {
  margin: 0.55rem 0 0;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  background: rgba(232, 184, 74, 0.12);
  color: #e8b84a;
}
.tg-inbox__messages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 0;
  min-height: 12rem;
}
.tg-msg {
  max-width: 82%;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.tg-msg--in {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
}
.tg-msg--out {
  align-self: flex-end;
  background: rgba(200, 245, 66, 0.18);
}
.tg-msg__meta {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.65;
}
.tg-inbox__draft {
  border: 1px dashed rgba(200, 245, 66, 0.45);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
  background: rgba(200, 245, 66, 0.07);
}
.tg-inbox__draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.tg-inbox__draft-text {
  margin: 0;
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.tg-inbox__composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
}
.tg-inbox__composer textarea {
  min-height: 3.4rem;
  resize: vertical;
}
.tg-inbox__events {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
}

.tg-client-kb {
  padding: 1rem 1.1rem;
}
.tg-client-kb__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.tg-client-kb__title {
  margin: 0;
  font-size: 1.05rem;
}
.tg-client-kb__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tg-kb-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
}
.tg-kb-item.is-off {
  opacity: 0.55;
}
.tg-kb-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.tg-kb-item__title {
  font-weight: 650;
}
.tg-kb-item__body {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tg-kb-item__badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(200, 245, 66, 0.16);
  color: var(--lime, #c8f542);
}
.tg-client-kb__form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.85rem;
}
.tg-client-kb__insights {
  margin-top: 0.85rem;
  font-size: 0.85rem;
}
.tg-client-kb__insights summary {
  cursor: pointer;
  color: var(--text-muted);
}
.tg-insight {
  border-left: 2px solid rgba(200, 245, 66, 0.5);
  padding: 0.15rem 0 0.15rem 0.6rem;
  margin: 0.45rem 0;
  color: var(--text-muted);
}
.tg-prompt-preview {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  max-height: min(60vh, 520px);
  overflow: auto;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 0.75rem;
}

@media (max-width: 960px) {
  .tg-client-runtime__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 860px) {
  .tg-client-runtime__grid {
    grid-template-columns: 1fr;
  }
  .tg-inbox {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .tg-inbox.is-chat-open .tg-inbox__list {
    display: none;
  }
  .tg-inbox:not(.is-chat-open) .tg-inbox__thread {
    display: none;
  }
  .tg-inbox.is-chat-open .tg-inbox__back {
    display: inline-flex;
  }
  .tg-inbox__thread-head {
    flex-wrap: wrap;
  }
}

html[data-console-theme='light'] .tg-dialog,
html[data-console-theme='light'] .tg-kb-item,
html[data-console-theme='light'] .tg-runtime-badge {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.03);
}
html[data-console-theme='light'] .tg-msg--in {
  background: rgba(0, 0, 0, 0.06);
}
html[data-console-theme='light'] .tg-prompt-preview {
  background: rgba(0, 0, 0, 0.04);
}

/* Канал переписки: бизнес-бот или личная сессия */
.tg-channel-card {
  margin: 0.75rem 0 1rem;
  padding: 1rem 1.1rem;
}
.tg-channel-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.tg-channel-card__title {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}
.tg-channel-card__lead {
  margin: 0;
  max-width: 62ch;
}
.tg-channel-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  white-space: nowrap;
}
.tg-channel-status__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.tg-channel-status[data-state='business'] {
  border-color: rgba(200, 245, 66, 0.45);
  background: rgba(200, 245, 66, 0.14);
  color: var(--lime, #c8f542);
}
.tg-channel-status[data-state='mtproto'] {
  border-color: rgba(232, 184, 74, 0.45);
  background: rgba(232, 184, 74, 0.14);
  color: #e8b84a;
}
.tg-channel-status[data-state='none'] {
  border-color: rgba(233, 96, 96, 0.45);
  background: rgba(233, 96, 96, 0.14);
  color: #e96060;
}
.tg-channel-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.9rem 0 0.75rem;
}
.tg-channel-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}
.tg-channel-option:hover {
  border-color: rgba(255, 255, 255, 0.2);
}
.tg-channel-option:has(input:checked) {
  border-color: rgba(200, 245, 66, 0.5);
  background: rgba(200, 245, 66, 0.08);
}
.tg-channel-option__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.tg-channel-option__title {
  font-weight: 700;
  font-size: 0.9rem;
}
.tg-channel-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem 1rem;
  margin: 0 0 0.75rem;
}
.tg-channel-facts dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.tg-channel-facts dd {
  margin: 0.1rem 0 0;
  font-size: 0.88rem;
  word-break: break-word;
}
.tg-channel-howto {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}
.tg-channel-howto summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
}
.tg-channel-howto__steps {
  margin: 0.5rem 0 0.4rem;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
@media (max-width: 860px) {
  .tg-channel-choice {
    grid-template-columns: 1fr;
  }
}
