:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #172033;
  --muted: #687386;
  --accent: #1d6fb8;
  --accent-dark: #155386;
  --ok: #147a4b;
  --warn: #8a5a00;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: grid-template-columns 160ms ease;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  grid-column: 1 / -1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf3f8;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(23, 32, 51, 0.12);
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card label,
.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-status {
  min-height: 20px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  background: #172033;
  color: #fff;
  padding: 24px 18px;
  overflow: hidden;
  transition: padding 160ms ease, width 160ms ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
}

.brand-subtitle {
  color: #b8c2d1;
  font-size: 13px;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  margin-left: auto;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #dce5f3;
  font-size: 22px;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  text-align: left;
  color: #dce5f3;
  background: transparent;
  border: 0;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

@media (min-width: 1051px) {
  body.sidebar-collapsed {
    grid-template-columns: 72px 1fr;
  }

  body.sidebar-collapsed .sidebar {
    padding: 20px 12px;
    align-items: center;
  }

  body.sidebar-collapsed .sidebar-main {
    width: 100%;
  }

  body.sidebar-collapsed .brand {
    justify-content: center;
    margin-bottom: 24px;
  }

  body.sidebar-collapsed .brand-copy {
    display: none;
  }

  body.sidebar-collapsed .brand-mark {
    width: 42px;
    height: 42px;
  }

  body.sidebar-collapsed .sidebar-toggle {
    position: absolute;
    top: 72px;
    right: -14px;
    z-index: 2;
    width: 28px;
    height: 28px;
    background: #23304a;
    transform: rotate(180deg);
  }

  body.sidebar-collapsed .nav {
    justify-items: center;
  }

  body.sidebar-collapsed .nav button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    text-align: center;
    font-size: 0;
  }

  body.sidebar-collapsed .nav button::before {
    content: attr(data-short);
    font-size: 16px;
    font-weight: 800;
  }

  body.sidebar-collapsed .profile-card {
    grid-template-columns: 1fr;
    justify-items: center;
    width: 48px;
    padding: 6px 4px;
    border-color: transparent;
    background: transparent;
  }

  body.sidebar-collapsed .profile-avatar {
    width: 42px;
    height: 42px;
  }

  body.sidebar-collapsed .profile-body {
    display: none;
  }

  body.sidebar-collapsed[data-screen="dialogs"] .messenger {
    grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.45fr) minmax(260px, 0.8fr);
  }
}

.profile-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.profile-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #172033;
  font-weight: 800;
}

.profile-body strong,
.profile-body span {
  display: block;
}

.profile-body span {
  color: #b8c2d1;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
}

.role-picker {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: #dce5f3;
  font-size: 12px;
  font-weight: 700;
}

.logout-button {
  width: 100%;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
}

select,
input,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 10px;
  font: inherit;
  color: var(--text);
}

textarea {
  padding-top: 9px;
  padding-bottom: 9px;
  line-height: 1.35;
  resize: none;
}

textarea.is-multiline {
  border-radius: 18px;
}

.shell {
  padding: 28px;
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

h3 {
  margin: 18px 0 10px;
  font-size: 15px;
}

.status {
  color: var(--ok);
  background: #e9f7ef;
  border: 1px solid #b9e4cc;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  white-space: nowrap;
}

.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px;
}

.menu-button span {
  display: block;
  height: 2px;
  background: #172033;
  border-radius: 2px;
}

.menu-button span + span {
  margin-top: 5px;
}

.dialogs-menu-button {
  display: none;
}

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

body[data-screen="dialogs"] .workspace {
  overflow: hidden;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel,
.dialog-item,
.message,
.check,
.stat-card,
.analytics-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header.compact {
  align-items: flex-start;
}

.dialog-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-search-button {
  background: #edf3fa;
  color: var(--accent-dark);
  border: 1px solid #cbdff1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.messenger {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(340px, 1.36fr) minmax(240px, 0.82fr);
  gap: 16px;
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.dialog-list-panel,
.chat-panel,
.context-panel {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.screen.active#screen-dialogs {
  height: 100%;
  min-height: 0;
}

.dialog-list-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.context-panel {
  overflow-y: auto;
}

.queue-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.queue-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.new,
.dialog-status.new {
  background: #fee4e2;
  color: var(--danger);
}

.dot.waiting,
.dialog-status.waiting {
  background: #fef0c7;
  color: var(--warn);
}

.dot.ai,
.dialog-status.ai {
  background: #dcfae6;
  color: var(--ok);
}

.dot.human,
.dialog-status.human {
  background: #e8eef7;
  color: #344054;
}

.dot.problem,
.dialog-status.problem {
  background: #ffead5;
  color: #b54708;
}

.conversation-list,
.checks,
.message-list,
.action-stack {
  display: grid;
  gap: 10px;
}

.conversation-list,
.message-list {
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  padding-right: 2px;
}

.empty-state {
  display: grid;
  gap: 6px;
  align-content: center;
  min-height: 160px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
}

.dialog-item {
  width: 100%;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 8px 10px;
  text-align: left;
  padding: 12px;
  color: var(--text);
}

.dialog-item:hover,
.dialog-item.active {
  border-color: #9ec5ea;
  background: #f4f8fd;
}

.dialog-status {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.dialog-avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d6fb8, #52a3d8);
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

.dialog-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dialog-main small,
.dialog-main span,
.dialog-meta {
  color: var(--muted);
  font-size: 13px;
}

.dialog-main strong,
.dialog-preview {
  overflow: hidden;
  text-overflow: ellipsis;
}

.dialog-main strong {
  white-space: nowrap;
}

.dialog-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.apartment-status {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7f8ef;
  color: var(--ok);
  font-size: 11px;
  font-weight: 800;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.dialog-mini-status,
.responder-status {
  width: fit-content;
  max-width: 32px;
  min-width: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

button.responder-status {
  cursor: pointer;
}

.dialog-mini-status {
  background: #e8eef7;
  color: #344054;
}

.dialog-mini-status.new,
.dialog-mini-status.problem {
  background: #fee4e2;
  color: var(--danger);
}

.dialog-mini-status.waiting {
  background: #fef0c7;
  color: var(--warn);
}

.dialog-mini-status.ai {
  background: #dcfae6;
  color: var(--ok);
}

.responder-status.ai {
  background: #eef4ff;
  color: #3538cd;
}

.responder-status.human {
  background: #f2f4f7;
  color: #344054;
}

.responder-menu {
  position: absolute;
  right: 10px;
  top: calc(100% + 8px);
  z-index: 8;
  width: 190px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(23, 32, 51, 0.18);
  color: var(--text);
}

.responder-menu[hidden] {
  display: none;
}

.responder-menu strong {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
}

.responder-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  font-size: 14px;
}

.responder-menu input {
  width: auto;
  min-height: 0;
}

.responder-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.responder-menu-actions button {
  padding: 8px 10px;
}

.dialog-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.dialog-meta b {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.chat-header span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.chat-back-button {
  display: none;
}

.chat-title-button {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.chat-title-button > span:last-child {
  min-width: 0;
}

.chat-title-button:hover {
  background: transparent;
  color: var(--text);
}

.chat-title-button h2,
.chat-title-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title-button small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.message-list {
  min-height: 0;
  height: 100%;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-empty {
  justify-self: stretch;
}

.message {
  max-width: 82%;
  padding: 12px;
}

.message span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.message p {
  margin-bottom: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-attachment {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}

.message-attachment img,
.message-attachment video {
  display: block;
  width: 100%;
  max-width: min(360px, 100%);
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.message-attachment audio {
  width: min(320px, 100%);
}

.message-attachment figcaption,
.file-attachment,
.media-attachment {
  display: grid;
  gap: 6px;
}

.message-attachment figcaption span,
.message-attachment strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.message-attachment small {
  color: var(--muted);
  font-size: 12px;
}

.message-attachment a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.message-attachment figcaption {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  column-gap: 10px;
}

.message-attachment figcaption small {
  grid-column: 1 / -1;
}

.file-attachment,
.media-attachment {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.file-attachment div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.message.guest {
  justify-self: start;
}

.message.manager,
.message.external-api {
  justify-self: end;
}

.message.external-api {
  background: #eaf4ff;
  border-color: #b8d9f4;
}

.message.ai {
  justify-self: start;
  background: #f2f4f7;
  border-style: dashed;
}

.reply-box {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reply-box.has-text {
  grid-template-columns: auto 1fr auto;
}

.reply-box:not(.has-text) .composer-send,
.reply-box.has-text .composer-optional {
  display: none;
}

.composer-icon,
.composer-send {
  min-height: 38px;
}

.composer-icon {
  width: 38px;
  padding: 0;
  background: #edf3fa;
  color: var(--accent-dark);
  border: 1px solid #cbdff1;
  border-radius: 50%;
  font-size: 17px;
}

.composer-send {
  width: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.context-block + .context-block {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.context-screen-header {
  display: none;
}

.ai-summary,
.context-note {
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #f4f8fd;
  color: #314057;
  line-height: 1.45;
}

.booking-link-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.booking-link-form select {
  min-width: 0;
}

dl {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 7px 12px;
  margin: 10px 0 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

li + li {
  margin-top: 6px;
}

.action-stack button {
  width: 100%;
  text-align: left;
  background: #edf3fa;
  color: var(--accent-dark);
  border: 1px solid #cbdff1;
}

.secondary-button {
  background: #edf3fa;
  color: var(--accent-dark);
  border: 1px solid #cbdff1;
}

.secondary-button:hover {
  background: #dbeaf8;
}

.integration-card {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #b8d9f4;
  border-radius: 8px;
  background: #f4f8fd;
}

.integration-card-header,
.webhook-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.integration-card-header strong,
.integration-card-header span {
  display: block;
}

.integration-card-header span,
.webhook-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.integration-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  background: #dcfae6;
  color: var(--ok) !important;
  font-size: 12px !important;
  font-weight: 800;
}

.integration-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.integration-metrics article {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.integration-metrics strong {
  font-size: 20px;
}

.webhook-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.webhook-url-row-with-test {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.webhook-url-row input {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.integration-settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.integration-settings-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.integration-settings-form input {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.integration-settings-form button {
  min-height: 38px;
}

.wappi-channel-list {
  display: grid;
  gap: 8px;
}

.wappi-channel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wappi-channel-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

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

.wappi-channel-main span {
  color: var(--muted);
  font-size: 13px;
}

.wappi-channel-actions {
  display: flex;
  gap: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.settings-modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.settings-modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.settings-modal .integration-settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px;
}

.wide-field,
.settings-modal-section {
  grid-column: 1 / -1;
}

.settings-modal-section {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.settings-modal-section strong,
.settings-modal-section p {
  margin: 0;
}

.settings-modal-section p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.compact-url-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.webhook-events {
  display: grid;
  gap: 8px;
}

.webhook-events > strong {
  font-size: 13px;
}

.webhook-events article {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.webhook-events article.webhook-event-error {
  border-color: #f4b5ad;
  background: #fff7f5;
}

.webhook-events time {
  color: var(--muted);
  font-size: 12px;
}

.webhook-events code {
  overflow-wrap: anywhere;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.35;
}

.api-token-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.api-token-box code,
.api-docs code {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: Consolas, "Liberation Mono", monospace;
}

.api-token-box code {
  color: var(--text);
  font-size: 13px;
}

.api-docs {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.api-docs summary {
  cursor: pointer;
  font-weight: 700;
}

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

.api-docs-stack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.api-doc-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.api-doc-panel > summary {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.api-doc-panel[open] > summary {
  border-bottom: 1px solid var(--line);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.api-doc-panel-body {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

.api-docs-grid section {
  display: grid;
  gap: 8px;
}

.api-docs-grid h4,
.api-docs-grid p {
  margin: 0;
}

.api-docs-grid h4 {
  font-size: 14px;
}

.api-docs-grid p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.api-docs pre {
  max-width: 100%;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 12px;
  line-height: 1.45;
}

.api-doc-panel pre {
  background: #f8fafc;
}

.api-param-list {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.api-param-list dt {
  color: var(--text);
  font-family: Consolas, "Liberation Mono", monospace;
  font-weight: 700;
}

.api-param-list dd {
  margin: 0;
  color: var(--muted);
}

.check {
  padding: 14px;
}

.check p {
  margin: 8px 0 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.saas-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.saas-tree-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.saas-tree-panel,
.saas-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.saas-tree-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.saas-tree-toolbar button,
.tree-action,
.tree-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
}

.saas-tree {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.tenant-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.tree-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
}

.tree-row-main {
  min-width: 0;
}

.tree-row-main strong,
.tree-row-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row-main span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.tree-actions {
  display: flex;
  gap: 6px;
}

.tree-children {
  display: grid;
  gap: 4px;
  padding: 0 8px 8px 42px;
}

.user-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tree-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.saas-editor {
  padding: 14px;
}

.saas-editor-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.saas-editor-header h3 {
  margin: 0;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.danger-button {
  border-color: #fecdca;
  background: #fff5f5;
  color: var(--danger);
}

.admin-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.admin-form h3 {
  margin: 0;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.settings-tabs button {
  background: #fff;
  color: var(--muted);
}

.settings-tabs button.active {
  background: #eaf4ff;
  border-color: #b8d9f4;
  color: var(--accent);
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-panel-header h3 {
  margin: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
}

.compact-table {
  min-width: 0;
}

.compact-table th,
.compact-table td {
  white-space: nowrap;
}

.icon-cell {
  width: 88px;
  text-align: right;
}

.icon-cell .icon-button + .icon-button {
  margin-left: 6px;
}

.compact-editor {
  margin-bottom: 14px;
}

.stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.stat-card {
  padding: 16px;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-size: 30px;
  margin: 8px 0 4px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  background: #f1f4f8;
  font-size: 13px;
  color: #314057;
}

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

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

.analytics-grid article {
  padding: 16px;
}

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

.analytics-grid strong {
  font-size: 26px;
  margin-bottom: 6px;
}

.scrim {
  display: none;
}

@media (max-width: 1280px) {
  .messenger {
    grid-template-columns: minmax(210px, 0.78fr) minmax(320px, 1.34fr) minmax(220px, 0.78fr);
  }
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(86vw, 320px);
    transform: translateX(-104%);
    transition: transform 180ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(23, 32, 51, 0.38);
  }

  body.menu-open .scrim {
    display: block;
  }

  .menu-button {
    display: grid;
    align-content: center;
  }

  .shell {
    padding: 18px;
  }

  .messenger,
  .stats,
  .topbar,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .dialog-list-panel,
  .chat-panel,
  .context-panel {
    min-height: 0;
  }

  .message-list {
    min-height: 0;
  }

  .top-actions {
    align-items: stretch;
  }

  .status {
    white-space: normal;
  }
}

@media (max-width: 560px) {
  body {
    background: #eef2f7;
  }

  .shell {
    padding: 0;
  }

  .topbar {
    padding: 12px 14px;
    margin-bottom: 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .eyebrow,
  .topbar h1 {
    display: none;
  }

  .status {
    display: none;
  }

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

  .wappi-channel .integration-status {
    justify-self: start;
  }

  .wappi-channel-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .settings-modal .integration-settings-form {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: calc(100vh - 67px);
  }

  body[data-screen="dialogs"] .topbar {
    display: none;
  }

  body[data-screen="dialogs"] .workspace,
  body[data-screen="dialogs"] .screen.active#screen-dialogs,
  body[data-screen="dialogs"] .messenger,
  body[data-screen="dialogs"] .dialog-list-panel,
  body[data-screen="dialogs"] .chat-panel {
    height: 100dvh;
    min-height: 100dvh;
  }

  .screen.active#screen-dialogs {
    min-height: calc(100vh - 67px);
  }

  .messenger {
    display: block;
    min-height: calc(100vh - 67px);
  }

  .dialog-list-panel,
  .chat-panel,
  .context-panel {
    min-height: calc(100vh - 67px);
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  .dialog-list-panel {
    display: block;
  }

  body.chat-open .dialog-list-panel {
    display: none;
  }

  .chat-panel {
    display: none;
    background: #0d111a;
    overflow: hidden;
  }

  body.chat-open .chat-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
  }

  .context-panel {
    display: none;
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
    border-top: 0;
    overflow-y: auto;
  }

  body.chat-open.context-open .context-panel {
    display: block;
  }

  body.chat-open.context-open .chat-panel {
    display: none;
  }

  .dialog-list-panel .panel-header {
    position: sticky;
    top: 0;
    z-index: 2;
    align-items: center;
    margin: 0;
    padding: 14px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .dialog-list-panel h2 {
    font-size: 26px;
  }

  .dialog-list-panel .muted,
  .queue-legend {
    display: none;
  }

  .dialog-tools button {
    min-width: 42px;
    min-height: 42px;
    border-radius: 50%;
    padding: 0 10px;
  }

  .dialogs-menu-button {
    display: grid;
    align-content: center;
    gap: 4px;
    background: #edf3fa;
    border: 1px solid #cbdff1;
  }

  .dialogs-menu-button span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    border-radius: 2px;
    background: var(--accent-dark);
  }

  .chat-search-button {
    font-size: 0;
  }

  .chat-search-button::before {
    content: "⌕";
    font-size: 22px;
  }

  .conversation-list {
    gap: 0;
    background: #fff;
  }

  .dialog-item {
    grid-template-columns: 54px 1fr auto;
    gap: 9px;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid #ecf0f5;
    border-radius: 0;
  }

  .dialog-item:hover,
  .dialog-item.active {
    background: #f6f9fd;
    border-color: #ecf0f5;
  }

  .dialog-avatar {
    width: 52px;
    height: 52px;
  }

  .dialog-main strong {
    font-size: 16px;
  }

  .dialog-preview {
    font-size: 14px;
  }

  .apartment-status {
    margin-top: 2px;
  }

  .dialog-meta time {
    font-size: 12px;
  }

  .chat-header {
    position: sticky;
    top: 0;
    z-index: 3;
    gap: 8px;
    margin: 0;
    padding: 8px 10px;
    border: 0;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 0 rgba(23, 32, 51, 0.08);
  }

  .chat-header .responder-status {
    max-width: 30px;
    min-width: 26px;
    padding: 4px 7px;
    font-size: 10px;
  }

  .chat-back-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    background: #edf3fa;
    color: var(--text);
    font-size: 32px;
    line-height: 1;
  }

  .chat-title-button .dialog-avatar {
    width: 40px;
    height: 40px;
  }

  .chat-title-button h2 {
    font-size: 16px;
  }

  .chat-title-button small {
    font-size: 12px;
  }

  .chat-header > .dialog-status {
    display: none;
  }

  .message-list {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    padding: 16px 10px 12px;
    align-content: start;
    gap: 8px;
    background:
      radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 22%),
      radial-gradient(circle at 70% 40%, rgba(255, 255, 255, 0.06), transparent 18%),
      #0d111a;
  }

  .message {
    max-width: 88%;
    border: 0;
    border-radius: 15px;
    padding: 9px 11px;
    background: #252a33;
    color: #fff;
  }

  .message span {
    color: #aab4c3;
  }

  .message.manager {
    background: #5476d8;
    color: #fff;
  }

  .message.ai {
    background: #1f2937;
    border: 1px dashed #667085;
    color: #eef4ff;
  }

  .reply-box {
    grid-template-columns: 34px minmax(0, 1fr) 34px 34px;
    gap: 8px;
    margin: 0;
    padding: 8px;
    border: 0;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -1px 0 rgba(23, 32, 51, 0.08);
  }

  .reply-box.has-text {
    grid-template-columns: 34px minmax(0, 1fr) 38px;
  }

  .reply-box textarea {
    min-height: 40px;
    max-height: 104px;
    border-radius: 20px;
    background: #f2f4f7;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .reply-box textarea.is-multiline {
    border-radius: 18px;
  }

  .composer-icon {
    width: 34px;
    min-height: 34px;
    height: 34px;
    font-size: 16px;
  }

  .composer-send {
    width: 38px;
    min-height: 38px;
    height: 38px;
    border-radius: 50%;
    padding: 0;
    font-size: 22px;
  }

  .context-screen-header {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--line);
  }

  .context-back-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    background: #edf3fa;
    color: var(--text);
    font-size: 32px;
    line-height: 1;
  }

  .context-screen-header h2 {
    margin: 0;
    font-size: 16px;
  }

  .context-screen-header span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
  }

  .context-block {
    background: #fff;
    padding: 14px;
  }

  .context-block + .context-block {
    margin-top: 12px;
  }

  .message {
    max-width: 88%;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .booking-link-form {
    grid-template-columns: 1fr;
  }

  .integration-card-header,
  .webhook-meta,
  .webhook-url-row,
  .webhook-url-row-with-test,
  .integration-settings-form,
  .api-docs-grid,
  .api-param-list,
  .saas-grid,
  .saas-tree-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 24px;
  }

  .stat-card strong {
    font-size: 25px;
  }
}
