:root {
  color-scheme: light;
  --ink: #17252b;
  --muted: #65757c;
  --line: #d8e0e3;
  --surface: #ffffff;
  --canvas: #f3f6f7;
  --sidebar: #17252b;
  --sidebar-soft: #22343b;
  --teal: #008f72;
  --teal-dark: #00745d;
  --teal-soft: #e2f4ef;
  --blue: #2878c8;
  --blue-soft: #e8f2fc;
  --amber: #a86704;
  --amber-soft: #fff3d4;
  --danger: #c23d36;
  --danger-soft: #fdebea;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, var(--sidebar) 0 34%, var(--canvas) 34% 100%);
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(23, 37, 43, 0.16);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--teal);
  color: white;
  font-size: 22px;
  font-weight: 800;
}

.brand-mark.compact {
  width: 38px;
  height: 38px;
  font-size: 18px;
}

.eyebrow {
  margin: 18px 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.login-panel h1 {
  margin-bottom: 8px;
  font-size: 29px;
}

.muted,
.section-heading p {
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #bfcbd0;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 143, 114, 0.12);
}

textarea {
  resize: none;
}

.button {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 750;
}

.button.primary {
  background: var(--teal);
  color: white;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: #bfcbd0;
  background: white;
  color: var(--ink);
}

.button.danger {
  color: #fff;
  border-color: #c9372c;
  background: #c9372c;
}

.nav-alert {
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 10px;
  color: #fff;
  background: #d83b2d;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.wide {
  width: 100%;
  margin-top: 10px;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.form-error {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: white;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  margin-top: 2px;
  color: #a9bbc2;
  font-size: 12px;
}

.steps {
  display: grid;
  gap: 5px;
  margin-top: 22px;
}

.step {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #c5d1d5;
  text-align: left;
  font-weight: 700;
}

.step span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid #5e737b;
  border-radius: 50%;
  font-size: 11px;
}

.step.active {
  background: var(--sidebar-soft);
  color: white;
}

.step.active span {
  border-color: var(--teal);
  background: var(--teal);
}

.sidebar-foot {
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #a9bbc2;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.text-button {
  margin-top: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: white;
  font-weight: 700;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 104px;
  padding: 22px clamp(20px, 4vw, 52px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: white;
}

.topbar .eyebrow {
  margin: 0 0 6px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar-status {
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.success {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.badge.neutral {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.content-section {
  width: min(1120px, calc(100% - 40px));
  margin: 32px auto;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin-bottom: 5px;
  font-size: 22px;
}

.section-heading p {
  margin-bottom: 0;
  font-size: 14px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.metric {
  min-width: 0;
  padding: 21px;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric span,
.metric strong,
.metric small {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  margin: 8px 0 5px;
  font-size: 21px;
}

.metric small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.settings-list {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  background: white;
}

.setting-row {
  min-height: 72px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--line);
  border-top: 0;
}

.setting-row strong,
.setting-row span {
  display: block;
}

.setting-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.notice {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid #eac66e;
  border-radius: 5px;
}

.warning-notice {
  background: var(--amber-soft);
  color: #6d4a06;
}

.connect-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(360px, 1.25fr);
  gap: 20px;
}

.flow-panel,
.details-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.flow-panel {
  padding: 20px;
}

.connection-mode {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.connection-mode legend {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.mode-option {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}

.mode-option:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.mode-option input {
  width: 16px;
  min-height: 16px;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.mode-option strong,
.mode-option small {
  display: block;
}

.mode-option small,
.mode-notice,
.completion-note,
#registrationPinField small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.mode-option small {
  margin-top: 3px;
}

.mode-notice {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
}

.selected-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--teal-soft);
}

.selected-mode span {
  color: var(--muted);
  font-size: 12px;
}

.completion-note {
  margin: 18px 0 0;
  padding: 11px 12px;
  border-left: 3px solid var(--teal);
  background: var(--teal-soft);
}

.flow-list {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.flow-list li {
  position: relative;
  min-height: 54px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.flow-list li:not(:last-child)::after {
  position: absolute;
  top: 30px;
  bottom: 2px;
  left: 13px;
  width: 1px;
  background: var(--line);
  content: "";
}

.flow-list li > span {
  z-index: 1;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid #b8c6cb;
  border-radius: 50%;
  background: white;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.flow-list li.current > span,
.flow-list li.done > span {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.flow-list strong,
.flow-list small {
  display: block;
}

.flow-list small {
  margin-top: 4px;
  color: var(--muted);
}

.details-panel h3 {
  margin-bottom: 16px;
  font-size: 17px;
}

.id-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.id-grid div {
  min-width: 0;
  padding: 12px;
}

.id-grid div + div {
  border-left: 1px solid var(--line);
}

.id-grid span,
.id-grid strong {
  display: block;
}

.id-grid span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.id-grid strong {
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafb;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td {
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 15px;
  border-radius: 5px;
  background: var(--sidebar);
  color: white;
  box-shadow: 0 12px 30px rgba(23, 37, 43, 0.24);
  font-size: 13px;
}

.chat-section {
  width: calc(100% - 48px);
  max-width: none;
}

.chat-heading {
  align-items: end;
}

.chat-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
}

.chat-toolbar label {
  min-width: 220px;
  margin: 0;
}

.new-chat {
  min-width: 300px;
}

.new-chat > label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.new-chat > div {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto;
  gap: 8px;
}

.chat-shell {
  height: min(720px, calc(100vh - 245px));
  min-height: 480px;
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  background: white;
}

.call-heading {
  align-items: end;
}

.call-channel-picker {
  display: flex;
  align-items: end;
  gap: 10px;
}

.call-channel-picker label {
  min-width: 300px;
}

.calls-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
}

.call-controls {
  display: grid;
  align-content: start;
  gap: 16px;
}

.call-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.call-panel h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.call-panel p {
  margin: 0;
}

.call-panel label {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  font-weight: 700;
  font-size: 13px;
}

.call-panel-heading,
.call-permission-row,
.call-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.call-help {
  margin: 10px 0 16px !important;
  color: var(--muted);
}

.permission-request {
  margin: 14px 0;
  padding: 14px;
  border-left: 3px solid #e0a800;
  background: #fff8dc;
}

.permission-confirm {
  grid-template-columns: auto 1fr !important;
  align-items: start;
  font-weight: 400 !important;
}

.active-call {
  color: #fff;
  background: #173c36;
}

.active-call > strong,
.active-call > span,
.active-call > time {
  display: block;
  margin-top: 8px;
}

.active-call > strong {
  font-size: 24px;
}

.active-call > time {
  margin: 18px 0;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.call-history {
  display: grid;
  margin: 0 -20px -20px;
}

.call-history-item {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 150px 110px;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.call-history-item strong,
.call-history-item span {
  display: block;
}

.call-history-item small {
  color: var(--muted);
}

.incoming-call-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(15 31 36 / 72%);
}

.incoming-call-overlay[hidden] {
  display: none;
}

.incoming-call-dialog {
  width: min(420px, 100%);
  padding: 32px;
  border-radius: 8px;
  background: #fff;
  text-align: center;
  box-shadow: 0 24px 80px rgb(0 0 0 / 30%);
}

.incoming-call-dialog strong,
.incoming-call-dialog span {
  display: block;
  margin: 8px 0;
}

.incoming-call-dialog .call-actions {
  margin-top: 24px;
}

.channel-name-dialog {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgb(0 0 0 / 30%);
}

.channel-name-dialog h2 {
  margin: 5px 0 8px;
}

.channel-name-dialog > p:not(.eyebrow, .form-error) {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.channel-name-dialog .call-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.channel-actions {
  width: 1%;
  white-space: nowrap;
}

.channel-rename-button {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.channel-rename-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

@media (max-width: 900px) {
  .calls-layout {
    grid-template-columns: 1fr;
  }

  .call-channel-picker {
    width: 100%;
  }

  .call-channel-picker label {
    min-width: 0;
    flex: 1;
  }
}

.conversation-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
}

.conversation-search {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fa;
}

.conversation-search input {
  min-height: 40px;
}

.conversation-list {
  overflow-y: auto;
}

.conversation-item {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: #edf4f3;
}

.contact-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #dce8eb;
  color: #31515c;
  font-size: 13px;
  font-weight: 800;
}

.conversation-copy {
  min-width: 0;
}

.conversation-copy strong,
.conversation-copy span,
.conversation-time {
  display: block;
}

.conversation-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.conversation-copy span {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-time {
  align-self: start;
  padding-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.chat-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  background: #efeae2;
}

.chat-contact {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fa;
}

.chat-contact strong,
.chat-contact span {
  display: block;
}

.chat-contact span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 20px clamp(14px, 5vw, 70px);
  background-image: radial-gradient(#d8d0c4 0.6px, transparent 0.6px);
  background-size: 12px 12px;
}

.message-row {
  display: flex;
  margin: 5px 0;
}

.message-row.outbound {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(72%, 650px);
  padding: 8px 10px 6px;
  border-radius: 6px;
  background: white;
  box-shadow: 0 1px 1px rgba(23, 37, 43, 0.12);
}

.message-row.outbound .message-bubble {
  background: #d9fdd3;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.4;
}

.message-image-link {
  display: block;
  width: min(360px, 58vw);
  overflow: hidden;
  border-radius: 4px;
  background: #edf1f2;
}

.message-image-link img {
  display: block;
  width: 100%;
  max-height: 440px;
  object-fit: contain;
}

.message-image-link.sticker {
  width: min(220px, 42vw);
  background: transparent;
}

.message-video {
  display: block;
  width: min(420px, 62vw);
  max-height: 440px;
  border-radius: 4px;
  background: #111;
}

.message-audio {
  width: min(380px, 64vw);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 2px;
}

.message-audio audio {
  min-width: 0;
  width: 100%;
  height: 38px;
}

.message-audio-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #008f79;
  color: white;
  font-size: 12px;
}

.message-document {
  width: min(360px, 62vw);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.055);
  color: inherit;
  text-decoration: none;
}

.message-document-icon {
  flex: 0 0 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #fff;
  color: #d34d3f;
  font-size: 10px;
  font-weight: 800;
}

.message-document strong,
.message-document small {
  display: block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-document small {
  margin-top: 2px;
  color: var(--muted);
}

.media-caption {
  margin-top: 7px;
}

.message-media-state {
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.message-media-state.failed {
  color: var(--danger);
}

.media-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid #c7d1d3;
  border-top-color: #008f79;
  border-radius: 50%;
  animation: media-spin 0.8s linear infinite;
}

@keyframes media-spin {
  to {
    transform: rotate(360deg);
  }
}

.message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.message-meta .failed {
  color: var(--danger);
  font-weight: 700;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #f7f9fa;
}

.chat-composer textarea {
  max-height: 120px;
}

.chat-window-notice {
  margin: 0;
  padding: 9px 12px;
  border-top: 1px solid #e2d4a8;
  background: #fff7d6;
  color: #654f00;
  font-size: 12px;
}

.chat-template-panel {
  max-height: min(520px, 70vh);
  overflow-y: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: white;
}

.chat-template-heading,
.chat-template-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-template-heading {
  margin-bottom: 12px;
}

.chat-template-heading strong,
.chat-template-heading span {
  display: block;
}

.chat-template-heading span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.chat-template-parameters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 10px;
}

.chat-template-preview {
  min-height: 70px;
  margin: 10px 0;
  padding: 11px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fa;
  font-size: 13px;
  line-height: 1.45;
}

.chat-template-confirm {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.chat-template-confirm input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.chat-template-actions {
  justify-content: flex-end;
}

.chat-error {
  min-height: 0;
  margin: 0;
  padding: 0 12px;
  background: #f7f9fa;
  color: var(--danger);
  font-size: 12px;
}

.chat-error:not(:empty) {
  padding-bottom: 9px;
}

.chat-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.compact-empty {
  min-height: 140px;
}

.template-heading {
  align-items: flex-end;
}

.template-toolbar,
.template-filters,
.button-fields {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.template-toolbar label {
  min-width: 280px;
  margin: 0;
}

.template-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.template-metrics div {
  min-width: 0;
  padding: 16px 18px;
}

.template-metrics div + div {
  border-left: 1px solid var(--line);
}

.template-metrics span,
.template-metrics strong {
  display: block;
}

.template-metrics span {
  color: var(--muted);
  font-size: 11px;
}

.template-metrics strong {
  margin-top: 4px;
  font-size: 24px;
}

.template-compose-layout {
  display: grid;
  grid-template-columns: minmax(430px, 1fr) minmax(340px, 420px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  overflow: visible;
}

.template-editor,
.template-browser,
.template-preview-panel {
  min-width: 0;
  padding: 20px;
}

.template-browser {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
}

.template-preview-panel {
  border-left: 1px solid var(--line);
  background: #f3f6f7;
}

.template-preview-heading {
  align-items: flex-start;
  margin-bottom: 14px;
}

.template-preview-heading p,
.template-library-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.template-phone {
  position: sticky;
  top: 18px;
  overflow: hidden;
  border: 1px solid #cbd5d8;
  border-radius: 6px;
  background: #efeae2;
  box-shadow: 0 12px 30px rgba(23, 43, 50, 0.12);
}

.template-phone-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 12px;
  background: #f0f2f5;
  border-bottom: 1px solid #d7dddf;
}

.template-phone-bar > span:last-child,
.template-phone-bar strong,
.template-phone-bar small {
  display: block;
}

.template-phone-bar strong {
  font-size: 13px;
}

.template-phone-bar small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.template-phone-avatar {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.template-chat-canvas {
  min-height: 510px;
  padding: 36px 18px 24px;
}

.template-message-bubble {
  position: relative;
  width: min(92%, 330px);
  margin-right: auto;
  padding: 9px 10px 8px;
  border-radius: 0 6px 6px 6px;
  background: white;
  box-shadow: 0 1px 1px rgba(23, 43, 50, 0.12);
}

.template-message-bubble::after {
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 9px solid white;
  border-left: 9px solid transparent;
  content: "";
}

.template-preview-header,
.template-preview-body,
.template-preview-footer {
  display: block;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.template-preview-header {
  margin: 0 0 5px;
  font-size: 14px;
}

.template-preview-body {
  margin: 0;
  color: #111b21;
  font-size: 13px;
  line-height: 1.45;
}

.template-preview-footer {
  margin-top: 7px;
  padding-right: 42px;
  color: #667781;
  font-size: 11px;
}

.template-preview-time {
  display: block;
  margin-top: 3px;
  color: #667781;
  font-size: 9px;
  text-align: right;
}

.template-preview-buttons {
  margin: 7px -10px -8px;
}

.template-preview-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 10px;
  border-top: 1px solid rgba(17, 27, 33, 0.12);
  color: #027eb5;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.template-preview-button > span {
  font-size: 14px;
}

.template-preview-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.template-preview-hint.warning {
  color: #9a6700;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h3 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-count {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.template-buttons {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.template-buttons legend {
  font-size: 13px;
  font-weight: 800;
}

.button-fields > label {
  min-width: 0;
  flex: 1;
}

.template-editor > .button {
  margin-top: 8px;
}

.template-filters {
  align-items: center;
}

.template-library-heading {
  margin-bottom: 14px;
}

.template-filters input {
  flex: 1;
}

.template-filters select {
  width: 190px;
}

.sync-state {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 11px;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  outline: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.template-card:hover,
.template-card:focus-visible {
  border-color: #7ea69e;
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.1);
}

.template-card.selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.template-card-head,
.template-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.template-card-head strong {
  overflow-wrap: anywhere;
}

.template-card-meta {
  justify-content: flex-start;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.template-card-body {
  margin: 12px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
}

.template-rejection {
  margin: 12px 0 0;
  padding: 9px 10px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}

@media (max-width: 800px) {
  .login-shell {
    background: var(--canvas);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 12px 14px;
  }

  .sidebar-brand {
    padding-bottom: 12px;
  }

  .steps {
    grid-template-columns: repeat(6, 1fr);
    margin-top: 12px;
  }

  .step {
    justify-content: center;
    font-size: 12px;
  }

  .sidebar-foot {
    display: none;
  }

  .topbar {
    min-height: auto;
    align-items: flex-start;
  }

  .topbar-status {
    flex-direction: column;
    align-items: flex-end;
  }

  .status-grid,
  .connect-layout,
  .template-compose-layout {
    grid-template-columns: 1fr;
  }

  .template-preview-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .template-phone {
    position: static;
  }

  .template-heading,
  .template-toolbar {
    align-items: stretch;
  }

  .template-heading {
    display: grid;
  }

  .template-toolbar {
    flex-wrap: wrap;
  }

  .template-toolbar label {
    min-width: min(100%, 280px);
    flex: 1;
  }

  .template-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-metrics div:nth-child(3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .template-metrics div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .chat-heading,
  .chat-toolbar,
  .call-heading {
    align-items: stretch;
  }

  .chat-heading,
  .call-heading {
    display: grid;
  }

  .chat-toolbar {
    flex-wrap: wrap;
  }

  .chat-toolbar label,
  .new-chat {
    min-width: min(100%, 260px);
    flex: 1;
  }

  .chat-shell {
    height: 650px;
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .metric + .metric {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .login-panel {
    padding: 25px 20px;
  }

  .step {
    gap: 5px;
    padding-inline: 4px;
  }

  .step span {
    display: none;
  }

  .steps {
    grid-template-columns: repeat(3, 1fr);
  }

  .topbar {
    padding: 18px 16px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .content-section {
    width: calc(100% - 24px);
    margin-top: 22px;
  }

  .call-channel-picker {
    display: grid;
  }

  .call-history-item {
    grid-template-columns: 1fr auto;
  }

  .call-history-item > small {
    grid-column: 1 / -1;
  }

  .chat-section {
    width: calc(100% - 24px);
  }

  .chat-shell {
    height: auto;
    min-height: 680px;
    grid-template-columns: 1fr;
    grid-template-rows: 250px minmax(430px, 1fr);
  }

  .conversation-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .message-bubble {
    max-width: 88%;
  }

  .chat-composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chat-composer textarea {
    grid-column: 1 / -1;
  }

  .chat-template-parameters {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .button-fields,
  .template-filters,
  .template-metrics,
  .template-list {
    grid-template-columns: 1fr;
  }

  .button-fields,
  .template-filters {
    display: grid;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .template-filters select {
    width: 100%;
  }

  .template-metrics div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .template-editor,
  .template-preview-panel,
  .template-browser {
    padding: 16px;
  }

  .template-chat-canvas {
    min-height: 390px;
    padding: 28px 14px 20px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .id-grid {
    grid-template-columns: 1fr;
  }

  .id-grid div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

/* Shared Messaging Hub visual system */
.login-shell {
  position: relative;
  overflow: hidden;
  background: #eef2f3;
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 34%;
  background: var(--sidebar);
}

.login-panel { position: relative; }
.app-shell { grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  padding: 18px 12px 12px;
  box-shadow: 8px 0 28px rgba(17, 37, 43, .08);
}

.sidebar-brand { padding: 0 8px 16px; }
.product-switcher {
  display: grid;
  gap: 5px;
  margin: 12px 0 4px;
  padding: 6px;
  border: 1px solid #30454d;
  border-radius: 7px;
  background: #101d22;
}

.product-option {
  min-height: 48px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 5px;
  background: transparent;
  color: #dbe4e7;
  text-decoration: none;
}

.product-option:hover { background: #1d2e35; }
.product-option.active { background: #2a3e46; color: #fff; }
.product-option > span:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.product-option strong, .product-option small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-option strong { font-size: 12px; }
.product-option small { color: #9eb0b7; font-size: 9px; }
.product-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

.product-mark.web { background: var(--teal); }
.product-mark.cloud { background: var(--blue); }
.steps { margin-top: 10px; }
.sidebar-foot { margin-top: auto; }
.topbar {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.content-section {
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(23, 37, 43, .045);
}

.status-grid > article:first-child,
.channel-card { border-top: 3px solid var(--blue); }

.connect-layout > aside { border-top: 3px solid var(--teal); }
.template-metrics,
.chat-shell,
.call-layout > section,
.call-layout > aside {
  box-shadow: 0 8px 26px rgba(23, 37, 43, .04);
}

@media (max-width: 800px) {
  .login-shell::before { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .product-switcher { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.bitrix-section {
  display: grid;
  gap: 20px;
}

.bitrix-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.bitrix-panel,
.bitrix-help,
.bitrix-bindings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bitrix-panel,
.bitrix-bindings {
  padding: 20px;
}

.bitrix-help {
  padding: 20px;
  border-top: 3px solid var(--blue);
}

.bitrix-help h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.bitrix-help ol {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bitrix-help li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.bitrix-help li > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #b9d8e8;
  border-radius: 50%;
  color: #1677a6;
  font-size: 12px;
  font-weight: 800;
}

.bitrix-help p,
.bitrix-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.bitrix-form {
  margin-top: 18px;
}

.bitrix-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.bitrix-install {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.bitrix-install .setting-row {
  margin: 0;
}

.bitrix-install .setting-row span {
  overflow-wrap: anywhere;
}

.compact-heading {
  margin-bottom: 16px;
}

.bitrix-search {
  width: min(100%, 310px);
}

.bitrix-binding-rows {
  display: grid;
}

.bitrix-binding-row {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.4fr) minmax(130px, .6fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 82px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.bitrix-binding-row:first-child {
  border-top: 0;
}

.bitrix-channel,
.bitrix-binding-status {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.bitrix-channel strong,
.bitrix-channel span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bitrix-channel span,
.bitrix-binding-status small {
  color: var(--muted);
  font-size: 11px;
}

.bitrix-binding-status .badge {
  justify-self: start;
}

@media (max-width: 1050px) {
  .bitrix-layout {
    grid-template-columns: 1fr;
  }

  .bitrix-binding-row {
    grid-template-columns: minmax(160px, .8fr) minmax(240px, 1.2fr) auto;
  }

  .bitrix-binding-status {
    display: none;
  }
}

@media (max-width: 700px) {
  .bitrix-panel,
  .bitrix-bindings,
  .bitrix-help {
    padding: 16px;
  }

  .bitrix-binding-row {
    grid-template-columns: 1fr auto;
  }

  .bitrix-binding-row select {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Bond-inspired CRM workspace */
:root {
  --ink: #181914;
  --muted: #77776f;
  --line: #d5d2c9;
  --surface: #fbfaf6;
  --canvas: #f3f1eb;
  --sidebar: #fbfaf6;
  --sidebar-soft: #ebe8df;
  --teal: #181914;
  --teal-dark: #33342e;
  --teal-soft: #efffc1;
  --blue: #6f63e8;
  --blue-soft: #ece9ff;
  --amber: #8a6512;
  --amber-soft: #fff0bd;
  --danger: #b63b31;
  --danger-soft: #ffe7e2;
  --lime: #d9ff55;
  --lavender: #c9c2ff;
  --peach: #ffc7a7;
  --sky: #bfe5ff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body {
  background: var(--canvas);
  color: var(--ink);
}

::selection { background: var(--lime); color: var(--ink); }

h1, h2, h3 { letter-spacing: 0; }

.login-shell {
  background: var(--canvas);
}

.login-shell::before { display: none; }

.login-panel {
  border-color: var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 12px 12px 0 var(--lime);
}

.brand-mark {
  border-radius: 8px;
  background: var(--ink);
  color: var(--lime);
}

.eyebrow { color: var(--ink); letter-spacing: .12em; }

input,
select,
textarea {
  min-height: 46px;
  border-color: var(--line);
  border-radius: 8px;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(24, 25, 20, .08);
}

.button {
  min-height: 42px;
  border-radius: 8px;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

.button.primary:hover {
  background: #33342e;
  transform: translateY(-1px);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: var(--ink);
  background: #fff;
  transform: translateY(-1px);
}

.app-shell { grid-template-columns: 274px minmax(0, 1fr); }

.sidebar {
  width: 274px;
  padding: 22px 15px 16px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 246, .96);
  color: var(--ink);
  box-shadow: none;
}

.sidebar-brand { padding: 0 8px 18px; }
.sidebar-brand strong { color: var(--ink); font-size: 15px; }
.sidebar-brand span { color: var(--muted); font-size: 10px; }

.product-switcher {
  gap: 3px;
  margin: 8px 0 12px;
  padding: 5px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--sidebar-soft);
}

.product-option {
  min-height: 49px;
  border-radius: 6px;
  color: var(--ink);
}

.product-option:hover { background: rgba(255, 255, 255, .6); }
.product-option.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(24, 25, 20, .08); }
.product-option small { color: var(--muted); }
.product-mark { border-radius: 7px; color: var(--ink); }
.product-mark.web { background: var(--lime); }
.product-mark.cloud { background: var(--lavender); }

.steps { display: grid; gap: 4px; margin-top: 6px; }

.step {
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #4d4e48;
}

.step:hover { border-color: var(--line); background: transparent; color: var(--ink); }
.step.active { background: var(--ink); color: #fff; }
.step > span { border-color: var(--line); color: var(--muted); }
.step.active > span { border-color: var(--lime); background: var(--lime); color: var(--ink); }
.sidebar-foot { border-color: var(--line); color: var(--muted); }
.sidebar-foot .text-button { color: var(--ink); }

.topbar {
  min-height: 94px;
  padding: 20px 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, .94);
  box-shadow: none;
}

.topbar h1 { font-size: 32px; letter-spacing: 0; }
.topbar-status { gap: 8px; }

.workspace > .content-section {
  max-width: 1440px;
  margin: 24px auto;
}

.content-section,
.flow-panel,
.details-panel,
.channel-card,
.template-card,
.template-editor,
.template-preview,
.chat-shell,
.call-layout > section,
.call-layout > aside,
.bitrix-panel,
.bitrix-help,
.bitrix-bindings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.content-section { padding: 24px; }
.section-heading { margin-bottom: 22px; }
.section-heading h2 { font-size: 22px; }
.section-heading p { color: var(--muted); }

.status-grid { gap: 14px; }

.status-grid .metric {
  min-height: 150px;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--ink);
  border-top: 1px solid var(--ink);
  border-radius: 8px;
  box-shadow: none;
}

.status-grid .metric:nth-child(1) { background: var(--lime); }
.status-grid .metric:nth-child(2) { background: var(--lavender); }
.status-grid .metric:nth-child(3) { background: var(--peach); }
.status-grid .metric span,
.status-grid .metric small { color: var(--ink); opacity: .62; }
.status-grid .metric strong { color: var(--ink); font-size: 30px; }

.badge {
  border-radius: 999px;
  border: 1px solid rgba(24, 25, 20, .12);
}

.badge.success { background: var(--lime); color: var(--ink); }
.badge.neutral { background: #efeee8; color: var(--ink); }
.badge.warning { background: var(--amber-soft); color: var(--ink); }

.settings-list,
.template-metrics { border-color: var(--line); border-radius: 8px; }
.setting-row { border-color: var(--line); }
.notice,
.mode-notice,
.completion-note { border-radius: 8px; }
.mode-notice,
.completion-note { background: var(--teal-soft); color: var(--ink); }

.connection-mode,
.mode-option,
.selected-mode,
.id-grid,
.flow-list li { border-color: var(--line); border-radius: 8px; }
.mode-option:has(input:checked) { border-color: var(--ink); background: var(--teal-soft); }
.flow-list li.current > span,
.flow-list li.done > span { background: var(--ink); color: var(--lime); }

.channel-card { border-top: 1px solid var(--line); }
.channel-card:hover { border-color: #aaa79e; }
.channel-avatar { background: var(--lime); color: var(--ink); }

.template-metrics {
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.template-metrics > div { background: var(--surface); }
.template-metrics > div:nth-child(1) { background: var(--lime); }
.template-metrics > div:nth-child(2) { background: var(--lavender); }
.template-metrics > div:nth-child(3) { background: var(--peach); }

.template-card,
.template-editor,
.template-preview { border-radius: 8px; }

.phone-preview,
.chat-messages { background: #efede6; }
.preview-message,
.message-bubble { border-radius: 8px 8px 8px 3px; box-shadow: none; }
.message-bubble.outbound { border-radius: 8px 8px 3px 8px; background: var(--teal-soft); }

.chat-shell { overflow: hidden; }
.chat-list,
.chat-panel,
.chat-header,
.chat-composer { border-color: var(--line); }
.chat-list { background: var(--surface); }
.chat-item:hover,
.chat-item.active { background: var(--sidebar-soft); }

.call-layout { gap: 18px; }
.call-layout > section,
.call-layout > aside { padding: 22px; }

.bitrix-help { border-top: 1px solid var(--line); }
.bitrix-help li > span { border-color: var(--ink); background: var(--ink); color: var(--lime); }

.form-error { color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .content-section:not([hidden]) { animation: bond-waba-enter .28s ease-out both; }
  @keyframes bond-waba-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 238px minmax(0, 1fr); }
  .sidebar { width: 238px; }
  .topbar { padding-inline: 24px; }
  .workspace > .content-section { margin: 20px 24px; }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .steps { grid-template-columns: repeat(7, minmax(82px, 1fr)); overflow-x: auto; }
  .step { min-height: 46px; padding: 7px; font-size: 11px; }
  .topbar { min-height: 78px; padding: 14px; }
  .workspace > .content-section { margin: 14px; }
  .status-grid { grid-template-columns: 1fr; }
  .status-grid .metric { min-height: 120px; }
}

/* Export.pdf dashboard reference pass */
:root {
  --ink: #181914;
  --muted: #74766f;
  --line: #d7d3c8;
  --surface: #fbfaf6;
  --canvas: #f4f2ec;
  --sidebar: #0d1714;
  --sidebar-soft: #1d3027;
  --teal: #22c55e;
  --teal-dark: #16a34a;
  --teal-soft: #efffc1;
  --blue: #3384e6;
  --blue-soft: #b8def3;
  --amber: #e58606;
  --amber-soft: #ffe9a8;
  --danger: #e23434;
  --danger-soft: #ffe5df;
  --lime: #d9ff55;
  --lavender: #c9c2ff;
  --peach: #ffc29e;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-weight: 560;
}

h1,
h2,
h3,
.metric strong,
.template-metrics strong {
  font-weight: 850;
}

.login-shell {
  background: var(--canvas);
}

.login-panel {
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 12px 12px 0 var(--lime);
}

.brand-mark {
  border-radius: 8px;
  background: var(--teal);
  color: #07130f;
}

.button {
  border-radius: 8px;
}

.button.primary,
.widget-template-panel .template-send {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.button.primary:hover {
  background: #30322b;
}

.button.secondary,
.widget-template-launch,
.widget-template-panel button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

input,
select,
textarea {
  border-color: var(--line);
  border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(24, 25, 20, .08);
}

.app-shell {
  grid-template-columns: 286px minmax(0, 1fr);
  background: var(--canvas);
}

.sidebar {
  width: 286px;
  padding: 28px 22px 20px;
  border-right: 0;
  background: var(--sidebar);
  color: #f6f8f2;
}

.sidebar-brand {
  padding: 0 0 24px;
  border-color: #294036;
}

.sidebar-brand strong {
  color: #fff;
  font-size: 20px;
}

.sidebar-brand span,
.product-option small,
.step,
.sidebar-foot {
  color: rgba(246, 248, 242, .62);
}

.product-switcher {
  gap: 8px;
  margin: 16px 0 18px;
  padding: 0;
  border: 0;
  background: transparent;
}

.product-option,
.step {
  border-radius: 8px;
}

.product-option {
  min-height: 62px;
  color: rgba(246, 248, 242, .74);
}

.product-option:hover,
.product-option.active,
.step:hover,
.step.active {
  background: var(--sidebar-soft);
  color: #fff;
}

.product-mark.web,
.product-mark.cloud,
.step.active > span {
  background: var(--lime);
  color: var(--ink);
}

.step {
  min-height: 58px;
  border: 1px solid transparent;
}

.step:hover,
.step.active {
  border-color: #294036;
}

.step > span {
  border-color: rgba(217, 255, 85, .55);
  color: var(--lime);
}

.sidebar-foot {
  border-color: #294036;
}

.sidebar-foot .text-button {
  color: #fff;
}

.topbar {
  min-height: 102px;
  padding: 22px 38px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  font-size: 36px;
}

.workspace > .content-section {
  max-width: 1480px;
  margin: 26px auto;
}

.content-section,
.flow-panel,
.details-panel,
.channel-card,
.template-card,
.template-editor,
.template-browser,
.template-preview-panel,
.chat-shell,
.call-layout > section,
.call-layout > aside,
.bitrix-panel,
.bitrix-help,
.bitrix-bindings,
.settings-list,
.template-metrics {
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.content-section,
.flow-panel,
.details-panel,
.call-layout > section,
.call-layout > aside {
  padding: 26px;
}

.section-heading h2 {
  font-size: 24px;
}

.section-heading p,
.muted {
  color: var(--muted);
}

.status-grid {
  gap: 14px;
}

.status-grid .metric,
.template-metrics div {
  min-height: 150px;
  position: relative;
  justify-content: space-between;
  padding: 22px;
  border: 1px solid var(--ink);
  border-radius: 8px;
}

.status-grid .metric::after,
.template-metrics div::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  margin-top: 12px;
  background: var(--ink);
}

.status-grid .metric:nth-child(1),
.template-metrics div:nth-child(1) {
  background: var(--lime);
}

.status-grid .metric:nth-child(2),
.template-metrics div:nth-child(2) {
  background: var(--lavender);
}

.status-grid .metric:nth-child(3),
.template-metrics div:nth-child(3) {
  background: var(--peach);
}

.template-metrics div:nth-child(4) {
  background: var(--blue-soft);
}

.metric span,
.metric small,
.template-metrics span {
  color: var(--ink);
  opacity: .62;
}

.metric strong,
.template-metrics strong {
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 42px;
}

.badge {
  border: 1px solid rgba(24, 25, 20, .12);
  border-radius: 999px;
}

.badge.success {
  background: #e2f8e8;
  color: #13883f;
}

.badge.warning {
  background: var(--amber-soft);
  color: var(--ink);
}

.badge.neutral {
  background: #efeee8;
  color: var(--ink);
}

.mode-option,
.selected-mode,
.id-grid,
.flow-list li,
.setting-row,
.bitrix-binding-row {
  border-color: var(--line);
  border-radius: 8px;
}

.mode-option:has(input:checked),
.mode-notice,
.completion-note,
.chat-template-panel,
.widget-template-preview,
.chat-template-preview {
  border: 1px solid #cfe7b1;
  background: var(--teal-soft);
  color: var(--ink);
}

.flow-list li.current > span,
.flow-list li.done > span,
.bitrix-help li > span {
  background: var(--ink);
  color: var(--lime);
}

.channel-card:hover,
.template-card:hover,
.template-card.selected,
.template-card:focus-visible {
  border-color: var(--ink);
  background: #fff;
}

.channel-avatar,
.conversation-avatar,
.template-phone-avatar {
  border-radius: 8px;
  background: var(--lavender);
  color: var(--ink);
}

.chat-shell {
  overflow: hidden;
}

.chat-list,
.conversation-sidebar,
.chat-header,
.chat-composer,
.message-composer,
.template-toolbar,
.widget-template-panel {
  border-color: var(--line);
  background: var(--surface);
}

.chat-item:hover,
.chat-item.active,
.conversation-item:hover,
.conversation-item.active {
  background: #e7e3d7;
  box-shadow: inset 4px 0 var(--ink);
}

.phone-preview,
.chat-messages,
.message-list,
.template-chat-canvas {
  background-color: #efede6;
  background-image: radial-gradient(rgba(24, 25, 20, .05) .7px, transparent .7px);
  background-size: 18px 18px;
}

.message-bubble,
.preview-message,
.template-message-bubble {
  border: 1px solid var(--line);
  border-radius: 8px 8px 8px 3px;
  background: #fff;
  box-shadow: none;
}

.message-bubble.outbound,
.template-message-bubble {
  border-color: #cfe7b1;
  border-radius: 8px 8px 3px 8px;
  background: var(--teal-soft);
}

.message-composer button {
  background: var(--ink);
}

.call-layout {
  gap: 18px;
}

.active-call-card,
.incoming-call-modal {
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--sidebar);
  color: #fff;
}

.template-preview-button {
  border-radius: 8px;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar { width: 250px; padding-inline: 16px; }
  .topbar { padding-inline: 24px; }
  .workspace > .content-section { margin: 20px 24px; }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    width: 100%;
    padding: 14px;
  }
  .steps {
    grid-template-columns: repeat(7, minmax(92px, 1fr));
  }
  .workspace > .content-section { margin: 14px; }
  .topbar {
    min-height: 82px;
    padding: 16px;
  }
  .topbar h1 { font-size: 28px; }
  .metric strong,
  .template-metrics strong { font-size: 34px; }
}
