@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-cyrillic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f7f5f2;
  --surface: #fdfcfb;
  --surface-strong: #fffefa;
  --surface-soft: #f2efeb;
  --text: #171716;
  --text-secondary: #6f6c68;
  --text-muted: #918d88;
  --border: #e5e0da;
  --border-strong: #d7d1ca;
  --accent: #ff4b38;
  --accent-dark: #d92f20;
  --accent-soft: #fff0ea;
  --success: #3f7e45;
  --success-soft: #edf5eb;
  --danger: #c9362b;
  --shadow: 0 18px 60px rgba(90, 72, 58, .14);
  --radius: 14px;
  --radius-small: 10px;
  --topbar-height: 72px;
  --sidebar-width: 376px;
  --drawer-width: 356px;
  font-family: "Manrope", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(255, 75, 56, .23);
  outline-offset: 1px;
}

.is-hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.loading-view { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 28px; }
.loading-logo { width: 152px; height: auto; }
.loading-line { width: 150px; height: 7px; border-radius: 99px; }
.skeleton { background: linear-gradient(90deg, #eeeae5 20%, #faf8f6 45%, #eeeae5 70%); background-size: 240% 100%; animation: shimmer 1.5s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -240% 0; } }

.login-view { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; padding: 34px clamp(24px, 5vw, 76px); background: radial-gradient(circle at 75% 18%, #fff7f3 0, transparent 34%), var(--bg); }
.login-brand { display: flex; align-items: center; gap: 18px; height: 48px; }
.login-logo { display: block; width: 138px; height: auto; }
.login-product { display: inline-flex; align-items: center; font-size: 18px; font-weight: 700; line-height: 1; }
.login-card { width: min(430px, 100%); align-self: center; justify-self: center; margin-top: -30px; padding: 34px; background: rgba(255,255,255,.92); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); display: grid; gap: 20px; }
.login-heading { margin-bottom: 4px; }
.login-heading h1 { margin: 6px 0 0; font-size: 29px; line-height: 1.2; letter-spacing: -.025em; }
.login-heading p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.login-profile { color: var(--accent-dark) !important; font-weight: 700; }

.field { display: grid; gap: 8px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; color: #3f3d3a; }
.field input, .field textarea, .field select, .note-form textarea, .composer textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-small); background: var(--surface-strong); color: var(--text); padding: 12px 13px; line-height: 1.45; transition: border-color .16s ease, box-shadow .16s ease;
}
.field input::placeholder, .field textarea::placeholder, .note-form textarea::placeholder, .composer textarea::placeholder { color: #86827e; opacity: 1; }
.field input:hover, .field textarea:hover, .field select:hover, .note-form textarea:hover, .composer textarea:hover { border-color: #bbb4ac; }
.field input:focus, .field textarea:focus, .field select:focus, .note-form textarea:focus, .composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,75,56,.12); outline: none; }
.field textarea, .note-form textarea { resize: vertical; }
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.input-icon { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.form-error { margin: -4px 0 0; color: var(--danger); background: #fff1ef; border: 1px solid #f1c8c3; border-radius: var(--radius-small); padding: 10px 12px; font-size: 13px; line-height: 1.45; }

.button { min-height: 42px; border: 1px solid transparent; border-radius: var(--radius-small); padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; cursor: pointer; font-weight: 700; font-size: 14px; transition: transform .12s ease, background .16s ease, border-color .16s ease; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button-secondary { background: var(--surface-strong); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--surface-soft); }
.button-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.button-ghost:hover { background: var(--surface-soft); color: var(--text); }
.button-full { width: 100%; }
.button-small { min-height: 36px; padding: 0 12px; font-size: 12px; }

.icon-button { width: 40px; height: 40px; border: 0; border-radius: var(--radius-small); background: transparent; display: inline-grid; place-items: center; cursor: pointer; font-size: 21px; transition: background .15s ease, transform .12s ease; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button:active { transform: scale(.96); }

.app-shell { min-height: 100dvh; }
.topbar { height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(253,252,251,.94); border-bottom: 1px solid var(--border); position: relative; z-index: 30; }
.topbar-brand { min-width: 0; display: flex; align-items: center; gap: 18px; }
.topbar-logo { display: block; width: 116px; height: auto; flex: none; }
.brand-separator { height: 27px; width: 1px; flex: none; background: var(--border-strong); }
.product-title { display: inline-flex; align-items: center; font-weight: 750; font-size: 18px; line-height: 1; }
.topbar-actions { position: relative; }
.profile-button { min-height: 42px; max-width: 300px; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface-strong); padding: 0 13px 0 15px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; cursor: pointer; }
.profile-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropdown { position: absolute; z-index: 60; background: var(--surface-strong); border: 1px solid var(--border); border-radius: var(--radius-small); box-shadow: 0 14px 38px rgba(70,56,45,.16); padding: 6px; }
.dropdown button { width: 100%; min-height: 38px; border: 0; border-radius: 8px; background: transparent; padding: 0 10px; display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; white-space: nowrap; font-size: 13px; }
.dropdown button:hover { background: var(--surface-soft); }
.dropdown button i { font-size: 18px; color: var(--text-secondary); }
.profile-menu { right: 0; top: calc(100% + 8px); width: 210px; }
.dropdown-divider { display: block; height: 1px; background: var(--border); margin: 5px; }
.danger-menu { color: var(--danger); }

.messenger-grid { height: calc(100dvh - var(--topbar-height)); display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); position: relative; }
.chat-sidebar { min-width: 0; background: var(--surface); border-right: 1px solid var(--border); display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
.sidebar-head { padding: 18px 16px 12px; border-bottom: 1px solid var(--border); display: grid; gap: 14px; }
.search-field { height: 44px; border: 1px solid var(--border-strong); border-radius: var(--radius-small); background: var(--surface-strong); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 0 11px; }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,75,56,.1); }
.search-field i { color: var(--text-secondary); font-size: 19px; }
.search-field input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-field input::placeholder { color: #817d78; opacity: 1; }
.search-clear { width: 26px; height: 26px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; color: var(--text-secondary); }
.filter-row { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-strong); white-space: nowrap; color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.filter-button:hover { border-color: var(--border-strong); color: var(--text); }
.filter-button.is-active { color: var(--accent-dark); border-color: #ffb9ae; background: var(--accent-soft); font-weight: 700; }
.filter-count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; margin-left: 4px; color: #fff; background: var(--accent); font-size: 10px; }

.chat-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat-item { width: 100%; min-height: 86px; border: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 13px 14px; display: grid; grid-template-columns: 50px minmax(0,1fr) auto; gap: 11px; text-align: left; cursor: pointer; position: relative; }
.chat-item:hover { background: #faf7f4; }
.chat-item.is-active { background: var(--accent-soft); }
.chat-item.is-active::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 4px 4px 0; background: var(--accent); }
.avatar { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: #ece7e1; color: #5d5751; display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: none; }
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-large { width: 46px; height: 46px; }
.chat-copy { min-width: 0; align-self: center; }
.chat-title-row { min-width: 0; display: flex; align-items: center; gap: 7px; }
.chat-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 750; }
.channel-mini { flex: none; font-size: 9px; line-height: 18px; height: 18px; padding: 0 6px; border-radius: 5px; font-weight: 800; color: #fff; }
.channel-mini.vk { background: #2787f5; }
.channel-mini.max { background: #6558e8; }
.chat-preview { margin: 5px 0 0; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 1.45; }
.chat-side { align-self: center; display: grid; justify-items: end; gap: 10px; }
.chat-time { color: var(--text-muted); font-size: 10px; }
.unread-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 10px; font-weight: 800; }
.sidebar-state { min-height: 320px; display: grid; place-content: center; justify-items: center; padding: 32px; text-align: center; color: var(--text-secondary); }
.sidebar-state i { font-size: 34px; color: #aaa39c; margin-bottom: 12px; }
.sidebar-state strong { color: var(--text); font-size: 14px; }
.sidebar-state p { max-width: 250px; margin: 7px 0 16px; font-size: 12px; line-height: 1.55; }

.conversation { min-width: 0; min-height: 0; background: #faf8f5; display: grid; overflow: hidden; }
.conversation-empty { align-self: center; justify-self: center; max-width: 390px; padding: 30px; text-align: center; display: grid; justify-items: center; }
.empty-illustration { width: 78px; height: 78px; border-radius: 23px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 40px; transform: rotate(-3deg); }
.conversation-empty h2 { margin: 22px 0 7px; font-size: 21px; }
.conversation-empty p { margin: 0 0 20px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.conversation-content { min-height: 0; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.conversation-header { height: 76px; padding: 0 18px 0 22px; background: rgba(253,252,251,.96); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.conversation-person { min-width: 0; flex: 1; }
.conversation-person h2 { margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.conversation-meta { display: flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: 11px; }
.meta-separator { width: 3px; height: 3px; background: #aaa39c; border-radius: 50%; }
.header-more { flex: none; }
.mobile-back { display: none; }

.message-list { min-height: 0; overflow-y: auto; padding: 26px max(24px, 5vw); display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.day-divider { align-self: center; margin: 3px 0 8px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.74); color: var(--text-secondary); font-size: 10px; }
.message-row { width: min(72%, 690px); display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; align-items: end; }
.message-row.out { align-self: flex-end; grid-template-columns: minmax(0, 1fr); }
.message-row.in { align-self: flex-start; }
.message-avatar { width: 34px; height: 34px; font-size: 10px; }
.message-bubble { min-width: 0; padding: 11px 13px 8px; border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; background: var(--surface-strong); box-shadow: 0 4px 18px rgba(72,59,50,.05); }
.message-row.out .message-bubble { border-color: #f0d4c9; border-radius: 14px 14px 4px 14px; background: var(--accent-soft); }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.52; }
.message-footer { margin-top: 5px; display: flex; justify-content: flex-end; align-items: center; gap: 5px; color: var(--text-muted); font-size: 9px; }
.message-footer .ph { color: var(--accent); font-size: 13px; }
.message-attachments { display: grid; gap: 7px; margin-bottom: 7px; }
.message-attachment { overflow: hidden; border: 1px solid rgba(0,0,0,.08); border-radius: 9px; background: rgba(255,255,255,.65); }
.message-attachment img, .message-attachment video { display: block; max-width: 100%; max-height: 320px; object-fit: contain; }
.message-attachment audio { display: block; width: min(320px, 100%); }
.attachment-file { min-height: 48px; padding: 8px 10px; display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.attachment-file i { font-size: 23px; color: var(--accent); }
.attachment-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.message-state { align-self: center; color: var(--text-secondary); font-size: 12px; }

.composer-uploads { padding: 9px 16px 0; background: var(--surface); display: flex; gap: 8px; overflow-x: auto; }
.upload-chip { min-width: 165px; max-width: 230px; height: 42px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-strong); padding: 0 7px 0 10px; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 7px; }
.upload-chip > i { color: var(--accent); font-size: 18px; }
.upload-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.upload-chip button { width: 26px; height: 26px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.upload-chip.is-uploading { opacity: .6; }
.composer { min-height: 78px; padding: 13px 16px 16px; background: var(--surface); border-top: 1px solid var(--border); display: grid; grid-template-columns: auto auto minmax(0,1fr) auto auto; align-items: end; gap: 6px; }
.composer-control { position: relative; }
.composer-icon { margin-bottom: 1px; }
.composer textarea { min-height: 44px; max-height: 130px; resize: none; padding: 11px 13px; }
.send-button { height: 44px; min-height: 44px; margin-left: 4px; }
.attach-menu { left: 0; bottom: calc(100% + 9px); width: 176px; }
.reply-popover { left: 0; bottom: calc(100% + 9px); width: 310px; max-height: 320px; overflow-y: auto; }
.reply-popover-empty { padding: 16px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.reply-popover button { height: auto; min-height: 48px; display: grid; gap: 2px; padding: 8px 10px; white-space: normal; }
.reply-popover button strong { font-size: 12px; }
.reply-popover button span { color: var(--text-secondary); font-size: 10px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.emoji-popover { right: 0; bottom: calc(100% + 9px); width: 310px; max-height: min(360px, calc(100dvh - 130px)); padding: 10px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; overflow-y: auto; overscroll-behavior: contain; }
.emoji-popover button { min-height: 34px; padding: 0; display: grid; place-items: center; font-size: 19px; }

.client-drawer { position: absolute; z-index: 22; top: 0; right: 0; width: var(--drawer-width); height: 100%; background: var(--surface); border-left: 1px solid var(--border); box-shadow: -18px 0 40px rgba(70,56,45,.08); transform: translateX(102%); transition: transform .24s cubic-bezier(.16,1,.3,1); overflow-y: auto; }
.client-drawer.is-open { transform: translateX(0); }
.drawer-header { height: 64px; padding: 0 13px 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.drawer-header h2 { margin: 0; font-size: 16px; }
.client-profile { padding: 20px 18px; border-bottom: 1px solid var(--border); }
.client-profile-main { display: flex; align-items: center; gap: 12px; }
.client-profile-main h3 { margin: 0 0 4px; font-size: 15px; }
.client-profile-main p { margin: 0; color: var(--text-secondary); font-size: 11px; }
.client-details { margin-top: 17px; display: grid; gap: 10px; }
.client-detail { min-width: 0; display: grid; grid-template-columns: 22px minmax(0,1fr); gap: 8px; color: var(--text-secondary); font-size: 11px; }
.client-detail i { font-size: 17px; color: #7f7a74; }
.client-detail span { overflow-wrap: anywhere; }
.drawer-section { padding: 18px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title-row h3 { margin: 0; font-size: 13px; }
.small-count { min-width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-soft); color: var(--text-secondary); font-size: 10px; }
.note-form { display: grid; justify-items: end; gap: 8px; }
.note-form textarea { min-height: 82px; font-size: 11px; resize: vertical; }
.note-list { margin-top: 15px; display: grid; gap: 9px; }
.note-card { border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface-strong); padding: 11px; }
.note-card p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.5; }
.note-meta { margin-top: 9px; display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 9px; }
.note-delete { width: 26px; height: 26px; border: 0; border-radius: 7px; background: transparent; color: var(--danger); cursor: pointer; }
.note-empty { color: var(--text-secondary); font-size: 11px; line-height: 1.5; }
.drawer-backdrop { display: none; }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; background: rgba(30,27,24,.38); backdrop-filter: blur(2px); }
.modal { position: fixed; z-index: 90; left: 50%; top: 50%; width: min(820px, calc(100vw - 32px)); max-height: min(760px, calc(100dvh - 32px)); transform: translate(-50%, -50%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.modal-wide { width: min(980px, calc(100vw - 32px)); }
.modal-header { min-height: 83px; padding: 17px 18px 15px 22px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0 0 4px; font-size: 18px; }
.modal-header p { margin: 0; color: var(--text-secondary); font-size: 11px; }
.modal-body { min-height: 0; max-height: calc(100dvh - 150px); overflow: auto; }
.quick-modal-grid { display: grid; grid-template-columns: minmax(0, .92fr) minmax(320px, 1.08fr); }
.settings-list { min-height: 430px; padding: 14px; border-right: 1px solid var(--border); }
.settings-list-item { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface-strong); padding: 12px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; text-align: left; margin-bottom: 8px; }
.settings-list-item h4 { margin: 0 0 5px; font-size: 12px; }
.settings-list-item p { margin: 0; color: var(--text-secondary); font-size: 10px; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list-actions { display: flex; gap: 2px; align-self: center; }
.list-action { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--text-secondary); }
.list-action:hover { background: var(--surface-soft); color: var(--text); }
.list-action.danger:hover { color: var(--danger); background: #fff1ef; }
.settings-form { padding: 21px; display: grid; align-content: start; gap: 16px; }
.form-heading h3 { margin: 0 0 4px; font-size: 14px; }
.form-heading p { margin: 0; color: var(--text-secondary); font-size: 10px; line-height: 1.45; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.settings-modal-grid { display: grid; grid-template-columns: minmax(340px,.94fr) minmax(390px,1.06fr); }
.connection-column { border-right: 1px solid var(--border); padding: 14px; min-height: 510px; }
.column-heading { min-height: 42px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.column-heading h3 { margin: 0; font-size: 13px; }
.connection-list { display: grid; gap: 8px; }
.connection-card { border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface-strong); padding: 11px; }
.connection-card-head { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 10px; }
.channel-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; }
.channel-icon.max { background: #6558e8; }
.channel-icon.vk { background: #2787f5; }
.connection-copy { min-width: 0; }
.connection-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.connection-status { margin-top: 3px; display: flex; align-items: center; gap: 5px; color: var(--text-secondary); font-size: 9px; }
.status-mark { width: 6px; height: 6px; border-radius: 50%; background: #a59f99; }
.status-mark.connected { background: var(--success); }
.status-mark.error { background: var(--danger); }
.connection-actions { display: flex; gap: 2px; }
.connection-error { margin: 8px 0 0 46px; color: var(--danger); font-size: 9px; line-height: 1.4; }
.switch-row { min-height: 53px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; cursor: pointer; }
.switch-row > span:first-child { display: grid; gap: 3px; }
.switch-row strong { font-size: 12px; }
.switch-row small { color: var(--text-secondary); font-size: 9px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 40px; height: 23px; border-radius: 99px; padding: 3px; background: #c9c4be; transition: background .16s ease; }
.switch::after { content: ""; display: block; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: transform .16s ease; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(17px); }
.webhook-box { padding: 10px 11px; border: 1px dashed var(--border-strong); border-radius: var(--radius-small); background: var(--surface-soft); color: var(--text-secondary); font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }

.toast-region { position: fixed; z-index: 120; right: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { min-height: 52px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-small); background: var(--surface-strong); box-shadow: 0 12px 36px rgba(70,56,45,.16); padding: 10px 12px; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 9px; animation: toast-in .22s ease both; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast i { font-size: 19px; }
.toast span { font-size: 11px; line-height: 1.45; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1100px) {
  :root { --sidebar-width: 330px; }
  .message-list { padding-left: 24px; padding-right: 24px; }
  .message-row { width: min(80%, 650px); }
}

@media (max-width: 760px) {
  :root { --topbar-height: 62px; --sidebar-width: 100%; --drawer-width: min(92vw, 360px); }
  .topbar { padding: 0 14px; }
  .topbar-logo { width: 98px; }
  .brand-separator { height: 22px; }
  .product-title { font-size: 14px; }
  .profile-button { max-width: 152px; min-height: 38px; font-size: 11px; }
  .messenger-grid { grid-template-columns: 1fr; }
  .chat-sidebar { width: 100%; }
  .messenger-grid.mobile-chat-open .chat-sidebar { display: none; }
  .conversation { display: none; }
  .messenger-grid.mobile-chat-open .conversation { display: grid; }
  .mobile-back { display: inline-grid; margin-left: -6px; }
  .conversation-header { height: 66px; padding: 0 10px; gap: 8px; }
  .avatar-large { width: 40px; height: 40px; }
  .conversation-person h2 { font-size: 14px; }
  .message-list { padding: 18px 12px; }
  .message-row { width: min(88%, 520px); }
  .message-bubble { padding: 10px 11px 7px; }
  .composer { min-height: 68px; padding: 9px 8px calc(9px + env(safe-area-inset-bottom)); grid-template-columns: auto auto minmax(0,1fr) auto auto; gap: 2px; }
  .composer .icon-button { width: 35px; height: 40px; font-size: 19px; }
  .composer textarea { min-height: 42px; padding: 10px; font-size: 12px; }
  .send-button { width: 42px; padding: 0; }
  .send-button span { display: none; }
  .reply-popover { position: fixed; left: 10px; right: 10px; bottom: 74px; width: auto; }
  .emoji-popover { position: fixed; left: 10px; right: 10px; bottom: 74px; width: auto; max-height: min(46dvh, 360px); grid-template-columns: repeat(8, 1fr); }
  .client-drawer { position: fixed; top: var(--topbar-height); height: calc(100dvh - var(--topbar-height)); }
  .drawer-backdrop { display: block; position: fixed; z-index: 21; inset: var(--topbar-height) 0 0; border: 0; background: rgba(30,27,24,.3); }
  .quick-modal-grid, .settings-modal-grid { grid-template-columns: 1fr; }
  .settings-list, .connection-column { min-height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings-list { max-height: 240px; overflow-y: auto; }
  .connection-column { max-height: 260px; overflow-y: auto; }
  .modal { width: calc(100vw - 18px); max-height: calc(100dvh - 18px); border-radius: 15px; }
  .modal-body { max-height: calc(100dvh - 102px); }
  .login-view { padding: 20px; }
  .login-card { margin-top: 0; padding: 26px 21px; }
}

@media (max-width: 410px) {
  .topbar .product-title, .topbar .brand-separator { display: none; }
  .profile-button { max-width: 170px; }
  .message-avatar { display: none; }
  .message-row.in { grid-template-columns: minmax(0,1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
