:root {
  --runza-blue: #1377A9;
  --runza-blue-dark: #0f628c;
  --runza-black: #0f172a;
  --runza-slate: #475569;
  --runza-line: #e2e8f0;
  --runza-line-strong: #cbd5e1;
  --runza-bg: #f8fafc;
  --runza-surface: #ffffff;
  --runza-surface-soft: #f1f5f9;
  --runza-success: #0f766e;
  --runza-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --runza-radius-xl: 24px;
  --runza-radius-lg: 18px;
  --runza-radius-md: 14px;
  --runza-radius-sm: 12px;
  --runza-transition: 0.18s ease;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.runza-chat-shell {
  width: 100%;
  min-height: 100%;
  color: var(--runza-black);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.runza-chat-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 140px);
}

.runza-chat-sidebar,
.runza-chat-thread-panel {
  min-width: 0;
  background: var(--runza-surface);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 28px;
  box-shadow: var(--runza-shadow);
}

.runza-chat-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.runza-chat-sidebar-top {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--runza-line);
  background:
    linear-gradient(180deg, rgba(19, 119, 169, 0.06) 0%, rgba(19, 119, 169, 0) 100%),
    var(--runza-surface);
}

.runza-chat-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--runza-blue);
}

.runza-chat-title {
  margin: 8px 0 6px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.runza-chat-subtitle {
  margin: 0;
  color: var(--runza-slate);
  font-size: 13px;
  line-height: 1.5;
}

.runza-chat-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.runza-chat-stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
  border: 1px solid var(--runza-line);
  border-radius: var(--runza-radius-md);
  padding: 14px 14px 12px;
}

.runza-chat-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 8px;
}

.runza-chat-stat-value {
  display: block;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--runza-black);
}

.runza-chat-stat-value.is-selected {
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.runza-chat-toolbar {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.runza-chat-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  background: var(--runza-surface);
  border: 1px solid var(--runza-line);
  border-radius: 999px;
}

.runza-chat-search-icon {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 16px;
  line-height: 1;
}

.runza-chat-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
  color: var(--runza-black);
}

.runza-chat-search input::placeholder {
  color: #94a3b8;
}

.runza-chat-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.runza-chat-filter-btn,
.runza-chat-refresh-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  transition: var(--runza-transition);
}

.runza-chat-filter-btn {
  background: #eef2f7;
  color: #334155;
}

.runza-chat-filter-btn.active {
  background: var(--runza-blue);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(19, 119, 169, 0.24);
}

.runza-chat-refresh-btn {
  background: var(--runza-black);
  color: #ffffff;
}

.runza-chat-filter-btn:hover,
.runza-chat-refresh-btn:hover,
.runza-chat-send-btn:hover,
.runza-chat-mode-btn:hover {
  transform: translateY(-1px);
}

.runza-chat-sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.runza-chat-sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12);
}

.runza-chat-list-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.runza-chat-list {
  height: 100%;
  overflow: auto;
  padding: 12px;
  background: var(--runza-bg);
}

.runza-chat-list::-webkit-scrollbar,
.runza-chat-messages::-webkit-scrollbar {
  width: 8px;
}

.runza-chat-list::-webkit-scrollbar-thumb,
.runza-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.26);
  border-radius: 999px;
}

.runza-chat-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  background: #ffffff;
  cursor: pointer;
  text-align: left;
  transition: var(--runza-transition);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.runza-chat-list-item:hover {
  transform: translateY(-1px);
  border-color: rgba(19, 119, 169, 0.18);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.runza-chat-list-item.active {
  border-color: rgba(19, 119, 169, 0.28);
  background: linear-gradient(180deg, rgba(19, 119, 169, 0.08) 0%, #ffffff 100%);
  box-shadow: 0 16px 36px rgba(19, 119, 169, 0.12);
}

.runza-chat-list-avatar,
.runza-chat-thread-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--runza-blue) 0%, var(--runza-blue-dark) 100%);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 26px rgba(19, 119, 169, 0.22);
}

.runza-chat-list-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 16px;
}

.runza-chat-list-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.runza-chat-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.runza-chat-list-top strong {
  min-width: 0;
  font-size: 14px;
  color: var(--runza-black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.runza-chat-list-time {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
}

.runza-chat-list-preview,
.runza-chat-list-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.runza-chat-list-preview {
  font-size: 13px;
  color: #334155;
}

.runza-chat-list-meta {
  font-size: 12px;
  color: #64748b;
}

.runza-chat-list-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.runza-chat-unread-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--runza-blue);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(19, 119, 169, 0.2);
}

.runza-chat-status-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: #334155;
  font-size: 11px;
  font-weight: 800;
}

.runza-chat-mode-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.runza-chat-mode-mini.is-ai {
  background: rgba(19, 119, 169, 0.12);
  color: var(--runza-blue);
}

.runza-chat-mode-mini.is-human {
  background: rgba(15, 23, 42, 0.08);
  color: var(--runza-black);
}

.runza-chat-thread-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  min-height: 0;
  background:
    radial-gradient(circle at top right, rgba(19, 119, 169, 0.08) 0%, transparent 30%),
    var(--runza-surface);
}

.runza-chat-thread-empty,
.runza-chat-thread-wrap {
  width: 100%;
}

.runza-chat-thread-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
}

.runza-chat-thread-empty-card {
  max-width: 420px;
  text-align: center;
  padding: 34px 28px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--runza-line);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.06);
}

.runza-chat-thread-empty-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(19, 119, 169, 0.1);
  font-size: 28px;
}

.runza-chat-thread-empty-card h3 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.runza-chat-thread-empty-card p {
  margin: 0;
  color: var(--runza-slate);
  font-size: 14px;
  line-height: 1.6;
}

.runza-chat-thread-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.runza-chat-thread-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--runza-line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.runza-chat-thread-head-left {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 0;
}

.runza-chat-thread-avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-size: 18px;
  flex: 0 0 auto;
}

.runza-chat-thread-head-copy {
  min-width: 0;
}

.runza-chat-thread-head-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.runza-chat-thread-head-topline h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  min-width: 0;
}

.runza-chat-thread-meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

.runza-chat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(19, 119, 169, 0.1);
  color: var(--runza-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.runza-chat-pill.is-status {
  background: rgba(15, 23, 42, 0.08);
  color: var(--runza-black);
}

.runza-chat-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.runza-chat-mode-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--runza-black);
  letter-spacing: 0.02em;
}

.runza-chat-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.runza-chat-mode-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  background: transparent;
  color: #334155;
  transition: var(--runza-transition);
}

.runza-chat-mode-btn.active {
  background: var(--runza-blue);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(19, 119, 169, 0.22);
}

.runza-chat-mode-toggle.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.runza-chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(19, 119, 169, 0.03) 0%, transparent 18%),
    #f8fafc;
}

.runza-chat-message-row {
  display: flex;
  margin-bottom: 14px;
}

.runza-chat-message-row.is-customer {
  justify-content: flex-start;
}

.runza-chat-message-row.is-merchant {
  justify-content: flex-end;
}

.runza-chat-bubble {
  max-width: min(640px, 78%);
  padding: 14px 16px;
  border-radius: 22px;
  border: 1px solid var(--runza-line);
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.05);
}

.runza-chat-message-row.is-merchant .runza-chat-bubble {
  background: linear-gradient(180deg, #187fb2 0%, #1377A9 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 16px 36px rgba(19, 119, 169, 0.24);
}

.runza-chat-bubble-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.runza-chat-bubble-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.runza-chat-bubble-time {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
}

.runza-chat-bubble-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.runza-chat-system-note {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 16px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.runza-chat-composer-wrap {
  border-top: 1px solid var(--runza-line);
  padding: 18px 22px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.runza-chat-composer-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.runza-chat-composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.runza-chat-composer-input {
  resize: vertical;
  min-height: 52px;
  max-height: 180px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--runza-line-strong);
  outline: none;
  background: #ffffff;
  color: var(--runza-black);
  font-size: 14px;
  line-height: 1.5;
  transition: var(--runza-transition);
}

.runza-chat-composer-input:focus {
  border-color: rgba(19, 119, 169, 0.42);
  box-shadow: 0 0 0 4px rgba(19, 119, 169, 0.08);
}

.runza-chat-composer-input::placeholder {
  color: #94a3b8;
}

.runza-chat-send-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  min-width: 140px;
  height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1880b3 0%, #1377A9 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 14px 34px rgba(19, 119, 169, 0.22);
  transition: var(--runza-transition);
}

.runza-chat-send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

.runza-chat-composer-hint {
  min-height: 18px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.runza-chat-loading,
.runza-chat-empty-list {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px dashed rgba(148, 163, 184, 0.32);
}

@media (max-width: 1180px) {
  .runza-chat-layout {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .runza-chat-thread-header {
    flex-direction: column;
    align-items: stretch;
  }

  .runza-chat-mode-toggle {
    justify-content: space-between;
  }
}

@media (max-width: 920px) {
  .runza-chat-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .runza-chat-sidebar,
  .runza-chat-thread-panel {
    min-height: 560px;
  }

  .runza-chat-bubble {
    max-width: 90%;
  }
}

@media (max-width: 640px) {
  .runza-chat-sidebar-top,
  .runza-chat-thread-header,
  .runza-chat-messages,
  .runza-chat-composer-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }

  .runza-chat-list {
    padding: 10px;
  }

  .runza-chat-stat-value {
    font-size: 20px;
  }

  .runza-chat-composer-box {
    grid-template-columns: 1fr;
  }

  .runza-chat-send-btn {
    width: 100%;
  }

  .runza-chat-list-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .runza-chat-list-side {
    grid-column: 2 / 3;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }
}
