.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.typing-indicator.is-visible {
  opacity: 1;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
}

.typing-dots::before,
.typing-dots::after,
.typing-dots span {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingPulse 1.2s infinite ease-in-out;
}

.typing-dots::before {
  animation-delay: 0s;
}

.typing-dots span {
  animation-delay: 0.2s;
}

.typing-dots::after {
  animation-delay: 0.4s;
}

.typing-dots {
  position: relative;
}

.typing-dots span {
  display: inline-block;
}

.typing-dots::before,
.typing-dots::after {
  display: inline-block;
}

@keyframes typingPulse {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Single source of truth. Do not add dashboard-v2.css or other admin stylesheets. */
/* Legacy gradient theme removed. */

:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --border: #e5e5e5;
  --text: #171717;
  --text-muted: #737373;
  --text-light: #a3a3a3;
  --ink: #171717;
  --muted: #737373;
  --bg-1: #ffffff;
  --bg-2: #fafafa;
  --shadow: rgba(0, 0, 0, 0.04);
  --shadow-lg: rgba(0, 0, 0, 0.08);
  --hover: #f5f5f5;
  --panel-muted: #f3f3f3;
  --active: #e5e5e5;
  --accent: #111;
  --accent-2: #000;
  --card: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans, "Segoe UI", sans-serif);
  color: var(--text);
  background: var(--panel);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

body.dashboard-page {
  height: 100vh;
  overflow: hidden;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
}

.topbar {
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.dashboard-page .main-content {
  height: 100vh;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.chat-header__left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header__title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__typing {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-header__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-info,
.chat-actions {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--text);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.chat__attachment {
  max-width: 240px;
  max-height: 240px;
  width: auto;
  height: auto;
  margin-top: 8px;
  border-radius: 12px;
  cursor: zoom-in;
  display: block;
}

.brand__title {
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand__sub {
  font-size: 12px;
  color: var(--muted);
}

.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  padding: 24px;
}

.image-viewer.is-open {
  display: flex !important;
}

.image-viewer__img {
  max-width: min(1200px, 96vw);
  max-height: 92vh;
  border-radius: 16px;
  background: #000;
}

.image-viewer__close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000 !important;
}

.lightbox.is-open {
  display: flex !important;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
}

.lightbox__img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  cursor: zoom-out;
}

.agent-info {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.sound-toggle input {
  accent-color: var(--accent);
}

.main {
  flex: 1;
  padding: 0 28px 28px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}



#login-screen {
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: 0 12px 32px var(--shadow-lg);
  width: min(100%, 400px);
  margin: 0 auto;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
  color: var(--text);
}

.login-card .muted {
  margin-bottom: var(--space-lg);
  display: block;
}

.hidden {
  display: none !important;
}

/* Login screen styles consolidated above */

h1,
h2,
h3 {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

/* Cleaned up duplicate form styles */

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

input,
select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.12);
}

.form input {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  transition: border-color var(--transition);
}

.form input:focus {
  border-color: var(--text);
  outline: none;
}

.primary-btn {
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:hover {
  opacity: 0.9;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--muted);
}

.ghost-btn--danger {
  border-color: rgba(180, 35, 24, 0.35);
  color: #b42318;
}

.error {
  min-height: 18px;
  font-size: 12px;
  color: #ef4444;
}

.dashboard {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.dashboard__layout {
  display: grid;
  gap: 20px;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.panel {
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}

.filter-btn.is-active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.inbox__list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  flex: 1;
  min-height: 0;
}

.conversation {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.conversation:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.conversation.is-active {
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.conversation__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation__title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation__time {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.conversation__meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conversation__status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: capitalize;
}

.conversation__status--open {
  color: #0f3d2e;
  background: rgba(46, 168, 139, 0.12);
}

.conversation__status--pending {
  color: #3f3f3f;
  background: rgba(0, 0, 0, 0.08);
}

.conversation__status--closed {
  color: #5f5f5f;
  background: rgba(0, 0, 0, 0.06);
}

.chat {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat__header {
  align-items: flex-start;
}

.chat__header-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.chat__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.chat__back {
  display: none;
}

.chat__title {
  font-weight: 700;
  font-size: 16px;
}

.chat__meta {
  font-size: 12px;
  color: var(--muted);
}

.chat__handled {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.chat__messages {
  margin-top: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
}

.chat__message {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-message {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat__message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat__message--agent {
  align-self: flex-end;
  background: #111;
  color: #fff;
}

.chat__message--visitor {
  align-self: flex-start;
  background: #f2f6ff;
  color: #1f2a3c;
}

.chat__message--system {
  align-self: center;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
  box-shadow: none;
  text-align: center;
  max-width: 80%;
}

.chat__message-meta {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
}

.chat__message--visitor .chat__message-meta,
.chat__message--system .chat__message-meta {
  color: rgba(31, 42, 60, 0.6);
}

.chat__attachment {
  max-width: 240px;
  max-height: 240px;
  width: auto;
  height: auto;
  margin-top: 8px;
  border-radius: 12px;
  cursor: zoom-in;
  display: block;
}

.chat__attachment-fallback {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.chat__attachment-link {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel-muted);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
}

.chat__attachment-link:hover {
  background: var(--hover);
}

.chat-link-button {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.chat-link-button:hover {
  background: var(--hover);
}

.chat-response-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.chat__confirm {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff8f1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat__confirm-preview {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.chat__confirm-preview img {
  width: 100%;
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  object-fit: contain;
}

.chat__confirm-text {
  font-size: 13px;
  color: var(--ink);
}

.chat__confirm-actions {
  display: flex;
  gap: 8px;
}

.chat__composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  position: sticky;
  bottom: 0;
  background: var(--card);
}

#chat-input {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
}

#chat-file {
  display: none;
}

.admin {
  margin-top: 20px;
}

.admin__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.admin__card {
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed var(--border);
}

.admin__card--wide {
  grid-column: 1 / -1;
}

.admin__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 12px;
}

.admin__tab-button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin__tab-button.is-active {
  background: var(--accent);
  border-color: transparent;
  color: #1b0e07;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.admin__tab-button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.admin__tab-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin__tab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.domain-list__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.domain-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.domain-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.domain-item__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.domain-item__info strong {
  font-size: 15px;
}

.domain-item__info .muted {
  font-size: 12px;
}

.domain-item__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin__header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.admin__table-wrap {
  margin-top: 12px;
  overflow: auto;
  max-height: 360px;
}

.admin__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin__table th,
.admin__table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.admin__table th {
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.admin__table .actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin__form {
  margin-top: 12px;
}

.admin__form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin__list {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.admin__list>div {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.admin__meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status--active {
  color: #0f3d2e;
  background: rgba(46, 168, 139, 0.12);
}

.status--inactive {
  color: #5f5f5f;
  background: rgba(0, 0, 0, 0.06);
}

.admin__hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.image-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 17, 17, 0.5);
  z-index: 50;
}

.image-modal.hidden {
  display: none;
}

.image-modal__content {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  max-width: min(90vw, 720px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-modal__content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
}

.image-modal__close {
  align-self: flex-end;
}

.image-modal__backdrop {
  position: absolute;
  inset: 0;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #111111;
  color: #ffffff;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.toast--info {
  background: #1f1f1f;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 17, 17, 0.45);
  z-index: 5000;
}

.modal.hidden {
  display: none;
}

.modal__content {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  width: min(90vw, 520px);
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
}

code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 980px) {
  .dashboard__layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .dashboard__layout {
    grid-template-columns: 1fr;
  }

  .dashboard[data-view="chat"] .inbox {
    display: none;
  }

  .dashboard[data-view="inbox"] .chat {
    display: none;
  }

  .chat__back {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .main {
    padding: 0 16px 20px;
  }

  .chat__composer {
    grid-template-columns: 1fr;
  }

  .ghost-btn,
  .primary-btn {
    width: 100%;
  }

  .admin__header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin__form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .conversation {
    height: 64px;
  }

  .conversation__row {
    flex-direction: column;
    align-items: flex-start;
  }

  .conversation__time {
    margin-top: 2px;
  }

  .chat__confirm-actions {
    flex-direction: column;
  }
}

/* ===== Unified Monochrome Dashboard System ===== */
:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --border: #e5e5e5;
  --text: #171717;
  --text-muted: #737373;
  --text-light: #a3a3a3;
  --shadow: rgba(0, 0, 0, 0.04);
  --shadow-lg: rgba(0, 0, 0, 0.08);
  --hover: #f5f5f5;
  --active: #e5e5e5;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Courier New", monospace;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-h: 60px;
  --sidebar-header-h: var(--topbar-h);
  --sidebar-footer-h: 96px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--panel);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app,
.app-shell {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  overflow: visible;
}

body.page-settings,
body.page-automations {
  height: 100vh;
  overflow: hidden;
}

body.page-settings .app-shell,
body.page-automations .app-shell,
body.page-settings .app,
body.page-automations .app {
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  flex-shrink: 0;
  overflow-x: hidden;
  z-index: 10;
}

.admin-layout.is-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

body.page-settings .sidebar,
body.page-automations .sidebar {
  overflow: hidden;
}

.sidebar__header {
  padding: var(--space-md) var(--space-lg);
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__logo {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
}

.admin-layout.is-collapsed .sidebar__logo-text {
  display: none;
}

.sidebar__toggle {
  background: none;
  border: none;
  padding: var(--space-sm);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__toggle:hover {
  color: var(--text);
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
  overflow-x: hidden;
}

body.page-settings .sidebar__nav,
body.page-automations .sidebar__nav {
  max-height: calc(100vh - var(--sidebar-header-h) - var(--sidebar-footer-h));
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: var(--space-xs);
}

.sidebar__link:hover {
  background: var(--hover);
  color: var(--text);
}

.sidebar__link.is-active {
  background: var(--active);
  color: var(--text);
}

.sidebar__link-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.admin-layout.is-collapsed .sidebar__link-text {
  display: none;
}

.admin-layout.is-collapsed .sidebar__nav {
  padding: var(--space-sm) 0;
}

.admin-layout.is-collapsed .sidebar__link {
  justify-content: center;
  gap: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: var(--space-xs) auto;
}

.sidebar__footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.sidebar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar__user-info {
  flex: 1;
  min-width: 0;
}

.sidebar__user-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-layout.is-collapsed .sidebar__user-info {
  display: none;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left 200ms ease;
}

.sidebar.hidden+.main-content {
  margin-left: 0;
}

.admin-layout.is-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

body.page-settings .main-content,
body.page-automations .main-content {
  height: 100vh;
  overflow-y: auto;
}

body.page-settings .settings-content,
body.page-automations .automations-content {
  flex: 1;
  min-height: 0;
}

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-h);
}

.topbar__title {
  font-size: 18px;
  font-weight: 600;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar__meta {
  font-size: 14px;
  color: var(--text-muted);
}

.sound-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
  color: var(--text-muted);
}

.dashboard-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-width: 0;
  flex: 1;
}

.input-hidden {
  display: none;
}

/* Standard Monochrome Buttons */
.btn,
.primary-btn,
.btn--primary,
.ghost-btn,
.btn--ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--text) !important;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--text) !important;
  color: var(--bg) !important;
  text-decoration: none;
}

.btn:hover,
.primary-btn:hover,
.btn--primary:hover,
.ghost-btn:hover,
.btn--ghost:hover {
  background: var(--text-muted);
  border-color: var(--text-muted);
  color: var(--bg);
}

.btn:active {
  background: var(--text);
  opacity: 0.8;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--danger,
.ghost-btn--danger {
  background: #111;
  color: #fff;
  border-color: #111;
}

.btn--danger:hover,
.ghost-btn--danger:hover {
  background: #000;
  border-color: #000;
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

.btn--sm {
  padding: var(--space-xs) var(--space-md);
  font-size: 13px;
}

/* Settings & Forms */
.settings-content {
  padding: var(--space-xl);
  max-width: 800px;
  margin: 0 auto;
}

.settings-header {
  margin-bottom: var(--space-xl);
}

.settings-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-md);
}

.form-field--inline .file-input {
  flex: 1;
  font-size: 13px;
}

.form-actions {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.upload-status {
  font-size: 12px;
  color: var(--text-muted);
}

.input,
.textarea,
.select,
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}

.input:focus,
.textarea:focus,
.select:focus,
select:focus {
  border-color: var(--text);
}

label {
  font-size: 12px;
  color: var(--text-muted);
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

option {
  background: var(--bg);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--text);
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group {
  display: grid;
  gap: var(--space-xs);
}

.form-group label {
  font-size: 12px;
  color: var(--text-muted);
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: 0 1px 3px var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge--active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 5000;
}

.modal.hidden {
  display: none;
}

.modal.is-open {
  display: flex;
}

.modal__content {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px var(--shadow-lg);
  padding: var(--space-lg);
  width: min(92vw, 560px);
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal__header {
  margin-bottom: var(--space-md);
}

.modal__title {
  font-size: 16px;
  font-weight: 600;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
}

.modal form {
  display: grid;
  gap: var(--space-md);
}

.modal .form-group {
  display: grid;
  gap: var(--space-xs);
}

.modal .form-group label {
  font-size: 12px;
  color: var(--text-muted);
}

.modal .form-group input,
.modal .form-group textarea,
.modal .form-group select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.modal .form-group textarea {
  min-height: 140px;
  resize: vertical;
}

.modal .form-actions,
.modal__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-md);
}

.modal__actions--spaced {
  margin-top: var(--space-md);
}

.modal__message {
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.image-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1100;
}

.image-modal.hidden {
  display: none;
}

.image-modal__content {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  max-width: min(92vw, 900px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  box-shadow: 0 12px 30px var(--shadow-lg);
}

.image-modal__content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.image-modal__close {
  align-self: flex-end;
}

.image-modal__backdrop {
  position: absolute;
  inset: 0;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .admin-layout.is-collapsed .sidebar {
    width: var(--sidebar-width);
  }

  .sidebar__overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: none;
  }

  .sidebar.is-open~.sidebar__overlay {
    display: block;
  }
}

/* ========== PAGE-SPECIFIC STYLES ========== */

/* Inbox page styles */
.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  width: 100%;
  min-width: 0;
}

.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 100%;
  min-width: 0;
}

.dashboard-content {
  flex: 1;
  padding: 0;
  background: var(--panel);
  display: flex;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.dashboard-page .dashboard-content {
  height: 100%;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  height: 100%;
  gap: 1px;
  background: var(--border);
  flex: 1;
  width: 100%;
  min-width: 0;
}

.inbox-sidebar {
  width: 320px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: auto;
}

.inbox-chat {
  min-width: 0;
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.inbox-profile {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
  overflow: auto;
  width: 300px;
  flex: 0 0 300px;
  border-left: 1px solid var(--border);
}

.profile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.profile-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.inbox-profile .section-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inbox-profile .add-btn {
  margin-left: auto;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.profile-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.tag-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.tag-input-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--panel-muted);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
}

.tag-pill--a {
  background: #e8f2ff;
  color: #1d4ed8;
}

.tag-pill--b {
  background: #ecfdf3;
  color: #047857;
}

.tag-pill--c {
  background: #fff7ed;
  color: #b45309;
}

.tag-pill--d {
  background: #fdf2f8;
  color: #be185d;
}

.tag-pill--e {
  background: #f3e8ff;
  color: #7c3aed;
}

.tag-pill__remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  border-radius: 8px;
  padding: 2px 6px;
  opacity: 0.5;
}

.tag-pill__remove:hover {
  color: var(--text);
  background: var(--hover);
  opacity: 1;
}

.inbox-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.inbox-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.filter-tabs {
  display: flex;
  gap: var(--space-xs);
}

.filter-tab {
  position: relative;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.pending-badge {
  background: #e5484d;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 6px;
}

.pending-badge.is-hidden {
  display: none;
}

.filter-tab:hover {
  background: var(--hover);
}

.filter-tab.is-active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.conversation-item:hover {
  background: var(--hover);
}

.conversation-item.is-active {
  background: var(--panel);
}

.conversation-name {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.conversation-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 12px;
  color: var(--text-light);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.chat-header__left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header__title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-info,
.chat-actions {
  min-width: 0;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}

.message {
  max-width: 70%;
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.message--visitor {
  background: var(--panel);
  align-self: flex-end;
}

.message--agent {
  background: var(--text);
  color: var(--bg);
  align-self: flex-start;
}

.message--system {
  background: var(--hover);
  color: var(--text-muted);
  font-size: 13px;
  align-self: center;
  text-align: center;
  max-width: 80%;
}

.message__text {
  word-wrap: break-word;
  margin-bottom: var(--space-xs);
}

.message__meta {
  font-size: 12px;
  opacity: 0.7;
}

.message .attachment {
  max-width: 220px;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  cursor: zoom-in;
}

.chat-composer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-sm);
  position: relative;
  overflow: visible;
}

.chat-composer input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.chat-composer button {
  padding: var(--space-sm) var(--space-lg);
}

.login-card .primary-btn {
  height: 44px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-md);
  font-weight: 600;
  margin-top: var(--space-sm);
  transition: opacity var(--transition);
}

.login-card .primary-btn:hover {
  opacity: 0.9;
}

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form input {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  transition: border-color var(--transition);
}

.form input:focus {
  border-color: var(--text);
  outline: none;
}

.error {
  color: #ef4444;
  font-size: 13px;
  margin-top: var(--space-sm);
}

.image-confirm {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.image-confirm img {
  max-width: 200px;
  border-radius: var(--radius-md);
}

.image-confirm-actions {
  display: flex;
  gap: var(--space-sm);
}

.mobile-back {
  display: none;
}

@media (max-width: 768px) {
  .inbox-layout {
    grid-template-columns: 1fr;
  }

  .inbox-sidebar {
    width: 100%;
  }

  .mobile-back {
    display: inline-flex;
  }

  .inbox-profile {
    display: none;
  }
}

/* Settings page styles */
body.page-settings .settings-content {
  padding: var(--space-xl);
  padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  width: 100%;
  max-width: none;
}

body.page-settings .settings-header {
  margin-bottom: var(--space-xl);
}

body.page-settings .settings-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

body.page-settings .settings-header .muted {
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-xl);
}

.tab-button {
  padding: var(--space-md) var(--space-lg);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
}

.tab-button:hover {
  color: var(--text);
  background: var(--hover);
}

.tab-button.is-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.form-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  min-width: 0;
  overflow: visible;
}

.form-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-field label {
  font-size: 13px;
  font-weight: 500;
}

.form-field input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.form-field small {
  font-size: 12px;
  color: var(--text-muted);
}

.page-search .form-grid,
.page-notifications .form-grid {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-search .form-grid .form-field,
.page-notifications .form-grid .form-field {
  flex: 1 1 220px;
}

.page-search .form-grid .form-field.form-field--inline,
.page-notifications .form-grid .form-field.form-field--inline {
  flex: 0 0 auto;
}

.page-search .form-section,
.page-notifications .form-section {
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  margin-bottom: 16px;
}

.login-card .primary-btn {
  height: 44px;
  margin-top: var(--space-sm);
}

.notification-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.notification-settings-row:last-child {
  border-bottom: none;
}

.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.table tr:hover {
  background: var(--hover);
  cursor: pointer;
}

.analytics-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-lg);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.filter-custom {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.filter-custom input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
}

.chart-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  height: 400px;
  position: relative;
}

.chart-card h3 {
  margin-bottom: var(--space-md);
  font-size: 16px;
}

.chart-card canvas {
  width: 100% !important;
  height: 100% !important;
}

.tenant-key-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.tenant-key-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tenant-key {
  font-family: var(--font-mono);
  background: var(--panel-muted);
  padding: 10px 12px;
  border-radius: 8px;
  word-break: break-all;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-lg);
}

.data-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.data-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
  background: var(--hover);
}

.table-actions {
  display: flex;
  gap: var(--space-xs);
}

.shortcut-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.shortcut-button-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--space-sm);
  align-items: center;
}

.shortcut-button-label,
.shortcut-button-url {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
}

@media (max-width: 768px) {
  .shortcut-button-row {
    grid-template-columns: 1fr;
  }
}

.guard-card {
  max-width: 400px;
  margin: 4rem auto;
  text-align: center;
}

.guard-card h1 {
  margin-bottom: var(--space-md);
}

.guard-card .muted {
  color: var(--text-muted);
}

/* Automations page styles */
body.page-automations .automations-content {
  padding: var(--space-xl);
  width: 100%;
  max-width: none;
}

.form-note {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
}

.form-field--inline {
  width: 200px;
  margin: 0;
}

.file-input {
  display: none;
}

.upload-status {
  min-height: 16px;
}

.embed-card {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.embed-code {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

@media (max-width: 768px) {
  body.page-settings .settings-content {
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  }

  .form-section {
    padding: var(--space-lg);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-field--inline {
    width: 100%;
  }

  .embed-card {
    margin-bottom: var(--space-xl);
  }
}

.flow-card {
  margin-bottom: 1.5rem;
}

.flow-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.flow-card__title {
  margin: 0;
}

.flow-card__meta {
  color: var(--text-muted);
}

.flow-card__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.node-toolbar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.node-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.node-card__type {
  color: var(--text-light);
}

.badge--start {
  margin-left: var(--space-sm);
}

.node-card__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.edge-item__meta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.edge-item__hint {
  color: var(--text-light);
}

.edge-item__actions {
  display: flex;
  gap: var(--space-sm);
}

.chat-composer {
  position: relative;
  overflow: visible;
}

.shortcut-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  display: none;
  z-index: 9999;
  pointer-events: auto;
}

.shortcut-dropdown.is-open {
  display: block;
}

.shortcut-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-item.is-selected {
  background: var(--hover);
}

.shortcut-item__command {
  font-weight: 600;
}

.shortcut-item__name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.welcome-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.welcome-toggle {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.welcome-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.welcome-rules {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-rule {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome-rule__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.welcome-rule__actions {
  display: flex;
  justify-content: flex-end;
}

.welcome-time-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome-time-row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 16px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.welcome-time-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.welcome-time-message {
  min-height: 72px;
}

.form-field--inline {
  display: flex;
  align-items: flex-end;
}

.away-hours-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.away-days {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.away-day {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.away-delay-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 16px;
}

@media (max-width: 720px) {
  .away-delay-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .welcome-time-row {
    grid-template-columns: 1fr;
  }
}

.conversation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.conversation-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.presence-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.presence-dot.is-online {
  background: #000;
}

.presence-dot.is-offline {
  background: #eee;
}

body.page-automations .automations-header {
  margin-bottom: var(--space-xl);
}

body.page-automations .automations-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

body.page-automations .automations-header .muted {
  color: var(--text-muted);
}

.subnav {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.subnav a {
  text-decoration: none;
}

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.section__title {
  font-size: 18px;
  font-weight: 600;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-md);
}

.table th {
  background: var(--hover);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.table tr:hover {
  background: var(--hover);
}

.table tr:last-child td {
  border-bottom: none;
}

.badge--active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.badge--inactive {
  background: #f0f0f0;
  color: #666;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.node-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.node-card {
  background: #f9f9f9;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}



.node-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.node-card__title {
  font-weight: 600;
}

.node-card__body {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.edge-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid #ddd;
}

.edge-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: white;
  border-radius: 4px;
  font-size: 0.875rem;
}


/* Chatbot editor styles */
body.page-chatbot-editor .editor-shell {
  display: flex;
  height: calc(100vh - 60px - 57px);
  overflow: visible;
}

.editor-canvas {
  position: relative;
  flex: 1;
  background: var(--panel);
  overflow: visible;
}

.node {
  position: absolute;
  width: 240px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px var(--shadow);
  user-select: none;
  touch-action: none;
}

.node.is-selected {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.node.is-dragging {
  cursor: grabbing;
}

body.is-dragging {
  user-select: none;
}

.node__header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  gap: var(--space-sm);
}

.node__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node__actions {
  display: flex;
  gap: 4px;
}

.node__edit,
.node__delete {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.node__delete {
  color: var(--danger);
  opacity: 0;
  transition: opacity 0.2s;
}

.node:hover .node__delete {
  opacity: 1;
}

.node__edit:hover,
.node__delete:hover {
  background: var(--hover);
}

.node__body {
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  color: var(--text-muted);
}

.node__ports {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  padding: 0 var(--space-md) var(--space-sm);
}

.port-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
  min-height: 24px;
}

.port-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.port {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: crosshair;
  border: 2px solid var(--bg);
  flex-shrink: 0;
  background: #000;
  transition: transform 0.1s;
}

.port:hover {
  transform: scale(1.2);
}

.port--in {
  position: absolute;
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg);
  border-color: var(--text);
}

.port--in:hover {
  transform: translateY(-50%) scale(1.2);
}

.node--start .node__header {
  background: var(--text);
  color: var(--bg);
}

.node--start .node__edit,
.node--start .node__delete {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.node--end .node__body::after {
  content: "End";
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.edge-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  overflow: visible;
}

.edge-path {
  stroke: var(--text);
  stroke-width: 2;
  fill: none;
  pointer-events: stroke;
  transition: stroke-width 0.1s;
}

.edge-path:hover {
  stroke-width: 4;
}

.edge-path.is-selected {
  stroke-width: 4;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.3));
}

.toolbar {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

/* Modal Extensions */
.buttons-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.buttons-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.buttons-header label {
  font-weight: 600;
  font-size: 14px;
}

.buttons-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.button-item {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.button-item input,
.button-item select {
  width: 100%;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Chatbot Editor Enhancements */

.node__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 8px;
  /* Ensure space for close button */
}

.node__delete-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-left: 8px;
}

.node__delete-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.edge-path.is-selected {
  stroke: #dc2626 !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 2px rgba(220, 38, 38, 0.4));
}

.modal {
  z-index: 9000;
}

#bot-modal {
  z-index: 9000 !important;
}

.node__delete {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-left: 8px;
}

.node__delete:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

/* Form Selection Modal Premium Styling */
.selection-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.selection-item {
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.selection-item:hover {
  border-color: var(--text-muted);
  background: var(--hover);
}

.selection-item.is-selected {
  border-color: var(--text);
  background: rgba(0, 0, 0, 0.04);
  box-shadow: 0 0 0 1px var(--text);
}

.selection-item.is-selected::after {
  content: 'SELECTED';
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--text);
}

.selection-item__name {
  font-weight: 700;
  font-size: 14px;
}

.selection-item__meta {
  font-size: 12px;
  color: var(--muted);
}

.btn--with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 44px;
}

.btn--with-icon span {
  font-weight: 700;
  font-size: 13px;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  margin-right: 12px;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--hover);
  border-color: var(--text-light);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  display: none;
}

.theme-dark .theme-toggle .sun-icon {
  display: block;
}

html:not(.theme-dark) .theme-toggle .moon-icon {
  display: block;
}

.theme-dark {
  --bg: #121212 !important;
  --panel: #1a1a1a !important;
  --border: #2e2e2e !important;
  --text: #e5e5e5 !important;
  --text-muted: #a3a3a3 !important;
  --text-light: #666666 !important;
  --ink: #e5e5e5 !important;
  --muted: #a3a3a3 !important;
  --bg-1: #121212 !important;
  --bg-2: #181818 !important;
  --shadow: rgba(0, 0, 0, 0.3) !important;
  --shadow-lg: rgba(0, 0, 0, 0.5) !important;
  --hover: #262626 !important;
  --panel-muted: #222222 !important;
  --active: #333333 !important;
  --accent: #fafafa !important;
  --accent-2: #ffffff !important;
  --card: #1e1e1e !important;
}

body,
* {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease !important;
}


/* Dark Mode Contrast Fixes */
.theme-dark .conversation__status--open {
  color: #4ade80 !important;
  background: rgba(74, 222, 128, 0.1);
}

.theme-dark .chat__message-meta,
.theme-dark .message__meta {
  color: #a3a3a3 !important;
}

.theme-dark .message--visitor .message__text,
.theme-dark .message--visitor .chat__message-text {
  color: #ffffff !important;
}

.theme-dark .message--agent .message__text,
.theme-dark .message--agent .chat__message-text {
  color: #171717 !important;
}