* {
  box-sizing: border-box;
}

:root {
  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-sidebar: #191f37;
  --bg-sidebar-soft: rgba(255, 255, 255, 0.08);
  --text-primary: #1f2329;
  --text-regular: #4e5969;
  --text-secondary: #86909c;
  --border-color: #e5e6eb;
  --primary: #409eff;
  --primary-soft: rgba(64, 158, 255, 0.12);
  --success: #67c23a;
  --danger: #f56c6c;
  --shadow-soft: 0 12px 32px rgba(15, 23, 42, 0.06);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
}

.login-page {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background: #ffffff;
}

body.login-mode .login-page {
  display: grid;
}

body.login-mode .app-shell {
  display: none;
}

.login-brand-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 56px;
  color: #ffffff;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.35), transparent 42%),
    radial-gradient(circle at 80% 0%, rgba(34, 211, 238, 0.22), transparent 36%),
    linear-gradient(145deg, #151b33 0%, #1f2a52 52%, #162447 100%);
  overflow: hidden;
}

.login-brand-panel::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
}

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

.login-brand-mark {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
  box-shadow: 0 16px 40px rgba(99, 102, 241, 0.35);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.login-brand-name {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.login-brand-tagline {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 14px;
}

.login-brand-lead {
  margin: 0 0 28px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 15px;
  line-height: 1.75;
}

.login-brand-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-brand-features li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.login-feature-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #67e8f9;
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 2px;
}

.login-brand-features strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.login-brand-features span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  line-height: 1.5;
}

.login-brand-footer {
  margin-top: 48px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.login-form-card {
  width: min(420px, 100%);
  padding: 40px 36px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

.login-form-header h2 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.login-form-header p {
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-size: 14px;
}

.login-field {
  display: block;
  margin-bottom: 18px;
}

.login-field span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-regular);
}

.login-field input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 14px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-field input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.login-submit-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  font-size: 15px;
  font-weight: 600;
}

.login-submit-btn:hover {
  filter: brightness(1.04);
}

.login-error {
  margin-top: 14px;
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 960px) {
  .login-page {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  body.login-mode .login-page {
    display: block;
  }

  .login-brand-panel {
    padding: 36px 28px 28px;
  }

  .login-brand-footer {
    margin-top: 28px;
  }

  .login-form-panel {
    padding: 0 20px 32px;
  }

  .login-form-card {
    padding: 28px 24px;
    box-shadow: none;
    border: none;
    background: transparent;
  }
}

.full-btn {
  width: 100%;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: #f7f8fa;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.brand p {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

.brand-large {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
  color: white;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.nav-item.active {
  background: rgba(64, 158, 255, 0.18);
  color: white;
  box-shadow: inset 0 0 0 1px rgba(64, 158, 255, 0.2);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
}

.sidebar-account {
  margin-top: auto;
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-sidebar-soft);
  color: #e5e7eb;
}

.sidebar-account-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.sidebar-account-meta {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.sidebar-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.sidebar-account-btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #f3f4f6;
  font-size: 12px;
  cursor: pointer;
}

.sidebar-account-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-account-btn--danger {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
}

.user-badge {
  padding: 12px 14px;
  margin-top: auto;
  border-radius: 16px;
  background: var(--bg-sidebar-soft);
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.6;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 28px;
  gap: 16px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: var(--shadow-soft);
}

.view-breadcrumb {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 6px;
}

.view-title {
  margin: 0 0 6px;
  font-size: 28px;
}

.view-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.toolbar-select {
  min-width: 180px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  font-size: 14px;
  color: var(--text-primary);
}

.toolbar-input {
  min-width: 220px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  font-size: 14px;
  color: var(--text-primary);
}

.content-view {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.content-view.active {
  display: flex;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 20px;
  border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-desc {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

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

/* ── Dashboard analytics charts ──────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.analytics-card {
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.donut-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Donut chart (CSS conic-gradient) */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 0 4px;
  flex: 1;
}

.donut-ring {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-hole {
  position: absolute;
  inset: 22px;
  background: var(--bg-card);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-center-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.donut-center-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  color: var(--text-regular);
}

.legend-count {
  font-weight: 600;
  color: var(--text-primary);
}

.legend-pct {
  color: var(--text-secondary);
  font-size: 11.5px;
  min-width: 34px;
  text-align: right;
}

/* Horizontal bar chart */
.hbars-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
  flex: 1;
  justify-content: center;
}

.hbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.hbar-label {
  width: 88px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-regular);
  font-size: 12px;
}

.hbar-track {
  flex: 1;
  background: var(--bg-soft);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.5s ease;
  min-width: 4px;
}

.hbar-count {
  min-width: 24px;
  text-align: right;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
}

/* Summary stats list */
.summary-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  justify-content: center;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row-label {
  color: var(--text-regular);
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.summary-row-value {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

/* ── Auth config field hint ──────────────────────────────────── */
.field-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 4px;
}

/* ── Refresh controls inline ─────────────────────────────────── */
.refresh-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-select-sm {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 6px 10px;
  background: white;
  font-size: 12.5px;
  color: var(--text-regular);
  cursor: pointer;
}

/* ── 7-day trend chart ───────────────────────────────────────── */
.trend-chart-wrap {
  padding: 8px 0 4px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
  padding: 0 4px;
}

.trend-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.trend-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
  transition: height 0.4s ease;
  min-height: 2px;
}

.trend-bar-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

.trend-labels {
  display: flex;
  gap: 6px;
  padding: 0 4px;
}

.trend-label {
  flex: 1;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.panel-card,
.reply-box {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.panel-head h3,
.conversation-header h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.panel-head p,
.conversation-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.hero-card {
  min-height: 220px;
  background: linear-gradient(135deg, #1d39c4 0%, #409eff 100%);
  color: white;
  border: none;
}

.hero-card .panel-head p,
.hero-card .hero-copy p {
  color: rgba(255, 255, 255, 0.82);
}

.hero-content {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
}

.hero-copy h4 {
  margin: 0 0 10px;
  font-size: 24px;
}

.hero-copy p {
  margin: 0;
  line-height: 1.8;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 260px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 12px;
}

.quick-card {
  min-height: 220px;
}

.quick-actions {
  display: grid;
  gap: 12px;
}

.quick-action {
  border: 1px solid var(--border-color);
  background: var(--bg-soft);
  color: var(--text-primary);
  border-radius: 14px;
  padding: 16px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.content-grid {
  display: grid;
  gap: 16px;
}

.content-grid.two-column {
  grid-template-columns: 340px minmax(0, 1fr);
}

.side-panel {
  min-width: 0;
}

/* Conversation view: compact inner padding for detail panel */
#conversationsView .detail-panel {
  padding: 12px;
}
#conversationsView .side-panel {
  padding: 12px;
}
#conversationsView .reply-box {
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: none;
  border-top: 1px solid var(--border-color);
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  min-height: 200px;
  max-height: calc(100vh - 260px);
}

.conversation-item {
  border: 1px solid var(--border-color);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.conversation-item:hover {
  background: #f4f8ff;
  border-color: #bcd4fa;
}

.conversation-item.active {
  border-color: var(--primary);
  background: #eef5ff;
}

.conversation-item h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.conversation-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-regular);
  line-height: 1.4;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  margin-right: 6px;
  background: var(--primary-soft);
  color: var(--primary);
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.conv-header-title h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.conv-header-title p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.conv-toolbar {
  flex-shrink: 0;
}

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

/* Small button variant */
.btn-sm {
  padding: 5px 10px !important;
  font-size: 12px !important;
  border-radius: 8px !important;
}

/* Danger (red) button */
.danger-btn {
  background: #fff1f0;
  color: #cf1322;
  border: 1px solid #ffa39e;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.danger-btn:hover:not(:disabled) {
  background: #ff4d4f;
  color: white;
  border-color: #ff4d4f;
}
.danger-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Collapsible customer-info (replaces old .customer-info-panel) ── */
.customer-info-collapsible {
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  overflow: hidden;
}

.customer-info-summary-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  list-style: none;
}
.customer-info-summary-toggle::-webkit-details-marker { display: none; }
.customer-info-summary-toggle::before {
  content: "▶";
  font-size: 10px;
  margin-right: 6px;
  color: var(--text-secondary);
  transition: transform 0.15s;
}
details[open] > .customer-info-summary-toggle::before {
  transform: rotate(90deg);
}

.customer-info-meta-inline {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

.customer-info-collapsible > div,
.customer-info-collapsible > details {
  padding: 0 12px 10px;
}

.customer-info-summary {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid rgba(64, 158, 255, 0.14);
}

.customer-info-summary.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border-style: dashed;
}

.customer-info-summary-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.customer-info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Structured field grid */
.customer-info-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 16px;
  margin: 12px 0 0;
}

.customer-info-fields.empty {
  display: none;
}

.cif-row {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  min-width: 0;
}

.cif-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.cif-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
  font-family: "SF Mono", "Fira Mono", monospace;
}

/* Collapsible raw JSON */
.customer-info-raw-details {
  margin-top: 10px;
}

.customer-info-raw-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
  padding: 4px 0;
}

.customer-info-raw-details summary:hover {
  color: var(--primary);
}

.customer-info-json {
  margin: 8px 0 0;
  padding: 14px;
  max-height: 220px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #0f172a;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.customer-info-json.empty {
  background: #f8fafc;
  color: var(--text-secondary);
}

/* Conversation list item improvements */
.conv-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.conv-id {
  font-size: 11px;
  font-family: "SF Mono", "Fira Mono", monospace;
  color: var(--text-secondary);
}

.conv-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 1px 0 2px;
}

.conv-item-msg {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}

.conv-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.8;
}

.tag-customer {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}

.message-panel {
  min-height: 280px;
  max-height: calc(100vh - 460px);
  background: #fbfcfd;
  border-radius: 12px;
  padding: 12px 14px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  margin-bottom: 8px;
}

.message-panel.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.message-item {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  max-width: 75%;
  line-height: 1.5;
}

.message-item.system {
  background: #eef2f6;
}

.message-item.visitor {
  background: #edf7ff;
  margin-right: auto;
}

.message-item.assistant {
  background: #f1f9e8;
  margin-left: auto;
}

.message-item.agent {
  background: #fff2f0;
  margin-left: auto;
}

.message-item.agent-notice {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  max-width: 100%;
  margin-right: auto;
  margin-left: auto;
}

.message-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.project-list-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 420px;
  max-height: 720px;
  overflow-y: auto;
}

.project-list-panel.empty {
  justify-content: center;
}

.project-card {
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.project-card.active {
  border-color: var(--primary);
  background: #f0f7ff;
}

.action-definition-card {
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.action-definition-card.active {
  border-color: var(--primary);
  background: #f0f7ff;
}

.action-definition-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.action-definition-card p {
  margin: 0;
  color: var(--text-regular);
  font-size: 13px;
  line-height: 1.5;
}

.project-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.project-card p {
  margin: 0;
  color: var(--text-regular);
  font-size: 13px;
  line-height: 1.5;
}

.registration-card {
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.registration-card.active {
  border-color: var(--primary);
  background: #f0f7ff;
}

.registration-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.registration-card p {
  margin: 0;
  color: var(--text-regular);
  font-size: 13px;
  line-height: 1.5;
}

.project-form-panel {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  background: var(--bg-soft);
}

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

.registration-detail.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.detail-item {
  padding: 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--border-color);
}

.detail-item.full-width {
  grid-column: 1 / -1;
}

.detail-item span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.detail-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}

.form-hint {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-regular);
}

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

.project-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-regular);
}

.project-form-grid span {
  font-weight: 600;
}

.project-form-grid input,
.project-form-grid textarea,
.project-form-grid select {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  background: white;
}

.project-form-grid .full-width {
  grid-column: 1 / -1;
}

.project-actions {
  gap: 12px;
}

.section-divider {
  grid-column: 1 / -1;
  padding: 8px 0 2px;
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #888);
}

.field-hint {
  font-size: 12px;
  color: var(--text-secondary, #888);
  margin-top: 2px;
}

.verify-result-box {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border-color);
  background: var(--bg-page, #f8f9fa);
  white-space: pre-wrap;
  word-break: break-all;
}

.verify-result-box.ok {
  border-color: #34c759;
  background: #f0faf3;
  color: #1a6632;
}

.verify-result-box.failed {
  border-color: #ff3b30;
  background: #fff5f5;
  color: #922;
}

.verify-result-box.skipped {
  border-color: #ff9500;
  background: #fffbf0;
  color: #7a5000;
}

.verify-result-box.loading {
  color: var(--text-secondary, #888);
}

.action-definition-layout {
  align-items: start;
}

.config-tip {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef6ff;
  color: var(--text-regular);
  font-size: 13px;
  line-height: 1.6;
}

.log-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  max-height: 520px;
  overflow-y: auto;
}

.log-item {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.log-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(65, 127, 249, 0.15);
}

.log-item h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.log-item p {
  margin: 0;
  color: var(--text-regular);
  font-size: 13px;
  line-height: 1.5;
}

.action-log-layout {
  align-items: start;
}

.log-detail {
  min-height: 220px;
  display: grid;
  gap: 12px;
}

.log-detail.empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.log-detail-section {
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-soft);
}

.log-detail-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.log-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-action-btn {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 6px 10px;
  background: white;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

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

.log-detail-grid div {
  min-width: 0;
}

.log-detail-grid strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.log-detail-grid span {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.log-json {
  margin: 0;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-success {
  color: var(--success);
}

.status-failed {
  color: var(--danger);
}

.status-audit {
  color: #8e44ad;
}

.status-info {
  color: var(--primary);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
}

.reply-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

/* Admin image preview bar in reply area */
.admin-image-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 6px;
  border-bottom: 1px dashed var(--border-color);
  margin-bottom: 8px;
}

.admin-img-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.admin-img-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-img-cancel {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.admin-img-cancel:hover { color: #ef4444; background: #fee2e2; }

/* Image message rendering in conversation panel */
.admin-msg-image {
  display: block;
  max-width: 220px;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: opacity 0.15s;
}

.admin-msg-image:hover { opacity: 0.85; }
.admin-msg-image-wrap { margin-top: 2px; }

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

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

.secondary-btn {
  background: #f2f3f5;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 1400px) {
  .stats-grid,
  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 1280px) {
  .content-grid.two-column {
    grid-template-columns: 1fr;
  }

  .registration-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
  }

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

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

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---- Conversation list filters ---- */
.conv-filter-bar {
  display: flex;
  gap: 6px;
  padding: 6px 0 8px;
  flex-wrap: wrap;
}

.conv-filter-bar .toolbar-select,
.conv-filter-bar .toolbar-input {
  flex: 1 1 auto;
  min-width: 100px;
}

/* ---- Log filter actions (multi-row) ---- */
.log-filter-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.log-filter-actions .toolbar-input[type="date"] {
  width: 130px;
  min-width: 130px;
}

/* ---- Pagination bar ---- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-regular);
}

.page-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: var(--text-primary);
  transition: background 0.15s;
}

.page-btn:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- Status tag colours ---- */
.tag-status-ai {
  background: rgba(64, 158, 255, 0.12);
  color: #409eff;
}

.tag-status-handoff {
  background: rgba(245, 108, 108, 0.12);
  color: #f56c6c;
}

.tag-status-closed {
  background: rgba(134, 144, 156, 0.12);
  color: #86909c;
}

.tag-pending-agent {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
  font-weight: 600;
  animation: pending-agent-pulse 2s ease-in-out infinite;
}

.conversation-item.has-agent-alert {
  border-left: 3px solid #f59e0b;
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.35) 0%, transparent 60%);
}

@keyframes pending-agent-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* ---- Login log popover ---- */
.login-log-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  right: 8px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
  overflow: hidden;
}

.login-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.login-log-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 0;
  font-size: 12px;
}

.login-log-item {
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-light, #f3f4f6);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-log-item:last-child { border-bottom: none; }

.login-log-item .log-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-log-item .log-status {
  font-weight: 600;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
}

.log-status.success {
  background: rgba(16,185,129,0.12);
  color: #10b981;
}

.log-status.failed {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

.login-log-item .log-meta {
  color: var(--text-secondary);
  font-size: 11px;
}

.btn-plain {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 2px 4px;
  border-radius: 4px;
}

.btn-plain:hover { background: var(--hover-bg); }

/* ── Project version history ─────────────────────────────── */
.project-versions-details {
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.project-versions-details > summary {
  cursor: pointer;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-soft);
  user-select: none;
  list-style: none;
}

.project-versions-details > summary:hover { color: var(--primary); }
.project-versions-details[open] > summary { border-bottom: 1px solid var(--border-color); }

.project-versions-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Widget config section ────────────────────────────────── */
.widget-config-section {
  margin-top: 4px;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.widget-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.widget-config-grid .full-width { grid-column: 1 / -1; }

.color-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-input-row input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  flex-shrink: 0;
}

.widget-preview-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  background: #f0f4ff;
  border-radius: 10px;
  border: 1px dashed #c7d2fe;
}

.widget-preview-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
}

.widget-preview-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preview-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.widget-header-preview {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.widget-header-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.widget-image-field .config-tip {
  margin-top: 6px;
}

.widget-image-upload {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.widget-image-preview-wrap {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 1px dashed var(--border-color);
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.widget-image-preview-wrap--round {
  border-radius: 50%;
}

.widget-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.widget-image-placeholder {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#widgetPreviewBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  min-width: 56px;
  cursor: default;
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: all 0.2s;
}

.embed-code-block {
  padding: 14px 16px;
}

.embed-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.embed-pre {
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  border: 1px solid rgba(255,255,255,0.06);
}

.version-item {
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
}

.version-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.version-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.version-type-create        { background: #dcfce7; color: #15803d; }
.version-type-update        { background: #dbeafe; color: #1d4ed8; }
.version-type-delete        { background: #fee2e2; color: #b91c1c; }
.version-type-openclaw_update { background: #fef3c7; color: #92400e; }

.version-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

.version-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.version-snapshot > summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--text-secondary);
  user-select: none;
}

.version-snapshot-pre {
  margin: 6px 0 0;
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  border-radius: 6px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── OpenClaw Gateway Config Section ──────────────────────────────── */
.oc-info-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #0c4a6e;
}
.oc-info-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.oc-info-text strong { display: block; margin-bottom: 2px; }
.oc-info-text code {
  background: #e0f2fe;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.oc-info-text a { color: #0369a1; }

/* ── Admin inline guides (Skills bridge, etc.) ─────────────────────── */
.admin-guide-panel {
  margin: 16px 0;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #f8fbff;
  overflow: hidden;
}
.admin-guide-panel > summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #1e40af;
  list-style: none;
  user-select: none;
}
.admin-guide-panel > summary::-webkit-details-marker { display: none; }
.admin-guide-panel > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}
.admin-guide-panel[open] > summary::before { transform: rotate(90deg); }
.admin-guide-body {
  padding: 0 14px 14px;
  font-size: 13px;
  line-height: 1.65;
  color: #334155;
}
.admin-guide-body p { margin: 0 0 10px; }
.admin-guide-body p:last-child { margin-bottom: 0; }
.guide-steps-title {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1e3a8a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.guide-steps,
.guide-list {
  margin: 0 0 10px;
  padding-left: 1.25rem;
}
.guide-steps li,
.guide-list li { margin-bottom: 6px; }
.guide-note {
  padding: 8px 10px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 12.5px;
}
.guide-code {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.admin-guide-body code {
  background: #e0f2fe;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: #0c4a6e;
}
.action-bridge-guide { margin-top: 0; margin-bottom: 14px; }
.oc-skills-bridge-guide { margin-top: 4px; margin-bottom: 0; }

.oc-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  gap: 4px;
}
.oc-status-unknown { background: #f3f4f6; color: #6b7280; }
.oc-status-ok      { background: #dcfce7; color: #166534; }
.oc-status-failed  { background: #fee2e2; color: #991b1b; }
.oc-status-testing { background: #fef3c7; color: #92400e; }

.oc-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.oc-config-grid .full-width,
.oc-config-grid label.full-width { grid-column: 1 / -1; }

.oc-provider-hint {
  grid-column: 1 / -1;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  display: none;
}
.oc-provider-hint.show { display: block; }
.oc-provider-hint.openclaw {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #14532d;
}
.oc-provider-hint.openai {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
}
.oc-provider-hint.other {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
}

.oc-verify-row {
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.oc-verify-result {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}
.oc-verify-result.ok     { background:#f0faf3; border-color:#34c759; color:#1a6632; }
.oc-verify-result.failed { background:#fff5f5; border-color:#ff3b30; color:#922; }
.oc-verify-result.loading{ color: #888; }

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color, #e5e7eb);
}

.oc-config-grid label > small.field-hint,
.project-form-grid label > small.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: #9ca3af;
  line-height: 1.4;
}

/* ── Toast notifications ────────────────────────────────────── */
/* ── Confirm modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--bg-card);
  border-radius: 18px;
  padding: 28px 28px 22px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  animation: modal-in 0.15s ease;
}

@keyframes modal-in {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-regular);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.danger-modal-ok {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.danger-modal-ok:hover {
  opacity: 0.88;
}

.password-modal-card {
  width: min(420px, calc(100vw - 32px));
}

.password-modal-hint {
  margin-top: -4px;
  margin-bottom: 16px;
}

.password-modal-field {
  display: block;
  margin-bottom: 14px;
}

.password-modal-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-regular);
}

.password-modal-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 14px;
}

.password-modal-field input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

#passwordModalError {
  text-align: left;
  min-height: 18px;
}

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(15,23,42,0.14);
  pointer-events: all;
  animation: toastIn 0.22s ease;
  border: 1px solid transparent;
}
.toast.toast-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.toast.toast-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.toast.toast-error   { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.toast.toast-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.toast-icon { flex-shrink: 0; font-size: 16px; line-height: 1; }
.toast-msg  { flex: 1; }
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: inherit;
  opacity: 0.55;
  padding: 0;
}
.toast-close:hover { opacity: 1; }
.toast.toast-fade {
  animation: toastOut 0.25s ease forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(18px); }
}

/* ── Closed-conversation banner ─────────────────────────────── */
.conv-closed-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  font-size: 13px;
  color: #be123c;
  margin-bottom: 6px;
}
.conv-closed-banner svg { flex-shrink: 0; }

.conv-agent-notice-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 6px;
}

/* ── Nav icon SVG sizing ─────────────────────────────────────── */
.nav-icon { font-size: 0; }
.nav-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Action definition structured form ──────────────────────── */
.config-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.config-section-title:first-child { margin-top: 0; }
.section-tip {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}
.inline-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-regular);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}
.inline-toggle input[type="checkbox"] { accent-color: var(--accent); }

/* Trigger keyword tags */
.trigger-keywords-wrap { display: flex; flex-direction: column; gap: 8px; }
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  padding: 6px 8px;
  background: #f5f7fa;
  border: 1px solid #dcdfe6;
  border-radius: 8px;
  align-items: center;
}
.tag-list:empty::before {
  content: "暂无关键词";
  color: var(--text-dim);
  font-size: 12px;
  align-self: center;
}
.kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--primary, #409eff);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(64,158,255,.25);
}
.kw-tag button {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  padding: 0 0 0 2px;
  font-size: 15px;
  line-height: 1;
}
.kw-tag button:hover { color: #fff; }
.tag-input-row {
  display: flex;
  gap: 8px;
}
.tag-input-row input { flex: 1; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Form schema section */
.form-schema-section {
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

/* Form fields builder table */
.form-fields-builder { margin-top: 14px; }
.fields-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.fields-table-wrap { overflow-x: auto; }
.fields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.fields-table th {
  text-align: left;
  padding: 6px 8px;
  background: var(--bg-alt2, #f0f4fa);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.fields-table td {
  padding: 4px 4px;
  border-bottom: 1px solid var(--border-light, #eef0f3);
  vertical-align: middle;
}
.fields-table td input,
.fields-table td select {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card);
  color: var(--text-regular);
}
.fields-table td.td-required { text-align: center; }
.fields-table td.td-del { text-align: center; width: 36px; }
.fields-table td.td-del button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 4px;
}
.fields-table tbody tr:last-child td { border-bottom: none; }

/* Advanced section */
.advanced-section {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.advanced-section summary {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  background: var(--bg-alt);
  user-select: none;
}
.advanced-section summary:hover { color: var(--text-secondary); }
.advanced-section[open] summary { border-bottom: 1px solid var(--border); }
.advanced-section > .project-form-grid { padding: 0 14px 14px; }
