:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --sidebar-w: 260px;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background-color: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo i {
  font-size: 28px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 10px;
  border-radius: var(--radius);
}

.logo h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.badge.online {
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.badge.online i {
  font-size: 8px;
  background: transparent;
  padding: 0;
  color: var(--success);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item i {
  font-size: 16px;
}

.nav-item:hover {
  background-color: var(--bg-main);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
}

.count-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.server-status small {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.server-status strong {
  font-size: 13px;
  color: var(--success);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  padding: 32px;
  gap: 24px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.top-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.global-chat-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 430px;
  padding: 9px 10px 9px 14px;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  background: #fff7ed;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
}

.global-chat-control.bot-active {
  border-color: #86efac;
  background: #f0fdf4;
}

.global-chat-control.has-error {
  border-color: #fca5a5;
  background: #fef2f2;
}

.global-chat-control.is-saving {
  opacity: 0.72;
}

.global-chat-copy {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.global-chat-eyebrow {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.global-chat-copy strong {
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.25;
}

.global-chat-copy small {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.3;
}

.global-chat-control.has-error .global-chat-copy small {
  color: #b91c1c;
}

.global-chat-toggle {
  position: relative;
  display: grid;
  flex: 0 0 210px;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: 210px;
  min-height: 42px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 999px;
  background: #e2e8f0;
  cursor: pointer;
  isolation: isolate;
}

.global-chat-toggle::before {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: #ea580c;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
  content: "";
  transition: transform 0.2s ease, background 0.2s ease;
}

.global-chat-toggle.bot-active::before {
  background: #16a34a;
  transform: translateX(100%);
}

.global-chat-toggle-side {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  padding: 7px 8px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  transition: color 0.2s;
}

.global-chat-toggle.owner-active .global-chat-toggle-side.owner,
.global-chat-toggle.bot-active .global-chat-toggle-side.bot {
  color: #fff;
}

.global-chat-toggle:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.3);
  outline-offset: 2px;
}

.global-chat-toggle:disabled {
  cursor: wait;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #fff;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-main);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
}

/* Tabs */
.tab-pane {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.tab-pane.active {
  display: flex;
}

/* Filters */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  position: relative;
  max-width: 400px;
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  outline: none;
}

.status-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Multi-selection & Batch delete styles */
.leads-selection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.lead-select-cb {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  border-radius: 4px;
  margin: 0;
  vertical-align: middle;
}

.selected-count-badge {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.btn-danger-outline {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-danger-outline:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.lead-cb-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

.lead-card.selected {
  border-color: var(--primary);
  background-color: #f8faff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.leads-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}

.leads-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Leads Grid / Cards */
.leads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.lead-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  min-width: 0;
  overflow: hidden;
}

.lead-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.lead-card.collapsed {
  gap: 10px;
  padding: 14px 16px;
}

.lead-card-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.lead-toggle-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.lead-toggle-pill-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.lead-card.expanded .lead-toggle-pill-btn {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.4);
}

.lead-toggle-pill-btn i {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.lead-icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.lead-icon-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

.lead-icon-btn.danger:hover {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.lead-quick-info {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 9px 10px;
  background: var(--bg-main);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.lead-quick-info:hover {
  background: #f1f5f9;
  border-color: var(--border);
}

.lead-quick-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-extra {
  display: block;
}

.lead-card.collapsed .lead-extra {
  display: none;
}

.lead-card.collapsed .lead-quick-info {
  padding: 7px 9px;
}

.lead-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  padding: 6px 8px;
  margin: -6px -8px;
  transition: background 0.15s ease;
  gap: 10px;
  min-width: 0;
}

.lead-header > div:first-child,
.lead-guest-info {
  min-width: 0;
}

.lead-header > div:first-child {
  flex: 1 1 100%;
}

.lead-header > div:first-child .lead-guest-info {
  flex: 1 1 auto;
}

.lead-guest-info h4,
.lead-instagram-link,
.lead-guest-info span {
  overflow-wrap: anywhere;
}

.lead-header:hover {
  background: #f8fafc;
}

.lead-guest-info h4 {
  font-size: 16px;
  font-weight: 700;
}

.lead-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
  color: #c13584;
  background: #fdf2f8;
  border: 1px solid #fbcfe8;
}

.lead-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lead-instagram-link {
  display: block;
  width: fit-content;
  margin: 1px 0;
  color: #c13584;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.lead-instagram-link:hover {
  text-decoration: underline;
}

.lead-guest-info span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.instagram-profile-panel {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #fbcfe8;
  border-radius: 9px;
  background: #fdf2f8;
}

.instagram-profile-panel strong {
  color: #9d174d;
  font-size: 12px;
}

.instagram-profile-panel span {
  color: var(--text-main);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.instagram-profile-panel small {
  color: var(--text-muted);
  font-size: 11px;
}

.status-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.status-tag.urgent { background: #fee2e2; color: #dc2626; }
.status-tag.deposit { background: #fef3c7; color: #d97706; }
.status-tag.hesitant { background: #e0e7ff; color: #4338ca; }
.status-tag.booked { background: #dcfce7; color: #15803d; }
.status-tag.inquiry { background: #f1f5f9; color: #475569; }

.conversation-mode-badge {
  padding: 4px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.conversation-mode-badge.owner { background: #ffedd5; color: #c2410c; }
.conversation-mode-badge.draft { background: #ede9fe; color: #6d28d9; }
.conversation-mode-badge.auto { background: #dcfce7; color: #15803d; }
.conversation-mode-badge.inherit { background: #f1f5f9; color: #475569; }

.lead-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-main);
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
}

.detail-item strong {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lead-summary {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.5;
  background: #fff;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
  overflow-wrap: anywhere;
}

.conversation-control-panel {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #ddd6fe;
  border-radius: 9px;
  background: #faf5ff;
}

.conversation-control-panel > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  min-width: 0;
  flex: 0 1 auto;
}

.conversation-control-panel small {
  color: var(--text-muted);
}

.lead-booking-panel {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lead-booking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.lead-booking-header h5 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lead-booking-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.lead-deposit-box {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  font-size: 12px;
  color: #92400e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.lead-deposit-box.confirmed {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.lead-deposit-box.rejected {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.conversation-mode-select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  background: #fff;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
}

.lead-special-request {
  color: #475569;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.lead-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

@media (max-width: 700px) {
  .conversation-mode-select {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 700px) {
  /* Multi-selection & Batch delete styles */
.leads-selection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.lead-select-cb {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  border-radius: 4px;
  margin: 0;
  vertical-align: middle;
}

.selected-count-badge {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #bfdbfe;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.btn-danger-outline {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-danger-outline:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.lead-cb-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

.lead-card.selected {
  border-color: var(--primary);
  background-color: #f8faff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.leads-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .lead-quick-info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Chat Simulator */
.simulator-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  height: calc(100vh - 180px);
}

.chat-container {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #fafafa;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.message.ai {
  align-self: flex-start;
}

.message.guest {
  align-self: flex-end;
}

.message.owner {
  align-self: flex-start;
}

.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.message.ai .bubble {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.message.ai .bubble strong,
.message.ai .bubble b {
  font-weight: 700;
  color: #0f172a;
}

.message.guest .bubble {
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.owner .bubble {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-bottom-left-radius: 4px;
}

.message.guest .bubble strong,
.message.guest .bubble b {
  font-weight: 700;
  color: #ffffff;
}

.chat-code {
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: Consolas, Monaco, "Liberation Mono", Menlo, monospace;
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

.message.guest .bubble .chat-code {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.message .time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-input-area {
  padding: 14px;
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  gap: 10px;
}

.chat-input-area input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 30px;
  font-size: 14px;
  outline: none;
}

/* Extracted Panel */
.extracted-lead-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}

.extracted-lead-panel h3 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
}

.preview-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.preview-empty i {
  font-size: 40px;
  margin-bottom: 12px;
  color: #cbd5e1;
}

/* Knowledge Base */
.kb-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  height: calc(100vh - 200px);
}

.kb-sidebar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kb-sidebar h3 {
  font-size: 14px;
  margin-bottom: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-list li {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-list li:hover {
  background: var(--bg-main);
}

.kb-list li.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.kb-editor-area {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kb-editor-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#kb-editor-content {
  flex: 1;
  padding: 20px;
  border: none;
  outline: none;
  font-family: monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  background: #fafafa;
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header i {
  color: var(--primary);
  font-size: 18px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
}

.form-group input, .form-group select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

.form-group small {
  color: var(--text-muted);
  font-size: 11px;
}

.copy-input {
  display: flex;
  gap: 8px;
}

.copy-input input {
  flex: 1;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: #fff;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  background: #f8fafc;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.owner-reply-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fff7ed;
}

.owner-reply-composer textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #fdba74;
  border-radius: 8px;
  resize: vertical;
  font: inherit;
}

.owner-reply-composer > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.owner-reply-composer small {
  color: #9a3412;
}

/* Thêm styles cho Image & Link Card trong Chat Bubble */
.chat-image-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.chat-image-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  cursor: pointer;
  max-height: 200px;
}

.chat-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.chat-image-card:hover img {
  transform: scale(1.05);
}

.chat-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
  margin-right: 6px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  transition: all 0.2s;
}

.chat-link-btn:hover {
  background: var(--primary);
  color: #fff;
}

.calendar-card {
  overflow: hidden;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.calendar-header select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.calendar-message {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
}

.calendar-table-wrap {
  overflow-x: auto;
}

.calendar-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.calendar-table th,
.calendar-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.calendar-table th {
  background: #f8fafc;
  font-size: 12px;
  color: var(--text-muted);
}

.calendar-table input {
  width: 100%;
  min-width: 72px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.calendar-unsynced {
  background: #fffbeb;
}

.calendar-status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.calendar-status.synced {
  background: #dcfce7;
  color: #166534;
}

.calendar-status.unsynced {
  background: #fef3c7;
  color: #92400e;
}

.calendar-actions {
  display: flex;
  gap: 6px;
}

.operations-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.live-status-panel,
.calendar-import-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.live-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  flex-wrap: wrap;
}

.live-source-health {
  font-size: 11px;
  color: var(--text-muted);
}

.live-status-panel h4 {
  font-size: 13px;
  margin: 2px 0;
}

.live-forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.live-forecast-day,
.live-alert-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #fff;
}

.live-forecast-day span,
.live-alert-item span {
  font-size: 12px;
}

.live-forecast-day small,
.live-alert-item small,
.live-alert-empty {
  color: var(--text-muted);
  font-size: 11px;
}

.live-risk,
.draft-error {
  color: #b91c1c;
  font-size: 11px;
}

.live-alert-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.calendar-import-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.calendar-import-actions input[type="file"] {
  max-width: 230px;
}

.import-warnings {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
  margin-bottom: 10px;
}

.import-preview-table {
  max-height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.drafts-list {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.draft-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}

.draft-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.draft-card-head > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.draft-card-head small {
  color: var(--text-muted);
  font-size: 11px;
}

.draft-guest-message {
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 13px;
}

.draft-card textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  line-height: 1.5;
}

.draft-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.eval-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.eval-result-card {
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
}

.eval-success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.eval-warning {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.eval-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.eval-failures details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid currentColor;
}

@media (max-width: 900px) {
  .top-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .global-chat-control {
    min-width: min(100%, 430px);
  }

  .operations-grid,
  .eval-grid {
    grid-template-columns: 1fr;
  }

  .drafts-list {
    grid-template-columns: 1fr;
    padding: 10px;
  }
}

@media (max-width: 600px) {
  .global-chat-control {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
    min-width: 0;
  }

  .global-chat-toggle {
    flex-basis: auto;
    width: 100%;
  }
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gallery-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.gallery-card-img {
  height: 180px;
  width: 100%;
  object-fit: cover;
}

.gallery-thumbnails {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  background: #f8fafc;
}

.gallery-thumbnails a {
  display: block;
  min-width: 0;
}

.gallery-thumbnails img {
  display: block;
  width: 100%;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
}

.gallery-image-count {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.gallery-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-card-body h4 {
  font-size: 14px;
  font-weight: 700;
}

.gallery-card-body small {
  font-size: 11px;
  color: var(--text-muted);
}

.typing-indicator .bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9 !important;
  color: var(--text-muted) !important;
  font-style: italic;
  font-size: 13px;
  border-color: var(--border) !important;
}

.cloudflare-dashboard-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(760px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(23, 37, 84, 0.96);
  color: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
  font-size: 12px;
  line-height: 1.45;
}

.cloudflare-dashboard-banner span {
  min-width: 220px;
}

.cloudflare-dashboard-banner button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.cloudflare-dashboard-banner button:first-of-type {
  border-color: #fff;
  background: #fff;
  color: #172554;
}

.cloudflare-feature-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.55;
}

.cloudflare-feature-notice > i {
  margin-top: 2px;
  font-size: 18px;
}

.btn:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

@media (max-width: 640px) {
  .cloudflare-dashboard-banner {
    right: 12px;
    bottom: 12px;
    left: 12px;
    flex-wrap: wrap;
    max-width: none;
  }

  .cloudflare-dashboard-banner span {
    flex: 1 1 100%;
  }
}
